# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
117586 | Bruteforceman | Tenis (COI19_tenis) | C++11 | 88 ms | 5624 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "bits/stdc++.h"
using namespace std;
int N, Q;
int a[4][100010];
int p[4][100010];
int opt() {
int mx1 = 0;
int mx2 = 0;
for(int i = 1; i <= N; i++) {
mx1 = max(mx1, a[2][i]);
mx2 = max(mx2, a[3][i]);
if(mx1 == mx2 && mx1 == i) {
return i;
}
}
return N + 1;
}
void update(int q, int x, int y) {
if(q == 1) {
update(2, x, y);
update(3, x, y);
swap(p[1][x], p[1][y]);
} else {
int f = p[q][x];
int g = p[q][y];
swap(a[q][f], a[q][g]);
swap(p[q][x], p[q][y]);
}
// cout << endl;
// for(int i = 2; i <= 3; i++) {
// for(int j = 1; j <= N; j++) {
// cout << a[i][j] << ' ';
// }
// cout << endl;
// }
}
int main(int argc, char const *argv[])
{
scanf("%d %d", &N, &Q);
for(int i = 1; i <= 3; i++) {
for(int j = 1; j <= N; j++) {
scanf("%d", &a[i][j]);
p[i][a[i][j]] = j;
}
}
for(int i = 2; i <= 3; i++) {
for(int j = 1; j <= N; j++) {
a[i][j] = p[1][a[i][j]];
p[i][a[i][j]] = j;
// cout << a[i][j] << ' ';
}
// cout << endl;
}
int first = opt();
for(int i = 1; i <= Q; i++) {
int c;
scanf("%d", &c);
if(c == 1) {
int x;
scanf("%d", &x);
if(p[1][x] <= first) printf("DA\n");
else printf("NE\n");
} else {
int f, x, y;
scanf("%d %d %d", &f, &x, &y);
update(f, p[1][x], p[1][y]);
first = opt();
}
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |