답안 #556873

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
556873 2022-05-04T08:38:14 Z new_acc Kutije (COCI21_kutije) C++14
70 / 70
173 ms 9504 KB
#include<bits/stdc++.h>
#define fi first
#define se second
#define pitem item*
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
const int N=1e6+10;
const int SS=1<<19;
const int INFi=2e9;
const ll INFl=1e13;
const ll mod2=998244353;
const ll mod=1e9+7;
const ll mod3=1000696969;
const ll p=70032301;
const ull p2=913;
const int L=20;
int t[N],fau[N];
int Find(int a){
    if(fau[a]==a) return a;
    return fau[a]=Find(fau[a]);
}
void Union(int a,int b){
    a=Find(a),b=Find(b);
    fau[a]=b;
}
void solve(){
    int n,m,q;
    cin>>n>>m>>q;
    for(int i=1;i<=n;i++) fau[i]=i;
    for(int i=1;i<=m;i++){
        for(int k=1;k<=n;k++){
            int a;
            cin>>a;
            Union(k,a);
        }
    }
    while(q--){
        int a,b;
        cin>>a>>b;
        cout<<(Find(a)==Find(b)?"DA":"NE")<<"\n";
    }
}
int main(){
    ios_base::sync_with_stdio(0),cin.tie(0);
    int tt=1;
    while(tt--) solve();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 91 ms 5560 KB Output is correct
2 Correct 99 ms 4980 KB Output is correct
3 Correct 73 ms 4556 KB Output is correct
4 Correct 86 ms 5620 KB Output is correct
5 Correct 100 ms 5556 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 352 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 2 ms 356 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 352 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 2 ms 356 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 360 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 91 ms 5560 KB Output is correct
2 Correct 99 ms 4980 KB Output is correct
3 Correct 73 ms 4556 KB Output is correct
4 Correct 86 ms 5620 KB Output is correct
5 Correct 100 ms 5556 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 352 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 2 ms 356 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 360 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 167 ms 9324 KB Output is correct
27 Correct 153 ms 9504 KB Output is correct
28 Correct 133 ms 7756 KB Output is correct
29 Correct 161 ms 9064 KB Output is correct
30 Correct 147 ms 7972 KB Output is correct
31 Correct 144 ms 7992 KB Output is correct
32 Correct 153 ms 9448 KB Output is correct
33 Correct 169 ms 9376 KB Output is correct
34 Correct 173 ms 9464 KB Output is correct
35 Correct 162 ms 9408 KB Output is correct