Submission #351331

# Submission time Handle Problem Language Result Execution time Memory
351331 2021-01-20T00:48:54 Z super_j6 Tenis (COI19_tenis) C++14
100 / 100
175 ms 14572 KB
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
#define endl '\n'
#define ll long long
#define pi pair<int, int>
#define f first
#define s second


const int mxn = 100000, k = 3;
int n, q;
int a[mxn][k], f[mxn];

int ff(int x){
	return *max_element(a[x], a[x] + k);
}

struct segTree{
	int l, r;
	segTree *tl, *tr;
	int vl, ss;
	
	segTree(int l, int r) : l(l), r(r){
		if(l != r){
			int mid = (l + r) / 2;
			tl = new segTree(l, mid);
			tr = new segTree(mid + 1, r);
			pul();
		}else{
			vl = ss = f[l] - 1;
		}
	}
	
	void pul(){
		vl = max(tl->vl, tl->ss + tr->vl);
		ss = tl->ss + tr->ss;
	}
	
	void add(int x, int v){
		if(x < l || r < x) return;
		if(l == r) return (void)(vl += v, ss += v);
		tl->add(x, v), tr->add(x, v);
		pul();
	}
	
	int qry(int x = 0){
		return l == r ? l : !(x + tl->vl) ? tl->qry(x) : tr->qry(x + tl->ss);
	}
};

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> q;
	
	for(int j = 0; j < k; j++)
	for(int i = 0; i < n; i++){
		int x;
		cin >> x;
		a[--x][j] = i;
	}
	
	for(int i = 0; i < n; i++) f[ff(i)]++;
	
	segTree tre(0, n - 1);
	while(q--){
		int t;
		cin >> t;
		if(t & 1){
			int x;
			cin >> x;
			x--;
			cout << (ff(x) <= tre.qry() ? "DA" : "NE") << endl;
		}else{
			int x, y, z;
			cin >> z >> x >> y;
			x--, y--, z--;
			tre.add(ff(x), -1), tre.add(ff(y), -1);
			swap(a[x][z], a[y][z]);
			tre.add(ff(x), 1), tre.add(ff(y), 1);
		}
	}
	
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 492 KB Output is correct
8 Correct 1 ms 492 KB Output is correct
9 Correct 1 ms 492 KB Output is correct
10 Correct 1 ms 492 KB Output is correct
11 Correct 1 ms 492 KB Output is correct
12 Correct 1 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 492 KB Output is correct
8 Correct 1 ms 492 KB Output is correct
9 Correct 1 ms 492 KB Output is correct
10 Correct 1 ms 492 KB Output is correct
11 Correct 1 ms 492 KB Output is correct
12 Correct 1 ms 492 KB Output is correct
13 Correct 41 ms 12940 KB Output is correct
14 Correct 41 ms 12964 KB Output is correct
15 Correct 41 ms 12908 KB Output is correct
16 Correct 40 ms 12908 KB Output is correct
17 Correct 43 ms 13036 KB Output is correct
18 Correct 42 ms 13036 KB Output is correct
19 Correct 51 ms 12908 KB Output is correct
20 Correct 43 ms 13036 KB Output is correct
21 Correct 48 ms 12908 KB Output is correct
22 Correct 41 ms 13036 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 72 ms 14060 KB Output is correct
2 Correct 71 ms 14316 KB Output is correct
3 Correct 73 ms 14188 KB Output is correct
4 Correct 69 ms 14060 KB Output is correct
5 Correct 72 ms 14188 KB Output is correct
6 Correct 71 ms 14060 KB Output is correct
7 Correct 72 ms 14188 KB Output is correct
8 Correct 70 ms 14060 KB Output is correct
9 Correct 72 ms 14060 KB Output is correct
10 Correct 68 ms 13932 KB Output is correct
11 Correct 69 ms 14060 KB Output is correct
12 Correct 73 ms 13932 KB Output is correct
13 Correct 69 ms 14060 KB Output is correct
14 Correct 88 ms 14060 KB Output is correct
15 Correct 74 ms 14140 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 492 KB Output is correct
8 Correct 1 ms 492 KB Output is correct
9 Correct 1 ms 492 KB Output is correct
10 Correct 1 ms 492 KB Output is correct
11 Correct 1 ms 492 KB Output is correct
12 Correct 1 ms 492 KB Output is correct
13 Correct 41 ms 12940 KB Output is correct
14 Correct 41 ms 12964 KB Output is correct
15 Correct 41 ms 12908 KB Output is correct
16 Correct 40 ms 12908 KB Output is correct
17 Correct 43 ms 13036 KB Output is correct
18 Correct 42 ms 13036 KB Output is correct
19 Correct 51 ms 12908 KB Output is correct
20 Correct 43 ms 13036 KB Output is correct
21 Correct 48 ms 12908 KB Output is correct
22 Correct 41 ms 13036 KB Output is correct
23 Correct 72 ms 14060 KB Output is correct
24 Correct 71 ms 14316 KB Output is correct
25 Correct 73 ms 14188 KB Output is correct
26 Correct 69 ms 14060 KB Output is correct
27 Correct 72 ms 14188 KB Output is correct
28 Correct 71 ms 14060 KB Output is correct
29 Correct 72 ms 14188 KB Output is correct
30 Correct 70 ms 14060 KB Output is correct
31 Correct 72 ms 14060 KB Output is correct
32 Correct 68 ms 13932 KB Output is correct
33 Correct 69 ms 14060 KB Output is correct
34 Correct 73 ms 13932 KB Output is correct
35 Correct 69 ms 14060 KB Output is correct
36 Correct 88 ms 14060 KB Output is correct
37 Correct 74 ms 14140 KB Output is correct
38 Correct 175 ms 14316 KB Output is correct
39 Correct 94 ms 14060 KB Output is correct
40 Correct 164 ms 14572 KB Output is correct
41 Correct 90 ms 14248 KB Output is correct
42 Correct 93 ms 14316 KB Output is correct
43 Correct 156 ms 14316 KB Output is correct
44 Correct 80 ms 14188 KB Output is correct
45 Correct 94 ms 14188 KB Output is correct
46 Correct 82 ms 14188 KB Output is correct
47 Correct 92 ms 14316 KB Output is correct
48 Correct 87 ms 14060 KB Output is correct
49 Correct 101 ms 14316 KB Output is correct
50 Correct 79 ms 14188 KB Output is correct
51 Correct 93 ms 14188 KB Output is correct
52 Correct 143 ms 14572 KB Output is correct
53 Correct 88 ms 14316 KB Output is correct
54 Correct 93 ms 14444 KB Output is correct
55 Correct 96 ms 14316 KB Output is correct
56 Correct 91 ms 14316 KB Output is correct
57 Correct 81 ms 14188 KB Output is correct
58 Correct 134 ms 14316 KB Output is correct