Submission #203698

#TimeUsernameProblemLanguageResultExecution timeMemory
203698SortingTenis (COI19_tenis)C++14
21 / 100
64 ms6008 KiB
#include <bits/stdc++.h>

using namespace std;

const int kNMax = 1e5 + 7;

int n, q;
int a[3][kNMax], mx[kNMax], pos[3][kNMax];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> n >> q;
	for(int i = 0; i < 3; ++i){
		for(int j = 1; j <= n; ++j){
			cin >> a[i][j];
			pos[i][a[i][j]] = j;
		}
	}

	for(int i = 1; i <= n; ++i){
		mx[i] = 0;
		for(int j = 0; j < 3; ++j)
			mx[i] = max(mx[i], pos[j][i]);
	}

	int border = -1, mx_all = 0;
	for(int i = 1; i <= n; ++i){
		int x = a[0][i];
		mx_all = max(mx_all, mx[x]);
		if(mx_all == i){
			border = i;
			break;
		}
	}

	for(int i = 0; i < q; ++i){
		int type;
		cin >> type;

		if(type == 1){
			int x;
			cin >> x;

			if(mx[x] <= border)
				cout << "DA\n";
			else
				cout << "NE\n";
		}
		else{

		}
	}
}
/*
4 2
1 2 3 4
2 1 3 4
2 4 3 1
1 1
1 4
*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...