# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
586914 |
2022-07-01T03:13:51 Z |
eecs |
Izlet (COI19_izlet) |
C++17 |
|
134 ms |
10348 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];
}
}
vector<array<int, 2>> E;
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)) {
E.push_back({i, 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 {
if (u ^ j && a[i][p] == a[j][u] && a[i][u] == a[j][p] + 1) {
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) << " ";
}
cout << "\n";
for (auto &e : E) {
cout << e[0] << " " << e[1] << "\n";
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
468 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
134 ms |
10348 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
468 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |