# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1041706 |
2024-08-02T07:18:16 Z |
vjudge1 |
Tenis (COI19_tenis) |
C++17 |
|
74 ms |
5728 KB |
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n, q, p[N][3], ind[N][3], f[3];
bool check(int x){
int it[3] = {n, n, n};
int nit[3] = {ind[x][0], ind[x][1], ind[x][2]};
int ite = 4 * n;
while (ite > 0){
for (int j = 0; j < 3; j ++){
ite--;
for (int i = it[j]; i >= nit[j]; i --){
ite--;
int ele = p[i][j];
nit[0] = min(nit[0], ind[ele][0]);
nit[1] = min(nit[1], ind[ele][1]);
nit[2] = min(nit[2], ind[ele][2]);
}
it[j] = nit[j] - 1;
}
}
return nit[0] == 1;
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n >> q;
for (int j = 0; j < 3; j ++){
for (int i = 1; i <= n; i ++){
cin >> p[i][j];
ind[p[i][j]][j] = i;
}
}
for (int j = 0; j < 3; j ++){
f[j] = 1;
int l = 1;
int r = n + 1;
while (r - l > 1){
int mid = (l + r) / 2;
if (check(p[mid][j]))
l = mid;
else
r = mid;
}
f[j] = l;
}
for (int i = 0; i < q; i ++){
int t;
cin >> t;
if (t == 1){
int x;
cin >> x;
if (q <= 10){
cout << (check(x) ? "DA\n" : "NE\n");
}
else{
if (ind[x][0] <= f[0] or ind[x][1] <= f[1] or ind[x][2] <= f[2])
cout << "DA\n";
else
cout << "NE\n";
}
}
else{
int j, a, b;
cin >> j >> a >> b;
j--;
swap(p[ind[a][j]][j], p[ind[b][j]][j]);
swap(ind[a][j], ind[b][j]);
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2392 KB |
Output is correct |
2 |
Correct |
0 ms |
2392 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
0 ms |
2396 KB |
Output is correct |
6 |
Correct |
0 ms |
2396 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2392 KB |
Output is correct |
2 |
Correct |
0 ms |
2392 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
0 ms |
2396 KB |
Output is correct |
6 |
Correct |
0 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2392 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
0 ms |
2396 KB |
Output is correct |
10 |
Correct |
0 ms |
2396 KB |
Output is correct |
11 |
Correct |
1 ms |
2396 KB |
Output is correct |
12 |
Correct |
0 ms |
2396 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2392 KB |
Output is correct |
2 |
Correct |
0 ms |
2392 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
0 ms |
2396 KB |
Output is correct |
6 |
Correct |
0 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2392 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
0 ms |
2396 KB |
Output is correct |
10 |
Correct |
0 ms |
2396 KB |
Output is correct |
11 |
Correct |
1 ms |
2396 KB |
Output is correct |
12 |
Correct |
0 ms |
2396 KB |
Output is correct |
13 |
Correct |
52 ms |
2648 KB |
Output is correct |
14 |
Correct |
42 ms |
2648 KB |
Output is correct |
15 |
Correct |
64 ms |
2692 KB |
Output is correct |
16 |
Correct |
64 ms |
2652 KB |
Output is correct |
17 |
Correct |
64 ms |
2652 KB |
Output is correct |
18 |
Correct |
69 ms |
2652 KB |
Output is correct |
19 |
Correct |
63 ms |
2652 KB |
Output is correct |
20 |
Correct |
54 ms |
2652 KB |
Output is correct |
21 |
Correct |
62 ms |
2652 KB |
Output is correct |
22 |
Correct |
59 ms |
2784 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
64 ms |
4176 KB |
Output is correct |
2 |
Correct |
71 ms |
3148 KB |
Output is correct |
3 |
Correct |
66 ms |
3192 KB |
Output is correct |
4 |
Correct |
70 ms |
3152 KB |
Output is correct |
5 |
Correct |
69 ms |
3156 KB |
Output is correct |
6 |
Correct |
68 ms |
3236 KB |
Output is correct |
7 |
Correct |
71 ms |
3152 KB |
Output is correct |
8 |
Correct |
74 ms |
3216 KB |
Output is correct |
9 |
Correct |
70 ms |
3152 KB |
Output is correct |
10 |
Correct |
65 ms |
3156 KB |
Output is correct |
11 |
Correct |
63 ms |
3204 KB |
Output is correct |
12 |
Correct |
68 ms |
3156 KB |
Output is correct |
13 |
Correct |
66 ms |
3056 KB |
Output is correct |
14 |
Correct |
69 ms |
3156 KB |
Output is correct |
15 |
Correct |
67 ms |
3152 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2392 KB |
Output is correct |
2 |
Correct |
0 ms |
2392 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
0 ms |
2396 KB |
Output is correct |
6 |
Correct |
0 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2392 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
0 ms |
2396 KB |
Output is correct |
10 |
Correct |
0 ms |
2396 KB |
Output is correct |
11 |
Correct |
1 ms |
2396 KB |
Output is correct |
12 |
Correct |
0 ms |
2396 KB |
Output is correct |
13 |
Correct |
52 ms |
2648 KB |
Output is correct |
14 |
Correct |
42 ms |
2648 KB |
Output is correct |
15 |
Correct |
64 ms |
2692 KB |
Output is correct |
16 |
Correct |
64 ms |
2652 KB |
Output is correct |
17 |
Correct |
64 ms |
2652 KB |
Output is correct |
18 |
Correct |
69 ms |
2652 KB |
Output is correct |
19 |
Correct |
63 ms |
2652 KB |
Output is correct |
20 |
Correct |
54 ms |
2652 KB |
Output is correct |
21 |
Correct |
62 ms |
2652 KB |
Output is correct |
22 |
Correct |
59 ms |
2784 KB |
Output is correct |
23 |
Correct |
64 ms |
4176 KB |
Output is correct |
24 |
Correct |
71 ms |
3148 KB |
Output is correct |
25 |
Correct |
66 ms |
3192 KB |
Output is correct |
26 |
Correct |
70 ms |
3152 KB |
Output is correct |
27 |
Correct |
69 ms |
3156 KB |
Output is correct |
28 |
Correct |
68 ms |
3236 KB |
Output is correct |
29 |
Correct |
71 ms |
3152 KB |
Output is correct |
30 |
Correct |
74 ms |
3216 KB |
Output is correct |
31 |
Correct |
70 ms |
3152 KB |
Output is correct |
32 |
Correct |
65 ms |
3156 KB |
Output is correct |
33 |
Correct |
63 ms |
3204 KB |
Output is correct |
34 |
Correct |
68 ms |
3156 KB |
Output is correct |
35 |
Correct |
66 ms |
3056 KB |
Output is correct |
36 |
Correct |
69 ms |
3156 KB |
Output is correct |
37 |
Correct |
67 ms |
3152 KB |
Output is correct |
38 |
Correct |
68 ms |
5712 KB |
Output is correct |
39 |
Correct |
57 ms |
5456 KB |
Output is correct |
40 |
Correct |
61 ms |
5728 KB |
Output is correct |
41 |
Incorrect |
69 ms |
5708 KB |
Output isn't correct |
42 |
Halted |
0 ms |
0 KB |
- |