# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
234261 |
2020-05-23T14:49:48 Z |
Vimmer |
Tenis (COI19_tenis) |
C++14 |
|
217 ms |
9472 KB |
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("-O3")
//#pragma GCC optimize("Ofast")
#define sz(x) ll(x.size())
#define base 1000000
#define M ll(1e9+7)
#define N 100005
#define F first
#define S second
#define pb push_back
#define in insert
#define eb emplace_back
#define ed "\n"
using namespace std;
//using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
typedef short int si;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
int a[3][N], n, q, pos[3][N], psh[N * 4];
pair <int, int> t[N * 4];
void bld(int v, int tl, int tr)
{
if (tl == tr) t[v] = {-tl, tl};
else {
int md = (tl + tr) >> 1;
bld(v + v, tl, md);
bld(v + v + 1, md + 1, tr);
if (t[v + v].F > t[v + v + 1].F) t[v] = t[v + v + 1];
else t[v] = t[v + v];
}
}
void Push(int v)
{
if (psh[v] == 0) return;
t[v].F += psh[v];
if (v + v + 1 < N * 4)
{
psh[v + v] += psh[v];
psh[v + v + 1] += psh[v];
}
psh[v] = 0;
}
void upd(int v, int tl, int tr, int l, int r, int val)
{
Push(v);
if (tr < l || r < tl || tl > tr || l > r) return;
if (l <= tl && tr <= r)
{
psh[v] += val;
Push(v);
return;
}
int md = (tl + tr) >> 1;
upd(v + v, tl, md, l, r, val);
upd(v + v + 1, md + 1, tr, l, r, val);
if (t[v + v].F > t[v + v + 1].F) t[v] = t[v + v + 1];
else t[v] = t[v + v];
}
void update(int v, int val) {upd(1, 1, n, min(min(pos[0][v], pos[1][v]), pos[2][v]), n, val);}
int main()
{
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
ios_base::sync_with_stdio(0); istream::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n >> q;
for (int j = 0; j < 3; j++)
for (int i = 1; i <= n; i++)
{
cin >> a[j][i];
pos[j][a[j][i]] = i;
}
bld(1, 1, n);
for (int i = 1; i <= n; i++) update(i, 1);
for (; q > 0; q--)
{
int tp, p, l, r;
cin >> tp;
if (tp == 2)
{
cin >> p >> l >> r;
p--;
update(l, -1);
update(r, -1);
swap(a[p][pos[p][l]], a[p][pos[p][r]]);
swap(pos[p][l], pos[p][r]);
update(l, 1);
update(r, 1);
continue;
}
cin >> p;
if (t[1].S >= pos[0][p]) cout << "DA" << '\n';
else cout << "NE" << '\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
4 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 |
432 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
4 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 |
432 KB |
Output is correct |
7 |
Correct |
5 ms |
512 KB |
Output is correct |
8 |
Correct |
5 ms |
512 KB |
Output is correct |
9 |
Correct |
5 ms |
512 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 |
512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
4 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 |
432 KB |
Output is correct |
7 |
Correct |
5 ms |
512 KB |
Output is correct |
8 |
Correct |
5 ms |
512 KB |
Output is correct |
9 |
Correct |
5 ms |
512 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 |
512 KB |
Output is correct |
13 |
Correct |
76 ms |
8056 KB |
Output is correct |
14 |
Correct |
81 ms |
7416 KB |
Output is correct |
15 |
Correct |
72 ms |
7416 KB |
Output is correct |
16 |
Correct |
70 ms |
7416 KB |
Output is correct |
17 |
Correct |
75 ms |
7416 KB |
Output is correct |
18 |
Correct |
76 ms |
7416 KB |
Output is correct |
19 |
Correct |
79 ms |
7420 KB |
Output is correct |
20 |
Correct |
74 ms |
7416 KB |
Output is correct |
21 |
Correct |
71 ms |
7416 KB |
Output is correct |
22 |
Correct |
70 ms |
7416 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
102 ms |
8656 KB |
Output is correct |
2 |
Correct |
101 ms |
8568 KB |
Output is correct |
3 |
Correct |
101 ms |
8572 KB |
Output is correct |
4 |
Correct |
97 ms |
8572 KB |
Output is correct |
5 |
Correct |
100 ms |
8568 KB |
Output is correct |
6 |
Correct |
99 ms |
8644 KB |
Output is correct |
7 |
Correct |
97 ms |
8608 KB |
Output is correct |
8 |
Correct |
106 ms |
8568 KB |
Output is correct |
9 |
Correct |
95 ms |
8568 KB |
Output is correct |
10 |
Correct |
96 ms |
8568 KB |
Output is correct |
11 |
Correct |
102 ms |
8568 KB |
Output is correct |
12 |
Correct |
96 ms |
8568 KB |
Output is correct |
13 |
Correct |
101 ms |
8572 KB |
Output is correct |
14 |
Correct |
96 ms |
8568 KB |
Output is correct |
15 |
Correct |
92 ms |
8568 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
4 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 |
432 KB |
Output is correct |
7 |
Correct |
5 ms |
512 KB |
Output is correct |
8 |
Correct |
5 ms |
512 KB |
Output is correct |
9 |
Correct |
5 ms |
512 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 |
512 KB |
Output is correct |
13 |
Correct |
76 ms |
8056 KB |
Output is correct |
14 |
Correct |
81 ms |
7416 KB |
Output is correct |
15 |
Correct |
72 ms |
7416 KB |
Output is correct |
16 |
Correct |
70 ms |
7416 KB |
Output is correct |
17 |
Correct |
75 ms |
7416 KB |
Output is correct |
18 |
Correct |
76 ms |
7416 KB |
Output is correct |
19 |
Correct |
79 ms |
7420 KB |
Output is correct |
20 |
Correct |
74 ms |
7416 KB |
Output is correct |
21 |
Correct |
71 ms |
7416 KB |
Output is correct |
22 |
Correct |
70 ms |
7416 KB |
Output is correct |
23 |
Correct |
102 ms |
8656 KB |
Output is correct |
24 |
Correct |
101 ms |
8568 KB |
Output is correct |
25 |
Correct |
101 ms |
8572 KB |
Output is correct |
26 |
Correct |
97 ms |
8572 KB |
Output is correct |
27 |
Correct |
100 ms |
8568 KB |
Output is correct |
28 |
Correct |
99 ms |
8644 KB |
Output is correct |
29 |
Correct |
97 ms |
8608 KB |
Output is correct |
30 |
Correct |
106 ms |
8568 KB |
Output is correct |
31 |
Correct |
95 ms |
8568 KB |
Output is correct |
32 |
Correct |
96 ms |
8568 KB |
Output is correct |
33 |
Correct |
102 ms |
8568 KB |
Output is correct |
34 |
Correct |
96 ms |
8568 KB |
Output is correct |
35 |
Correct |
101 ms |
8572 KB |
Output is correct |
36 |
Correct |
96 ms |
8568 KB |
Output is correct |
37 |
Correct |
92 ms |
8568 KB |
Output is correct |
38 |
Correct |
208 ms |
8696 KB |
Output is correct |
39 |
Correct |
130 ms |
9208 KB |
Output is correct |
40 |
Correct |
217 ms |
9464 KB |
Output is correct |
41 |
Correct |
133 ms |
9208 KB |
Output is correct |
42 |
Correct |
140 ms |
9336 KB |
Output is correct |
43 |
Correct |
211 ms |
9464 KB |
Output is correct |
44 |
Correct |
117 ms |
9208 KB |
Output is correct |
45 |
Correct |
148 ms |
9336 KB |
Output is correct |
46 |
Correct |
135 ms |
9208 KB |
Output is correct |
47 |
Correct |
140 ms |
9336 KB |
Output is correct |
48 |
Correct |
127 ms |
9208 KB |
Output is correct |
49 |
Correct |
146 ms |
9336 KB |
Output is correct |
50 |
Correct |
119 ms |
9208 KB |
Output is correct |
51 |
Correct |
143 ms |
9336 KB |
Output is correct |
52 |
Correct |
216 ms |
9472 KB |
Output is correct |
53 |
Correct |
134 ms |
9412 KB |
Output is correct |
54 |
Correct |
139 ms |
9208 KB |
Output is correct |
55 |
Correct |
145 ms |
9336 KB |
Output is correct |
56 |
Correct |
143 ms |
9336 KB |
Output is correct |
57 |
Correct |
126 ms |
9208 KB |
Output is correct |
58 |
Correct |
167 ms |
9380 KB |
Output is correct |