# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
586919 | eecs | Izlet (COI19_izlet) | C++17 | 747 ms | 74648 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int maxn = 3010;
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);
}
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |