QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#648368#5466. Permutation CompressionRepeaterRE 43ms3948kbC++203.3kb2024-10-17 18:38:422024-10-17 18:38:43

Judging History

你现在查看的是最新测评结果

  • [2024-10-17 18:38:43]
  • 评测
  • 测评结果:RE
  • 用时:43ms
  • 内存:3948kb
  • [2024-10-17 18:38:42]
  • 提交

answer

#include<iostream>
using namespace std;
#include<vector>
#include<algorithm>
#include<set>

using i64 = long long;

vector<int> arr;

void update(int p){
	for(int i = p; i < arr.size(); i += i & -i){
		arr[i]++;
	}
	return;
}

int getsum(int p){
	int sum = 0;
	for(int i = p; i > 0; i -= i & -i){
		sum += arr[i];
	}
	return sum;
}

int getsum(int l, int r){
	return getsum(r) - getsum(l - 1);
}

const int N = 2e5 + 10;
vector<int> Log(N + 1);

void init(){
	for(int i = 2; i <= N; ++i) Log[i] = Log[i >> 1] + 1;
	return;
}

vector<vector<int>> st;
void build(vector<int>& t){
	int n = t.size();
	st.resize(n, vector<int>(Log[n] + 1, 0));

	for(int i = 0; i < n; ++i) st[i][0] = t[i];
	for(int i = 1; i <= Log[n]; ++i){
		int d = 1 << (i - 1);
		for(int j = 0; j + d < n; ++j){
			st[j][i] = max(st[j][i - 1], st[j + d][i - 1]);
			//cout << j << " " << i << " " << st[j][i] << "\n";
		}
	}

	return;
}

int tquery(int l, int r){
	int L = Log[r - l + 1];
	return max(st[l][L], st[r - (1 << L) + 1][L]);
}

void solve(){
	int n, m, k;
	cin >> n >> m >> k;

	arr.resize(n + 2);

	vector<int> a(n + 2), b(m + 1), p(n + 1);
	a[0] = a[n + 1] = 1e9;

	for(int i = 1; i <= n; ++i) {
		cin >> a[i];
		p[a[i]] = i;
		arr[i] = 0;
	}
	for(int i = 1; i <= m; ++i) cin >> b[i];

	multiset<int> s;
	for(int i = 1; i <= k; ++i) {
		int v = 0;
		cin >> v;
		s.insert(v);
	}

	if(k < n - m) {
		cout << "NO\n";
		return;
	}

	int tp = 1;
	for(int i = 1; i <= m; ++i){
		while(tp <= n && a[tp] != b[i]) ++tp;
	}

	if(tp == n + 1){
		cout << "NO\n";
		return;
	}

	s.insert(0), s.insert(1e9);

	vector<bool> vis(n + 2);
	for(int i = 1; i <= m; ++i){
		vis[b[i]] = true;
	}

	vector<int> l(n + 2), r(n + 2, n + 1);

	vector<int> t(n + 2);

	for(int i = 1; i <= n; ++i){
		if(vis[i]) t[p[i]] = i;
	}
	t[0] = t[n + 1] = 1e9;

	build(t);

	// cout << tquery(2, 3) << "\n";

	for(int i = 1; i <= n; ++i){
		if(vis[i]) l[p[i]] = r[p[i]] = p[i];
		else{
			int tl = 0, tr = p[i];
			while(tl + 1 < tr){
				int mid = (tl + tr) >> 1;
				(tquery(mid, p[i]) > i ? tl : tr) = mid;
				//cout << mid << " " << p[i] << " " << tquery(mid, p[i]) << "\n";
			}
			//cout << tl << " " << tr << "\n";
			l[p[i]] = tl;

			//cout << "daf\n";

			tl = p[i], tr = n + 1;
			while(tl + 1 < tr){
				int mid = (tl + tr) >> 1;
				(tquery(p[i], mid) > i ? tr : tl) = mid;
				//cout << p[i] << " " << mid << " " << tquery(p[i], mid) << "\n";
			}
			//cout << tl << " " << tr << "\n";
			r[p[i]] = tr;

			//cout << "daf\n";

			//cout << p[i] << " " << l[p[i]] << " " << r[p[i]] << "\n";
		}
	}

	l[0] = r[0] = 0;
	l[n + 1] = r[n + 1] = n + 1;

	// for(int i = 0; i <= n + 1; ++i){
	// 	cout << i << " " << l[i] << " " << r[i] << "\n";
	// }


	for(int i = n; i >= 1; --i){
		if(!vis[i]){
			int j = p[i];
			int q = getsum(l[j] + 1, r[j] - 1);
			auto t = prev(s.upper_bound(r[j] - l[j] - 1 - q));
			//cout << i << " " << l[i] << " " << r[i] << " " << q << " " << (*t) << "\n";
			if(*t == 0){
				cout << "NO\n";
				return;
			}
			else{
				s.extract(*t);
				update(j);
			}
		}
	}

	cout << "YES\n";

	return;
	
}

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

	init();

	int t = 1;
	cin >> t;
	while(t--) solve();

	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3948kb

input:

3
5 2 3
5 1 3 2 4
5 2
1 2 4
5 5 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
3 2 2
3 1 2
3 2
2 3

output:

YES
YES
NO

result:

ok 3 lines

Test #2:

score: 0
Accepted
time: 1ms
memory: 3796kb

input:

100
2 1 2
2 1
2
1 1
2 1 2
1 2
1
2 2
2 1 1
1 2
1
2
6 1 5
3 4 2 5 6 1
3
5 2 1 1 1
6 1 6
2 1 3 6 4 5
1
4 1 2 2 1 4
3 3 2
2 1 3
2 1 3
2 2
1 1 1
1
1
1
1 1 1
1
1
1
2 1 2
2 1
2
1 2
4 4 3
2 1 3 4
2 1 3 4
4 3 1
1 1 1
1
1
1
6 5 1
6 2 5 4 3 1
6 2 4 3 1
4
1 1 1
1
1
1
6 5 3
3 6 1 4 5 2
3 6 1 4 2
3 3 4
4 3 4
3 4 ...

output:

YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
YES
YES
YES
YES
NO
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
NO
NO
YES
YES
NO
NO
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
YES
YES
YES
YES
YES
YES
NO
YES
YES
YES
YES
YES
YES
YES
NO
YES
YES
YES
YES
YE...

result:

ok 100 lines

Test #3:

score: 0
Accepted
time: 1ms
memory: 3788kb

input:

99
6 1 6
1 5 3 4 2 6
1
1 2 1 1 1 6
1 1 1
1
1
1
4 1 3
3 4 1 2
1
1 1 2
2 2 1
2 1
2 1
2
1 1 1
1
1
1
2 1 2
1 2
2
1 2
1 1 1
1
1
1
1 1 1
1
1
1
3 2 2
3 2 1
2 1
1 2
3 3 1
2 3 1
2 3 1
1
6 1 5
3 4 2 5 6 1
3
4 2 1 1 1
6 4 4
1 6 5 2 3 4
1 2 3 4
5 4 4 6
2 1 1
1 2
1
1
6 5 1
2 1 4 5 6 3
2 1 4 6 3
2
6 3 6
5 6 2 1 3...

output:

YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
NO
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
YES
YES
YES
YES
YES
YES
YES
NO
NO
YES
YES
YES
NO
YES
YES
YES
NO
YES
YES
NO
YES
NO
YES
NO
YES
YES
YES
YES
YES
YES
NO
YES
NO
NO
YES
YES
YES
YE...

result:

ok 99 lines

Test #4:

score: 0
Accepted
time: 1ms
memory: 3780kb

input:

98
6 1 6
6 1 4 5 2 3
3
1 2 2 1 1 6
4 3 2
2 3 4 1
2 1 3
3 4
1 1 1
1
1
1
6 1 6
6 4 3 1 2 5
1
3 1 3 1 1 5
1 1 1
1
1
1
6 4 4
3 4 1 2 5 6
3 4 1 2
2 4 3 1
6 5 1
4 5 3 6 1 2
4 5 3 1 2
6
1 1 1
1
1
1
5 1 4
1 3 2 4 5
1
5 3 4 4
6 3 4
1 4 2 3 6 5
1 2 5
5 4 6 5
4 1 3
2 1 4 3
2
1 1 1
1 1 1
1
1
1
6 3 5
5 1 3 6 4 2...

output:

YES
NO
YES
YES
YES
YES
YES
YES
NO
NO
YES
YES
NO
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
YES
YES
YES
NO
YES
YES
YES
NO
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
YES
YES
YES
YES
NO
YES
YES
YES
YES
YES
NO
YES
NO
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
YES
NO
Y...

result:

ok 98 lines

Test #5:

score: 0
Accepted
time: 35ms
memory: 3628kb

input:

60000
1 1 1
1
1
1
1 1 1
1
1
1
3 2 1
2 3 1
2 1
2
3 3 1
1 2 3
1 2 3
1
1 1 1
1
1
1
1 1 1
1
1
1
1 1 1
1
1
1
3 3 2
3 2 1
3 2 1
1 1
2 2 1
2 1
2 1
1
1 1 1
1
1
1
2 2 1
1 2
1 2
1
1 1 1
1
1
1
3 1 3
2 3 1
1
2 3 2
3 3 2
2 3 1
2 3 1
2 1
1 1 1
1
1
1
1 1 1
1
1
1
1 1 1
1
1
1
3 2 3
3 2 1
2 1
1 2 1
3 2 2
1 3 2
3 2
3 ...

output:

YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
YES
YES
YES
YES
YES
YES
NO
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES...

result:

ok 60000 lines

Test #6:

score: 0
Accepted
time: 34ms
memory: 3948kb

input:

50000
1 1 1
1
1
1
4 3 4
1 2 3 4
1 2 3
2 3 4 4
1 1 1
1
1
1
3 2 1
3 1 2
1 2
3
4 1 4
2 1 4 3
2
4 4 3 4
3 1 2
1 2 3
2
3 3
4 1 3
4 2 1 3
1
3 2 4
4 4 2
4 1 2 3
4 1 2 3
3 4
3 1 2
2 1 3
3
1 3
4 2 2
4 3 1 2
3 1
2 1
1 1 1
1
1
1
4 3 1
1 2 3 4
1 2 4
4
4 1 4
4 3 2 1
4
2 1 1 2
3 3 1
2 1 3
2 1 3
1
4 3 2
1 3 2 4
1 ...

output:

YES
YES
YES
YES
NO
NO
YES
YES
NO
YES
YES
NO
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
YES
NO
YES
YES
YES
YES
YES
YES
YES
YES
NO
YES
YES
YES
YES
YES
YES
NO
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
YES
YES
YES
Y...

result:

ok 50000 lines

Test #7:

score: 0
Accepted
time: 32ms
memory: 3688kb

input:

40000
3 2 1
3 2 1
2 1
3
5 5 1
5 2 1 3 4
5 2 1 3 4
5
4 1 3
1 4 3 2
1
1 1 1
5 3 3
5 3 4 1 2
3 1 2
1 2 1
3 1 2
1 3 2
1
3 1
2 2 2
1 2
1 2
2 2
5 4 2
5 4 2 1 3
4 2 1 3
1 2
1 1 1
1
1
1
3 1 2
1 2 3
1
2 1
2 1 1
1 2
1
2
5 5 2
5 2 3 1 4
5 2 3 1 4
1 1
5 3 4
4 5 1 2 3
4 2 3
1 1 1 3
1 1 1
1
1
1
5 4 2
2 1 4 5 3
2 ...

output:

YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
YES
NO
YES
YES
YES
YES
YES
YES
YES
NO
NO
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
YES
NO
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
YES
YES
YES
NO
YES
NO
YES
YES
NO
YES
YES
YES
YES
YES
NO
NO
YES
YES
YES
YES
...

