Logo
(追記) (追記ここまで)

25735번 - Similarity Graph 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 (추가 시간 없음) 1024 MB (추가 메모리 없음)42191365.000%

문제

Let $p$ and $q$ be two permutations of $\{1,2,\dots ,N\}$.

Similarity graph of $p$ and $q,ドル $S(p,q),ドル is defined as following:

  • $S(p,q)$ has $N$ labeled vertices, numbered from 1ドル$ to $N$.
  • There is a edge between vertex $i$ and $j$ if and only if $p_i<p_j$ and $q_i<q_j$ are both true, or both false. (1ドル\leq i<j\leq N$)

You are given a simple undirected graph $G$ with $N$ labeled vertices, numbered from 1ドル$ to $N$.

Find a pair $(p,q)$ of permutations of $\{1,2,\dots ,N\},ドル satisfying $S(p,q) =G$.

입력

The first line contains one integer, $N$.

The next $N$ lines contain space-separated $N$ integers. The $j$-th integer of the $i$-th line is $E(i,j)$. $E(i,j)$ is 1ドル$ if there is an edge between vertex $i$ and vertex $j,ドル and 0ドル$ otherwise.

출력

If it is impossible to find $p$ and $q$ satisfying the condition, output NO.

Otherwise, output YES on the first line. On the following two lines, output $p$ and $q$. If there are multiple answers, output any.

제한

  • 1ドル\le N\le 100$
  • 0ドル\le E(i,j)\le 1$ (1ドル\le i,j\le N$)
  • $E(i,j) =E(j,i)$ (1ドル\le i<j\le N$)
  • $E(i,i) =0$ (1ドル\le i\le N$)

예제 입력 1

4
0 1 0 1
1 0 0 0
0 0 0 1
1 0 1 0

예제 출력 1

YES
1 2 3 4
2 4 1 3

예제 입력 2

6
0 1 0 1 0 1
1 0 0 0 1 0
0 0 0 1 1 1
1 0 1 0 0 0
0 1 1 0 0 0
1 0 1 0 0 0

예제 출력 2

NO

힌트

출처

University > KAIST > KAIST ICPC Mock Competition > 2022 KAIST 12th ICPC Mock Competition I번

Camp > Petrozavodsk Programming Camp > Winter 2023 > Day 4: KAIST+KOI Contest, Grand Prix of Korea I번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /