QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#641072 | #6109. Similarity Graph | cxm1024 | WA | 1ms | 3696kb | C++17 | 1.6kb | 2024-10-14 18:18:14 | 2024-10-14 18:18:16 |
Judging History
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"