# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
650227 |
2022-10-13T00:54:57 Z |
czhang2718 |
Tenis (COI19_tenis) |
C++17 |
|
182 ms |
7824 KB |
#include "bits/stdc++.h"
using namespace std;
const int N=1e5;
int n, q;
int p[3][N];
int ind[3][N];
int mn[4*N];
int lazy[4*N];
void push(int x, int lx, int rx){
if(rx-lx==1 || !lazy[x]) return;
mn[2*x+1]+=lazy[x];
mn[2*x+2]+=lazy[x];
lazy[2*x+1]+=lazy[x];
lazy[2*x+2]+=lazy[x];
lazy[x]=0;
}
void upd(int i, int v, int x, int lx, int rx){
push(x, lx, rx);
if(rx<=i) return;
if(lx>=i){
mn[x]+=v;
lazy[x]+=v;
return;
}
int m=(lx+rx)/2;
upd(i, v, 2*x+1, lx, m);
upd(i, v, 2*x+2, m, rx);
mn[x]=min(mn[2*x+1], mn[2*x+2]);
}
void upd(int i, int v){
upd(i, v, 0, 0, n);
}
int walk(int x, int lx, int rx){
push(x, lx, rx);
if(rx-lx==1) return lx;
int m=(lx+rx)/2;
if(mn[2*x+1]==0) return walk(2*x+1, lx, m);
else return walk(2*x+2, m, rx);
}
int main(){
cin.tie(0)->sync_with_stdio(0);
cin >> n >> q;
for(int j=0; j<3; j++){
for(int i=0; i<n; i++){
cin >> p[j][i];
p[j][i]--;
ind[j][p[j][i]]=i;
}
}
for(int i=0; i<n; i++){
upd(i, 1);
upd(max({ind[0][i], ind[1][i], ind[2][i]}), -1);
}
while(q--){
int op; cin >> op;
if(op==1){
int i; cin >> i;
--i;
int r=walk(0, 0, n);
// cout << "walk " << r << '\n';
if(max({ind[0][i], ind[1][i], ind[2][i]})<=r) cout << "DA\n";
else cout << "NE\n";
}
else{
int t, i,j; cin >> t >> i >> j;
--t, --i, --j;
upd(max({ind[0][i], ind[1][i], ind[2][i]}), 1);
upd(max({ind[0][j], ind[1][j], ind[2][j]}), 1);
swap(ind[t][i], ind[t][j]);
upd(max({ind[0][i], ind[1][i], ind[2][i]}), -1);
upd(max({ind[0][j], ind[1][j], ind[2][j]}), -1);
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
328 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
328 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
332 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 |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
328 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
328 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
332 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 |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
328 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
80 ms |
6440 KB |
Output is correct |
14 |
Correct |
72 ms |
6464 KB |
Output is correct |
15 |
Correct |
93 ms |
6428 KB |
Output is correct |
16 |
Correct |
75 ms |
6428 KB |
Output is correct |
17 |
Correct |
84 ms |
6560 KB |
Output is correct |
18 |
Correct |
80 ms |
6348 KB |
Output is correct |
19 |
Correct |
74 ms |
6476 KB |
Output is correct |
20 |
Correct |
75 ms |
6344 KB |
Output is correct |
21 |
Correct |
82 ms |
6432 KB |
Output is correct |
22 |
Correct |
75 ms |
6348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
99 ms |
7480 KB |
Output is correct |
2 |
Correct |
97 ms |
7400 KB |
Output is correct |
3 |
Correct |
105 ms |
7500 KB |
Output is correct |
4 |
Correct |
103 ms |
7476 KB |
Output is correct |
5 |
Correct |
101 ms |
7452 KB |
Output is correct |
6 |
Correct |
96 ms |
7452 KB |
Output is correct |
7 |
Correct |
96 ms |
7484 KB |
Output is correct |
8 |
Correct |
100 ms |
7508 KB |
Output is correct |
9 |
Correct |
98 ms |
7388 KB |
Output is correct |
10 |
Correct |
98 ms |
7456 KB |
Output is correct |
11 |
Correct |
101 ms |
7388 KB |
Output is correct |
12 |
Correct |
99 ms |
7416 KB |
Output is correct |
13 |
Correct |
96 ms |
7512 KB |
Output is correct |
14 |
Correct |
103 ms |
7492 KB |
Output is correct |
15 |
Correct |
98 ms |
7512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
328 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
332 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 |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
328 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
80 ms |
6440 KB |
Output is correct |
14 |
Correct |
72 ms |
6464 KB |
Output is correct |
15 |
Correct |
93 ms |
6428 KB |
Output is correct |
16 |
Correct |
75 ms |
6428 KB |
Output is correct |
17 |
Correct |
84 ms |
6560 KB |
Output is correct |
18 |
Correct |
80 ms |
6348 KB |
Output is correct |
19 |
Correct |
74 ms |
6476 KB |
Output is correct |
20 |
Correct |
75 ms |
6344 KB |
Output is correct |
21 |
Correct |
82 ms |
6432 KB |
Output is correct |
22 |
Correct |
75 ms |
6348 KB |
Output is correct |
23 |
Correct |
99 ms |
7480 KB |
Output is correct |
24 |
Correct |
97 ms |
7400 KB |
Output is correct |
25 |
Correct |
105 ms |
7500 KB |
Output is correct |
26 |
Correct |
103 ms |
7476 KB |
Output is correct |
27 |
Correct |
101 ms |
7452 KB |
Output is correct |
28 |
Correct |
96 ms |
7452 KB |
Output is correct |
29 |
Correct |
96 ms |
7484 KB |
Output is correct |
30 |
Correct |
100 ms |
7508 KB |
Output is correct |
31 |
Correct |
98 ms |
7388 KB |
Output is correct |
32 |
Correct |
98 ms |
7456 KB |
Output is correct |
33 |
Correct |
101 ms |
7388 KB |
Output is correct |
34 |
Correct |
99 ms |
7416 KB |
Output is correct |
35 |
Correct |
96 ms |
7512 KB |
Output is correct |
36 |
Correct |
103 ms |
7492 KB |
Output is correct |
37 |
Correct |
98 ms |
7512 KB |
Output is correct |
38 |
Correct |
182 ms |
7740 KB |
Output is correct |
39 |
Correct |
125 ms |
7476 KB |
Output is correct |
40 |
Correct |
181 ms |
7728 KB |
Output is correct |
41 |
Correct |
139 ms |
7572 KB |
Output is correct |
42 |
Correct |
135 ms |
7628 KB |
Output is correct |
43 |
Correct |
169 ms |
7812 KB |
Output is correct |
44 |
Correct |
112 ms |
7524 KB |
Output is correct |
45 |
Correct |
148 ms |
7656 KB |
Output is correct |
46 |
Correct |
118 ms |
7524 KB |
Output is correct |
47 |
Correct |
132 ms |
7644 KB |
Output is correct |
48 |
Correct |
117 ms |
7580 KB |
Output is correct |
49 |
Correct |
132 ms |
7672 KB |
Output is correct |
50 |
Correct |
110 ms |
7512 KB |
Output is correct |
51 |
Correct |
142 ms |
7588 KB |
Output is correct |
52 |
Correct |
164 ms |
7824 KB |
Output is correct |
53 |
Correct |
123 ms |
7628 KB |
Output is correct |
54 |
Correct |
133 ms |
7644 KB |
Output is correct |
55 |
Correct |
127 ms |
7640 KB |
Output is correct |
56 |
Correct |
129 ms |
7644 KB |
Output is correct |
57 |
Correct |
120 ms |
7592 KB |
Output is correct |
58 |
Correct |
128 ms |
7644 KB |
Output is correct |