# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
866672 |
2023-10-26T16:34:43 Z |
epicci23 |
Kutije (COCI21_kutije) |
C++17 |
|
142 ms |
9648 KB |
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define endl "\n"
#define int long long
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
constexpr int N = 1005;
int par[N];
int siz[N];
int find(int a){
if(par[a]==a) return a;
return par[a]=find(par[a]);
}
void unite(int a,int b){
a=find(a),b=find(b);
if(a==b) return;
if(siz[a]>siz[b]) swap(a,b);
siz[b]+=siz[a];
par[a]=b;
}
void solve(){
iota(par,par+N,0LL);
fill(siz,siz+N,1LL);
int n,m,q;
cin >> n >> m >> q;
for(int j=1;j<=m;j++){
for(int i=1;i<=n;i++){
int u;
cin >> u;
unite(i,u);
}
}
while(q--){
int a,b;
cin >> a >> b;
if(find(a)==find(b)) cout << "DA\n";
else cout << "NE\n";
}
}
int32_t main(){
cin.tie(0); ios::sync_with_stdio(0);
int t=1;//cin >> t;
while(t--) solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
62 ms |
5556 KB |
Output is correct |
2 |
Correct |
54 ms |
4928 KB |
Output is correct |
3 |
Correct |
57 ms |
4992 KB |
Output is correct |
4 |
Correct |
64 ms |
5716 KB |
Output is correct |
5 |
Correct |
65 ms |
5716 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
476 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
476 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
460 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
344 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
62 ms |
5556 KB |
Output is correct |
2 |
Correct |
54 ms |
4928 KB |
Output is correct |
3 |
Correct |
57 ms |
4992 KB |
Output is correct |
4 |
Correct |
64 ms |
5716 KB |
Output is correct |
5 |
Correct |
65 ms |
5716 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
476 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
460 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
344 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
348 KB |
Output is correct |
25 |
Correct |
1 ms |
348 KB |
Output is correct |
26 |
Correct |
118 ms |
9536 KB |
Output is correct |
27 |
Correct |
142 ms |
9648 KB |
Output is correct |
28 |
Correct |
110 ms |
7868 KB |
Output is correct |
29 |
Correct |
113 ms |
9012 KB |
Output is correct |
30 |
Correct |
108 ms |
8196 KB |
Output is correct |
31 |
Correct |
102 ms |
8020 KB |
Output is correct |
32 |
Correct |
114 ms |
9552 KB |
Output is correct |
33 |
Correct |
131 ms |
9328 KB |
Output is correct |
34 |
Correct |
114 ms |
9528 KB |
Output is correct |
35 |
Correct |
121 ms |
9524 KB |
Output is correct |