# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
234712 |
2020-05-25T10:25:10 Z |
amoo_safar |
Tenis (COI19_tenis) |
C++14 |
|
275 ms |
8952 KB |
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " : " << x << '\n'
using namespace std;
typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<int, int> pii;
const ll Mod = 1000000007LL;
const int N = 1e5 + 10;
const ll Inf = 2242545357980376863LL;
const ll Log = 30;
int n, p[4][N], ind[4][N];
int lz[N << 2];
pii seg[N << 2];
void Build(int id, int L, int R){
if(L + 1 == R){
seg[id] = {0, L};
return ;
}
int mid = (L + R) >> 1;
Build(id << 1, L, mid);
Build(id << 1 | 1, mid, R);
seg[id] = min(seg[id << 1], seg[id << 1 | 1]);
seg[id].F += lz[id];
}
void Add(int id, int l, int r, int x, int L, int R){
if(r <= L || R <= l) return ;
if(l <= L && R <= r){
lz[id] += x; seg[id].F += x;
return ;
}
int mid = (L + R) >> 1;
Add(id << 1, l, r, x, L, mid);
Add(id << 1 | 1, l, r, x, mid, R);
seg[id] = min(seg[id << 1], seg[id << 1 | 1]);
seg[id].F += lz[id];
}
void Apply(int x, int d){
int l = min({ind[1][x], ind[2][x], ind[3][x]});
int r = max({ind[1][x], ind[2][x], ind[3][x]});
Add(1, l, r, d, 1, n + 1);
//cerr << "! " << l << ' ' << r << ' ' << d << '\n';
}
int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int q;
cin >> n >> q;
for(int k = 1; k <= 3; k++) for(int i = 1; i <= n; i++){
cin >> p[k][i];
ind[k][p[k][i]] = i;
}
Build(1, 1, n + 1);
for(int i = 1; i <= n; i++) Apply(i, 1);
int t, x, a, b, P;
for(int i = 0; i < q; i++){
//cerr << seg[1].F << ' ' << seg[1].S << '\n';
cin >> t;
if(t == 1){
cin >> x;
cout << (min({ind[1][x], ind[2][x], ind[3][x]}) <= seg[1].S ? "DA" : "NE") << '\n';
} else {
cin >> P >> a >> b;
Apply(a, -1);
Apply(b, -1);
p[P][ind[P][a]] = b;
p[P][ind[P][b]] = a;
swap(ind[P][a], ind[P][b]);
Apply(a, 1);
Apply(b, 1);
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 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 |
4 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 |
5 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 |
4 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
512 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
512 KB |
Output is correct |
10 |
Correct |
5 ms |
512 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 |
5 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 |
4 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
512 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
512 KB |
Output is correct |
10 |
Correct |
5 ms |
512 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
77 ms |
7544 KB |
Output is correct |
14 |
Correct |
83 ms |
7672 KB |
Output is correct |
15 |
Correct |
75 ms |
7544 KB |
Output is correct |
16 |
Correct |
84 ms |
7680 KB |
Output is correct |
17 |
Correct |
66 ms |
7416 KB |
Output is correct |
18 |
Correct |
68 ms |
7432 KB |
Output is correct |
19 |
Correct |
94 ms |
7416 KB |
Output is correct |
20 |
Correct |
78 ms |
7544 KB |
Output is correct |
21 |
Correct |
69 ms |
7544 KB |
Output is correct |
22 |
Correct |
75 ms |
7544 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
98 ms |
8568 KB |
Output is correct |
2 |
Correct |
95 ms |
8612 KB |
Output is correct |
3 |
Correct |
99 ms |
8568 KB |
Output is correct |
4 |
Correct |
89 ms |
8572 KB |
Output is correct |
5 |
Correct |
94 ms |
8568 KB |
Output is correct |
6 |
Correct |
90 ms |
8568 KB |
Output is correct |
7 |
Correct |
93 ms |
8568 KB |
Output is correct |
8 |
Correct |
90 ms |
8568 KB |
Output is correct |
9 |
Correct |
97 ms |
8568 KB |
Output is correct |
10 |
Correct |
100 ms |
8568 KB |
Output is correct |
11 |
Correct |
104 ms |
8568 KB |
Output is correct |
12 |
Correct |
105 ms |
8688 KB |
Output is correct |
13 |
Correct |
94 ms |
8568 KB |
Output is correct |
14 |
Correct |
100 ms |
8608 KB |
Output is correct |
15 |
Correct |
102 ms |
8568 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 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 |
4 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
512 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
512 KB |
Output is correct |
10 |
Correct |
5 ms |
512 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
77 ms |
7544 KB |
Output is correct |
14 |
Correct |
83 ms |
7672 KB |
Output is correct |
15 |
Correct |
75 ms |
7544 KB |
Output is correct |
16 |
Correct |
84 ms |
7680 KB |
Output is correct |
17 |
Correct |
66 ms |
7416 KB |
Output is correct |
18 |
Correct |
68 ms |
7432 KB |
Output is correct |
19 |
Correct |
94 ms |
7416 KB |
Output is correct |
20 |
Correct |
78 ms |
7544 KB |
Output is correct |
21 |
Correct |
69 ms |
7544 KB |
Output is correct |
22 |
Correct |
75 ms |
7544 KB |
Output is correct |
23 |
Correct |
98 ms |
8568 KB |
Output is correct |
24 |
Correct |
95 ms |
8612 KB |
Output is correct |
25 |
Correct |
99 ms |
8568 KB |
Output is correct |
26 |
Correct |
89 ms |
8572 KB |
Output is correct |
27 |
Correct |
94 ms |
8568 KB |
Output is correct |
28 |
Correct |
90 ms |
8568 KB |
Output is correct |
29 |
Correct |
93 ms |
8568 KB |
Output is correct |
30 |
Correct |
90 ms |
8568 KB |
Output is correct |
31 |
Correct |
97 ms |
8568 KB |
Output is correct |
32 |
Correct |
100 ms |
8568 KB |
Output is correct |
33 |
Correct |
104 ms |
8568 KB |
Output is correct |
34 |
Correct |
105 ms |
8688 KB |
Output is correct |
35 |
Correct |
94 ms |
8568 KB |
Output is correct |
36 |
Correct |
100 ms |
8608 KB |
Output is correct |
37 |
Correct |
102 ms |
8568 KB |
Output is correct |
38 |
Correct |
233 ms |
8952 KB |
Output is correct |
39 |
Correct |
121 ms |
8644 KB |
Output is correct |
40 |
Correct |
238 ms |
8824 KB |
Output is correct |
41 |
Correct |
126 ms |
8696 KB |
Output is correct |
42 |
Correct |
142 ms |
8672 KB |
Output is correct |
43 |
Correct |
232 ms |
8824 KB |
Output is correct |
44 |
Correct |
113 ms |
8696 KB |
Output is correct |
45 |
Correct |
161 ms |
8728 KB |
Output is correct |
46 |
Correct |
125 ms |
8696 KB |
Output is correct |
47 |
Correct |
132 ms |
8696 KB |
Output is correct |
48 |
Correct |
128 ms |
8696 KB |
Output is correct |
49 |
Correct |
151 ms |
8672 KB |
Output is correct |
50 |
Correct |
118 ms |
8568 KB |
Output is correct |
51 |
Correct |
158 ms |
8696 KB |
Output is correct |
52 |
Correct |
275 ms |
8952 KB |
Output is correct |
53 |
Correct |
122 ms |
8696 KB |
Output is correct |
54 |
Correct |
141 ms |
8696 KB |
Output is correct |
55 |
Correct |
142 ms |
8824 KB |
Output is correct |
56 |
Correct |
187 ms |
8696 KB |
Output is correct |
57 |
Correct |
168 ms |
8700 KB |
Output is correct |
58 |
Correct |
181 ms |
8744 KB |
Output is correct |