# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
611807 |
2022-07-29T07:43:57 Z |
장태환(#8498) |
Tenis (COI19_tenis) |
C++17 |
|
189 ms |
5588 KB |
#include <bits/stdc++.h>
using namespace std;
int stree[1 << 20];
int lazy[1 << 20];
int arr[3][100100];
int revarr[100100][3];
int treeN;
void ul(int n)
{
stree[n] += lazy[n];
if (n < treeN)
{
lazy[n * 2] += lazy[n];
lazy[n * 2 + 1] += lazy[n];
}
lazy[n] = 0;
}
void upd(int qs, int qe, int v, int s = 0, int e = treeN - 1, int i = 1)
{
ul(i);
if (s > qe || qs > e||qs>qe)
{
return;
}
if (qs <= s && e <= qe)
{
lazy[i] += v;
ul(i);
return;
}
upd(qs, qe, v, s, (s + e) / 2, i * 2);
upd(qs, qe, v, (s + e) / 2+1,e, i * 2+1);
stree[i] = min(stree[i * 2], stree[i * 2 + 1]);
}
int ge(int qs, int qe, int s = 0, int e = treeN - 1, int i = 1)
{
ul(i);
if (s > qe || qs > e || qs > qe)
{
return 1 << 30;
}
if (qs <= s && e <= qe)
{
return stree[i];
}
return min(ge(qs, qe ,s ,(s + e) / 2, i * 2), ge(qs, qe, (s + e) / 2 + 1, e, i * 2 + 1));
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int N, M;
cin >> N >> M;
for (treeN = 1; treeN <= N; treeN *= 2);
int i;
for (i = 0; i < N; i++)
{
cin >> arr[0][i];
revarr[arr[0][i]][0] = i;
}
for (i = 0; i < N; i++)
{
cin >> arr[1][i];
revarr[arr[1][i]][1] = i;
}
for (i = 0; i < N; i++)
{
cin >> arr[2][i];
revarr[arr[2][i]][2] = i;
}
for (i = 1; i <= N; i++)
{
upd(min({ revarr[i][0],revarr[i][1],revarr[i][2] }), revarr[i][0]-1, 1);
}
for (i = 0; i < M; i++)
{
int x;
cin >> x;
if (x == 1)
{
int a;
cin >> a;
int v = ge(0, revarr[a][0] - 1);
if (v)
cout << "DA" << '\n';
else
cout << "NE" << '\n';
}
else
{
int a, b, c;
cin >> a >> b >> c;
upd(min({ revarr[b][0],revarr[b][1],revarr[b][2] }), revarr[b][0]-1, -1);
upd(min({ revarr[c][0],revarr[c][1],revarr[c][2] }), revarr[c][0]-1, -1);
swap(revarr[b][a - 1], revarr[c][a - 1]);
upd(min({ revarr[b][0],revarr[b][1],revarr[b][2] }), revarr[b][0]-1, 1);
upd(min({ revarr[c][0],revarr[c][1],revarr[c][2] }), revarr[c][0]-1, 1);
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
54 ms |
4704 KB |
Output is correct |
14 |
Correct |
51 ms |
4844 KB |
Output is correct |
15 |
Correct |
46 ms |
4684 KB |
Output is correct |
16 |
Correct |
47 ms |
4772 KB |
Output is correct |
17 |
Correct |
55 ms |
4816 KB |
Output is correct |
18 |
Correct |
43 ms |
4808 KB |
Output is correct |
19 |
Correct |
56 ms |
4776 KB |
Output is correct |
20 |
Correct |
68 ms |
4732 KB |
Output is correct |
21 |
Correct |
67 ms |
4792 KB |
Output is correct |
22 |
Correct |
47 ms |
4812 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
89 ms |
5588 KB |
Output is correct |
2 |
Correct |
95 ms |
5228 KB |
Output is correct |
3 |
Correct |
96 ms |
5128 KB |
Output is correct |
4 |
Correct |
93 ms |
5128 KB |
Output is correct |
5 |
Correct |
103 ms |
5108 KB |
Output is correct |
6 |
Correct |
89 ms |
5160 KB |
Output is correct |
7 |
Correct |
142 ms |
5324 KB |
Output is correct |
8 |
Correct |
93 ms |
5164 KB |
Output is correct |
9 |
Correct |
94 ms |
5224 KB |
Output is correct |
10 |
Correct |
113 ms |
5136 KB |
Output is correct |
11 |
Correct |
114 ms |
5128 KB |
Output is correct |
12 |
Correct |
117 ms |
5164 KB |
Output is correct |
13 |
Correct |
124 ms |
5140 KB |
Output is correct |
14 |
Correct |
138 ms |
5196 KB |
Output is correct |
15 |
Correct |
109 ms |
5140 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
54 ms |
4704 KB |
Output is correct |
14 |
Correct |
51 ms |
4844 KB |
Output is correct |
15 |
Correct |
46 ms |
4684 KB |
Output is correct |
16 |
Correct |
47 ms |
4772 KB |
Output is correct |
17 |
Correct |
55 ms |
4816 KB |
Output is correct |
18 |
Correct |
43 ms |
4808 KB |
Output is correct |
19 |
Correct |
56 ms |
4776 KB |
Output is correct |
20 |
Correct |
68 ms |
4732 KB |
Output is correct |
21 |
Correct |
67 ms |
4792 KB |
Output is correct |
22 |
Correct |
47 ms |
4812 KB |
Output is correct |
23 |
Correct |
89 ms |
5588 KB |
Output is correct |
24 |
Correct |
95 ms |
5228 KB |
Output is correct |
25 |
Correct |
96 ms |
5128 KB |
Output is correct |
26 |
Correct |
93 ms |
5128 KB |
Output is correct |
27 |
Correct |
103 ms |
5108 KB |
Output is correct |
28 |
Correct |
89 ms |
5160 KB |
Output is correct |
29 |
Correct |
142 ms |
5324 KB |
Output is correct |
30 |
Correct |
93 ms |
5164 KB |
Output is correct |
31 |
Correct |
94 ms |
5224 KB |
Output is correct |
32 |
Correct |
113 ms |
5136 KB |
Output is correct |
33 |
Correct |
114 ms |
5128 KB |
Output is correct |
34 |
Correct |
117 ms |
5164 KB |
Output is correct |
35 |
Correct |
124 ms |
5140 KB |
Output is correct |
36 |
Correct |
138 ms |
5196 KB |
Output is correct |
37 |
Correct |
109 ms |
5140 KB |
Output is correct |
38 |
Correct |
179 ms |
4824 KB |
Output is correct |
39 |
Correct |
127 ms |
4908 KB |
Output is correct |
40 |
Correct |
180 ms |
4888 KB |
Output is correct |
41 |
Correct |
138 ms |
4976 KB |
Output is correct |
42 |
Correct |
136 ms |
4984 KB |
Output is correct |
43 |
Correct |
189 ms |
4900 KB |
Output is correct |
44 |
Correct |
128 ms |
5036 KB |
Output is correct |
45 |
Correct |
154 ms |
4948 KB |
Output is correct |
46 |
Correct |
136 ms |
4992 KB |
Output is correct |
47 |
Correct |
138 ms |
4944 KB |
Output is correct |
48 |
Correct |
131 ms |
4968 KB |
Output is correct |
49 |
Correct |
136 ms |
4912 KB |
Output is correct |
50 |
Correct |
122 ms |
5000 KB |
Output is correct |
51 |
Correct |
122 ms |
4940 KB |
Output is correct |
52 |
Correct |
183 ms |
4908 KB |
Output is correct |
53 |
Correct |
114 ms |
5004 KB |
Output is correct |
54 |
Correct |
117 ms |
4956 KB |
Output is correct |
55 |
Correct |
141 ms |
4952 KB |
Output is correct |
56 |
Correct |
125 ms |
4940 KB |
Output is correct |
57 |
Correct |
111 ms |
4972 KB |
Output is correct |
58 |
Correct |
134 ms |
4892 KB |
Output is correct |