# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
171671 |
2019-12-29T22:14:09 Z |
Milki |
Tenis (COI19_tenis) |
C++14 |
|
188 ms |
9364 KB |
#include<bits/stdc++.h>
using namespace std;
#define TRACE(x) cerr << #x << " = " << x << endl
#define _ << " " <<
typedef long long ll;
typedef pair<int, int> point;
const int mod = 1e9 + 7;
int add(int x, int y) {x += y; if(x >= mod) return x - mod; return x;}
int sub(int x, int y) {x -= y; if(x < 0) return x + mod; return x;}
int mul(int x, int y) {return (ll) x * y % mod;}
const int off = 1 << 17, MAXN = 1e5 + 5;
struct Node{
int mn, pos, prop;
Node(){}
Node(int mn, int pos, int prop) : mn(mn), pos(pos), prop(prop) {}
};
Node merge(Node &A, Node &B){
Node ret;
if(A.mn <= B.mn)
return Node(A.mn, A.pos, 0);
else
return Node(B.mn, B.pos, 0);
}
const int inf = 1e9;
struct Tournament{
Node t[2 * off];
void prop(int x){
t[x].mn += t[x].prop;
if(x < off){
t[x * 2].prop += t[x].prop;
t[x * 2 + 1].prop += t[x].prop;
}
t[x].prop = 0;
}
void update(int x, int lo, int hi, int a, int b, int val){
prop(x);
if(lo >= b || hi <= a) return;
if(lo >= a && hi <= b) { t[x].prop += val; prop(x); return; }
int mid = (lo + hi) >> 1;
update(x * 2, lo, mid, a, b, val);
update(x * 2 + 1, mid, hi, a, b, val);
t[x] = merge(t[x * 2], t[x * 2 + 1]);
}
void init(){
t[off] = Node(inf, inf, 0);
for(int x = off + 1; x < 2 * off; ++x)
t[x] = Node(x - off, x - off, 0);
for(int x = off - 1; x >= 0; --x)
t[x] = merge(t[x * 2], t[x * 2 + 1]);
}
int query(){
prop(1);
return t[1].pos;
}
} T;
int n, q, p[3][MAXN], in[3][MAXN], mx[MAXN];
void refresh(int x){
mx[x] = max( max(p[0][x], p[1][x]), p[2][x] );
}
int main(){
ios_base::sync_with_stdio(false); cin.tie(0);
cin >> n >> q;
T.init();
for(int i = 0; i < 3; ++i)
for(int j = 0; j < n; ++j){
cin >> in[i][j];
in[i][j] --;
p[i][ in[i][j] ] = j + 1;
}
for(int i = 0; i < n; ++i){
refresh(i);
T.update(1, 0, off, mx[i], off, -1);
}
for(int i = 0; i < q; ++i){
int tip; cin >> tip;
if(tip == 1){
int x; cin >> x; x --;
if(mx[x] <= T.query())
cout << "DA\n";
else
cout << "NE\n";
}
else{
int col, a, b; cin >> col >> a >> b;
col --; a --; b --;
T.update(1, 0, off, mx[a], off, 1);
T.update(1, 0, off, mx[b], off, 1);
swap(p[col][a], p[col][b]);
refresh(a); refresh(b);
T.update(1, 0, off, mx[a], off, -1);
T.update(1, 0, off, mx[b], off, -1);
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
3448 KB |
Output is correct |
2 |
Correct |
5 ms |
3448 KB |
Output is correct |
3 |
Correct |
5 ms |
3448 KB |
Output is correct |
4 |
Correct |
5 ms |
3448 KB |
Output is correct |
5 |
Correct |
5 ms |
3448 KB |
Output is correct |
6 |
Correct |
4 ms |
3448 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
3448 KB |
Output is correct |
2 |
Correct |
5 ms |
3448 KB |
Output is correct |
3 |
Correct |
5 ms |
3448 KB |
Output is correct |
4 |
Correct |
5 ms |
3448 KB |
Output is correct |
5 |
Correct |
5 ms |
3448 KB |
Output is correct |
6 |
Correct |
4 ms |
3448 KB |
Output is correct |
7 |
Correct |
5 ms |
3448 KB |
Output is correct |
8 |
Correct |
5 ms |
3448 KB |
Output is correct |
9 |
Correct |
5 ms |
3448 KB |
Output is correct |
10 |
Correct |
5 ms |
3448 KB |
Output is correct |
11 |
Correct |
5 ms |
3484 KB |
Output is correct |
12 |
Correct |
5 ms |
3448 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
3448 KB |
Output is correct |
2 |
Correct |
5 ms |
3448 KB |
Output is correct |
3 |
Correct |
5 ms |
3448 KB |
Output is correct |
4 |
Correct |
5 ms |
3448 KB |
Output is correct |
5 |
Correct |
5 ms |
3448 KB |
Output is correct |
6 |
Correct |
4 ms |
3448 KB |
Output is correct |
7 |
Correct |
5 ms |
3448 KB |
Output is correct |
8 |
Correct |
5 ms |
3448 KB |
Output is correct |
9 |
Correct |
5 ms |
3448 KB |
Output is correct |
10 |
Correct |
5 ms |
3448 KB |
Output is correct |
11 |
Correct |
5 ms |
3484 KB |
Output is correct |
12 |
Correct |
5 ms |
3448 KB |
Output is correct |
13 |
Correct |
71 ms |
7900 KB |
Output is correct |
14 |
Correct |
71 ms |
7900 KB |
Output is correct |
15 |
Correct |
70 ms |
7800 KB |
Output is correct |
16 |
Correct |
73 ms |
7900 KB |
Output is correct |
17 |
Correct |
65 ms |
7928 KB |
Output is correct |
18 |
Correct |
71 ms |
7864 KB |
Output is correct |
19 |
Correct |
69 ms |
7900 KB |
Output is correct |
20 |
Correct |
71 ms |
7928 KB |
Output is correct |
21 |
Correct |
71 ms |
8056 KB |
Output is correct |
22 |
Correct |
71 ms |
7928 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
93 ms |
8932 KB |
Output is correct |
2 |
Correct |
91 ms |
8952 KB |
Output is correct |
3 |
Correct |
95 ms |
9012 KB |
Output is correct |
4 |
Correct |
92 ms |
8952 KB |
Output is correct |
5 |
Correct |
94 ms |
9024 KB |
Output is correct |
6 |
Correct |
92 ms |
9080 KB |
Output is correct |
7 |
Correct |
93 ms |
8996 KB |
Output is correct |
8 |
Correct |
92 ms |
8952 KB |
Output is correct |
9 |
Correct |
91 ms |
8940 KB |
Output is correct |
10 |
Correct |
92 ms |
9052 KB |
Output is correct |
11 |
Correct |
92 ms |
9192 KB |
Output is correct |
12 |
Correct |
92 ms |
8952 KB |
Output is correct |
13 |
Correct |
92 ms |
8952 KB |
Output is correct |
14 |
Correct |
91 ms |
8952 KB |
Output is correct |
15 |
Correct |
91 ms |
8972 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
3448 KB |
Output is correct |
2 |
Correct |
5 ms |
3448 KB |
Output is correct |
3 |
Correct |
5 ms |
3448 KB |
Output is correct |
4 |
Correct |
5 ms |
3448 KB |
Output is correct |
5 |
Correct |
5 ms |
3448 KB |
Output is correct |
6 |
Correct |
4 ms |
3448 KB |
Output is correct |
7 |
Correct |
5 ms |
3448 KB |
Output is correct |
8 |
Correct |
5 ms |
3448 KB |
Output is correct |
9 |
Correct |
5 ms |
3448 KB |
Output is correct |
10 |
Correct |
5 ms |
3448 KB |
Output is correct |
11 |
Correct |
5 ms |
3484 KB |
Output is correct |
12 |
Correct |
5 ms |
3448 KB |
Output is correct |
13 |
Correct |
71 ms |
7900 KB |
Output is correct |
14 |
Correct |
71 ms |
7900 KB |
Output is correct |
15 |
Correct |
70 ms |
7800 KB |
Output is correct |
16 |
Correct |
73 ms |
7900 KB |
Output is correct |
17 |
Correct |
65 ms |
7928 KB |
Output is correct |
18 |
Correct |
71 ms |
7864 KB |
Output is correct |
19 |
Correct |
69 ms |
7900 KB |
Output is correct |
20 |
Correct |
71 ms |
7928 KB |
Output is correct |
21 |
Correct |
71 ms |
8056 KB |
Output is correct |
22 |
Correct |
71 ms |
7928 KB |
Output is correct |
23 |
Correct |
93 ms |
8932 KB |
Output is correct |
24 |
Correct |
91 ms |
8952 KB |
Output is correct |
25 |
Correct |
95 ms |
9012 KB |
Output is correct |
26 |
Correct |
92 ms |
8952 KB |
Output is correct |
27 |
Correct |
94 ms |
9024 KB |
Output is correct |
28 |
Correct |
92 ms |
9080 KB |
Output is correct |
29 |
Correct |
93 ms |
8996 KB |
Output is correct |
30 |
Correct |
92 ms |
8952 KB |
Output is correct |
31 |
Correct |
91 ms |
8940 KB |
Output is correct |
32 |
Correct |
92 ms |
9052 KB |
Output is correct |
33 |
Correct |
92 ms |
9192 KB |
Output is correct |
34 |
Correct |
92 ms |
8952 KB |
Output is correct |
35 |
Correct |
92 ms |
8952 KB |
Output is correct |
36 |
Correct |
91 ms |
8952 KB |
Output is correct |
37 |
Correct |
91 ms |
8972 KB |
Output is correct |
38 |
Correct |
186 ms |
9348 KB |
Output is correct |
39 |
Correct |
115 ms |
9060 KB |
Output is correct |
40 |
Correct |
188 ms |
9336 KB |
Output is correct |
41 |
Correct |
130 ms |
9080 KB |
Output is correct |
42 |
Correct |
132 ms |
9308 KB |
Output is correct |
43 |
Correct |
184 ms |
9312 KB |
Output is correct |
44 |
Correct |
117 ms |
9208 KB |
Output is correct |
45 |
Correct |
142 ms |
9208 KB |
Output is correct |
46 |
Correct |
115 ms |
9080 KB |
Output is correct |
47 |
Correct |
145 ms |
9132 KB |
Output is correct |
48 |
Correct |
115 ms |
8996 KB |
Output is correct |
49 |
Correct |
142 ms |
9104 KB |
Output is correct |
50 |
Correct |
112 ms |
9080 KB |
Output is correct |
51 |
Correct |
128 ms |
9080 KB |
Output is correct |
52 |
Correct |
187 ms |
9364 KB |
Output is correct |
53 |
Correct |
122 ms |
9208 KB |
Output is correct |
54 |
Correct |
131 ms |
9208 KB |
Output is correct |
55 |
Correct |
139 ms |
9076 KB |
Output is correct |
56 |
Correct |
134 ms |
9336 KB |
Output is correct |
57 |
Correct |
122 ms |
9080 KB |
Output is correct |
58 |
Correct |
146 ms |
9080 KB |
Output is correct |