# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
233250 |
2020-05-20T07:33:15 Z |
VEGAnn |
Tenis (COI19_tenis) |
C++14 |
|
500 ms |
2720 KB |
#include <bits/stdc++.h>
using namespace std;
const int N = 100100;
const int md = int(1e9) + 7;
int loc[3][N], n, q, a[3][N];
bool mrk[N];
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef _LOCAL
freopen("in.txt","r",stdin);
#endif // _LOCAL
cin >> n >> q;
for (int tp = 0; tp < 3; tp++)
for (int i = 0; i < n; i++){
int x; cin >> x;
x--;
loc[tp][x] = i;
a[tp][i] = x;
}
for (; q; q--){
int tp; cin >> tp;
if (tp == 1){
int x; cin >> x; x--;
fill(mrk, mrk + n, 0);
for (int tp = 0; tp < 3; tp++)
for (int i = loc[tp][x]; i < n; i++) {
assert(a[tp][i] == a[tp][loc[tp][a[tp][i]]]);
mrk[a[tp][i]] = 1;
}
for (int tp = 0; tp < 3; tp++)
for (int i = 0, cur = 0; i < n; i++){
assert(a[tp][i] == a[tp][loc[tp][a[tp][i]]]);
cur |= mrk[a[tp][i]];
if (cur)
mrk[a[tp][i]] = 1;
}
bool ok = 1;
for (int i = 0; i < n && ok; i++)
if (!mrk[i])
ok = 0;
cout << (ok ? "DA\n" : "NE\n");
} else {
int x, y; cin >> tp >> x >> y;
tp--; x--; y--;
swap(loc[tp][x], loc[tp][y]);
swap(a[tp][loc[tp][x]], a[tp][loc[tp][y]]);
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1077 ms |
2720 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |