# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
234477 |
2020-05-24T09:45:01 Z |
shayan_p |
Tenis (COI19_tenis) |
C++14 |
|
163 ms |
7164 KB |
// Never let them see you bleed...
#include<bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define sz(s) int((s).size())
#define bit(n,k) (((n)>>(k))&1)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 1e5 + 10, mod = 1e9 + 7, inf = 1e9 + 10;
int b[3][maxn], mx[maxn];
int val[4 * maxn], MX[4 * maxn], n;
void add(int pos, int x, int l = 0, int r = n, int id = 1){
val[id]+= x;
if(r-l == 1){
MX[id] = val[id];
return;
}
int mid = (l+r) >> 1;
if(pos < mid)
add(pos, x, l, mid, 2*id);
else
add(pos, x, mid, r, 2*id+1);
MX[id] = max(MX[2*id], val[2*id] + MX[2*id+1]);
}
int solve(int x = 0, int l = 0, int r = n, int id = 1){
if(r-l == 1)
return l;
int mid = (l+r) >> 1;
if(MX[2*id] == x)
return solve(x, l, mid, 2*id);
return solve(x - val[2*id], mid, r, 2*id+1);
}
int main(){
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie();
int q;
cin >> n >> q;
for(int i = 0; i < 3; i++){
for(int j = 0; j < n; j++){
int x;
cin >> x;
--x;
b[i][x] = j;
}
}
for(int i = 0; i < n; i++){
mx[i] = max({b[0][i], b[1][i], b[2][i]});
add(mx[i], 1);
add(i, -1);
}
while(q--){
int task;
cin >> task;
if(task == 1){
int x;
cin >> x;
--x;
cout << (mx[x] <= solve() ? "DA\n" : "NE\n");
}
else{
int p, x, y;
cin >> p >> x >> y;
--p, --x, --y;
add(mx[x], -1);
add(mx[y], -1);
swap(b[p][x], b[p][y]);
mx[x] = max({b[0][x], b[1][x], b[2][x]});
mx[y] = max({b[0][y], b[1][y], b[2][y]});
add(mx[x], 1);
add(mx[y], 1);
}
}
return 0;
}
# |
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 |
6 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 |
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 |
6 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 |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
72 ms |
5624 KB |
Output is correct |
14 |
Correct |
74 ms |
5624 KB |
Output is correct |
15 |
Correct |
72 ms |
5624 KB |
Output is correct |
16 |
Correct |
69 ms |
5624 KB |
Output is correct |
17 |
Correct |
72 ms |
5624 KB |
Output is correct |
18 |
Correct |
76 ms |
5624 KB |
Output is correct |
19 |
Correct |
72 ms |
5624 KB |
Output is correct |
20 |
Correct |
72 ms |
5752 KB |
Output is correct |
21 |
Correct |
72 ms |
5624 KB |
Output is correct |
22 |
Correct |
72 ms |
5752 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
98 ms |
6776 KB |
Output is correct |
2 |
Correct |
97 ms |
6776 KB |
Output is correct |
3 |
Correct |
99 ms |
6776 KB |
Output is correct |
4 |
Correct |
100 ms |
6808 KB |
Output is correct |
5 |
Correct |
96 ms |
6776 KB |
Output is correct |
6 |
Correct |
101 ms |
6780 KB |
Output is correct |
7 |
Correct |
99 ms |
6776 KB |
Output is correct |
8 |
Correct |
101 ms |
6776 KB |
Output is correct |
9 |
Correct |
100 ms |
6776 KB |
Output is correct |
10 |
Correct |
99 ms |
6784 KB |
Output is correct |
11 |
Correct |
104 ms |
6776 KB |
Output is correct |
12 |
Correct |
99 ms |
6776 KB |
Output is correct |
13 |
Correct |
108 ms |
6776 KB |
Output is correct |
14 |
Correct |
94 ms |
6776 KB |
Output is correct |
15 |
Correct |
98 ms |
6776 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 |
6 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 |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
72 ms |
5624 KB |
Output is correct |
14 |
Correct |
74 ms |
5624 KB |
Output is correct |
15 |
Correct |
72 ms |
5624 KB |
Output is correct |
16 |
Correct |
69 ms |
5624 KB |
Output is correct |
17 |
Correct |
72 ms |
5624 KB |
Output is correct |
18 |
Correct |
76 ms |
5624 KB |
Output is correct |
19 |
Correct |
72 ms |
5624 KB |
Output is correct |
20 |
Correct |
72 ms |
5752 KB |
Output is correct |
21 |
Correct |
72 ms |
5624 KB |
Output is correct |
22 |
Correct |
72 ms |
5752 KB |
Output is correct |
23 |
Correct |
98 ms |
6776 KB |
Output is correct |
24 |
Correct |
97 ms |
6776 KB |
Output is correct |
25 |
Correct |
99 ms |
6776 KB |
Output is correct |
26 |
Correct |
100 ms |
6808 KB |
Output is correct |
27 |
Correct |
96 ms |
6776 KB |
Output is correct |
28 |
Correct |
101 ms |
6780 KB |
Output is correct |
29 |
Correct |
99 ms |
6776 KB |
Output is correct |
30 |
Correct |
101 ms |
6776 KB |
Output is correct |
31 |
Correct |
100 ms |
6776 KB |
Output is correct |
32 |
Correct |
99 ms |
6784 KB |
Output is correct |
33 |
Correct |
104 ms |
6776 KB |
Output is correct |
34 |
Correct |
99 ms |
6776 KB |
Output is correct |
35 |
Correct |
108 ms |
6776 KB |
Output is correct |
36 |
Correct |
94 ms |
6776 KB |
Output is correct |
37 |
Correct |
98 ms |
6776 KB |
Output is correct |
38 |
Correct |
160 ms |
7104 KB |
Output is correct |
39 |
Correct |
111 ms |
6780 KB |
Output is correct |
40 |
Correct |
163 ms |
7164 KB |
Output is correct |
41 |
Correct |
129 ms |
6904 KB |
Output is correct |
42 |
Correct |
126 ms |
6980 KB |
Output is correct |
43 |
Correct |
159 ms |
7032 KB |
Output is correct |
44 |
Correct |
103 ms |
6880 KB |
Output is correct |
45 |
Correct |
125 ms |
6904 KB |
Output is correct |
46 |
Correct |
113 ms |
6904 KB |
Output is correct |
47 |
Correct |
126 ms |
6904 KB |
Output is correct |
48 |
Correct |
110 ms |
6776 KB |
Output is correct |
49 |
Correct |
122 ms |
6904 KB |
Output is correct |
50 |
Correct |
112 ms |
6840 KB |
Output is correct |
51 |
Correct |
121 ms |
6904 KB |
Output is correct |
52 |
Correct |
152 ms |
7032 KB |
Output is correct |
53 |
Correct |
117 ms |
6904 KB |
Output is correct |
54 |
Correct |
124 ms |
6872 KB |
Output is correct |
55 |
Correct |
123 ms |
6904 KB |
Output is correct |
56 |
Correct |
121 ms |
6912 KB |
Output is correct |
57 |
Correct |
118 ms |
6904 KB |
Output is correct |
58 |
Correct |
138 ms |
7032 KB |
Output is correct |