result:

ok 40000 lines

Test #8:

score: 0
Accepted
time: 35ms
memory: 3652kb

input:

40000
6 3 5
3 6 2 5 1 4
3 2 1
1 2 3 6 1
4 3 1
1 3 4 2
1 3 2
1
1 1 1
1
1
1
1 1 1
1
1
1
6 2 6
4 1 3 2 6 5
2 5
6 5 5 3 5 5
6 6 2
3 6 2 5 1 4
3 6 2 5 1 4
6 4
2 2 1
1 2
1 2
2
2 2 1
1 2
1 2
1
3 3 3
2 1 3
2 1 3
2 3 1
6 4 5
5 1 3 4 6 2
5 1 3 2
5 5 4 3 4
6 2 4
4 3 5 6 2 1
4 3
2 2 1 1
3 1 2
2 3 1
1
2 2
3 3 1
...

output:

YES
YES
YES
YES
NO
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
YES
YES
YES
NO
YES
YES
YES
YES
YES
YES
YES
YES
YE...

result:

ok 40000 lines

Test #9:

score: 0
Accepted
time: 38ms
memory: 3816kb

input:

40000
7 5 2
6 4 2 1 3 5 7
6 4 2 1 3
3 1
2 2 2
2 1
2 1
1 1
4 1 4
3 4 2 1
1
3 4 2 1
3 2 2
1 3 2
1 2
1 3
5 2 4
4 3 2 5 1
2 1
2 2 2 5
7 1 7
2 7 5 6 1 4 3
3
3 3 1 1 3 1 6
7 7 2
3 7 2 5 1 6 4
3 7 2 5 1 6 4
5 6
6 2 6
2 6 3 4 1 5
2 1
6 3 4 5 3 5
3 1 3
3 1 2
1
2 3 3
7 5 3
1 7 5 4 6 3 2
5 4 6 3 2
6 1 1
6 3 5
...

output:

YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
NO
YES
YES
NO
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
YES
YES
YES
YES
YES
YES
NO
YES
YES
NO
YES
YES
YES
YES
YES
YES
YES
NO
YES
YES
YES
NO
YES
YES
YES
YES
YES
YES
YES
YES
NO
YES
YES
YES
YES
YES
NO
YES
YES
NO
YES
YES
NO
YES
YES
...

result:

ok 40000 lines

Test #10:

score: 0
Accepted
time: 36ms
memory: 3632kb

input:

40000
4 2 4
4 1 3 2
4 2
3 4 4 3
6 3 5
6 2 4 5 1 3
2 1 3
1 1 2 6 1
8 5 6
1 7 2 8 6 5 3 4
1 7 5 2 3
3 1 2 8 7 8
6 6 1
3 4 6 1 5 2
3 4 6 1 5 2
6
8 7 2
6 8 5 7 1 3 2 4
6 5 7 1 3 2 4
8 7
1 1 1
1
1
1
4 3 3
2 4 3 1
2 4 3
1 2 4
4 3 3
1 3 4 2
1 3 2
4 4 3
2 2 1
1 2
1 2
2
7 5 3
5 2 3 7 1 6 4
2 3 1 6 4
7 5 6
7 ...

output:

NO
YES
NO
YES
YES
YES
YES
YES
YES
NO
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
YES
NO
YES
YES
YES
YES
YES
YES
YES
NO
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
YES
YES
YES
YES
NO
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
YES
NO...

result:

ok 40000 lines

Test #11:

score: 0
Accepted
time: 37ms
memory: 3668kb

input:

40000
2 2 2
1 2
1 2
1 1
8 2 6
1 3 5 4 6 7 2 8
3 2
2 8 6 8 7 8
8 5 4
3 1 2 7 8 5 4 6
3 1 2 5 4
8 7 7 7
1 1 1
1
1
1
1 1 1
1
1
1
2 1 1
1 2
2
2
2 2 2
1 2
2 1
2 2
2 2 2
2 1
2 1
2 1
8 1 7
5 3 8 4 1 7 6 2
2
3 5 2 1 1 1 1
9 8 2
7 8 1 6 4 5 9 3 2
7 8 1 6 4 5 3 2
2 9
2 1 2
2 1
2
1 1
4 1 4
3 1 4 2
3
1 2 1 2
3 ...

output:

YES
NO
NO
YES
YES
NO
NO
YES
YES
YES
YES
YES
YES
YES
YES
NO
YES
NO
YES
YES
YES
YES
NO
YES
YES
YES
NO
YES
NO
NO
NO
YES
YES
NO
YES
YES
YES
YES
NO
YES
NO
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
YES
NO
YES
YES
YES
YES
YES
YES
YES
YES
NO
YES
YES
YES
NO
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
YES
YES...

result:

ok 40000 lines

Test #12:

score: 0
Accepted
time: 43ms
memory: 3648kb

input:

40000
1 1 1
1
1
1
7 5 4
7 4 6 2 5 1 3
7 4 6 2 1
1 2 3 7
7 4 3
7 4 1 3 2 5 6
1 3 2 5
6 5 7
7 1 6
5 4 3 1 7 2 6
6
4 2 3 1 1 1
4 3 4
2 4 3 1
2 3 1
2 3 3 3
3 1 3
3 1 2
2
1 3 3
1 1 1
1
1
1
2 1 1
1 2
1
2
9 2 8
9 8 6 4 2 1 5 7 3
4 1
1 2 2 3 5 4 2 9
1 1 1
1
1
1
4 2 3
2 4 3 1
2 1
3 2 4
3 3 3
1 3 2
1 3 2
3 3 ...

output:

YES
YES
NO
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
YES
YES
YES
NO
NO
YES
YES
NO
YES
YES
YES
YES
NO
NO
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
YES
NO
NO
NO
YES
NO
YES
YES
YES
NO
YES
YES
YES
YES
YES
NO
NO
YES
YES
YES
YES
YES
YES
YES
YES
NO
YES
NO
YES
YES
YES
NO
YES
YES
YES
YES
YE...

result:

ok 40000 lines

Test #13:

score: 0
Accepted
time: 35ms
memory: 3652kb

input:

40000
6 3 5
4 3 2 5 1 6
2 3 1
2 1 1 6 6
2 1 1
1 2
1
1
6 5 4
1 3 5 6 2 4
1 3 6 2 4
2 2 6 6
8 2 7
5 8 4 7 1 3 2 6
6 2
1 3 1 1 1 1 7
1 1 1
1
1
1
11 6 5
2 4 11 6 9 3 8 1 7 5 10
2 4 3 6 8 5
3 1 4 1 1
8 3 8
6 4 8 5 1 3 7 2
4 1 2
2 2 1 3 3 4 8 4
2 1 2
2 1
1
2 2
5 5 1
1 5 3 4 2
1 5 3 4 2
5
9 2 9
8 7 5 6 2 4...

output:

NO
YES
YES
NO
YES
NO
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
YES
YES
YES
YES
YES
NO
YES
YES
YES
YES
NO
YES
NO
NO
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
YES
YES
NO
YES
NO
YES
YES
YES
YES
YES
YES
NO
YES
YES
YES
YES
YES
YES
NO
NO
YES
NO
YES
YES
YES
YES...

result:

ok 40000 lines

Test #14:

score: 0
Accepted
time: 40ms
memory: 3772kb

input:

40000
5 4 3
1 5 4 2 3
1 4 2 3
1 5 4
12 1 12
8 11 5 1 7 3 10 6 4 9 12 2
4
3 6 2 1 1 2 9 11 12 10 11 12
2 2 1
2 1
2 1
2
4 3 4
2 3 4 1
2 3 1
2 2 1 3
2 2 1
2 1
2 1
2
6 4 5
2 5 3 4 1 6
2 3 1 6
3 6 6 3 6
4 4 1
3 4 1 2
3 4 1 2
2
3 1 2
3 2 1
1
3 3
11 8 4
11 3 10 5 1 6 4 8 7 9 2
11 3 1 6 4 7 9 2
10 8 11 10
1...

