QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#640199 | #6109. Similarity Graph | cxm1024 | WA | 0ms | 3724kb | C++17 | 1.0kb | 2024-10-14 09:02:31 | 2024-10-14 09:02:36 |
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], 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: 100
Accepted
time: 0ms
memory: 3720kb
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: 0ms
memory: 3580kb
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: 3640kb
input:
1 0
output:
YES 1 1
result:
ok ok
Test #4:
score: 0
Accepted
time: 0ms
memory: 3724kb
input:
2 0 0 0 0
output:
YES 1 2 2 1
result:
ok ok
Test #5:
score: 0
Accepted
time: 0ms
memory: 3640kb
input:
2 0 1 1 0
output:
YES 1 2 1 2
result:
ok ok
Test #6:
score: 0
Accepted
time: 0ms
memory: 3692kb
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: 3716kb
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: -100
Wrong Answer
time: 0ms
memory: 3596kb
input:
3 0 0 1 0 0 0 1 0 0
output:
NO
result:
wrong answer P did not found the answer