# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
256066 |
2020-08-02T09:24:36 Z |
반딧불(#5032) |
Joker (BOI20_joker) |
C++17 |
|
1165 ms |
18044 KB |
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
struct dat{
int s, e, i;
dat(){}
dat(int s, int e, int i): s(s), e(e), i(i){}
};
vector<dat> link[200002];
int n, m, q;
int l, r;
int edgeX[200002], edgeY[200002];
int chk[200002];
int minNeeded[2002];
pair<int, bool> par[200002];
int sz[200002];
pair<int, int> find(int x){
if(x == par[x].first) return par[x];
bool tmp = par[x].second;
par[x] = find(par[x].first);
par[x].second ^= tmp;
return par[x];
}
bool merge(int x, int y){
pair<int, int> px = find(x), py = find(y);
if(px.first == py.first && px.second == py.second) return false;
if(px.first == py.first) return true;
int xx = par[x].second, yy = par[y].second;
x = par[x].first, y = par[y].first;
if(sz[x] < sz[y]) swap(x, y);
par[y] = make_pair(x, xx ^ yy ^ 1);
if(sz[x] == sz[y]) x++;
return true;
}
bool dfs(int x, int y = 1){
chk[x] = y;
for(auto &nxt: link[x]){
if(l <= nxt.i && nxt.i <= r) continue;
if(chk[nxt.e] == y) return true;
if(chk[nxt.e] == 0 && dfs(nxt.e, 3-y)) return true;
}
return false;
}
int main(){
scanf("%d %d %d", &n, &m, &q);
for(int i=1; i<=m; i++){
int s, e;
scanf("%d %d", &s, &e);
link[s].push_back(dat(s, e, i));
link[e].push_back(dat(e, s, i));
edgeX[i] = s, edgeY[i] = e;
}
for(int i=1; i<=200 && i<=m; i++){
for(int j=1; j<=n; j++) par[j] = make_pair(j, 0), sz[j] = 1;
for(int j=1; j<i; j++){
int s = edgeX[j];
int e = edgeY[j];
if(!merge(s, e)){
minNeeded[i] = 1e9;
break;
}
}
if(minNeeded[i] == 1e9) continue;
for(int j=m; j>i; j--){
int s = edgeX[j];
int e = edgeY[j];
if(!merge(s, e)){
minNeeded[i] = j;
break;
}
}
}
while(q--){
scanf("%d %d", &l, &r);
printf("%s\n", minNeeded[l] > r ? "YES" : "NO");
}
}
Compilation message
Joker.cpp: In function 'int main()':
Joker.cpp:57:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d %d", &n, &m, &q);
~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Joker.cpp:60:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d", &s, &e);
~~~~~^~~~~~~~~~~~~~~~~
Joker.cpp:92:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d", &l, &r);
~~~~~^~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
4992 KB |
Output is correct |
2 |
Correct |
4 ms |
4992 KB |
Output is correct |
3 |
Correct |
3 ms |
4992 KB |
Output is correct |
4 |
Correct |
4 ms |
4992 KB |
Output is correct |
5 |
Correct |
4 ms |
4992 KB |
Output is correct |
6 |
Correct |
4 ms |
4992 KB |
Output is correct |
7 |
Correct |
3 ms |
4992 KB |
Output is correct |
8 |
Correct |
4 ms |
4992 KB |
Output is correct |
9 |
Correct |
4 ms |
4992 KB |
Output is correct |
10 |
Correct |
5 ms |
4992 KB |
Output is correct |
11 |
Correct |
3 ms |
4992 KB |
Output is correct |
12 |
Correct |
3 ms |
4992 KB |
Output is correct |
13 |
Correct |
3 ms |
4992 KB |
Output is correct |
14 |
Correct |
5 ms |
4992 KB |
Output is correct |
15 |
Correct |
3 ms |
4992 KB |
Output is correct |
16 |
Correct |
4 ms |
5120 KB |
Output is correct |
17 |
Correct |
3 ms |
4992 KB |
Output is correct |
18 |
Correct |
3 ms |
4992 KB |
Output is correct |
19 |
Correct |
4 ms |
4992 KB |
Output is correct |
20 |
Correct |
4 ms |
4992 KB |
Output is correct |
21 |
Correct |
4 ms |
4992 KB |
Output is correct |
22 |
Correct |
4 ms |
5120 KB |
Output is correct |
23 |
Correct |
4 ms |
4992 KB |
Output is correct |
24 |
Correct |
3 ms |
4992 KB |
Output is correct |
25 |
Correct |
4 ms |
4992 KB |
Output is correct |
26 |
Correct |
4 ms |
4992 KB |
Output is correct |
27 |
Correct |
3 ms |
4992 KB |
Output is correct |
28 |
Correct |
3 ms |
4992 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
4992 KB |
Output is correct |
2 |
Correct |
4 ms |
4992 KB |
Output is correct |
3 |
Correct |
3 ms |
4992 KB |
Output is correct |
4 |
Correct |
4 ms |
4992 KB |
Output is correct |
5 |
Correct |
4 ms |
4992 KB |
Output is correct |
6 |
Correct |
4 ms |
4992 KB |
Output is correct |
7 |
Correct |
3 ms |
4992 KB |
Output is correct |
8 |
Correct |
4 ms |
4992 KB |
Output is correct |
9 |
Correct |
4 ms |
4992 KB |
Output is correct |
10 |
Correct |
5 ms |
4992 KB |
Output is correct |
11 |
Correct |
3 ms |
4992 KB |
Output is correct |
12 |
Correct |
3 ms |
4992 KB |
Output is correct |
13 |
Correct |
3 ms |
4992 KB |
Output is correct |
14 |
Correct |
5 ms |
4992 KB |
Output is correct |
15 |
Correct |
3 ms |
4992 KB |
Output is correct |
16 |
Correct |
4 ms |
5120 KB |
Output is correct |
17 |
Correct |
3 ms |
4992 KB |
Output is correct |
18 |
Correct |
3 ms |
4992 KB |
Output is correct |
19 |
Correct |
4 ms |
4992 KB |
Output is correct |
20 |
Correct |
4 ms |
4992 KB |
Output is correct |
21 |
Correct |
4 ms |
4992 KB |
Output is correct |
22 |
Correct |
4 ms |
5120 KB |
Output is correct |
23 |
Correct |
4 ms |
4992 KB |
Output is correct |
24 |
Correct |
3 ms |
4992 KB |
Output is correct |
25 |
Correct |
4 ms |
4992 KB |
Output is correct |
26 |
Correct |
4 ms |
4992 KB |
Output is correct |
27 |
Correct |
3 ms |
4992 KB |
Output is correct |
28 |
Correct |
3 ms |
4992 KB |
Output is correct |
29 |
Correct |
7 ms |
5120 KB |
Output is correct |
30 |
Incorrect |
7 ms |
5120 KB |
Output isn't correct |
31 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
4992 KB |
Output is correct |
2 |
Correct |
4 ms |
4992 KB |
Output is correct |
3 |
Correct |
511 ms |
15292 KB |
Output is correct |
4 |
Correct |
1110 ms |
17840 KB |
Output is correct |
5 |
Correct |
315 ms |
17776 KB |
Output is correct |
6 |
Correct |
263 ms |
16632 KB |
Output is correct |
7 |
Correct |
256 ms |
16504 KB |
Output is correct |
8 |
Correct |
564 ms |
16268 KB |
Output is correct |
9 |
Correct |
576 ms |
16632 KB |
Output is correct |
10 |
Correct |
944 ms |
18044 KB |
Output is correct |
11 |
Correct |
825 ms |
16436 KB |
Output is correct |
12 |
Correct |
839 ms |
17712 KB |
Output is correct |
13 |
Correct |
697 ms |
15480 KB |
Output is correct |
14 |
Correct |
575 ms |
16120 KB |
Output is correct |
15 |
Correct |
824 ms |
17016 KB |
Output is correct |
16 |
Correct |
923 ms |
17836 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
4992 KB |
Output is correct |
2 |
Correct |
4 ms |
4992 KB |
Output is correct |
3 |
Correct |
3 ms |
4992 KB |
Output is correct |
4 |
Correct |
4 ms |
4992 KB |
Output is correct |
5 |
Correct |
4 ms |
4992 KB |
Output is correct |
6 |
Correct |
4 ms |
4992 KB |
Output is correct |
7 |
Correct |
3 ms |
4992 KB |
Output is correct |
8 |
Correct |
4 ms |
4992 KB |
Output is correct |
9 |
Correct |
4 ms |
4992 KB |
Output is correct |
10 |
Correct |
5 ms |
4992 KB |
Output is correct |
11 |
Correct |
3 ms |
4992 KB |
Output is correct |
12 |
Correct |
3 ms |
4992 KB |
Output is correct |
13 |
Correct |
3 ms |
4992 KB |
Output is correct |
14 |
Correct |
5 ms |
4992 KB |
Output is correct |
15 |
Correct |
3 ms |
4992 KB |
Output is correct |
16 |
Correct |
4 ms |
5120 KB |
Output is correct |
17 |
Correct |
3 ms |
4992 KB |
Output is correct |
18 |
Correct |
3 ms |
4992 KB |
Output is correct |
19 |
Correct |
4 ms |
4992 KB |
Output is correct |
20 |
Correct |
4 ms |
4992 KB |
Output is correct |
21 |
Correct |
4 ms |
4992 KB |
Output is correct |
22 |
Correct |
4 ms |
5120 KB |
Output is correct |
23 |
Correct |
4 ms |
4992 KB |
Output is correct |
24 |
Correct |
3 ms |
4992 KB |
Output is correct |
25 |
Correct |
4 ms |
4992 KB |
Output is correct |
26 |
Correct |
4 ms |
4992 KB |
Output is correct |
27 |
Correct |
3 ms |
4992 KB |
Output is correct |
28 |
Correct |
3 ms |
4992 KB |
Output is correct |
29 |
Correct |
511 ms |
15292 KB |
Output is correct |
30 |
Correct |
1110 ms |
17840 KB |
Output is correct |
31 |
Correct |
315 ms |
17776 KB |
Output is correct |
32 |
Correct |
263 ms |
16632 KB |
Output is correct |
33 |
Correct |
256 ms |
16504 KB |
Output is correct |
34 |
Correct |
564 ms |
16268 KB |
Output is correct |
35 |
Correct |
576 ms |
16632 KB |
Output is correct |
36 |
Correct |
944 ms |
18044 KB |
Output is correct |
37 |
Correct |
825 ms |
16436 KB |
Output is correct |
38 |
Correct |
839 ms |
17712 KB |
Output is correct |
39 |
Correct |
697 ms |
15480 KB |
Output is correct |
40 |
Correct |
575 ms |
16120 KB |
Output is correct |
41 |
Correct |
824 ms |
17016 KB |
Output is correct |
42 |
Correct |
923 ms |
17836 KB |
Output is correct |
43 |
Correct |
538 ms |
15224 KB |
Output is correct |
44 |
Correct |
1165 ms |
17912 KB |
Output is correct |
45 |
Correct |
994 ms |
17656 KB |
Output is correct |
46 |
Correct |
235 ms |
16632 KB |
Output is correct |
47 |
Correct |
244 ms |
16376 KB |
Output is correct |
48 |
Correct |
622 ms |
16888 KB |
Output is correct |
49 |
Correct |
969 ms |
18040 KB |
Output is correct |
50 |
Correct |
963 ms |
16448 KB |
Output is correct |
51 |
Correct |
852 ms |
17076 KB |
Output is correct |
52 |
Correct |
828 ms |
17836 KB |
Output is correct |
53 |
Correct |
594 ms |
15396 KB |
Output is correct |
54 |
Correct |
610 ms |
16360 KB |
Output is correct |
55 |
Correct |
846 ms |
17016 KB |
Output is correct |
56 |
Correct |
978 ms |
17812 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
4992 KB |
Output is correct |
2 |
Correct |
4 ms |
4992 KB |
Output is correct |
3 |
Correct |
3 ms |
4992 KB |
Output is correct |
4 |
Correct |
4 ms |
4992 KB |
Output is correct |
5 |
Correct |
4 ms |
4992 KB |
Output is correct |
6 |
Correct |
4 ms |
4992 KB |
Output is correct |
7 |
Correct |
3 ms |
4992 KB |
Output is correct |
8 |
Correct |
4 ms |
4992 KB |
Output is correct |
9 |
Correct |
4 ms |
4992 KB |
Output is correct |
10 |
Correct |
5 ms |
4992 KB |
Output is correct |
11 |
Correct |
3 ms |
4992 KB |
Output is correct |
12 |
Correct |
3 ms |
4992 KB |
Output is correct |
13 |
Correct |
3 ms |
4992 KB |
Output is correct |
14 |
Correct |
5 ms |
4992 KB |
Output is correct |
15 |
Correct |
3 ms |
4992 KB |
Output is correct |
16 |
Correct |
4 ms |
5120 KB |
Output is correct |
17 |
Correct |
3 ms |
4992 KB |
Output is correct |
18 |
Correct |
3 ms |
4992 KB |
Output is correct |
19 |
Correct |
4 ms |
4992 KB |
Output is correct |
20 |
Correct |
4 ms |
4992 KB |
Output is correct |
21 |
Correct |
4 ms |
4992 KB |
Output is correct |
22 |
Correct |
4 ms |
5120 KB |
Output is correct |
23 |
Correct |
4 ms |
4992 KB |
Output is correct |
24 |
Correct |
3 ms |
4992 KB |
Output is correct |
25 |
Correct |
4 ms |
4992 KB |
Output is correct |
26 |
Correct |
4 ms |
4992 KB |
Output is correct |
27 |
Correct |
3 ms |
4992 KB |
Output is correct |
28 |
Correct |
3 ms |
4992 KB |
Output is correct |
29 |
Correct |
7 ms |
5120 KB |
Output is correct |
30 |
Incorrect |
7 ms |
5120 KB |
Output isn't correct |
31 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
4992 KB |
Output is correct |
2 |
Correct |
4 ms |
4992 KB |
Output is correct |
3 |
Correct |
3 ms |
4992 KB |
Output is correct |
4 |
Correct |
4 ms |
4992 KB |
Output is correct |
5 |
Correct |
4 ms |
4992 KB |
Output is correct |
6 |
Correct |
4 ms |
4992 KB |
Output is correct |
7 |
Correct |
3 ms |
4992 KB |
Output is correct |
8 |
Correct |
4 ms |
4992 KB |
Output is correct |
9 |
Correct |
4 ms |
4992 KB |
Output is correct |
10 |
Correct |
5 ms |
4992 KB |
Output is correct |
11 |
Correct |
3 ms |
4992 KB |
Output is correct |
12 |
Correct |
3 ms |
4992 KB |
Output is correct |
13 |
Correct |
3 ms |
4992 KB |
Output is correct |
14 |
Correct |
5 ms |
4992 KB |
Output is correct |
15 |
Correct |
3 ms |
4992 KB |
Output is correct |
16 |
Correct |
4 ms |
5120 KB |
Output is correct |
17 |
Correct |
3 ms |
4992 KB |
Output is correct |
18 |
Correct |
3 ms |
4992 KB |
Output is correct |
19 |
Correct |
4 ms |
4992 KB |
Output is correct |
20 |
Correct |
4 ms |
4992 KB |
Output is correct |
21 |
Correct |
4 ms |
4992 KB |
Output is correct |
22 |
Correct |
4 ms |
5120 KB |
Output is correct |
23 |
Correct |
4 ms |
4992 KB |
Output is correct |
24 |
Correct |
3 ms |
4992 KB |
Output is correct |
25 |
Correct |
4 ms |
4992 KB |
Output is correct |
26 |
Correct |
4 ms |
4992 KB |
Output is correct |
27 |
Correct |
3 ms |
4992 KB |
Output is correct |
28 |
Correct |
3 ms |
4992 KB |
Output is correct |
29 |
Correct |
7 ms |
5120 KB |
Output is correct |
30 |
Incorrect |
7 ms |
5120 KB |
Output isn't correct |
31 |
Halted |
0 ms |
0 KB |
- |