# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
515818 | aris12345678 | Kutije (COCI21_kutije) | C++14 | 210 ms | 9392 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int mxN = 1005;
int par[mxN], sz[mxN];
void make_set(int x) {
par[x] = x, sz[x] = 1;
}
int find_set(int x) {
return par[x] == x ? x : par[x] = find_set(par[x]);
}
void union_sets(int x, int y) {
x = find_set(x), y = find_set(y);
if(x == y) return;
if(sz[x] < sz[y])
swap(x, y);
par[y] = x, sz[x] += sz[y];
}
int main() {
int n, m, q;
scanf("%d %d %d", &n, &m, &q);
for(int i = 0; i < n; i++)
make_set(i);
for(int i = 0; i < m; i++) {
for(int j = 0; j < n; j++) {
int x;
scanf("%d", &x);
union_sets(j, x-1);
}
}
while(q--) {
int x, y;
scanf("%d %d", &x, &y);
if(find_set(x-1) == find_set(y-1))
printf("DA\n");
else
printf("NE\n");
}
return 0;
}
컴파일 시 표준 에러 (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... |