# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
233297 |
2020-05-20T08:48:41 Z |
NONAME |
Tenis (COI19_tenis) |
C++17 |
|
500 ms |
4304 KB |
#include <bits/stdc++.h>
#define sz(x) int(x.size())
#define in(x) freopen(x, "r", stdin)
#define out(x) freopen(x, "w", stdout)
#define N 100500
#define oo ll(1e16)
#define ft first
#define sd second
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define el '\n'
#define elf endl
#define base ll(1e9 + 7)
using namespace std;
typedef long long ll;
typedef long double ld;
int n, q, pos[3][N], a[3][N];
bool mk[N], mrk[N];
bool f(int v) {
fill(mk, mk + n, 0);
fill(mrk, mrk + n, 0);
queue <int> q;
q.push(v);
// for (int i = 0; i < 3; i++, cerr << el)
// for (int j = 0; j < n; j++)
// cerr << a[i][j] + 1 << ' ';
// cerr << el;
int lst[3];
for (int i = 0; i < 3; i++)
lst[i] = n;
while (!q.empty()) {
int v = q.front();
q.pop();
mk[v] = 1;
mrk[v] = 1;
for (int t = 0; t < 3; t++)
for (int i = pos[t][v] + 1; i < lst[t]; i++) {
int x = a[t][i];
if (mk[x])
break;
if (!mrk[x])
mrk[x] = 1, q.push(x);
}
for (int i = 0; i < 3; i++)
lst[i] = pos[i][v];
}
bool ok = 1;
for (int i = 0; i < n; i++)
ok &= mk[i];
return ok;
}
int main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
// in("input.txt");
cin >> n >> q;
for (int t = 0; t < 3; t++)
for (int i = 0; i < n; i++) {
cin >> a[t][i];
a[t][i]--;
pos[t][a[t][i]] = i;
}
while (q--) {
int type;
cin >> type;
if (type == 1) {
int x;
cin >> x;
x--;
bool ok = f(x);
cout << ((ok) ? "DA" : "NE") << el;
}
if (type == 2) {
int x, y, z;
cin >> x >> y >> z;
x--; y--; z--;
swap(pos[x][y], pos[x][z]);
swap(a[x][pos[x][y]], a[x][pos[x][z]]);
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
6 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 |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
6 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 |
5 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 |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
6 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 |
5 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 |
56 ms |
4000 KB |
Output is correct |
14 |
Correct |
57 ms |
3968 KB |
Output is correct |
15 |
Correct |
59 ms |
4232 KB |
Output is correct |
16 |
Correct |
65 ms |
4164 KB |
Output is correct |
17 |
Correct |
76 ms |
4304 KB |
Output is correct |
18 |
Correct |
66 ms |
4288 KB |
Output is correct |
19 |
Correct |
62 ms |
4296 KB |
Output is correct |
20 |
Correct |
45 ms |
3576 KB |
Output is correct |
21 |
Correct |
66 ms |
4276 KB |
Output is correct |
22 |
Correct |
61 ms |
4268 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1078 ms |
4072 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 |
Correct |
6 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 |
5 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 |
56 ms |
4000 KB |
Output is correct |
14 |
Correct |
57 ms |
3968 KB |
Output is correct |
15 |
Correct |
59 ms |
4232 KB |
Output is correct |
16 |
Correct |
65 ms |
4164 KB |
Output is correct |
17 |
Correct |
76 ms |
4304 KB |
Output is correct |
18 |
Correct |
66 ms |
4288 KB |
Output is correct |
19 |
Correct |
62 ms |
4296 KB |
Output is correct |
20 |
Correct |
45 ms |
3576 KB |
Output is correct |
21 |
Correct |
66 ms |
4276 KB |
Output is correct |
22 |
Correct |
61 ms |
4268 KB |
Output is correct |
23 |
Execution timed out |
1078 ms |
4072 KB |
Time limit exceeded |
24 |
Halted |
0 ms |
0 KB |
- |