QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#641086#6109. Similarity Graphcxm1024WA 24ms3676kbC++171.7kb2024-10-14 18:23:492024-10-14 18:23:50

Judging History

你现在查看的是最新测评结果

  • [2024-10-14 18:23:50]
  • 评测
  • 测评结果:WA
  • 用时:24ms
  • 内存:3676kb
  • [2024-10-14 18:23:49]
  • 提交

answer

#include <bits/stdc++.h>
#define cerr cout << "in " << __LINE__ << "\t: "
using namespace std;
int n, m, a[110][110], p[110], q[110], b[110][110], ans[110];
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	cin >> n, m = n, iota(q + 1, q + n + 1, 1);
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++)
			cin >> a[i][j];
	if (n <= 6) {
		for (int i = 1; i <= n; i++)
			p[i] = q[i] = i;
		do {
			do {
				bool flag = 1;
				for (int i = 1; i <= n; i++)
					for (int j = 1; j <= n; j++)
						if (i != j && a[i][j] != ((p[i] < p[j]) == (q[i] < q[j])))
							flag = 0;
				if (flag) {
					cout << "YES\n";
					for (int i = 1; i <= n; i++)
						cout << p[i] << " \n"[i == n];
					for (int i = 1; i <= n; i++)
						cout << q[i] << " \n"[i == n];
					return 0;
				}
			} while (next_permutation(q + 1, q + n + 1));
		} while (next_permutation(p + 1, p + n + 1));
		cout << "NO\n";
		return 0;
	}
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++)
			a[i][j] ^= (i > j);
	for (; n; n--) {
		int flag = 0;
		for (int i = 1; i <= n; i++) {
			int res = 0;
			for (int j = 1; j <= n; j++)
				res += a[i][j];
			if (res == n - 1) flag = i;
		}
		if (!flag) {
			cout << "NO\n";
			return 0;
		}
		ans[q[flag]] = n;
		int tot = 0;
		for (int i = 1; i <= n; i++)
			if (i != flag) p[i] = ++tot, q[p[i]] = q[i];
		for (int i = 1; i <= n; i++)
			for (int j = 1; j <= n; j++)
				if (i != flag && j != flag) b[p[i]][p[j]] = a[i][j];
		memcpy(a, b, sizeof(b));
	}
	cout << "YES\n";
	for (int i = 1; i <= m; i++)
		cout << i << " \n"[i == m];
	for (int i = 1; i <= m; i++)
		cout << ans[i] << " \n"[i == m];
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3516kb

input:

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

output:

YES
1 2 3 4
2 4 1 3

result:

ok ok

Test #2:

score: 0
Accepted
time: 24ms
memory: 3508kb

input:

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

output:

NO

result:

ok ok

Test #3:

score: 0
Accepted
time: 0ms
memory: 3568kb

input:

1
0

output:

YES
1
1

result:

ok ok

Test #4:

score: 0
Accepted
time: 0ms
memory: 3544kb

input:

2
0 0
0 0

output:

YES
1 2
2 1

result:

ok ok

Test #5:

score: 0
Accepted
time: 0ms
memory: 3676kb

input:

2
0 1
1 0

output:

YES
1 2
1 2

result:

ok ok

Test #6:

score: 0
Accepted
time: 0ms
memory: 3568kb

input:

3
0 0 0
0 0 0
0 0 0

output:

YES
1 2 3
3 2 1

result:

ok ok

Test #7:

score: 0
Accepted
time: 0ms
memory: 3512kb

input:

3
0 0 0
0 0 1
0 1 0

output:

YES
1 2 3
3 1 2

result:

ok ok

Test #8:

score: 0
Accepted
time: 0ms
memory: 3592kb

input:

3
0 0 1
0 0 0
1 0 0

output:

YES
1 3 2
2 1 3

result:

ok ok

Test #9:

score: 0
Accepted
time: 0ms
memory: 3516kb

input:

3
0 0 1
0 0 1
1 1 0

output:

YES
1 2 3
2 1 3

result:

ok ok

Test #10:

score: 0
Accepted
time: 0ms
memory: 3576kb

input:

3
0 1 0
1 0 0
0 0 0

output:

YES
1 2 3
2 3 1

result:

ok ok

Test #11:

score: 0
Accepted
time: 0ms
memory: 3568kb

