# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
899593 | duckindog | Kutije (COCI21_kutije) | C++14 | 125 ms | 9556 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// from duckindog wth depression
#include<bits/stdc++.h>
using namespace std;
const int N = 1e3 + 10;
int n, m, q;
int par[N];
int root(int u) {
return (par[u] < 0 ? u : par[u] = root(par[u]));
}
void add(int u, int v) {
u = root(u); v = root(v);
if (u == v) return;
if (par[u] >= par[v]) swap(u, v);
par[u] += par[v];
par[v] = u;
}
int32_t main() {
cin.tie(0)->sync_with_stdio(0);
if (fopen("duck.inp", "r")) {
freopen("duck.inp", "r", stdin);
freopen("duck.out", "w", stdout);
}
memset(par, -1, sizeof par);
cin >> n >> m >> q;
for (int i = 1; i <= m; ++i) {
for (int j = 1; j <= n; ++j) {
int p; cin >> p;
add(j, p);
}
}
while(q--) {
int x, y; cin >> x >> y;
cout << (root(x) == root(y) ? "DA" : "NE") << '\n';
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |