# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1102515 | EkinOnal | Kutije (COCI21_kutije) | C++17 | 125 ms | 1880 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//#pragma GCC optimize("O3,unroll-loops,Ofast")
//#pragma GCC target("avx2,bmi,bmi2,popcnt,lzcnt")
#include <bits/stdc++.h>
using namespace std;
struct DSU {
vector<short> e; void init(short N) { e = vector<short>(N,-1);}
short get(short x) { return e[x] < 0 ? x : e[x] = get(e[x]); }
bool sameSet(short a, short b) { return get(a) == get(b); }
short size(short x) { return -e[get(x)]; }
bool unite(short x, short y) { // union by size
x = get(x), y = get(y); if (x == y) return 0;
if (e[x] > e[y]) swap(x,y);
e[x] += e[y]; e[y] = x; return 1;
}
};
DSU t;
short n,m,a,b;
int q;
int32_t main(){
ios_base::sync_with_stdio(0); cin.tie(0);
scanf("%hi %hi %d",&n,&m,&q);
t.init(n+2);
for(int i=1;i<=m;i++){
for(int j=1;j<=n;j++){
scanf("%hi",&a);
t.unite(j,a);
}
}
while(q--){
scanf("%hi %hi",&a,&b);
if(t.sameSet(a,b)) 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... |