# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
642288 |
2022-09-19T07:54:39 Z |
dozer |
Joker (BOI20_joker) |
C++14 |
|
172 ms |
262144 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 200005
const int modulo = 1e9 + 7;
int ans[N], u[N], v[N], l[N], r[N];
vector<int> ind[N], root, gh[N];
map<int, int> res[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 n, 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];
}
for (int i = 1; i <= q; i++)
{
cin>>l[i]>>r[i];
ind[r[i]].pb(l[i]);
}
for (int i = m; i >= 1; i--)
{
sort(ind[i].begin(), ind[i].end());
if (ind[i].size() > 0)
{
vector<int> tmp(root.begin(), root.end());
gh[i] = tmp;
}
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 (a < 0) a *= -1, b *= -1;
root[a] = -b;
}
//cout<<i<<sp<<ans[i]<<endl;
}
for (int i = m; i >= 1; i--)
{
if (ind[i].empty()) continue;
int last = 1;
for (auto j : ind[i])
{
if (ans[i] == 1 || res[i][last] == 1)
{
res[i][j] = 1;
//cout<<i<<sp<<j<<sp<<ans[i]<<sp<<res[i][j]<<endl;
continue;
}
for (int k = last; k < j && res[i][j] == 0; k++)
{
int a = find(gh[i], u[k]), b = find(gh[i], v[k]);
if (a == b) res[i][j] = 1;
else
{
if (a < 0) a *= -1, b *= -1;
gh[i][a] = -b;
}
}
//cout<<i<<sp<<j<<sp<<res[i][j]<<endl;
last = j;
}
}
for (int i = 1; i <= q; i++)
{
if (res[r[i]][l[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 |
11 ms |
19116 KB |
Output is correct |
2 |
Correct |
9 ms |
19028 KB |
Output is correct |
3 |
Correct |
9 ms |
19072 KB |
Output is correct |
4 |
Correct |
9 ms |
19028 KB |
Output is correct |
5 |
Correct |
9 ms |
19112 KB |
Output is correct |
6 |
Correct |
12 ms |
19028 KB |
Output is correct |
7 |
Correct |
12 ms |
19156 KB |
Output is correct |
8 |
Correct |
10 ms |
19116 KB |
Output is correct |
9 |
Correct |
10 ms |
19156 KB |
Output is correct |
10 |
Correct |
12 ms |
19116 KB |
Output is correct |
11 |
Correct |
10 ms |
19156 KB |
Output is correct |
12 |
Correct |
10 ms |
19140 KB |
Output is correct |
13 |
Correct |
11 ms |
19156 KB |
Output is correct |
14 |
Correct |
11 ms |
19156 KB |
Output is correct |
15 |
Correct |
10 ms |
19224 KB |
Output is correct |
16 |
Correct |
10 ms |
19156 KB |
Output is correct |
17 |
Correct |
10 ms |
19156 KB |
Output is correct |
18 |
Correct |
10 ms |
19156 KB |
Output is correct |
19 |
Correct |
10 ms |
19156 KB |
Output is correct |
20 |
Correct |
14 ms |
19120 KB |
Output is correct |
21 |
Correct |
10 ms |
19156 KB |
Output is correct |
22 |
Correct |
11 ms |
19152 KB |
Output is correct |
23 |
Correct |
10 ms |
19112 KB |
Output is correct |
24 |
Correct |
10 ms |
19184 KB |
Output is correct |
25 |
Correct |
11 ms |
19112 KB |
Output is correct |
26 |
Correct |
10 ms |
19156 KB |
Output is correct |
27 |
Correct |
12 ms |
19112 KB |
Output is correct |
28 |
Correct |
10 ms |
19156 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
19116 KB |
Output is correct |
2 |
Correct |
9 ms |
19028 KB |
Output is correct |
3 |
Correct |
9 ms |
19072 KB |
Output is correct |
4 |
Correct |
9 ms |
19028 KB |
Output is correct |
5 |
Correct |
9 ms |
19112 KB |
Output is correct |
6 |
Correct |
12 ms |
19028 KB |
Output is correct |
7 |
Correct |
12 ms |
19156 KB |
Output is correct |
8 |
Correct |
10 ms |
19116 KB |
Output is correct |
9 |
Correct |
10 ms |
19156 KB |
Output is correct |
10 |
Correct |
12 ms |
19116 KB |
Output is correct |
11 |
Correct |
10 ms |
19156 KB |
Output is correct |
12 |
Correct |
10 ms |
19140 KB |
Output is correct |
13 |
Correct |
11 ms |
19156 KB |
Output is correct |
14 |
Correct |
11 ms |
19156 KB |
Output is correct |
15 |
Correct |
10 ms |
19224 KB |
Output is correct |
16 |
Correct |
10 ms |
19156 KB |
Output is correct |
17 |
Correct |
10 ms |
19156 KB |
Output is correct |
18 |
Correct |
10 ms |
19156 KB |
Output is correct |
19 |
Correct |
10 ms |
19156 KB |
Output is correct |
20 |
Correct |
14 ms |
19120 KB |
Output is correct |
21 |
Correct |
10 ms |
19156 KB |
Output is correct |
22 |
Correct |
11 ms |
19152 KB |
Output is correct |
23 |
Correct |
10 ms |
19112 KB |
Output is correct |
24 |
Correct |
10 ms |
19184 KB |
Output is correct |
25 |
Correct |
11 ms |
19112 KB |
Output is correct |
26 |
Correct |
10 ms |
19156 KB |
Output is correct |
27 |
Correct |
12 ms |
19112 KB |
Output is correct |
28 |
Correct |
10 ms |
19156 KB |
Output is correct |
29 |
Correct |
22 ms |
25956 KB |
Output is correct |
30 |
Correct |
17 ms |
23380 KB |
Output is correct |
31 |
Correct |
18 ms |
22868 KB |
Output is correct |
32 |
Correct |
17 ms |
21332 KB |
Output is correct |
33 |
Correct |
13 ms |
20336 KB |
Output is correct |
34 |
Correct |
22 ms |
23124 KB |
Output is correct |
35 |
Correct |
21 ms |
23876 KB |
Output is correct |
36 |
Correct |
16 ms |
21332 KB |
Output is correct |
37 |
Correct |
30 ms |
25812 KB |
Output is correct |
38 |
Correct |
44 ms |
29216 KB |
Output is correct |
39 |
Correct |
14 ms |
22740 KB |
Output is correct |
40 |
Correct |
13 ms |
21204 KB |
Output is correct |
41 |
Correct |
13 ms |
21196 KB |
Output is correct |
42 |
Correct |
13 ms |
21204 KB |
Output is correct |
43 |
Correct |
14 ms |
22240 KB |
Output is correct |
44 |
Correct |
16 ms |
24220 KB |
Output is correct |
45 |
Correct |
17 ms |
27068 KB |
Output is correct |
46 |
Correct |
24 ms |
29004 KB |
Output is correct |
47 |
Correct |
14 ms |
20916 KB |
Output is correct |
48 |
Correct |
15 ms |
21588 KB |
Output is correct |
49 |
Correct |
16 ms |
22280 KB |
Output is correct |
50 |
Correct |
17 ms |
23480 KB |
Output is correct |
51 |
Correct |
13 ms |
20692 KB |
Output is correct |
52 |
Correct |
13 ms |
21332 KB |
Output is correct |
53 |
Correct |
15 ms |
22268 KB |
Output is correct |
54 |
Correct |
20 ms |
23676 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
19116 KB |
Output is correct |
2 |
Correct |
9 ms |
19028 KB |
Output is correct |
3 |
Runtime error |
172 ms |
262144 KB |
Execution killed with signal 9 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
19116 KB |
Output is correct |
2 |
Correct |
9 ms |
19028 KB |
Output is correct |
3 |
Correct |
9 ms |
19072 KB |
Output is correct |
4 |
Correct |
9 ms |
19028 KB |
Output is correct |
5 |
Correct |
9 ms |
19112 KB |
Output is correct |
6 |
Correct |
12 ms |
19028 KB |
Output is correct |
7 |
Correct |
12 ms |
19156 KB |
Output is correct |
8 |
Correct |
10 ms |
19116 KB |
Output is correct |
9 |
Correct |
10 ms |
19156 KB |
Output is correct |
10 |
Correct |
12 ms |
19116 KB |
Output is correct |
11 |
Correct |
10 ms |
19156 KB |
Output is correct |
12 |
Correct |
10 ms |
19140 KB |
Output is correct |
13 |
Correct |
11 ms |
19156 KB |
Output is correct |
14 |
Correct |
11 ms |
19156 KB |
Output is correct |
15 |
Correct |
10 ms |
19224 KB |
Output is correct |
16 |
Correct |
10 ms |
19156 KB |
Output is correct |
17 |
Correct |
10 ms |
19156 KB |
Output is correct |
18 |
Correct |
10 ms |
19156 KB |
Output is correct |
19 |
Correct |
10 ms |
19156 KB |
Output is correct |
20 |
Correct |
14 ms |
19120 KB |
Output is correct |
21 |
Correct |
10 ms |
19156 KB |
Output is correct |
22 |
Correct |
11 ms |
19152 KB |
Output is correct |
23 |
Correct |
10 ms |
19112 KB |
Output is correct |
24 |
Correct |
10 ms |
19184 KB |
Output is correct |
25 |
Correct |
11 ms |
19112 KB |
Output is correct |
26 |
Correct |
10 ms |
19156 KB |
Output is correct |
27 |
Correct |
12 ms |
19112 KB |
Output is correct |
28 |
Correct |
10 ms |
19156 KB |
Output is correct |
29 |
Runtime error |
172 ms |
262144 KB |
Execution killed with signal 9 |
30 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
19116 KB |
Output is correct |
2 |
Correct |
9 ms |
19028 KB |
Output is correct |
3 |
Correct |
9 ms |
19072 KB |
Output is correct |
4 |
Correct |
9 ms |
19028 KB |
Output is correct |
5 |
Correct |
9 ms |
19112 KB |
Output is correct |
6 |
Correct |
12 ms |
19028 KB |
Output is correct |
7 |
Correct |
12 ms |
19156 KB |
Output is correct |
8 |
Correct |
10 ms |
19116 KB |
Output is correct |
9 |
Correct |
10 ms |
19156 KB |
Output is correct |
10 |
Correct |
12 ms |
19116 KB |
Output is correct |
11 |
Correct |
10 ms |
19156 KB |
Output is correct |
12 |
Correct |
10 ms |
19140 KB |
Output is correct |
13 |
Correct |
11 ms |
19156 KB |
Output is correct |
14 |
Correct |
11 ms |
19156 KB |
Output is correct |
15 |
Correct |
10 ms |
19224 KB |
Output is correct |
16 |
Correct |
10 ms |
19156 KB |
Output is correct |
17 |
Correct |
10 ms |
19156 KB |
Output is correct |
18 |
Correct |
10 ms |
19156 KB |
Output is correct |
19 |
Correct |
10 ms |
19156 KB |
Output is correct |
20 |
Correct |
14 ms |
19120 KB |
Output is correct |
21 |
Correct |
10 ms |
19156 KB |
Output is correct |
22 |
Correct |
11 ms |
19152 KB |
Output is correct |
23 |
Correct |
10 ms |
19112 KB |
Output is correct |
24 |
Correct |
10 ms |
19184 KB |
Output is correct |
25 |
Correct |
11 ms |
19112 KB |
Output is correct |
26 |
Correct |
10 ms |
19156 KB |
Output is correct |
27 |
Correct |
12 ms |
19112 KB |
Output is correct |
28 |
Correct |
10 ms |
19156 KB |
Output is correct |
29 |
Correct |
22 ms |
25956 KB |
Output is correct |
30 |
Correct |
17 ms |
23380 KB |
Output is correct |
31 |
Correct |
18 ms |
22868 KB |
Output is correct |
32 |
Correct |
17 ms |
21332 KB |
Output is correct |
33 |
Correct |
13 ms |
20336 KB |
Output is correct |
34 |
Correct |
22 ms |
23124 KB |
Output is correct |
35 |
Correct |
21 ms |
23876 KB |
Output is correct |
36 |
Correct |
16 ms |
21332 KB |
Output is correct |
37 |
Correct |
30 ms |
25812 KB |
Output is correct |
38 |
Correct |
44 ms |
29216 KB |
Output is correct |
39 |
Correct |
14 ms |
22740 KB |
Output is correct |
40 |
Correct |
13 ms |
21204 KB |
Output is correct |
41 |
Correct |
13 ms |
21196 KB |
Output is correct |
42 |
Correct |
13 ms |
21204 KB |
Output is correct |
43 |
Correct |
14 ms |
22240 KB |
Output is correct |
44 |
Correct |
16 ms |
24220 KB |
Output is correct |
45 |
Correct |
17 ms |
27068 KB |
Output is correct |
46 |
Correct |
24 ms |
29004 KB |
Output is correct |
47 |
Correct |
14 ms |
20916 KB |
Output is correct |
48 |
Correct |
15 ms |
21588 KB |
Output is correct |
49 |
Correct |
16 ms |
22280 KB |
Output is correct |
50 |
Correct |
17 ms |
23480 KB |
Output is correct |
51 |
Correct |
13 ms |
20692 KB |
Output is correct |
52 |
Correct |
13 ms |
21332 KB |
Output is correct |
53 |
Correct |
15 ms |
22268 KB |
Output is correct |
54 |
Correct |
20 ms |
23676 KB |
Output is correct |
55 |
Runtime error |
133 ms |
262144 KB |
Execution killed with signal 9 |
56 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
19116 KB |
Output is correct |
2 |
Correct |
9 ms |
19028 KB |
Output is correct |
3 |
Correct |
9 ms |
19072 KB |
Output is correct |
4 |
Correct |
9 ms |
19028 KB |
Output is correct |
5 |
Correct |
9 ms |
19112 KB |
Output is correct |
6 |
Correct |
12 ms |
19028 KB |
Output is correct |
7 |
Correct |
12 ms |
19156 KB |
Output is correct |
8 |
Correct |
10 ms |
19116 KB |
Output is correct |
9 |
Correct |
10 ms |
19156 KB |
Output is correct |
10 |
Correct |
12 ms |
19116 KB |
Output is correct |
11 |
Correct |
10 ms |
19156 KB |
Output is correct |
12 |
Correct |
10 ms |
19140 KB |
Output is correct |
13 |
Correct |
11 ms |
19156 KB |
Output is correct |
14 |
Correct |
11 ms |
19156 KB |
Output is correct |
15 |
Correct |
10 ms |
19224 KB |
Output is correct |
16 |
Correct |
10 ms |
19156 KB |
Output is correct |
17 |
Correct |
10 ms |
19156 KB |
Output is correct |
18 |
Correct |
10 ms |
19156 KB |
Output is correct |
19 |
Correct |
10 ms |
19156 KB |
Output is correct |
20 |
Correct |
14 ms |
19120 KB |
Output is correct |
21 |
Correct |
10 ms |
19156 KB |
Output is correct |
22 |
Correct |
11 ms |
19152 KB |
Output is correct |
23 |
Correct |
10 ms |
19112 KB |
Output is correct |
24 |
Correct |
10 ms |
19184 KB |
Output is correct |
25 |
Correct |
11 ms |
19112 KB |
Output is correct |
26 |
Correct |
10 ms |
19156 KB |
Output is correct |
27 |
Correct |
12 ms |
19112 KB |
Output is correct |
28 |
Correct |
10 ms |
19156 KB |
Output is correct |
29 |
Correct |
22 ms |
25956 KB |
Output is correct |
30 |
Correct |
17 ms |
23380 KB |
Output is correct |
31 |
Correct |
18 ms |
22868 KB |
Output is correct |
32 |
Correct |
17 ms |
21332 KB |
Output is correct |
33 |
Correct |
13 ms |
20336 KB |
Output is correct |
34 |
Correct |
22 ms |
23124 KB |
Output is correct |
35 |
Correct |
21 ms |
23876 KB |
Output is correct |
36 |
Correct |
16 ms |
21332 KB |
Output is correct |
37 |
Correct |
30 ms |
25812 KB |
Output is correct |
38 |
Correct |
44 ms |
29216 KB |
Output is correct |
39 |
Correct |
14 ms |
22740 KB |
Output is correct |
40 |
Correct |
13 ms |
21204 KB |
Output is correct |
41 |
Correct |
13 ms |
21196 KB |
Output is correct |
42 |
Correct |
13 ms |
21204 KB |
Output is correct |
43 |
Correct |
14 ms |
22240 KB |
Output is correct |
44 |
Correct |
16 ms |
24220 KB |
Output is correct |
45 |
Correct |
17 ms |
27068 KB |
Output is correct |
46 |
Correct |
24 ms |
29004 KB |
Output is correct |
47 |
Correct |
14 ms |
20916 KB |
Output is correct |
48 |
Correct |
15 ms |
21588 KB |
Output is correct |
49 |
Correct |
16 ms |
22280 KB |
Output is correct |
50 |
Correct |
17 ms |
23480 KB |
Output is correct |
51 |
Correct |
13 ms |
20692 KB |
Output is correct |
52 |
Correct |
13 ms |
21332 KB |
Output is correct |
53 |
Correct |
15 ms |
22268 KB |
Output is correct |
54 |
Correct |
20 ms |
23676 KB |
Output is correct |
55 |
Runtime error |
172 ms |
262144 KB |
Execution killed with signal 9 |
56 |
Halted |
0 ms |
0 KB |
- |