# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
586917 |
2022-07-01T03:19:21 Z |
eecs |
Izlet (COI19_izlet) |
C++17 |
|
128 ms |
4324 KB |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1010;
int n, a[maxn][maxn], fa[maxn];
vector<int> G[maxn];
int find(int x) {
return x == fa[x] ? x : fa[x] = find(fa[x]);
}
int main() {
ios::sync_with_stdio(0), cin.tie(0);
cin >> *new int >> n;
iota(fa + 1, fa + n + 1, 1);
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
cin >> a[i][j];
}
}
for (int x : {1, 2}) {
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
if (a[i][j] == x && find(i) ^ find(j)) {
fa[find(i)] = find(j);
G[i].push_back(j), G[j].push_back(i);
}
}
}
}
iota(fa + 1, fa + n + 1, 1);
for (int i = 1; i <= n; i++) {
for (int j : G[i]) {
auto dfs = [&](auto self, int u, int p) -> void {
int x = a[j][p] + 1;
if (u ^ j && a[i][u] == x && a[i][p] == x && a[j][u] == x) {
fa[find(i)] = find(u);
}
for (int v : G[u]) {
if (v ^ p) self(self, v, u);
}
};
dfs(dfs, j, i);
}
}
for (int i = 1; i <= n; i++) {
cout << find(i) << " \n"[i == n];
}
for (int i = 1; i <= n; i++) {
for (int j : G[i]) if (i < j) {
cout << i << " " << j << "\n";
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
128 ms |
4324 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |