# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
649788 |
2022-10-11T10:55:14 Z |
DJeniUp |
Joker (BOI20_joker) |
C++17 |
|
2000 ms |
10244 KB |
#include "bits/stdc++.h"
//#pragma GCC optimize("O3")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pairll;
typedef long double ld;
#define fr first
#define sc second
#define pb push_back
#define INF 100000000007
#define endl '\n'
#define MOD 998244353
#define N 200007
ll n,m,q,p[N],t[N],res[N],h[N],f,k;
struct Q{
ll l,r;
}o[N];
struct D{
ll l,r;
}d[N];
set<ll>s;
ll P(ll x){
if(p[x]==x)return x;
return P(p[x]);
}
ll H(ll x){
ll r1=0;
while(p[x]!=x){
r1+=h[x];
x=p[x];
}
return r1;
}
void A(ll x,ll y){
if(rand()%2)swap(x,y);
ll x1=P(x);
ll y1=P(y);
h[x1]=H(x)+1+H(y);
p[x1]=y1;
return ;
}
int main(){
cin>>n>>m>>q;
//s.insert(0);
for(int i=1;i<=m;i++){
cin>>d[i].l>>d[i].r;
}
for(int i=1;i<=q;i++){
cin>>o[i].l>>o[i].r;
s.insert(o[i].l-1);
}
for(auto it:s){
res[it]=0;
for(int i=1;i<=n;i++){
p[i]=i;
h[i]=0;
}
for(int i=1;i<=it;i++){
if(P(d[i].l)!=P(d[i].r)){
A(d[i].l,d[i].r);
}else if(H(d[i].l)%2==H(d[i].r)%2){
res[it]=m+1;
}
}
if(res[it]!=0)continue;
for(int i=m;i>=it;i--){
if(P(d[i].l)==P(d[i].r) && H(d[i].l)%2==H(d[i].r)%2){
res[it]=i;
break;
}else if(P(d[i].l)!=P(d[i].r))A(d[i].l,d[i].r);
}
}
for(int i=1;i<=q;i++){
if(res[o[i].l-1]>o[i].r)cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
2 ms |
340 KB |
Output is correct |
9 |
Correct |
2 ms |
340 KB |
Output is correct |
10 |
Correct |
2 ms |
340 KB |
Output is correct |
11 |
Correct |
2 ms |
340 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 |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
2 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
2 ms |
340 KB |
Output is correct |
20 |
Correct |
2 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 |
340 KB |
Output is correct |
24 |
Correct |
2 ms |
340 KB |
Output is correct |
25 |
Correct |
1 ms |
340 KB |
Output is correct |
26 |
Correct |
2 ms |
340 KB |
Output is correct |
27 |
Correct |
2 ms |
340 KB |
Output is correct |
28 |
Correct |
3 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
2 ms |
340 KB |
Output is correct |
9 |
Correct |
2 ms |
340 KB |
Output is correct |
10 |
Correct |
2 ms |
340 KB |
Output is correct |
11 |
Correct |
2 ms |
340 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 |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
2 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
2 ms |
340 KB |
Output is correct |
20 |
Correct |
2 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 |
340 KB |
Output is correct |
24 |
Correct |
2 ms |
340 KB |
Output is correct |
25 |
Correct |
1 ms |
340 KB |
Output is correct |
26 |
Correct |
2 ms |
340 KB |
Output is correct |
27 |
Correct |
2 ms |
340 KB |
Output is correct |
28 |
Correct |
3 ms |
340 KB |
Output is correct |
29 |
Correct |
34 ms |
460 KB |
Output is correct |
30 |
Correct |
92 ms |
488 KB |
Output is correct |
31 |
Correct |
222 ms |
492 KB |
Output is correct |
32 |
Correct |
332 ms |
468 KB |
Output is correct |
33 |
Correct |
367 ms |
472 KB |
Output is correct |
34 |
Correct |
150 ms |
468 KB |
Output is correct |
35 |
Correct |
157 ms |
496 KB |
Output is correct |
36 |
Correct |
783 ms |
472 KB |
Output is correct |
37 |
Correct |
77 ms |
488 KB |
Output is correct |
38 |
Correct |
110 ms |
480 KB |
Output is correct |
39 |
Incorrect |
148 ms |
496 KB |
Output isn't correct |
40 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
201 ms |
8744 KB |
Output is correct |
4 |
Correct |
196 ms |
10244 KB |
Output is correct |
5 |
Correct |
216 ms |
9960 KB |
Output is correct |
6 |
Correct |
201 ms |
8652 KB |
Output is correct |
7 |
Correct |
206 ms |
8692 KB |
Output is correct |
8 |
Execution timed out |
2078 ms |
7552 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
2 ms |
340 KB |
Output is correct |
9 |
Correct |
2 ms |
340 KB |
Output is correct |
10 |
Correct |
2 ms |
340 KB |
Output is correct |
11 |
Correct |
2 ms |
340 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 |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
2 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
2 ms |
340 KB |
Output is correct |
20 |
Correct |
2 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 |
340 KB |
Output is correct |
24 |
Correct |
2 ms |
340 KB |
Output is correct |
25 |
Correct |
1 ms |
340 KB |
Output is correct |
26 |
Correct |
2 ms |
340 KB |
Output is correct |
27 |
Correct |
2 ms |
340 KB |
Output is correct |
28 |
Correct |
3 ms |
340 KB |
Output is correct |
29 |
Correct |
201 ms |
8744 KB |
Output is correct |
30 |
Correct |
196 ms |
10244 KB |
Output is correct |
31 |
Correct |
216 ms |
9960 KB |
Output is correct |
32 |
Correct |
201 ms |
8652 KB |
Output is correct |
33 |
Correct |
206 ms |
8692 KB |
Output is correct |
34 |
Execution timed out |
2078 ms |
7552 KB |
Time limit exceeded |
35 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
2 ms |
340 KB |
Output is correct |
9 |
Correct |
2 ms |
340 KB |
Output is correct |
10 |
Correct |
2 ms |
340 KB |
Output is correct |
11 |
Correct |
2 ms |
340 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 |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
2 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
2 ms |
340 KB |
Output is correct |
20 |
Correct |
2 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 |
340 KB |
Output is correct |
24 |
Correct |
2 ms |
340 KB |
Output is correct |
25 |
Correct |
1 ms |
340 KB |
Output is correct |
26 |
Correct |
2 ms |
340 KB |
Output is correct |
27 |
Correct |
2 ms |
340 KB |
Output is correct |
28 |
Correct |
3 ms |
340 KB |
Output is correct |
29 |
Correct |
34 ms |
460 KB |
Output is correct |
30 |
Correct |
92 ms |
488 KB |
Output is correct |
31 |
Correct |
222 ms |
492 KB |
Output is correct |
32 |
Correct |
332 ms |
468 KB |
Output is correct |
33 |
Correct |
367 ms |
472 KB |
Output is correct |
34 |
Correct |
150 ms |
468 KB |
Output is correct |
35 |
Correct |
157 ms |
496 KB |
Output is correct |
36 |
Correct |
783 ms |
472 KB |
Output is correct |
37 |
Correct |
77 ms |
488 KB |
Output is correct |
38 |
Correct |
110 ms |
480 KB |
Output is correct |
39 |
Incorrect |
148 ms |
496 KB |
Output isn't correct |
40 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
2 ms |
340 KB |
Output is correct |
9 |
Correct |
2 ms |
340 KB |
Output is correct |
10 |
Correct |
2 ms |
340 KB |
Output is correct |
11 |
Correct |
2 ms |
340 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 |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
2 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
2 ms |
340 KB |
Output is correct |
20 |
Correct |
2 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 |
340 KB |
Output is correct |
24 |
Correct |
2 ms |
340 KB |
Output is correct |
25 |
Correct |
1 ms |
340 KB |
Output is correct |
26 |
Correct |
2 ms |
340 KB |
Output is correct |
27 |
Correct |
2 ms |
340 KB |
Output is correct |
28 |
Correct |
3 ms |
340 KB |
Output is correct |
29 |
Correct |
34 ms |
460 KB |
Output is correct |
30 |
Correct |
92 ms |
488 KB |
Output is correct |
31 |
Correct |
222 ms |
492 KB |
Output is correct |
32 |
Correct |
332 ms |
468 KB |
Output is correct |
33 |
Correct |
367 ms |
472 KB |
Output is correct |
34 |
Correct |
150 ms |
468 KB |
Output is correct |
35 |
Correct |
157 ms |
496 KB |
Output is correct |
36 |
Correct |
783 ms |
472 KB |
Output is correct |
37 |
Correct |
77 ms |
488 KB |
Output is correct |
38 |
Correct |
110 ms |
480 KB |
Output is correct |
39 |
Incorrect |
148 ms |
496 KB |
Output isn't correct |
40 |
Halted |
0 ms |
0 KB |
- |