# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
930609 |
2024-02-20T07:53:37 Z |
Faisal_Saqib |
Joker (BOI20_joker) |
C++17 |
|
2000 ms |
22520 KB |
#include <bits/stdc++.h>
using namespace std;
const int M=2e5+1;
int n,m,q;
bool mark[M],vis[M];
int val[M];
vector<pair<int,int>> ma[M],query;
int mx_r_for_l[M];
bool found=0;
void dfs(int x)
{
vis[x]=1;
for(auto [y,ind]:ma[x])
{
if(mark[ind])
continue;
if(!vis[y])
{
val[y]=(val[x]+1)%2;
dfs(y);
}
else if((val[y]+1)%2!=val[x])
{
found=1;
}
}
}
bool check(int l,int r)
{
// cout<<"Check "<<l<<' '<<r<<endl;
for(int i=1;i<=n;i++)
vis[i]=0;
for(int i=0;i<m;i++)
mark[i]=(l<=i and i<=r);
found=0;
for(int i=1;i<=n;i++)
{
if(!vis[i])
{
dfs(i);
}
}
// cout<<"Answer "<<found<<endl;
return found;
}
int main()
{
cin.tie(0);
cout.tie(0);
ios::sync_with_stdio(0);
cin>>n>>m>>q;
for(int i=0;i<m;i++)
{
int a,b;
cin>>a>>b;
// cout<<i+1<<"th edge is "<<a<<' '<<b<<endl;
ma[a].push_back({b,i});
ma[b].push_back({a,i});
}
vector<int> difl={-1};
for(int lp=0;lp<q;lp++)
{
int l,r;
cin>>l>>r;
l--;
r--;
query.push_back({l,r});
difl.push_back(l);
}
sort(begin(difl),end(difl));
int p=-1;
for(int i=1;i<difl.size();i++)
{
if(difl[i-1]!=difl[i])
{
int l=difl[i];
int sr=max(p,l-1);
int er=m;
// cout<<"Solve "<<l<<endl;
while(sr+1<er)
{
int mid=(sr+er)/2;
if(check(l,mid))
{
//is there is odd cycle then we have to remove more edge
sr=mid;
}
else{
er=mid;
}
}
// cout<<"mx r"<<sr<<endl;
mx_r_for_l[l]=sr;
p=max(p,sr);
}
}
for(auto [l,r]:query)
{
if(mx_r_for_l[l]>=r)
{
cout<<"YES"<<'\n';
}
else{
cout<<"NO"<<'\n';
}
}
return 0;
}
Compilation message
Joker.cpp: In function 'int main()':
Joker.cpp:73:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
73 | for(int i=1;i<difl.size();i++)
| ~^~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
6492 KB |
Output is correct |
2 |
Correct |
1 ms |
6492 KB |
Output is correct |
3 |
Correct |
1 ms |
6492 KB |
Output is correct |
4 |
Correct |
2 ms |
6552 KB |
Output is correct |
5 |
Correct |
1 ms |
6492 KB |
Output is correct |
6 |
Correct |
1 ms |
6492 KB |
Output is correct |
7 |
Correct |
2 ms |
6492 KB |
Output is correct |
8 |
Correct |
2 ms |
6492 KB |
Output is correct |
9 |
Correct |
2 ms |
6492 KB |
Output is correct |
10 |
Correct |
2 ms |
6492 KB |
Output is correct |
11 |
Correct |
2 ms |
6580 KB |
Output is correct |
12 |
Correct |
3 ms |
6492 KB |
Output is correct |
13 |
Correct |
2 ms |
6492 KB |
Output is correct |
14 |
Correct |
3 ms |
6488 KB |
Output is correct |
15 |
Correct |
2 ms |
6492 KB |
Output is correct |
16 |
Correct |
2 ms |
6492 KB |
Output is correct |
17 |
Correct |
2 ms |
6488 KB |
Output is correct |
18 |
Correct |
2 ms |
6492 KB |
Output is correct |
19 |
Correct |
2 ms |
6492 KB |
Output is correct |
20 |
Correct |
2 ms |
6492 KB |
Output is correct |
21 |
Correct |
2 ms |
6492 KB |
Output is correct |
22 |
Correct |
2 ms |
6492 KB |
Output is correct |
23 |
Correct |
2 ms |
6492 KB |
Output is correct |
24 |
Correct |
2 ms |
6492 KB |
Output is correct |
25 |
Correct |
2 ms |
6492 KB |
Output is correct |
26 |
Correct |
2 ms |
6492 KB |
Output is correct |
27 |
Correct |
2 ms |
6492 KB |
Output is correct |
28 |
Correct |
2 ms |
6580 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
6492 KB |
Output is correct |
2 |
Correct |
1 ms |
6492 KB |
Output is correct |
3 |
Correct |
1 ms |
6492 KB |
Output is correct |
4 |
Correct |
2 ms |
6552 KB |
Output is correct |
5 |
Correct |
1 ms |
6492 KB |
Output is correct |
6 |
Correct |
1 ms |
6492 KB |
Output is correct |
7 |
Correct |
2 ms |
6492 KB |
Output is correct |
8 |
Correct |
2 ms |
6492 KB |
Output is correct |
9 |
Correct |
2 ms |
6492 KB |
Output is correct |
10 |
Correct |
2 ms |
6492 KB |
Output is correct |
11 |
Correct |
2 ms |
6580 KB |
Output is correct |
12 |
Correct |
3 ms |
6492 KB |
Output is correct |
13 |
Correct |
2 ms |
6492 KB |
Output is correct |
14 |
Correct |
3 ms |
6488 KB |
Output is correct |
15 |
Correct |
2 ms |
6492 KB |
Output is correct |
16 |
Correct |
2 ms |
6492 KB |
Output is correct |
17 |
Correct |
2 ms |
6488 KB |
Output is correct |
18 |
Correct |
2 ms |
6492 KB |
Output is correct |
19 |
Correct |
2 ms |
6492 KB |
Output is correct |
20 |
Correct |
2 ms |
6492 KB |
Output is correct |
21 |
Correct |
2 ms |
6492 KB |
Output is correct |
22 |
Correct |
2 ms |
6492 KB |
Output is correct |
23 |
Correct |
2 ms |
6492 KB |
Output is correct |
24 |
Correct |
2 ms |
6492 KB |
Output is correct |
25 |
Correct |
2 ms |
6492 KB |
Output is correct |
26 |
Correct |
2 ms |
6492 KB |
Output is correct |
27 |
Correct |
2 ms |
6492 KB |
Output is correct |
28 |
Correct |
2 ms |
6580 KB |
Output is correct |
29 |
Correct |
128 ms |
6692 KB |
Output is correct |
30 |
Correct |
136 ms |
6492 KB |
Output is correct |
31 |
Correct |
109 ms |
6728 KB |
Output is correct |
32 |
Correct |
50 ms |
6744 KB |
Output is correct |
33 |
Correct |
13 ms |
6748 KB |
Output is correct |
34 |
Correct |
96 ms |
6748 KB |
Output is correct |
35 |
Correct |
175 ms |
6724 KB |
Output is correct |
36 |
Correct |
70 ms |
6748 KB |
Output is correct |
37 |
Correct |
133 ms |
6992 KB |
Output is correct |
38 |
Correct |
243 ms |
6748 KB |
Output is correct |
39 |
Correct |
70 ms |
6740 KB |
Output is correct |
40 |
Correct |
39 ms |
6744 KB |
Output is correct |
41 |
Correct |
35 ms |
6764 KB |
Output is correct |
42 |
Correct |
34 ms |
7004 KB |
Output is correct |
43 |
Correct |
26 ms |
6748 KB |
Output is correct |
44 |
Correct |
60 ms |
6760 KB |
Output is correct |
45 |
Correct |
72 ms |
6744 KB |
Output is correct |
46 |
Correct |
156 ms |
7000 KB |
Output is correct |
47 |
Correct |
59 ms |
6744 KB |
Output is correct |
48 |
Correct |
72 ms |
6736 KB |
Output is correct |
49 |
Correct |
93 ms |
6724 KB |
Output is correct |
50 |
Correct |
118 ms |
6716 KB |
Output is correct |
51 |
Correct |
32 ms |
6744 KB |
Output is correct |
52 |
Correct |
52 ms |
6748 KB |
Output is correct |
53 |
Correct |
96 ms |
6736 KB |
Output is correct |
54 |
Correct |
161 ms |
6748 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
6492 KB |
Output is correct |
2 |
Correct |
1 ms |
6492 KB |
Output is correct |
3 |
Correct |
133 ms |
18996 KB |
Output is correct |
4 |
Correct |
198 ms |
19256 KB |
Output is correct |
5 |
Correct |
167 ms |
18316 KB |
Output is correct |
6 |
Correct |
203 ms |
18972 KB |
Output is correct |
7 |
Correct |
186 ms |
18996 KB |
Output is correct |
8 |
Correct |
167 ms |
18360 KB |
Output is correct |
9 |
Correct |
224 ms |
19268 KB |
Output is correct |
10 |
Correct |
292 ms |
18720 KB |
Output is correct |
11 |
Correct |
214 ms |
18276 KB |
Output is correct |
12 |
Correct |
226 ms |
18112 KB |
Output is correct |
13 |
Correct |
125 ms |
16432 KB |
Output is correct |
14 |
Correct |
166 ms |
18100 KB |
Output is correct |
15 |
Correct |
239 ms |
19128 KB |
Output is correct |
16 |
Correct |
282 ms |
18460 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
6492 KB |
Output is correct |
2 |
Correct |
1 ms |
6492 KB |
Output is correct |
3 |
Correct |
1 ms |
6492 KB |
Output is correct |
4 |
Correct |
2 ms |
6552 KB |
Output is correct |
5 |
Correct |
1 ms |
6492 KB |
Output is correct |
6 |
Correct |
1 ms |
6492 KB |
Output is correct |
7 |
Correct |
2 ms |
6492 KB |
Output is correct |
8 |
Correct |
2 ms |
6492 KB |
Output is correct |
9 |
Correct |
2 ms |
6492 KB |
Output is correct |
10 |
Correct |
2 ms |
6492 KB |
Output is correct |
11 |
Correct |
2 ms |
6580 KB |
Output is correct |
12 |
Correct |
3 ms |
6492 KB |
Output is correct |
13 |
Correct |
2 ms |
6492 KB |
Output is correct |
14 |
Correct |
3 ms |
6488 KB |
Output is correct |
15 |
Correct |
2 ms |
6492 KB |
Output is correct |
16 |
Correct |
2 ms |
6492 KB |
Output is correct |
17 |
Correct |
2 ms |
6488 KB |
Output is correct |
18 |
Correct |
2 ms |
6492 KB |
Output is correct |
19 |
Correct |
2 ms |
6492 KB |
Output is correct |
20 |
Correct |
2 ms |
6492 KB |
Output is correct |
21 |
Correct |
2 ms |
6492 KB |
Output is correct |
22 |
Correct |
2 ms |
6492 KB |
Output is correct |
23 |
Correct |
2 ms |
6492 KB |
Output is correct |
24 |
Correct |
2 ms |
6492 KB |
Output is correct |
25 |
Correct |
2 ms |
6492 KB |
Output is correct |
26 |
Correct |
2 ms |
6492 KB |
Output is correct |
27 |
Correct |
2 ms |
6492 KB |
Output is correct |
28 |
Correct |
2 ms |
6580 KB |
Output is correct |
29 |
Correct |
133 ms |
18996 KB |
Output is correct |
30 |
Correct |
198 ms |
19256 KB |
Output is correct |
31 |
Correct |
167 ms |
18316 KB |
Output is correct |
32 |
Correct |
203 ms |
18972 KB |
Output is correct |
33 |
Correct |
186 ms |
18996 KB |
Output is correct |
34 |
Correct |
167 ms |
18360 KB |
Output is correct |
35 |
Correct |
224 ms |
19268 KB |
Output is correct |
36 |
Correct |
292 ms |
18720 KB |
Output is correct |
37 |
Correct |
214 ms |
18276 KB |
Output is correct |
38 |
Correct |
226 ms |
18112 KB |
Output is correct |
39 |
Correct |
125 ms |
16432 KB |
Output is correct |
40 |
Correct |
166 ms |
18100 KB |
Output is correct |
41 |
Correct |
239 ms |
19128 KB |
Output is correct |
42 |
Correct |
282 ms |
18460 KB |
Output is correct |
43 |
Execution timed out |
2016 ms |
22520 KB |
Time limit exceeded |
44 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
6492 KB |
Output is correct |
2 |
Correct |
1 ms |
6492 KB |
Output is correct |
3 |
Correct |
1 ms |
6492 KB |
Output is correct |
4 |
Correct |
2 ms |
6552 KB |
Output is correct |
5 |
Correct |
1 ms |
6492 KB |
Output is correct |
6 |
Correct |
1 ms |
6492 KB |
Output is correct |
7 |
Correct |
2 ms |
6492 KB |
Output is correct |
8 |
Correct |
2 ms |
6492 KB |
Output is correct |
9 |
Correct |
2 ms |
6492 KB |
Output is correct |
10 |
Correct |
2 ms |
6492 KB |
Output is correct |
11 |
Correct |
2 ms |
6580 KB |
Output is correct |
12 |
Correct |
3 ms |
6492 KB |
Output is correct |
13 |
Correct |
2 ms |
6492 KB |
Output is correct |
14 |
Correct |
3 ms |
6488 KB |
Output is correct |
15 |
Correct |
2 ms |
6492 KB |
Output is correct |
16 |
Correct |
2 ms |
6492 KB |
Output is correct |
17 |
Correct |
2 ms |
6488 KB |
Output is correct |
18 |
Correct |
2 ms |
6492 KB |
Output is correct |
19 |
Correct |
2 ms |
6492 KB |
Output is correct |
20 |
Correct |
2 ms |
6492 KB |
Output is correct |
21 |
Correct |
2 ms |
6492 KB |
Output is correct |
22 |
Correct |
2 ms |
6492 KB |
Output is correct |
23 |
Correct |
2 ms |
6492 KB |
Output is correct |
24 |
Correct |
2 ms |
6492 KB |
Output is correct |
25 |
Correct |
2 ms |
6492 KB |
Output is correct |
26 |
Correct |
2 ms |
6492 KB |
Output is correct |
27 |
Correct |
2 ms |
6492 KB |
Output is correct |
28 |
Correct |
2 ms |
6580 KB |
Output is correct |
29 |
Correct |
128 ms |
6692 KB |
Output is correct |
30 |
Correct |
136 ms |
6492 KB |
Output is correct |
31 |
Correct |
109 ms |
6728 KB |
Output is correct |
32 |
Correct |
50 ms |
6744 KB |
Output is correct |
33 |
Correct |
13 ms |
6748 KB |
Output is correct |
34 |
Correct |
96 ms |
6748 KB |
Output is correct |
35 |
Correct |
175 ms |
6724 KB |
Output is correct |
36 |
Correct |
70 ms |
6748 KB |
Output is correct |
37 |
Correct |
133 ms |
6992 KB |
Output is correct |
38 |
Correct |
243 ms |
6748 KB |
Output is correct |
39 |
Correct |
70 ms |
6740 KB |
Output is correct |
40 |
Correct |
39 ms |
6744 KB |
Output is correct |
41 |
Correct |
35 ms |
6764 KB |
Output is correct |
42 |
Correct |
34 ms |
7004 KB |
Output is correct |
43 |
Correct |
26 ms |
6748 KB |
Output is correct |
44 |
Correct |
60 ms |
6760 KB |
Output is correct |
45 |
Correct |
72 ms |
6744 KB |
Output is correct |
46 |
Correct |
156 ms |
7000 KB |
Output is correct |
47 |
Correct |
59 ms |
6744 KB |
Output is correct |
48 |
Correct |
72 ms |
6736 KB |
Output is correct |
49 |
Correct |
93 ms |
6724 KB |
Output is correct |
50 |
Correct |
118 ms |
6716 KB |
Output is correct |
51 |
Correct |
32 ms |
6744 KB |
Output is correct |
52 |
Correct |
52 ms |
6748 KB |
Output is correct |
53 |
Correct |
96 ms |
6736 KB |
Output is correct |
54 |
Correct |
161 ms |
6748 KB |
Output is correct |
55 |
Execution timed out |
2067 ms |
15204 KB |
Time limit exceeded |
56 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
6492 KB |
Output is correct |
2 |
Correct |
1 ms |
6492 KB |
Output is correct |
3 |
Correct |
1 ms |
6492 KB |
Output is correct |
4 |
Correct |
2 ms |
6552 KB |
Output is correct |
5 |
Correct |
1 ms |
6492 KB |
Output is correct |
6 |
Correct |
1 ms |
6492 KB |
Output is correct |
7 |
Correct |
2 ms |
6492 KB |
Output is correct |
8 |
Correct |
2 ms |
6492 KB |
Output is correct |
9 |
Correct |
2 ms |
6492 KB |
Output is correct |
10 |
Correct |
2 ms |
6492 KB |
Output is correct |
11 |
Correct |
2 ms |
6580 KB |
Output is correct |
12 |
Correct |
3 ms |
6492 KB |
Output is correct |
13 |
Correct |
2 ms |
6492 KB |
Output is correct |
14 |
Correct |
3 ms |
6488 KB |
Output is correct |
15 |
Correct |
2 ms |
6492 KB |
Output is correct |
16 |
Correct |
2 ms |
6492 KB |
Output is correct |
17 |
Correct |
2 ms |
6488 KB |
Output is correct |
18 |
Correct |
2 ms |
6492 KB |
Output is correct |
19 |
Correct |
2 ms |
6492 KB |
Output is correct |
20 |
Correct |
2 ms |
6492 KB |
Output is correct |
21 |
Correct |
2 ms |
6492 KB |
Output is correct |
22 |
Correct |
2 ms |
6492 KB |
Output is correct |
23 |
Correct |
2 ms |
6492 KB |
Output is correct |
24 |
Correct |
2 ms |
6492 KB |
Output is correct |
25 |
Correct |
2 ms |
6492 KB |
Output is correct |
26 |
Correct |
2 ms |
6492 KB |
Output is correct |
27 |
Correct |
2 ms |
6492 KB |
Output is correct |
28 |
Correct |
2 ms |
6580 KB |
Output is correct |
29 |
Correct |
128 ms |
6692 KB |
Output is correct |
30 |
Correct |
136 ms |
6492 KB |
Output is correct |
31 |
Correct |
109 ms |
6728 KB |
Output is correct |
32 |
Correct |
50 ms |
6744 KB |
Output is correct |
33 |
Correct |
13 ms |
6748 KB |
Output is correct |
34 |
Correct |
96 ms |
6748 KB |
Output is correct |
35 |
Correct |
175 ms |
6724 KB |
Output is correct |
36 |
Correct |
70 ms |
6748 KB |
Output is correct |
37 |
Correct |
133 ms |
6992 KB |
Output is correct |
38 |
Correct |
243 ms |
6748 KB |
Output is correct |
39 |
Correct |
70 ms |
6740 KB |
Output is correct |
40 |
Correct |
39 ms |
6744 KB |
Output is correct |
41 |
Correct |
35 ms |
6764 KB |
Output is correct |
42 |
Correct |
34 ms |
7004 KB |
Output is correct |
43 |
Correct |
26 ms |
6748 KB |
Output is correct |
44 |
Correct |
60 ms |
6760 KB |
Output is correct |
45 |
Correct |
72 ms |
6744 KB |
Output is correct |
46 |
Correct |
156 ms |
7000 KB |
Output is correct |
47 |
Correct |
59 ms |
6744 KB |
Output is correct |
48 |
Correct |
72 ms |
6736 KB |
Output is correct |
49 |
Correct |
93 ms |
6724 KB |
Output is correct |
50 |
Correct |
118 ms |
6716 KB |
Output is correct |
51 |
Correct |
32 ms |
6744 KB |
Output is correct |
52 |
Correct |
52 ms |
6748 KB |
Output is correct |
53 |
Correct |
96 ms |
6736 KB |
Output is correct |
54 |
Correct |
161 ms |
6748 KB |
Output is correct |
55 |
Correct |
133 ms |
18996 KB |
Output is correct |
56 |
Correct |
198 ms |
19256 KB |
Output is correct |
57 |
Correct |
167 ms |
18316 KB |
Output is correct |
58 |
Correct |
203 ms |
18972 KB |
Output is correct |
59 |
Correct |
186 ms |
18996 KB |
Output is correct |
60 |
Correct |
167 ms |
18360 KB |
Output is correct |
61 |
Correct |
224 ms |
19268 KB |
Output is correct |
62 |
Correct |
292 ms |
18720 KB |
Output is correct |
63 |
Correct |
214 ms |
18276 KB |
Output is correct |
64 |
Correct |
226 ms |
18112 KB |
Output is correct |
65 |
Correct |
125 ms |
16432 KB |
Output is correct |
66 |
Correct |
166 ms |
18100 KB |
Output is correct |
67 |
Correct |
239 ms |
19128 KB |
Output is correct |
68 |
Correct |
282 ms |
18460 KB |
Output is correct |
69 |
Execution timed out |
2016 ms |
22520 KB |
Time limit exceeded |
70 |
Halted |
0 ms |
0 KB |
- |