# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
684392 |
2023-01-21T05:46:43 Z |
doni |
Kutije (COCI21_kutije) |
C++14 |
|
433 ms |
25312 KB |
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
ll parent[1001];
ll r[1001];
ll z=0;
vector<string>s;
void make_set(ll v) {
parent[v] = v;
r[v] = z;
}
ll find_set(ll v) {
if (v == parent[v])
return v;
return parent[v] = find_set (parent[v]);
}
void union_sets(ll a, ll b) {
a = find_set (a);
b = find_set (b);
if (a != b) {
if (r[a] < r[b])
swap (a, b);
parent[b] = a;
if (r[a] == r[b])
++r[a];
}
}
void bf(){
ll n,a,b,m,q;
cin>>n>>m>>q;
for(ll i=1;i<=n;i++){
make_set(i);
}
for(ll mm=0;mm<m;mm++){
for(ll i=0;i<n;i++){
cin>>a;
union_sets(a,i+1);
}
}
for(ll i=0;i<q;i++){
cin>>a>>b;
if(find_set(a)==find_set(b)){
s.push_back("DA");
}
else{
s.push_back("NE");
}
}
for(int i=0;i<s.size();i++){
cout<<s[i]<<"\n";
}
}
/*
*/
int main(){
// ll t;cin>>t;while(t--)
bf();
}
Compilation message
Main.cpp: In function 'void bf()':
Main.cpp:56:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
56 | for(int i=0;i<s.size();i++){
| ~^~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
260 ms |
21412 KB |
Output is correct |
2 |
Correct |
250 ms |
18968 KB |
Output is correct |
3 |
Correct |
209 ms |
18968 KB |
Output is correct |
4 |
Correct |
244 ms |
21376 KB |
Output is correct |
5 |
Correct |
257 ms |
21364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
336 KB |
Output is correct |
2 |
Correct |
2 ms |
312 KB |
Output is correct |
3 |
Correct |
2 ms |
340 KB |
Output is correct |
4 |
Correct |
2 ms |
316 KB |
Output is correct |
5 |
Correct |
2 ms |
316 KB |
Output is correct |
6 |
Correct |
2 ms |
332 KB |
Output is correct |
7 |
Correct |
2 ms |
340 KB |
Output is correct |
8 |
Correct |
2 ms |
340 KB |
Output is correct |
9 |
Correct |
3 ms |
340 KB |
Output is correct |
10 |
Correct |
2 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
336 KB |
Output is correct |
2 |
Correct |
2 ms |
312 KB |
Output is correct |
3 |
Correct |
2 ms |
340 KB |
Output is correct |
4 |
Correct |
2 ms |
316 KB |
Output is correct |
5 |
Correct |
2 ms |
316 KB |
Output is correct |
6 |
Correct |
2 ms |
332 KB |
Output is correct |
7 |
Correct |
2 ms |
340 KB |
Output is correct |
8 |
Correct |
2 ms |
340 KB |
Output is correct |
9 |
Correct |
3 ms |
340 KB |
Output is correct |
10 |
Correct |
2 ms |
340 KB |
Output is correct |
11 |
Correct |
3 ms |
316 KB |
Output is correct |
12 |
Correct |
2 ms |
340 KB |
Output is correct |
13 |
Correct |
2 ms |
340 KB |
Output is correct |
14 |
Correct |
2 ms |
340 KB |
Output is correct |
15 |
Correct |
3 ms |
340 KB |
Output is correct |
16 |
Correct |
2 ms |
340 KB |
Output is correct |
17 |
Correct |
2 ms |
340 KB |
Output is correct |
18 |
Correct |
2 ms |
316 KB |
Output is correct |
19 |
Correct |
2 ms |
340 KB |
Output is correct |
20 |
Correct |
3 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
260 ms |
21412 KB |
Output is correct |
2 |
Correct |
250 ms |
18968 KB |
Output is correct |
3 |
Correct |
209 ms |
18968 KB |
Output is correct |
4 |
Correct |
244 ms |
21376 KB |
Output is correct |
5 |
Correct |
257 ms |
21364 KB |
Output is correct |
6 |
Correct |
4 ms |
336 KB |
Output is correct |
7 |
Correct |
2 ms |
312 KB |
Output is correct |
8 |
Correct |
2 ms |
340 KB |
Output is correct |
9 |
Correct |
2 ms |
316 KB |
Output is correct |
10 |
Correct |
2 ms |
316 KB |
Output is correct |
11 |
Correct |
2 ms |
332 KB |
Output is correct |
12 |
Correct |
2 ms |
340 KB |
Output is correct |
13 |
Correct |
2 ms |
340 KB |
Output is correct |
14 |
Correct |
3 ms |
340 KB |
Output is correct |
15 |
Correct |
2 ms |
340 KB |
Output is correct |
16 |
Correct |
3 ms |
316 KB |
Output is correct |
17 |
Correct |
2 ms |
340 KB |
Output is correct |
18 |
Correct |
2 ms |
340 KB |
Output is correct |
19 |
Correct |
2 ms |
340 KB |
Output is correct |
20 |
Correct |
3 ms |
340 KB |
Output is correct |
21 |
Correct |
2 ms |
340 KB |
Output is correct |
22 |
Correct |
2 ms |
340 KB |
Output is correct |
23 |
Correct |
2 ms |
316 KB |
Output is correct |
24 |
Correct |
2 ms |
340 KB |
Output is correct |
25 |
Correct |
3 ms |
340 KB |
Output is correct |
26 |
Correct |
429 ms |
25168 KB |
Output is correct |
27 |
Correct |
428 ms |
25160 KB |
Output is correct |
28 |
Correct |
352 ms |
22200 KB |
Output is correct |
29 |
Correct |
416 ms |
24296 KB |
Output is correct |
30 |
Correct |
383 ms |
22384 KB |
Output is correct |
31 |
Correct |
357 ms |
22388 KB |
Output is correct |
32 |
Correct |
427 ms |
25140 KB |
Output is correct |
33 |
Correct |
420 ms |
25312 KB |
Output is correct |
34 |
Correct |
420 ms |
25192 KB |
Output is correct |
35 |
Correct |
433 ms |
25204 KB |
Output is correct |