# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
235000 |
2020-05-26T16:13:05 Z |
Saboon |
Tenis (COI19_tenis) |
C++14 |
|
296 ms |
8952 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef complex<long double> point;
const int maxn = 1e5 + 10;
int a[4][maxn], b[4][maxn];
pair<int,int> seg[4*maxn];
int lazy[4*maxn];
void add(int id, int L, int R, int l, int r, int val){
if (r <= L or R <= l)
return;
if (l <= L and R <= r){
seg[id].first += val;
lazy[id] += val;
return;
}
int mid = (L + R) >> 1;
add(2*id+0, L, mid, l, r, val);
add(2*id+1, mid, R, l, r, val);
seg[id] = min(seg[2*id+0], seg[2*id+1]);
seg[id].first += lazy[id];
}
void build(int id, int L, int R){
seg[id].second = L;
if (L + 1 == R)
return;
int mid = (L + R) >> 1;
build(2*id+0, L, mid);
build(2*id+1, mid, R);
}
int getmax(int idx){
int ret = 1;
for (int i = 1; i <= 3; i++)
ret = max(ret, a[i][idx]);
return ret;
}
int getmin(int idx){
int ret = maxn;
for (int i = 1; i <= 3; i++)
ret = min(ret, a[i][idx]);
return ret;
}
int main(){
ios_base::sync_with_stdio(false);
int n, q;
cin >> n >> q;
for (int j = 1; j <= 3; j++)
for (int i = 1; i <= n; i++){
int x;
cin >> x;
b[j][i] = x;
a[j][x] = i;
}
build(1, 1, n+1);
for (int i = 1; i <= n; i++){
int l = getmin(i), r = getmax(i);
add(1, 1, n+1, l, r, +1);
}
for (int i = 1; i <= q; i++){
int type;
cin >> type;
if (type == 1){
int idx;
cin >> idx;
int l = getmin(idx);
if (l <= seg[1].second)
cout << "DA\n";
else
cout << "NE\n";
}
else{
int p, A, B;
cin >> p >> A >> B;
int l = getmin(A), r = getmax(A);
add(1, 1, n+1, l, r, -1);
l = getmin(B), r = getmax(B);
add(1, 1, n+1, l, r, -1);
swap(a[p][A], a[p][B]);
l = getmin(A), r = getmax(A);
add(1, 1, n+1, l, r, +1);
l = getmin(B), r = getmax(B);
add(1, 1, n+1, l, r, +1);
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
6 ms |
512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
6 ms |
512 KB |
Output is correct |
13 |
Correct |
75 ms |
7416 KB |
Output is correct |
14 |
Correct |
81 ms |
7544 KB |
Output is correct |
15 |
Correct |
77 ms |
7548 KB |
Output is correct |
16 |
Correct |
78 ms |
7420 KB |
Output is correct |
17 |
Correct |
66 ms |
7416 KB |
Output is correct |
18 |
Correct |
70 ms |
7416 KB |
Output is correct |
19 |
Correct |
67 ms |
7420 KB |
Output is correct |
20 |
Correct |
80 ms |
7544 KB |
Output is correct |
21 |
Correct |
71 ms |
7416 KB |
Output is correct |
22 |
Correct |
74 ms |
7416 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
281 ms |
6012 KB |
Output is correct |
2 |
Correct |
279 ms |
8648 KB |
Output is correct |
3 |
Correct |
286 ms |
8696 KB |
Output is correct |
4 |
Correct |
275 ms |
8568 KB |
Output is correct |
5 |
Correct |
279 ms |
8568 KB |
Output is correct |
6 |
Correct |
281 ms |
8568 KB |
Output is correct |
7 |
Correct |
287 ms |
8568 KB |
Output is correct |
8 |
Correct |
279 ms |
8568 KB |
Output is correct |
9 |
Correct |
277 ms |
8568 KB |
Output is correct |
10 |
Correct |
296 ms |
8696 KB |
Output is correct |
11 |
Correct |
283 ms |
8620 KB |
Output is correct |
12 |
Correct |
280 ms |
8508 KB |
Output is correct |
13 |
Correct |
283 ms |
8696 KB |
Output is correct |
14 |
Correct |
281 ms |
8696 KB |
Output is correct |
15 |
Correct |
280 ms |
8568 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
6 ms |
512 KB |
Output is correct |
13 |
Correct |
75 ms |
7416 KB |
Output is correct |
14 |
Correct |
81 ms |
7544 KB |
Output is correct |
15 |
Correct |
77 ms |
7548 KB |
Output is correct |
16 |
Correct |
78 ms |
7420 KB |
Output is correct |
17 |
Correct |
66 ms |
7416 KB |
Output is correct |
18 |
Correct |
70 ms |
7416 KB |
Output is correct |
19 |
Correct |
67 ms |
7420 KB |
Output is correct |
20 |
Correct |
80 ms |
7544 KB |
Output is correct |
21 |
Correct |
71 ms |
7416 KB |
Output is correct |
22 |
Correct |
74 ms |
7416 KB |
Output is correct |
23 |
Correct |
281 ms |
6012 KB |
Output is correct |
24 |
Correct |
279 ms |
8648 KB |
Output is correct |
25 |
Correct |
286 ms |
8696 KB |
Output is correct |
26 |
Correct |
275 ms |
8568 KB |
Output is correct |
27 |
Correct |
279 ms |
8568 KB |
Output is correct |
28 |
Correct |
281 ms |
8568 KB |
Output is correct |
29 |
Correct |
287 ms |
8568 KB |
Output is correct |
30 |
Correct |
279 ms |
8568 KB |
Output is correct |
31 |
Correct |
277 ms |
8568 KB |
Output is correct |
32 |
Correct |
296 ms |
8696 KB |
Output is correct |
33 |
Correct |
283 ms |
8620 KB |
Output is correct |
34 |
Correct |
280 ms |
8508 KB |
Output is correct |
35 |
Correct |
283 ms |
8696 KB |
Output is correct |
36 |
Correct |
281 ms |
8696 KB |
Output is correct |
37 |
Correct |
280 ms |
8568 KB |
Output is correct |
38 |
Correct |
292 ms |
8824 KB |
Output is correct |
39 |
Correct |
265 ms |
8760 KB |
Output is correct |
40 |
Correct |
295 ms |
8952 KB |
Output is correct |
41 |
Correct |
255 ms |
8696 KB |
Output is correct |
42 |
Correct |
251 ms |
8696 KB |
Output is correct |
43 |
Correct |
295 ms |
8824 KB |
Output is correct |
44 |
Correct |
252 ms |
8704 KB |
Output is correct |
45 |
Correct |
272 ms |
8688 KB |
Output is correct |
46 |
Correct |
262 ms |
8700 KB |
Output is correct |
47 |
Correct |
257 ms |
8776 KB |
Output is correct |
48 |
Correct |
269 ms |
8596 KB |
Output is correct |
49 |
Correct |
259 ms |
8824 KB |
Output is correct |
50 |
Correct |
262 ms |
8696 KB |
Output is correct |
51 |
Correct |
266 ms |
8792 KB |
Output is correct |
52 |
Correct |
290 ms |
8832 KB |
Output is correct |
53 |
Correct |
252 ms |
8696 KB |
Output is correct |
54 |
Correct |
246 ms |
8696 KB |
Output is correct |
55 |
Correct |
261 ms |
8800 KB |
Output is correct |
56 |
Correct |
259 ms |
8696 KB |
Output is correct |
57 |
Correct |
263 ms |
8696 KB |
Output is correct |
58 |
Correct |
290 ms |
8696 KB |
Output is correct |