# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
275270 |
2020-08-20T05:10:47 Z |
caoash |
Tenis (COI19_tenis) |
C++14 |
|
282 ms |
8312 KB |
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx2")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
#define pb push_back
#define rsz resize
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
using pi = pair<int,int>;
#define f first
#define s second
#define mp make_pair
const int MX = 100005;
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
#define pb push_back
#define rsz resize
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
using pi = pair<int,int>;
#define f first
#define s second
#define mp make_pair
int n; int a[3][MX];
template<class T, int SZ> struct LazySeg{
T tree[4 * SZ], lazy[4 * SZ];
T merge(T a, T b){
return min(a, b);
}
void build(int v, int l, int r) {
if (l == r) {
tree[v] = (l + 1);
return;
}
else {
int m = (l + r) / 2;
build(2 * v + 1, l, m);
build(2 * v + 2, m + 1, r);
tree[v] = merge(tree[2 * v + 1], tree[2 * v + 2]);
return;
}
}
void prop(int v, int l, int r){
if (lazy[v] != 0) {
tree[v] += lazy[v];
if (l != r) {
lazy[2 * v + 1] += lazy[v];
lazy[2 * v + 2] += lazy[v];
}
lazy[v] = 0;
}
return;
}
void update(int v, int l, int r, int ql, int qr, int x) {
prop(v, l, r);
if (r < ql || l > qr) {
return;
}
if (l >= ql && r <= qr) {
tree[v] += x;
if (l != r) {
lazy[2 * v + 1] += x;
lazy[2 * v + 2] += x;
}
return;
}
int m = (l + r) / 2;
update(2 * v + 1, l, m, ql, qr, x);
update(2 * v + 2, m + 1, r, ql, qr, x);
tree[v] = merge(tree[2 * v + 1], tree[2 * v +2]);
return;
}
void query(int v, int l, int r, int &best) {
prop(v, l, r);
if (tree[v] != 0) {
best = min(best, n);
return;
}
if (l == r) {
best = min(best, l);
return;
} else {
int m = (l + r) / 2;
prop(2 * v + 1, l, m);
prop(2 * v + 2, m + 1, r);
tree[v] = merge(tree[2 * v + 1], tree[2 * v + 2]);
if (tree[2 * v + 1] == 0) {
query(2 * v + 1, l, m, best);
}
else {
query(2 * v + 2, m + 1, r, best);
}
return;
}
}
};
LazySeg<int, MX> orz; int mi[MX]; int pos[3][MX];
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int q; cin >> n >> q;
for (int i = 0; i < 3; i++) for (int j = 0; j < n; j++) {
cin >> a[i][j];
mi[a[i][j]] = max(mi[a[i][j]], j);
pos[i][a[i][j]] = j;
}
orz.build(0, 0, n - 1);
for (int i = 1; i <= n; i++) {
orz.update(0, 0, n - 1, mi[i], n - 1, -1);
}
int cbest = n;
auto relax = [&] () {
cbest = n;
orz.query(0, 0, n - 1, cbest);
};
relax();
auto swp = [&] (int p, int i, int j) {
swap(pos[p][i], pos[p][j]);
mi[i] = max({pos[0][i], pos[1][i], pos[2][i]});
mi[j] = max({pos[0][j], pos[1][j], pos[2][j]});
};
for (int i = 0; i < q; i++) {
int qt; cin >> qt;
if (qt == 1) {
int x; cin >> x;
if (mi[x] <= cbest) {
cout << "DA" << '\n';
}
else {
cout << "NE" << '\n';
}
}
else {
int p, x, y; cin >> p >> x >> y;
p--;
orz.update(0, 0, n - 1, mi[x], n - 1, 1);
orz.update(0, 0, n - 1, mi[y], n - 1, 1);
swp(p, x, y);
orz.update(0, 0, n - 1, mi[x], n - 1, -1);
orz.update(0, 0, n - 1, mi[y], n - 1, -1);
relax();
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
512 KB |
Output is correct |
13 |
Correct |
81 ms |
5148 KB |
Output is correct |
14 |
Correct |
87 ms |
5192 KB |
Output is correct |
15 |
Correct |
96 ms |
5112 KB |
Output is correct |
16 |
Correct |
74 ms |
5112 KB |
Output is correct |
17 |
Correct |
72 ms |
5188 KB |
Output is correct |
18 |
Correct |
71 ms |
5180 KB |
Output is correct |
19 |
Correct |
96 ms |
5112 KB |
Output is correct |
20 |
Correct |
92 ms |
5112 KB |
Output is correct |
21 |
Correct |
69 ms |
5240 KB |
Output is correct |
22 |
Correct |
68 ms |
5112 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
94 ms |
5504 KB |
Output is correct |
2 |
Correct |
111 ms |
8000 KB |
Output is correct |
3 |
Correct |
113 ms |
7928 KB |
Output is correct |
4 |
Correct |
114 ms |
7960 KB |
Output is correct |
5 |
Correct |
106 ms |
7928 KB |
Output is correct |
6 |
Correct |
105 ms |
7972 KB |
Output is correct |
7 |
Correct |
102 ms |
7944 KB |
Output is correct |
8 |
Correct |
114 ms |
7928 KB |
Output is correct |
9 |
Correct |
126 ms |
7928 KB |
Output is correct |
10 |
Correct |
102 ms |
7928 KB |
Output is correct |
11 |
Correct |
96 ms |
7928 KB |
Output is correct |
12 |
Correct |
95 ms |
7928 KB |
Output is correct |
13 |
Correct |
141 ms |
7928 KB |
Output is correct |
14 |
Correct |
98 ms |
8000 KB |
Output is correct |
15 |
Correct |
99 ms |
7928 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
512 KB |
Output is correct |
13 |
Correct |
81 ms |
5148 KB |
Output is correct |
14 |
Correct |
87 ms |
5192 KB |
Output is correct |
15 |
Correct |
96 ms |
5112 KB |
Output is correct |
16 |
Correct |
74 ms |
5112 KB |
Output is correct |
17 |
Correct |
72 ms |
5188 KB |
Output is correct |
18 |
Correct |
71 ms |
5180 KB |
Output is correct |
19 |
Correct |
96 ms |
5112 KB |
Output is correct |
20 |
Correct |
92 ms |
5112 KB |
Output is correct |
21 |
Correct |
69 ms |
5240 KB |
Output is correct |
22 |
Correct |
68 ms |
5112 KB |
Output is correct |
23 |
Correct |
94 ms |
5504 KB |
Output is correct |
24 |
Correct |
111 ms |
8000 KB |
Output is correct |
25 |
Correct |
113 ms |
7928 KB |
Output is correct |
26 |
Correct |
114 ms |
7960 KB |
Output is correct |
27 |
Correct |
106 ms |
7928 KB |
Output is correct |
28 |
Correct |
105 ms |
7972 KB |
Output is correct |
29 |
Correct |
102 ms |
7944 KB |
Output is correct |
30 |
Correct |
114 ms |
7928 KB |
Output is correct |
31 |
Correct |
126 ms |
7928 KB |
Output is correct |
32 |
Correct |
102 ms |
7928 KB |
Output is correct |
33 |
Correct |
96 ms |
7928 KB |
Output is correct |
34 |
Correct |
95 ms |
7928 KB |
Output is correct |
35 |
Correct |
141 ms |
7928 KB |
Output is correct |
36 |
Correct |
98 ms |
8000 KB |
Output is correct |
37 |
Correct |
99 ms |
7928 KB |
Output is correct |
38 |
Correct |
225 ms |
8292 KB |
Output is correct |
39 |
Correct |
166 ms |
8044 KB |
Output is correct |
40 |
Correct |
282 ms |
8288 KB |
Output is correct |
41 |
Correct |
131 ms |
8128 KB |
Output is correct |
42 |
Correct |
171 ms |
8164 KB |
Output is correct |
43 |
Correct |
220 ms |
8300 KB |
Output is correct |
44 |
Correct |
132 ms |
8056 KB |
Output is correct |
45 |
Correct |
167 ms |
8060 KB |
Output is correct |
46 |
Correct |
131 ms |
8004 KB |
Output is correct |
47 |
Correct |
134 ms |
8100 KB |
Output is correct |
48 |
Correct |
125 ms |
8060 KB |
Output is correct |
49 |
Correct |
143 ms |
8056 KB |
Output is correct |
50 |
Correct |
115 ms |
8056 KB |
Output is correct |
51 |
Correct |
140 ms |
8056 KB |
Output is correct |
52 |
Correct |
194 ms |
8312 KB |
Output is correct |
53 |
Correct |
132 ms |
8056 KB |
Output is correct |
54 |
Correct |
138 ms |
8056 KB |
Output is correct |
55 |
Correct |
141 ms |
8184 KB |
Output is correct |
56 |
Correct |
133 ms |
8184 KB |
Output is correct |
57 |
Correct |
124 ms |
7996 KB |
Output is correct |
58 |
Correct |
158 ms |
8184 KB |
Output is correct |