# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
642336 |
2022-09-19T08:56:39 Z |
dozer |
Joker (BOI20_joker) |
C++14 |
|
828 ms |
181052 KB |
#include <bits/stdc++.h>
using namespace std;
#define fileio() freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define fastio() cin.tie(0), ios_base::sync_with_stdio(0)
#define sp " "
#define endl "\n"
#define pb push_back
#define pii pair<int, int>
#define st first
#define nd second
#define N 400005
const int modulo = 1e9 + 7;
int ans[N], u[N], v[N], l[N], r[N], n, sz[N];
vector<int> ind[N], root, gh[N];
int res[205][N];
int find(vector<int> &b, int node)
{
if (node < 0) return -(find(b, -node));
if (node == b[node]) return node;
return b[node] = find(b, b[node]);
}
int32_t main()
{
fastio();
int m, q;
cin>>n>>m>>q;
root.resize(n + 5, 0);
for (int i = 1; i <= n; i++)
root[i] = i;
for (int i = 1; i <= m; i++)
{
cin>>u[i]>>v[i];
}
int maks = 0;
for (int i = 1; i <= q; i++)
{
cin>>l[i]>>r[i];
maks = max(maks, l[i]);
ind[l[i]].pb(r[i]);
}
for (int t = 1; t <= maks; t++)
{
for (int i = 1; i <= n; i++) root[i] = i;
for (int i = 1; i < t; i++)
{
if (ans[i] == 1)
{
ans[i + 1] = 1;
continue;
}
int a = find(root, u[i]), b = find(root, v[i]);
if (a == b)
{
ans[i + 1] = 1;
}
else
{
if (sz[abs(a)] > sz[abs(b)]) swap(a, b);
if (a < 0) a *= -1, b *= -1;
root[a] = -b;
}
}
if (ans[t] == 1) res[t][m] = 1;
for (int i = m; i >= t; i--)
{
if (res[t][i] == 1)
{
res[t][i - 1] = 1;
continue;
}
int a = find(root, u[i]), b = find(root, v[i]);
if (a == b)
{
res[t][i - 1] = 1;
}
else
{
if (sz[abs(a)] > sz[abs(b)]) swap(a, b);
if (a < 0) a *= -1, b *= -1;
root[a] = -b;
}
//cout<<i<<sp<<ans[i]<<endl;
}
}
for (int i = 1; i <= q; i++)
{
if (res[l[i]][r[i]]) cout<<"YES\n";
else cout<<"NO\n";
}
cerr<<"time taken : "<<(float)clock() / CLOCKS_PER_SEC<<" seconds\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
19156 KB |
Output is correct |
2 |
Correct |
10 ms |
19140 KB |
Output is correct |
3 |
Correct |
9 ms |
19156 KB |
Output is correct |
4 |
Correct |
9 ms |
19156 KB |
Output is correct |
5 |
Correct |
9 ms |
19156 KB |
Output is correct |
6 |
Correct |
10 ms |
19156 KB |
Output is correct |
7 |
Correct |
10 ms |
19412 KB |
Output is correct |
8 |
Correct |
11 ms |
20436 KB |
Output is correct |
9 |
Correct |
11 ms |
20564 KB |
Output is correct |
10 |
Correct |
11 ms |
20564 KB |
Output is correct |
11 |
Correct |
10 ms |
20564 KB |
Output is correct |
12 |
Correct |
11 ms |
20564 KB |
Output is correct |
13 |
Correct |
10 ms |
20564 KB |
Output is correct |
14 |
Correct |
11 ms |
19668 KB |
Output is correct |
15 |
Correct |
11 ms |
20528 KB |
Output is correct |
16 |
Correct |
11 ms |
20632 KB |
Output is correct |
17 |
Correct |
12 ms |
20564 KB |
Output is correct |
18 |
Correct |
11 ms |
20592 KB |
Output is correct |
19 |
Correct |
11 ms |
20564 KB |
Output is correct |
20 |
Correct |
10 ms |
20564 KB |
Output is correct |
21 |
Correct |
10 ms |
20564 KB |
Output is correct |
22 |
Correct |
10 ms |
20564 KB |
Output is correct |
23 |
Correct |
10 ms |
20564 KB |
Output is correct |
24 |
Correct |
10 ms |
20564 KB |
Output is correct |
25 |
Correct |
10 ms |
20564 KB |
Output is correct |
26 |
Correct |
10 ms |
20564 KB |
Output is correct |
27 |
Correct |
10 ms |
20564 KB |
Output is correct |
28 |
Correct |
10 ms |
20564 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
19156 KB |
Output is correct |
2 |
Correct |
10 ms |
19140 KB |
Output is correct |
3 |
Correct |
9 ms |
19156 KB |
Output is correct |
4 |
Correct |
9 ms |
19156 KB |
Output is correct |
5 |
Correct |
9 ms |
19156 KB |
Output is correct |
6 |
Correct |
10 ms |
19156 KB |
Output is correct |
7 |
Correct |
10 ms |
19412 KB |
Output is correct |
8 |
Correct |
11 ms |
20436 KB |
Output is correct |
9 |
Correct |
11 ms |
20564 KB |
Output is correct |
10 |
Correct |
11 ms |
20564 KB |
Output is correct |
11 |
Correct |
10 ms |
20564 KB |
Output is correct |
12 |
Correct |
11 ms |
20564 KB |
Output is correct |
13 |
Correct |
10 ms |
20564 KB |
Output is correct |
14 |
Correct |
11 ms |
19668 KB |
Output is correct |
15 |
Correct |
11 ms |
20528 KB |
Output is correct |
16 |
Correct |
11 ms |
20632 KB |
Output is correct |
17 |
Correct |
12 ms |
20564 KB |
Output is correct |
18 |
Correct |
11 ms |
20592 KB |
Output is correct |
19 |
Correct |
11 ms |
20564 KB |
Output is correct |
20 |
Correct |
10 ms |
20564 KB |
Output is correct |
21 |
Correct |
10 ms |
20564 KB |
Output is correct |
22 |
Correct |
10 ms |
20564 KB |
Output is correct |
23 |
Correct |
10 ms |
20564 KB |
Output is correct |
24 |
Correct |
10 ms |
20564 KB |
Output is correct |
25 |
Correct |
10 ms |
20564 KB |
Output is correct |
26 |
Correct |
10 ms |
20564 KB |
Output is correct |
27 |
Correct |
10 ms |
20564 KB |
Output is correct |
28 |
Correct |
10 ms |
20564 KB |
Output is correct |
29 |
Runtime error |
32 ms |
39312 KB |
Execution killed with signal 11 |
30 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
19156 KB |
Output is correct |
2 |
Correct |
10 ms |
19140 KB |
Output is correct |
3 |
Correct |
68 ms |
24960 KB |
Output is correct |
4 |
Correct |
69 ms |
24796 KB |
Output is correct |
5 |
Correct |
75 ms |
25232 KB |
Output is correct |
6 |
Correct |
70 ms |
24772 KB |
Output is correct |
7 |
Correct |
71 ms |
24600 KB |
Output is correct |
8 |
Correct |
70 ms |
24508 KB |
Output is correct |
9 |
Correct |
68 ms |
24668 KB |
Output is correct |
10 |
Correct |
73 ms |
25132 KB |
Output is correct |
11 |
Correct |
69 ms |
24704 KB |
Output is correct |
12 |
Correct |
75 ms |
25160 KB |
Output is correct |
13 |
Correct |
70 ms |
24276 KB |
Output is correct |
14 |
Correct |
78 ms |
24356 KB |
Output is correct |
15 |
Correct |
75 ms |
24724 KB |
Output is correct |
16 |
Correct |
72 ms |
24944 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
19156 KB |
Output is correct |
2 |
Correct |
10 ms |
19140 KB |
Output is correct |
3 |
Correct |
9 ms |
19156 KB |
Output is correct |
4 |
Correct |
9 ms |
19156 KB |
Output is correct |
5 |
Correct |
9 ms |
19156 KB |
Output is correct |
6 |
Correct |
10 ms |
19156 KB |
Output is correct |
7 |
Correct |
10 ms |
19412 KB |
Output is correct |
8 |
Correct |
11 ms |
20436 KB |
Output is correct |
9 |
Correct |
11 ms |
20564 KB |
Output is correct |
10 |
Correct |
11 ms |
20564 KB |
Output is correct |
11 |
Correct |
10 ms |
20564 KB |
Output is correct |
12 |
Correct |
11 ms |
20564 KB |
Output is correct |
13 |
Correct |
10 ms |
20564 KB |
Output is correct |
14 |
Correct |
11 ms |
19668 KB |
Output is correct |
15 |
Correct |
11 ms |
20528 KB |
Output is correct |
16 |
Correct |
11 ms |
20632 KB |
Output is correct |
17 |
Correct |
12 ms |
20564 KB |
Output is correct |
18 |
Correct |
11 ms |
20592 KB |
Output is correct |
19 |
Correct |
11 ms |
20564 KB |
Output is correct |
20 |
Correct |
10 ms |
20564 KB |
Output is correct |
21 |
Correct |
10 ms |
20564 KB |
Output is correct |
22 |
Correct |
10 ms |
20564 KB |
Output is correct |
23 |
Correct |
10 ms |
20564 KB |
Output is correct |
24 |
Correct |
10 ms |
20564 KB |
Output is correct |
25 |
Correct |
10 ms |
20564 KB |
Output is correct |
26 |
Correct |
10 ms |
20564 KB |
Output is correct |
27 |
Correct |
10 ms |
20564 KB |
Output is correct |
28 |
Correct |
10 ms |
20564 KB |
Output is correct |
29 |
Correct |
68 ms |
24960 KB |
Output is correct |
30 |
Correct |
69 ms |
24796 KB |
Output is correct |
31 |
Correct |
75 ms |
25232 KB |
Output is correct |
32 |
Correct |
70 ms |
24772 KB |
Output is correct |
33 |
Correct |
71 ms |
24600 KB |
Output is correct |
34 |
Correct |
70 ms |
24508 KB |
Output is correct |
35 |
Correct |
68 ms |
24668 KB |
Output is correct |
36 |
Correct |
73 ms |
25132 KB |
Output is correct |
37 |
Correct |
69 ms |
24704 KB |
Output is correct |
38 |
Correct |
75 ms |
25160 KB |
Output is correct |
39 |
Correct |
70 ms |
24276 KB |
Output is correct |
40 |
Correct |
78 ms |
24356 KB |
Output is correct |
41 |
Correct |
75 ms |
24724 KB |
Output is correct |
42 |
Correct |
72 ms |
24944 KB |
Output is correct |
43 |
Correct |
369 ms |
108696 KB |
Output is correct |
44 |
Correct |
828 ms |
29824 KB |
Output is correct |
45 |
Correct |
715 ms |
46832 KB |
Output is correct |
46 |
Correct |
189 ms |
181052 KB |
Output is correct |
47 |
Correct |
203 ms |
179628 KB |
Output is correct |
48 |
Correct |
469 ms |
141124 KB |
Output is correct |
49 |
Correct |
720 ms |
104772 KB |
Output is correct |
50 |
Correct |
803 ms |
109004 KB |
Output is correct |
51 |
Correct |
678 ms |
108868 KB |
Output is correct |
52 |
Correct |
577 ms |
108872 KB |
Output is correct |
53 |
Correct |
804 ms |
136008 KB |
Output is correct |
54 |
Correct |
486 ms |
145724 KB |
Output is correct |
55 |
Correct |
596 ms |
124364 KB |
Output is correct |
56 |
Correct |
653 ms |
105052 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
19156 KB |
Output is correct |
2 |
Correct |
10 ms |
19140 KB |
Output is correct |
3 |
Correct |
9 ms |
19156 KB |
Output is correct |
4 |
Correct |
9 ms |
19156 KB |
Output is correct |
5 |
Correct |
9 ms |
19156 KB |
Output is correct |
6 |
Correct |
10 ms |
19156 KB |
Output is correct |
7 |
Correct |
10 ms |
19412 KB |
Output is correct |
8 |
Correct |
11 ms |
20436 KB |
Output is correct |
9 |
Correct |
11 ms |
20564 KB |
Output is correct |
10 |
Correct |
11 ms |
20564 KB |
Output is correct |
11 |
Correct |
10 ms |
20564 KB |
Output is correct |
12 |
Correct |
11 ms |
20564 KB |
Output is correct |
13 |
Correct |
10 ms |
20564 KB |
Output is correct |
14 |
Correct |
11 ms |
19668 KB |
Output is correct |
15 |
Correct |
11 ms |
20528 KB |
Output is correct |
16 |
Correct |
11 ms |
20632 KB |
Output is correct |
17 |
Correct |
12 ms |
20564 KB |
Output is correct |
18 |
Correct |
11 ms |
20592 KB |
Output is correct |
19 |
Correct |
11 ms |
20564 KB |
Output is correct |
20 |
Correct |
10 ms |
20564 KB |
Output is correct |
21 |
Correct |
10 ms |
20564 KB |
Output is correct |
22 |
Correct |
10 ms |
20564 KB |
Output is correct |
23 |
Correct |
10 ms |
20564 KB |
Output is correct |
24 |
Correct |
10 ms |
20564 KB |
Output is correct |
25 |
Correct |
10 ms |
20564 KB |
Output is correct |
26 |
Correct |
10 ms |
20564 KB |
Output is correct |
27 |
Correct |
10 ms |
20564 KB |
Output is correct |
28 |
Correct |
10 ms |
20564 KB |
Output is correct |
29 |
Runtime error |
32 ms |
39312 KB |
Execution killed with signal 11 |
30 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
19156 KB |
Output is correct |
2 |
Correct |
10 ms |
19140 KB |
Output is correct |
3 |
Correct |
9 ms |
19156 KB |
Output is correct |
4 |
Correct |
9 ms |
19156 KB |
Output is correct |
5 |
Correct |
9 ms |
19156 KB |
Output is correct |
6 |
Correct |
10 ms |
19156 KB |
Output is correct |
7 |
Correct |
10 ms |
19412 KB |
Output is correct |
8 |
Correct |
11 ms |
20436 KB |
Output is correct |
9 |
Correct |
11 ms |
20564 KB |
Output is correct |
10 |
Correct |
11 ms |
20564 KB |
Output is correct |
11 |
Correct |
10 ms |
20564 KB |
Output is correct |
12 |
Correct |
11 ms |
20564 KB |
Output is correct |
13 |
Correct |
10 ms |
20564 KB |
Output is correct |
14 |
Correct |
11 ms |
19668 KB |
Output is correct |
15 |
Correct |
11 ms |
20528 KB |
Output is correct |
16 |
Correct |
11 ms |
20632 KB |
Output is correct |
17 |
Correct |
12 ms |
20564 KB |
Output is correct |
18 |
Correct |
11 ms |
20592 KB |
Output is correct |
19 |
Correct |
11 ms |
20564 KB |
Output is correct |
20 |
Correct |
10 ms |
20564 KB |
Output is correct |
21 |
Correct |
10 ms |
20564 KB |
Output is correct |
22 |
Correct |
10 ms |
20564 KB |
Output is correct |
23 |
Correct |
10 ms |
20564 KB |
Output is correct |
24 |
Correct |
10 ms |
20564 KB |
Output is correct |
25 |
Correct |
10 ms |
20564 KB |
Output is correct |
26 |
Correct |
10 ms |
20564 KB |
Output is correct |
27 |
Correct |
10 ms |
20564 KB |
Output is correct |
28 |
Correct |
10 ms |
20564 KB |
Output is correct |
29 |
Runtime error |
32 ms |
39312 KB |
Execution killed with signal 11 |
30 |
Halted |
0 ms |
0 KB |
- |