output:

YES
NO
YES
YES
YES
YES
YES
NO
NO
YES
YES
YES
YES
YES
YES
NO
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
YES
YES
NO
YES
YES
YES
YES
NO
YES
YES
NO
YES
YES
YES
YES
NO
YES
YES
YES
YES
NO
YES
YES
YES
YES
YES
NO
YES
NO
YES
YES
YES
YES
YES
YES
YES
NO
YES
YE...

result:

ok 40000 lines

Test #15:

score: 0
Accepted
time: 17ms
memory: 3640kb

input:

10000
10 5 6
5 6 9 10 7 1 3 2 4 8
5 6 9 1 2
8 9 9 10 10 10
10 6 5
5 6 7 2 4 8 10 9 1 3
5 2 8 9 1 3
9 7 7 10 10
5 3 4
3 5 4 1 2
4 1 2
3 5 4 5
6 3 5
6 1 2 5 4 3
1 4 3
4 5 5 5 4
10 8 5
7 3 1 5 9 8 2 6 10 4
3 1 5 9 8 2 6 4
6 1 4 8 10
10 6 4
7 1 4 5 8 9 3 10 2 6
1 4 8 3 2 6
2 1 2 1
10 3 10
9 6 4 7 2 5 8 ...

output:

NO
NO
NO
NO
YES
YES
NO
YES
YES
YES
NO
NO
YES
YES
YES
NO
NO
YES
YES
YES
YES
NO
YES
YES
NO
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
YES
YES
YES
NO
YES
YES
YES
NO
YES
YES
NO
YES
YES
YES
YES
NO
NO
YES
YES
YES
NO
NO
NO
YES
YES
YES
YES
YES
YES
NO
YES
YES
NO
YES
YES
YES
NO
YES
NO
NO
NO
YES
YES
NO
YES
YES
YES...

result:

ok 10000 lines

Test #16:

score: 0
Accepted
time: 26ms
memory: 3804kb

input:

10000
15 15 1
15 6 5 8 3 2 12 9 10 1 4 7 14 11 13
15 6 5 8 3 2 12 9 10 1 4 7 14 11 13
10
8 3 6
5 6 2 4 1 3 8 7
6 1 7
7 7 8 8 8 7
19 1 19
7 10 13 3 5 16 12 17 19 8 1 2 11 18 6 14 9 15 4
1
4 8 1 1 5 1 1 3 2 5 2 2 1 17 18 18 18 17 18
20 11 12
5 14 20 19 1 10 8 3 13 15 4 2 16 18 7 6 17 9 11 12
5 14 10 8...

output:

YES
NO
NO
NO
YES
YES
YES
YES
NO
NO
NO
NO
YES
NO
NO
NO
NO
YES
NO
YES
NO
NO
YES
YES
YES
NO
NO
NO
YES
NO
NO
NO
YES
YES
YES
YES
YES
YES
YES
NO
YES
YES
YES
NO
YES
NO
YES
YES
YES
YES
NO
NO
YES
YES
YES
NO
YES
NO
YES
YES
YES
YES
YES
YES
YES
NO
YES
YES
YES
NO
NO
NO
NO
NO
YES
NO
NO
YES
YES
YES
NO
NO
YES
YES
Y...

result:

ok 10000 lines

Test #17:

score: -100
Runtime Error

input:

10000
4 3 4
1 4 3 2
1 3 2
2 4 3 4
1 1 1
1
1
1
79 70 9
73 34 21 66 52 46 72 32 63 44 48 11 77 40 15 51 50 67 70 53 62 3 31 69 20 41 28 30 54 10 7 19 24 74 5 4 59 1 18 37 68 25 23 58 6 33 65 55 43 39 17 12 49 35 56 8 75 64 45 14 36 22 13 57 60 27 71 61 42 9 76 2 16 79 78 26 38 47 29
73 34 21 66 52 46 ...

output:


result: