# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
208385 |
2020-03-11T05:13:42 Z |
bensonlzl |
Tenis (COI19_tenis) |
C++14 |
|
172 ms |
14900 KB |
#include <bits/stdc++.h>
using namespace std;
int N, Q, R1[100005], R2[100005], R3[100005], M[100005], X, P, A, B, k;
int maxiR(int x){
return max(R1[x],max(R2[x],R3[x]));
}
int val[100005];
struct node{
node *left, *right;
int m = 1e9, mdex, S, E, lazy;
node(int _s, int _e){
S = _s, E = _e;
if (S == E){
m = val[S];
mdex = S;
return;
}
left = new node(S,(S+E)/2);
right = new node((S+E)/2+1,E);
if (left->m < right->m){
mdex = left->mdex;
m = left->m;
}
else{
m = right->m;
mdex = right->mdex;
}
}
void propagate(){
if (lazy){
left->m += lazy;
right->m += lazy;
left->lazy += lazy;
right->lazy += lazy;
lazy = 0;
}
}
void update(int l, int r, int v){
if (l > r) return;
if (l > E || r < S) return;
if (l <= S && E <= r){
lazy += v;
m += v;
return;
}
propagate();
left->update(l,r,v);
right->update(l,r,v);
if (left->m < right->m){
mdex = left->mdex;
m = left->m;
}
else{
m = right->m;
mdex = right->mdex;
}
}
}*root;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> N >> Q;
int x;
for (int i = N; i >= 1; --i){
cin >> x;
R1[x] = i;
}
for (int i = N; i >= 1; --i){
cin >> x;
R2[x] = i;
}
for (int i = N; i >= 1; --i){
cin >> x;
R3[x] = i;
}
for (int i = 1; i <= N; ++i){
M[i] = maxiR(i);
val[M[i]]++;
}
for (int i = 1; i <= N; ++i){
val[i] += val[i-1];
}
for (int i = 1; i <= N; ++i){
val[i] = i-val[i];
}
root = new node(1,N-1);
for (int i = 1; i <= Q; ++i){
cin >> k;
if (k == 1){
cin >> X;
if (maxiR(X) > root->mdex || root->m > 0){
cout << "DA\n";
}
else cout << "NE\n";
}
if (k == 2){
cin >> P >> A >> B;
int oldA = maxiR(A), oldB = maxiR(B);
int t;
if (P == 1){
t = R1[A];
R1[A] = R1[B];
R1[B] = t;
}
if (P == 2){
t = R2[A];
R2[A] = R2[B];
R2[B] = t;
}
if (P == 3){
t = R3[A];
R3[A] = R3[B];
R3[B] = t;
}
root->update(oldA,N-1,1);
root->update(oldB,N-1,1);
root->update(maxiR(A),N-1,-1);
root->update(maxiR(B),N-1,-1);
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
248 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
6 |
Correct |
5 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
248 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
6 |
Correct |
5 ms |
376 KB |
Output is correct |
7 |
Correct |
5 ms |
508 KB |
Output is correct |
8 |
Correct |
5 ms |
504 KB |
Output is correct |
9 |
Correct |
6 ms |
504 KB |
Output is correct |
10 |
Correct |
5 ms |
508 KB |
Output is correct |
11 |
Correct |
5 ms |
480 KB |
Output is correct |
12 |
Correct |
5 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
248 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
6 |
Correct |
5 ms |
376 KB |
Output is correct |
7 |
Correct |
5 ms |
508 KB |
Output is correct |
8 |
Correct |
5 ms |
504 KB |
Output is correct |
9 |
Correct |
6 ms |
504 KB |
Output is correct |
10 |
Correct |
5 ms |
508 KB |
Output is correct |
11 |
Correct |
5 ms |
480 KB |
Output is correct |
12 |
Correct |
5 ms |
504 KB |
Output is correct |
13 |
Correct |
51 ms |
13304 KB |
Output is correct |
14 |
Correct |
49 ms |
13432 KB |
Output is correct |
15 |
Correct |
49 ms |
13328 KB |
Output is correct |
16 |
Correct |
50 ms |
13304 KB |
Output is correct |
17 |
Correct |
50 ms |
13432 KB |
Output is correct |
18 |
Correct |
47 ms |
13432 KB |
Output is correct |
19 |
Correct |
52 ms |
13304 KB |
Output is correct |
20 |
Correct |
54 ms |
13432 KB |
Output is correct |
21 |
Correct |
50 ms |
13304 KB |
Output is correct |
22 |
Correct |
48 ms |
13408 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
73 ms |
14456 KB |
Output is correct |
2 |
Correct |
71 ms |
14580 KB |
Output is correct |
3 |
Correct |
71 ms |
14456 KB |
Output is correct |
4 |
Correct |
71 ms |
14456 KB |
Output is correct |
5 |
Correct |
73 ms |
14456 KB |
Output is correct |
6 |
Correct |
70 ms |
14584 KB |
Output is correct |
7 |
Correct |
68 ms |
14456 KB |
Output is correct |
8 |
Correct |
68 ms |
14456 KB |
Output is correct |
9 |
Correct |
68 ms |
14456 KB |
Output is correct |
10 |
Correct |
69 ms |
14456 KB |
Output is correct |
11 |
Correct |
68 ms |
14456 KB |
Output is correct |
12 |
Correct |
70 ms |
14328 KB |
Output is correct |
13 |
Correct |
71 ms |
14480 KB |
Output is correct |
14 |
Correct |
71 ms |
14584 KB |
Output is correct |
15 |
Correct |
73 ms |
14432 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
248 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
6 |
Correct |
5 ms |
376 KB |
Output is correct |
7 |
Correct |
5 ms |
508 KB |
Output is correct |
8 |
Correct |
5 ms |
504 KB |
Output is correct |
9 |
Correct |
6 ms |
504 KB |
Output is correct |
10 |
Correct |
5 ms |
508 KB |
Output is correct |
11 |
Correct |
5 ms |
480 KB |
Output is correct |
12 |
Correct |
5 ms |
504 KB |
Output is correct |
13 |
Correct |
51 ms |
13304 KB |
Output is correct |
14 |
Correct |
49 ms |
13432 KB |
Output is correct |
15 |
Correct |
49 ms |
13328 KB |
Output is correct |
16 |
Correct |
50 ms |
13304 KB |
Output is correct |
17 |
Correct |
50 ms |
13432 KB |
Output is correct |
18 |
Correct |
47 ms |
13432 KB |
Output is correct |
19 |
Correct |
52 ms |
13304 KB |
Output is correct |
20 |
Correct |
54 ms |
13432 KB |
Output is correct |
21 |
Correct |
50 ms |
13304 KB |
Output is correct |
22 |
Correct |
48 ms |
13408 KB |
Output is correct |
23 |
Correct |
73 ms |
14456 KB |
Output is correct |
24 |
Correct |
71 ms |
14580 KB |
Output is correct |
25 |
Correct |
71 ms |
14456 KB |
Output is correct |
26 |
Correct |
71 ms |
14456 KB |
Output is correct |
27 |
Correct |
73 ms |
14456 KB |
Output is correct |
28 |
Correct |
70 ms |
14584 KB |
Output is correct |
29 |
Correct |
68 ms |
14456 KB |
Output is correct |
30 |
Correct |
68 ms |
14456 KB |
Output is correct |
31 |
Correct |
68 ms |
14456 KB |
Output is correct |
32 |
Correct |
69 ms |
14456 KB |
Output is correct |
33 |
Correct |
68 ms |
14456 KB |
Output is correct |
34 |
Correct |
70 ms |
14328 KB |
Output is correct |
35 |
Correct |
71 ms |
14480 KB |
Output is correct |
36 |
Correct |
71 ms |
14584 KB |
Output is correct |
37 |
Correct |
73 ms |
14432 KB |
Output is correct |
38 |
Correct |
169 ms |
14712 KB |
Output is correct |
39 |
Correct |
93 ms |
14456 KB |
Output is correct |
40 |
Correct |
172 ms |
14840 KB |
Output is correct |
41 |
Correct |
92 ms |
14584 KB |
Output is correct |
42 |
Correct |
110 ms |
14716 KB |
Output is correct |
43 |
Correct |
162 ms |
14900 KB |
Output is correct |
44 |
Correct |
85 ms |
14584 KB |
Output is correct |
45 |
Correct |
104 ms |
14584 KB |
Output is correct |
46 |
Correct |
92 ms |
14456 KB |
Output is correct |
47 |
Correct |
101 ms |
14584 KB |
Output is correct |
48 |
Correct |
90 ms |
14456 KB |
Output is correct |
49 |
Correct |
104 ms |
14588 KB |
Output is correct |
50 |
Correct |
82 ms |
14584 KB |
Output is correct |
51 |
Correct |
102 ms |
14712 KB |
Output is correct |
52 |
Correct |
154 ms |
14844 KB |
Output is correct |
53 |
Correct |
95 ms |
14584 KB |
Output is correct |
54 |
Correct |
97 ms |
14716 KB |
Output is correct |
55 |
Correct |
105 ms |
14608 KB |
Output is correct |
56 |
Correct |
99 ms |
14708 KB |
Output is correct |
57 |
Correct |
90 ms |
14584 KB |
Output is correct |
58 |
Correct |
132 ms |
14584 KB |
Output is correct |