input:

3
0 1 0
1 0 1
0 1 0

output:

YES
1 3 2
2 3 1

result:

ok ok

Test #12:

score: 0
Accepted
time: 0ms
memory: 3572kb

input:

3
0 1 1
1 0 0
1 0 0

output:

YES
1 2 3
1 3 2

result:

ok ok

Test #13:

score: 0
Accepted
time: 0ms
memory: 3676kb

input:

3
0 1 1
1 0 1
1 1 0

output:

YES
1 2 3
1 2 3

result:

ok ok

Test #14:

score: 0
Accepted
time: 0ms
memory: 3572kb

input:

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

output:

YES
1 2 3 4
3 2 4 1

result:

ok ok

Test #15:

score: 0
Accepted
time: 0ms
memory: 3628kb

input:

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

output:

YES
1 2 3 4
1 4 3 2

result:

ok ok

Test #16:

score: 0
Accepted
time: 0ms
memory: 3548kb

input:

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

output:

YES
1 4 3 2
2 3 1 4

result:

ok ok

Test #17:

score: 0
Accepted
time: 0ms
memory: 3568kb

input:

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

output:

YES
1 2 3 4
3 4 1 2

result:

ok ok

Test #18:

score: 0
Accepted
time: 0ms
memory: 3572kb

input:

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

output:

YES
1 2 3 4
4 3 1 2

result:

ok ok

Test #19:

score: 0
Accepted
time: 0ms
memory: 3624kb

input:

5
0 0 1 0 1
0 0 1 1 1
1 1 0 1 1
0 1 1 0 0
1 1 1 0 0

output:

YES
1 2 5 4 3
3 1 5 2 4

result:

ok ok

Test #20:

score: 0
Accepted
time: 0ms
memory: 3572kb

input:

5
0 0 1 0 1
0 0 1 0 1
1 1 0 0 0
0 0 0 0 1
1 1 0 1 0

output:

YES
1 2 3 4 5
3 2 5 1 4

result:

ok ok

Test #21:

score: 0
Accepted
time: 0ms
memory: 3580kb

input:

5
0 1 0 1 0
1 0 1 0 1
0 1 0 1 1
1 0 1 0 0
0 1 1 0 0

output:

YES
1 5 2 3 4
3 4 1 5 2

result:

ok ok

Test #22:

score: 0
Accepted
time: 0ms
memory: 3548kb

input:

5
0 1 0 1 0
1 0 1 1 1
0 1 0 1 0
1 1 1 0 1
0 1 0 1 0

output:

YES
1 4 2 5 3
3 4 2 5 1

result:

ok ok

Test #23:

score: 0
Accepted
time: 0ms
memory: 3628kb

input:

5
0 1 0 0 1
1 0 1 1 0
0 1 0 0 0
0 1 0 0 0
1 0 0 0 0

output:

YES
1 5 3 4 2
3 4 2 1 5

result:

ok ok

Test #24:

score: 0
Accepted
time: 0ms
memory: 3584kb

input:

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

output:

YES
1 5 4 2 3 6
4 3 6 1 2 5

result:

ok ok

Test #25:

score: 0
Accepted
time: 1ms
memory: 3672kb

input:

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

output:

YES
1 3 2 6 5 4
4 1 5 2 6 3

result:

ok ok

Test #26:

score: 0
Accepted
time: 3ms
memory: 3572kb

input:

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

output:

YES
1 5 6 2 3 4
3 2 4 1 6 5

result:

ok ok

Test #27:

score: 0
Accepted
time: 1ms
memory: 3584kb

input:

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

output:

YES
1 2 6 5 3 4
4 6 2 5 3 1

result:

ok ok

Test #28:

score: 0
Accepted
time: 0ms
memory: 3508kb

input:

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

output:

YES
1 2 3 4 6 5
5 2 3 1 4 6

result:

ok ok

Test #29:

score: -100
Wrong Answer
time: 0ms
memory: 3576kb

input:

7
0 1 0 1 1 0 1
1 0 1 0 1 1 1
0 1 0 0 0 0 0
1 0 0 0 0 0 0
1 1 0 0 0 0 1
0 1 0 0 0 0 1
1 1 0 0 1 1 0

output:

NO

result:

wrong answer P did not found the answer