# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
925809 |
2024-02-12T09:11:26 Z |
vjudge1 |
Joker (BOI20_joker) |
C++17 |
|
2000 ms |
20904 KB |
/*
no more temmy :(
*/
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
// #include<icecream.hpp>
// using namespace icecream;
#define ll long long
// #define int ll
// #define ld long double
#define y1 cheza
// mt19937 rng(1983413);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T> using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
const int N=2e5+100;
const int M=1e6;
const int B=317;
const int mod=998244353;
// const int INF=1e18;
const int lg=64;
const int dx[]={1,-1,0,0};
const int dy[]={0,0,1,-1};
const double eps=1e-9;
int n,m,q;
vector<pair<int,int>>g[N];
int a[N];
int lx,rx;
int dfs(int x){
for(auto [i,w]:g[x]){
if(lx<=w&&w<=rx)continue;
if(a[i]==-1){
a[i]=a[x]^1;
if(dfs(i)){
return 1;
}
}
else{
if(a[i]==a[x]){
return 1;
}
}
}
return 0;
}
bool check(){
for(int i=1;i<=n;i++){
a[i]=-1;
}
for(int i=1;i<=n;i++){
if(a[i]==-1){
if(dfs(i)){
return 1;
}
}
}
return 0;
}
void solve1(){
for(;q--;){
cin>>lx>>rx;
for(int i=1;i<=n;i++){
a[i]=-1;
}
int ans=0;
for(int i=1;i<=n;i++){
if(a[i]==-1){
if(dfs(i)){
ans=1;
break;
}
}
}
if(ans){
cout<<"YES\n";
}
else{
cout<<"NO\n";
}
}
}
vector<pair<int,int>>f[N];
bitset<N> ans;
void test(){
// cin>>n>>m>>q;
scanf("%d%d%d",&n,&m,&q);
for(int i=1,x,y;i<=m;i++){
// cin>>x>>y;
scanf("%d%d",&x,&y);
g[x].push_back({y,i});
g[y].push_back({x,i});
}
if(n<=2000&&m<=2000&&q<=2000){
solve1();
return;
}
for(int i=1;i<=q;i++){
// cin>>lx>>rx;
scanf("%d%d",&lx,&rx);
f[lx].push_back({rx,i});
}
for(int i=1;i<=min(n,200);i++){
sort(f[i].begin(),f[i].end());
int l=0;
int r=f[i].size()-1;
while(l<=r){
int mid=(l+r)>>1ll;
lx=i;
rx=f[i][mid].first;
if(check()){
l=mid+1;
}
else{
r=mid-1;
}
}
l--;
for(int j=0;j<=l;j++){
ans[f[i][j].second]=1;
}
}
for(int i=1;i<=q;i++){
if(ans[i]){
printf("YES\n");
// cout<<"YES\n";
}
else{
printf("NO\n");
// cout<<"NO\n";
}
}
}
/*
*/
signed main(){
// ic.prefix("debug->| ");
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
// ios_base::sync_with_stdio(false);
// cin.tie(nullptr);
// cout.tie(nullptr);
long long t2=1;
// cin>>t2;
for(int i=1;i<=t2;i++){
test();
}
return 0;
}
Compilation message
Joker.cpp: In function 'void test()':
Joker.cpp:95:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
95 | scanf("%d%d%d",&n,&m,&q);
| ~~~~~^~~~~~~~~~~~~~~~~~~
Joker.cpp:98:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
98 | scanf("%d%d",&x,&y);
| ~~~~~^~~~~~~~~~~~~~
Joker.cpp:108:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
108 | scanf("%d%d",&lx,&rx);
| ~~~~~^~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
10584 KB |
Output is correct |
2 |
Correct |
3 ms |
10588 KB |
Output is correct |
3 |
Correct |
3 ms |
10588 KB |
Output is correct |
4 |
Correct |
2 ms |
10424 KB |
Output is correct |
5 |
Correct |
3 ms |
10588 KB |
Output is correct |
6 |
Correct |
3 ms |
10612 KB |
Output is correct |
7 |
Correct |
3 ms |
10584 KB |
Output is correct |
8 |
Correct |
3 ms |
10432 KB |
Output is correct |
9 |
Correct |
4 ms |
10588 KB |
Output is correct |
10 |
Correct |
3 ms |
10588 KB |
Output is correct |
11 |
Correct |
4 ms |
10840 KB |
Output is correct |
12 |
Correct |
4 ms |
10584 KB |
Output is correct |
13 |
Correct |
4 ms |
10584 KB |
Output is correct |
14 |
Correct |
4 ms |
10588 KB |
Output is correct |
15 |
Correct |
4 ms |
10588 KB |
Output is correct |
16 |
Correct |
4 ms |
10588 KB |
Output is correct |
17 |
Correct |
3 ms |
10588 KB |
Output is correct |
18 |
Correct |
3 ms |
10588 KB |
Output is correct |
19 |
Correct |
3 ms |
10588 KB |
Output is correct |
20 |
Correct |
3 ms |
10588 KB |
Output is correct |
21 |
Correct |
3 ms |
10588 KB |
Output is correct |
22 |
Correct |
3 ms |
10588 KB |
Output is correct |
23 |
Correct |
4 ms |
10588 KB |
Output is correct |
24 |
Correct |
3 ms |
10588 KB |
Output is correct |
25 |
Correct |
4 ms |
10588 KB |
Output is correct |
26 |
Correct |
3 ms |
10584 KB |
Output is correct |
27 |
Correct |
3 ms |
10588 KB |
Output is correct |
28 |
Correct |
4 ms |
10840 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
10584 KB |
Output is correct |
2 |
Correct |
3 ms |
10588 KB |
Output is correct |
3 |
Correct |
3 ms |
10588 KB |
Output is correct |
4 |
Correct |
2 ms |
10424 KB |
Output is correct |
5 |
Correct |
3 ms |
10588 KB |
Output is correct |
6 |
Correct |
3 ms |
10612 KB |
Output is correct |
7 |
Correct |
3 ms |
10584 KB |
Output is correct |
8 |
Correct |
3 ms |
10432 KB |
Output is correct |
9 |
Correct |
4 ms |
10588 KB |
Output is correct |
10 |
Correct |
3 ms |
10588 KB |
Output is correct |
11 |
Correct |
4 ms |
10840 KB |
Output is correct |
12 |
Correct |
4 ms |
10584 KB |
Output is correct |
13 |
Correct |
4 ms |
10584 KB |
Output is correct |
14 |
Correct |
4 ms |
10588 KB |
Output is correct |
15 |
Correct |
4 ms |
10588 KB |
Output is correct |
16 |
Correct |
4 ms |
10588 KB |
Output is correct |
17 |
Correct |
3 ms |
10588 KB |
Output is correct |
18 |
Correct |
3 ms |
10588 KB |
Output is correct |
19 |
Correct |
3 ms |
10588 KB |
Output is correct |
20 |
Correct |
3 ms |
10588 KB |
Output is correct |
21 |
Correct |
3 ms |
10588 KB |
Output is correct |
22 |
Correct |
3 ms |
10588 KB |
Output is correct |
23 |
Correct |
4 ms |
10588 KB |
Output is correct |
24 |
Correct |
3 ms |
10588 KB |
Output is correct |
25 |
Correct |
4 ms |
10588 KB |
Output is correct |
26 |
Correct |
3 ms |
10584 KB |
Output is correct |
27 |
Correct |
3 ms |
10588 KB |
Output is correct |
28 |
Correct |
4 ms |
10840 KB |
Output is correct |
29 |
Correct |
64 ms |
10584 KB |
Output is correct |
30 |
Correct |
59 ms |
10784 KB |
Output is correct |
31 |
Correct |
46 ms |
10588 KB |
Output is correct |
32 |
Correct |
27 ms |
10588 KB |
Output is correct |
33 |
Correct |
13 ms |
10588 KB |
Output is correct |
34 |
Correct |
39 ms |
10588 KB |
Output is correct |
35 |
Correct |
64 ms |
10584 KB |
Output is correct |
36 |
Correct |
19 ms |
10584 KB |
Output is correct |
37 |
Correct |
84 ms |
10588 KB |
Output is correct |
38 |
Correct |
103 ms |
10840 KB |
Output is correct |
39 |
Correct |
55 ms |
10588 KB |
Output is correct |
40 |
Correct |
26 ms |
10584 KB |
Output is correct |
41 |
Correct |
27 ms |
10588 KB |
Output is correct |
42 |
Correct |
25 ms |
10588 KB |
Output is correct |
43 |
Correct |
8 ms |
10584 KB |
Output is correct |
44 |
Correct |
9 ms |
10588 KB |
Output is correct |
45 |
Correct |
12 ms |
10584 KB |
Output is correct |
46 |
Correct |
15 ms |
10588 KB |
Output is correct |
47 |
Correct |
35 ms |
10588 KB |
Output is correct |
48 |
Correct |
44 ms |
10588 KB |
Output is correct |
49 |
Correct |
43 ms |
10584 KB |
Output is correct |
50 |
Correct |
52 ms |
10588 KB |
Output is correct |
51 |
Correct |
35 ms |
10676 KB |
Output is correct |
52 |
Correct |
38 ms |
10700 KB |
Output is correct |
53 |
Correct |
47 ms |
10844 KB |
Output is correct |
54 |
Correct |
62 ms |
10588 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
10584 KB |
Output is correct |
2 |
Correct |
3 ms |
10588 KB |
Output is correct |
3 |
Correct |
144 ms |
19420 KB |
Output is correct |
4 |
Correct |
337 ms |
20904 KB |
Output is correct |
5 |
Correct |
156 ms |
20168 KB |
Output is correct |
6 |
Correct |
214 ms |
19868 KB |
Output is correct |
7 |
Correct |
202 ms |
19220 KB |
Output is correct |
8 |
Correct |
155 ms |
19908 KB |
Output is correct |
9 |
Correct |
185 ms |
20352 KB |
Output is correct |
10 |
Correct |
245 ms |
20240 KB |
Output is correct |
11 |
Correct |
226 ms |
19016 KB |
Output is correct |
12 |
Correct |
215 ms |
19520 KB |
Output is correct |
13 |
Correct |
193 ms |
18816 KB |
Output is correct |
14 |
Correct |
233 ms |
19772 KB |
Output is correct |
15 |
Correct |
203 ms |
19964 KB |
Output is correct |
16 |
Correct |
248 ms |
20088 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
10584 KB |
Output is correct |
2 |
Correct |
3 ms |
10588 KB |
Output is correct |
3 |
Correct |
3 ms |
10588 KB |
Output is correct |
4 |
Correct |
2 ms |
10424 KB |
Output is correct |
5 |
Correct |
3 ms |
10588 KB |
Output is correct |
6 |
Correct |
3 ms |
10612 KB |
Output is correct |
7 |
Correct |
3 ms |
10584 KB |
Output is correct |
8 |
Correct |
3 ms |
10432 KB |
Output is correct |
9 |
Correct |
4 ms |
10588 KB |
Output is correct |
10 |
Correct |
3 ms |
10588 KB |
Output is correct |
11 |
Correct |
4 ms |
10840 KB |
Output is correct |
12 |
Correct |
4 ms |
10584 KB |
Output is correct |
13 |
Correct |
4 ms |
10584 KB |
Output is correct |
14 |
Correct |
4 ms |
10588 KB |
Output is correct |
15 |
Correct |
4 ms |
10588 KB |
Output is correct |
16 |
Correct |
4 ms |
10588 KB |
Output is correct |
17 |
Correct |
3 ms |
10588 KB |
Output is correct |
18 |
Correct |
3 ms |
10588 KB |
Output is correct |
19 |
Correct |
3 ms |
10588 KB |
Output is correct |
20 |
Correct |
3 ms |
10588 KB |
Output is correct |
21 |
Correct |
3 ms |
10588 KB |
Output is correct |
22 |
Correct |
3 ms |
10588 KB |
Output is correct |
23 |
Correct |
4 ms |
10588 KB |
Output is correct |
24 |
Correct |
3 ms |
10588 KB |
Output is correct |
25 |
Correct |
4 ms |
10588 KB |
Output is correct |
26 |
Correct |
3 ms |
10584 KB |
Output is correct |
27 |
Correct |
3 ms |
10588 KB |
Output is correct |
28 |
Correct |
4 ms |
10840 KB |
Output is correct |
29 |
Correct |
144 ms |
19420 KB |
Output is correct |
30 |
Correct |
337 ms |
20904 KB |
Output is correct |
31 |
Correct |
156 ms |
20168 KB |
Output is correct |
32 |
Correct |
214 ms |
19868 KB |
Output is correct |
33 |
Correct |
202 ms |
19220 KB |
Output is correct |
34 |
Correct |
155 ms |
19908 KB |
Output is correct |
35 |
Correct |
185 ms |
20352 KB |
Output is correct |
36 |
Correct |
245 ms |
20240 KB |
Output is correct |
37 |
Correct |
226 ms |
19016 KB |
Output is correct |
38 |
Correct |
215 ms |
19520 KB |
Output is correct |
39 |
Correct |
193 ms |
18816 KB |
Output is correct |
40 |
Correct |
233 ms |
19772 KB |
Output is correct |
41 |
Correct |
203 ms |
19964 KB |
Output is correct |
42 |
Correct |
248 ms |
20088 KB |
Output is correct |
43 |
Execution timed out |
2027 ms |
20140 KB |
Time limit exceeded |
44 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
10584 KB |
Output is correct |
2 |
Correct |
3 ms |
10588 KB |
Output is correct |
3 |
Correct |
3 ms |
10588 KB |
Output is correct |
4 |
Correct |
2 ms |
10424 KB |
Output is correct |
5 |
Correct |
3 ms |
10588 KB |
Output is correct |
6 |
Correct |
3 ms |
10612 KB |
Output is correct |
7 |
Correct |
3 ms |
10584 KB |
Output is correct |
8 |
Correct |
3 ms |
10432 KB |
Output is correct |
9 |
Correct |
4 ms |
10588 KB |
Output is correct |
10 |
Correct |
3 ms |
10588 KB |
Output is correct |
11 |
Correct |
4 ms |
10840 KB |
Output is correct |
12 |
Correct |
4 ms |
10584 KB |
Output is correct |
13 |
Correct |
4 ms |
10584 KB |
Output is correct |
14 |
Correct |
4 ms |
10588 KB |
Output is correct |
15 |
Correct |
4 ms |
10588 KB |
Output is correct |
16 |
Correct |
4 ms |
10588 KB |
Output is correct |
17 |
Correct |
3 ms |
10588 KB |
Output is correct |
18 |
Correct |
3 ms |
10588 KB |
Output is correct |
19 |
Correct |
3 ms |
10588 KB |
Output is correct |
20 |
Correct |
3 ms |
10588 KB |
Output is correct |
21 |
Correct |
3 ms |
10588 KB |
Output is correct |
22 |
Correct |
3 ms |
10588 KB |
Output is correct |
23 |
Correct |
4 ms |
10588 KB |
Output is correct |
24 |
Correct |
3 ms |
10588 KB |
Output is correct |
25 |
Correct |
4 ms |
10588 KB |
Output is correct |
26 |
Correct |
3 ms |
10584 KB |
Output is correct |
27 |
Correct |
3 ms |
10588 KB |
Output is correct |
28 |
Correct |
4 ms |
10840 KB |
Output is correct |
29 |
Correct |
64 ms |
10584 KB |
Output is correct |
30 |
Correct |
59 ms |
10784 KB |
Output is correct |
31 |
Correct |
46 ms |
10588 KB |
Output is correct |
32 |
Correct |
27 ms |
10588 KB |
Output is correct |
33 |
Correct |
13 ms |
10588 KB |
Output is correct |
34 |
Correct |
39 ms |
10588 KB |
Output is correct |
35 |
Correct |
64 ms |
10584 KB |
Output is correct |
36 |
Correct |
19 ms |
10584 KB |
Output is correct |
37 |
Correct |
84 ms |
10588 KB |
Output is correct |
38 |
Correct |
103 ms |
10840 KB |
Output is correct |
39 |
Correct |
55 ms |
10588 KB |
Output is correct |
40 |
Correct |
26 ms |
10584 KB |
Output is correct |
41 |
Correct |
27 ms |
10588 KB |
Output is correct |
42 |
Correct |
25 ms |
10588 KB |
Output is correct |
43 |
Correct |
8 ms |
10584 KB |
Output is correct |
44 |
Correct |
9 ms |
10588 KB |
Output is correct |
45 |
Correct |
12 ms |
10584 KB |
Output is correct |
46 |
Correct |
15 ms |
10588 KB |
Output is correct |
47 |
Correct |
35 ms |
10588 KB |
Output is correct |
48 |
Correct |
44 ms |
10588 KB |
Output is correct |
49 |
Correct |
43 ms |
10584 KB |
Output is correct |
50 |
Correct |
52 ms |
10588 KB |
Output is correct |
51 |
Correct |
35 ms |
10676 KB |
Output is correct |
52 |
Correct |
38 ms |
10700 KB |
Output is correct |
53 |
Correct |
47 ms |
10844 KB |
Output is correct |
54 |
Correct |
62 ms |
10588 KB |
Output is correct |
55 |
Incorrect |
53 ms |
16468 KB |
Output isn't correct |
56 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
10584 KB |
Output is correct |
2 |
Correct |
3 ms |
10588 KB |
Output is correct |
3 |
Correct |
3 ms |
10588 KB |
Output is correct |
4 |
Correct |
2 ms |
10424 KB |
Output is correct |
5 |
Correct |
3 ms |
10588 KB |
Output is correct |
6 |
Correct |
3 ms |
10612 KB |
Output is correct |
7 |
Correct |
3 ms |
10584 KB |
Output is correct |
8 |
Correct |
3 ms |
10432 KB |
Output is correct |
9 |
Correct |
4 ms |
10588 KB |
Output is correct |
10 |
Correct |
3 ms |
10588 KB |
Output is correct |
11 |
Correct |
4 ms |
10840 KB |
Output is correct |
12 |
Correct |
4 ms |
10584 KB |
Output is correct |
13 |
Correct |
4 ms |
10584 KB |
Output is correct |
14 |
Correct |
4 ms |
10588 KB |
Output is correct |
15 |
Correct |
4 ms |
10588 KB |
Output is correct |
16 |
Correct |
4 ms |
10588 KB |
Output is correct |
17 |
Correct |
3 ms |
10588 KB |
Output is correct |
18 |
Correct |
3 ms |
10588 KB |
Output is correct |
19 |
Correct |
3 ms |
10588 KB |
Output is correct |
20 |
Correct |
3 ms |
10588 KB |
Output is correct |
21 |
Correct |
3 ms |
10588 KB |
Output is correct |
22 |
Correct |
3 ms |
10588 KB |
Output is correct |
23 |
Correct |
4 ms |
10588 KB |
Output is correct |
24 |
Correct |
3 ms |
10588 KB |
Output is correct |
25 |
Correct |
4 ms |
10588 KB |
Output is correct |
26 |
Correct |
3 ms |
10584 KB |
Output is correct |
27 |
Correct |
3 ms |
10588 KB |
Output is correct |
28 |
Correct |
4 ms |
10840 KB |
Output is correct |
29 |
Correct |
64 ms |
10584 KB |
Output is correct |
30 |
Correct |
59 ms |
10784 KB |
Output is correct |
31 |
Correct |
46 ms |
10588 KB |
Output is correct |
32 |
Correct |
27 ms |
10588 KB |
Output is correct |
33 |
Correct |
13 ms |
10588 KB |
Output is correct |
34 |
Correct |
39 ms |
10588 KB |
Output is correct |
35 |
Correct |
64 ms |
10584 KB |
Output is correct |
36 |
Correct |
19 ms |
10584 KB |
Output is correct |
37 |
Correct |
84 ms |
10588 KB |
Output is correct |
38 |
Correct |
103 ms |
10840 KB |
Output is correct |
39 |
Correct |
55 ms |
10588 KB |
Output is correct |
40 |
Correct |
26 ms |
10584 KB |
Output is correct |
41 |
Correct |
27 ms |
10588 KB |
Output is correct |
42 |
Correct |
25 ms |
10588 KB |
Output is correct |
43 |
Correct |
8 ms |
10584 KB |
Output is correct |
44 |
Correct |
9 ms |
10588 KB |
Output is correct |
45 |
Correct |
12 ms |
10584 KB |
Output is correct |
46 |
Correct |
15 ms |
10588 KB |
Output is correct |
47 |
Correct |
35 ms |
10588 KB |
Output is correct |
48 |
Correct |
44 ms |
10588 KB |
Output is correct |
49 |
Correct |
43 ms |
10584 KB |
Output is correct |
50 |
Correct |
52 ms |
10588 KB |
Output is correct |
51 |
Correct |
35 ms |
10676 KB |
Output is correct |
52 |
Correct |
38 ms |
10700 KB |
Output is correct |
53 |
Correct |
47 ms |
10844 KB |
Output is correct |
54 |
Correct |
62 ms |
10588 KB |
Output is correct |
55 |
Correct |
144 ms |
19420 KB |
Output is correct |
56 |
Correct |
337 ms |
20904 KB |
Output is correct |
57 |
Correct |
156 ms |
20168 KB |
Output is correct |
58 |
Correct |
214 ms |
19868 KB |
Output is correct |
59 |
Correct |
202 ms |
19220 KB |
Output is correct |
60 |
Correct |
155 ms |
19908 KB |
Output is correct |
61 |
Correct |
185 ms |
20352 KB |
Output is correct |
62 |
Correct |
245 ms |
20240 KB |
Output is correct |
63 |
Correct |
226 ms |
19016 KB |
Output is correct |
64 |
Correct |
215 ms |
19520 KB |
Output is correct |
65 |
Correct |
193 ms |
18816 KB |
Output is correct |
66 |
Correct |
233 ms |
19772 KB |
Output is correct |
67 |
Correct |
203 ms |
19964 KB |
Output is correct |
68 |
Correct |
248 ms |
20088 KB |
Output is correct |
69 |
Execution timed out |
2027 ms |
20140 KB |
Time limit exceeded |
70 |
Halted |
0 ms |
0 KB |
- |