QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#641072#6109. Similarity Graphcxm1024WA 1ms3696kbC++171.6kb2024-10-14 18:18:142024-10-14 18:18:16

Judging History

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

  • [2024-10-14 18:18:16]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3696kb
  • [2024-10-14 18:18:14]
  • 提交

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 <= 5) {
		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++)
						flag &= (a[i][j] == ((p[i] > p[j]) ^ (q[i] > q[j])));
				if (flag) {
					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(p + 1, p + n + 1));
		} while (next_permutation(q + 1, q + n + 1));
		cout << "-1\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;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3696kb

input:

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

output:

3 1 4 2
1 2 3 4

result:

wrong answer Token parameter [name=YES_or_NO] equals to "3", doesn't correspond to pattern "YES|NO"