QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#421284#8724. SeptemberHossamHero730 2ms8200kbC++201.9kb2024-05-25 16:07:232024-05-25 16:07:23

Judging History

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

  • [2024-05-25 16:07:23]
  • 评测
  • 测评结果:30
  • 用时:2ms
  • 内存:8200kb
  • [2024-05-25 16:07:23]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#include "september.h"
const int N = 2e5+5;
int in[N] , out[N] , dp[N][20];
vector<int> adj[N];
int pt = 0;
void dfs(int node){
	in[node] = ++pt;
	for(auto ch : adj[node]){
		dfs(ch);
	}
	out[node] = pt;
}
void build(vector<int> &v){
	int n = v.size();
	for(int i=0;i<n;i++) dp[i][0] = v[i];
	for(int k=1;k<20;k++){
		for(int i=0;i+(1<<k)-1<n;i++){
			dp[i][k] = max(dp[i][k-1] , dp[i+(1<<k-1)][k-1]);
		}
	}
}
int query(int l,int r){
	int lg = __lg(r-l+1);
	return max(dp[l][lg],dp[r-(1<<lg)+1][lg]);
}
struct DSU{
	int n;
	vector<int> par;
	int comps;
	DSU(int _n){
		n = _n;
		par.resize(n);
		iota(par.begin(),par.end(),0);
		comps = n;
	}
	int getP(int node){
		if(node == par[node]) return node;
		return par[node] = getP(par[node]);
	}
	void add(int a,int b){
		a = getP(a);
		b = getP(b);
		if(a == b) return;
		comps --;
		par[b] = a;
	}
};
bool check_anc(int a,int b){
	return in[a] <= in[b] && out[b] <= out[a];
}
int solve(int n, int m, std::vector<int> p, std::vector<std::vector<int>> v) {
	pt = 0;
	for(int i=0;i<=n;i++){
		in[i] = out[i] = 0;
		adj[i].clear();
	}
	for(int i=1;i<n;i++){
		adj[p[i]].push_back(i);
	}
	vector<vector<bool>> rel(n,vector<bool>(n));
	dfs(0);
	DSU ds(n);
	for(auto a : v){
		DSU tmp2(n);
		vector<int> idx(n+1);
		for(int i=0;i<n-1;i++){
			idx[a[i]] = i;
		}
		vector<int> tmp(n+1);
		for(int i=1;i<n;i++) tmp[in[i]] = idx[i];
		build(tmp);
		vector<int> sts;
		sts.push_back(0);
		int t = -1;
		for(int i=0;i<n-1;i++){
			if(i == t) sts.push_back(i);
			t = max(t , query(in[a[i]],out[a[i]]) + 1);
		}
		int sz = sts.size();
		for(int i=0;i<sz-1;i++){
			for(int j=sts[i]+1;j<sts[i+1];j++) {
				ds.add(a[j],a[j-1]);
				tmp2.add(a[j],a[j-1]);
			}
		}
		for(int i=sts.back()+1;i<n-1;i++) {
			ds.add(a[i],a[i-1]);
			tmp2.add(a[i],a[i-1]);
		}
	}
	return ds.comps - 1;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 11
Accepted

Test #1:

score: 11
Accepted
time: 2ms
memory: 7624kb

input:

txy4h26c1rm1uv8tr3eonahd67u8h56x
4
7 1
0 0 2 3 3 5
1 6 4 3 5 2
10 1
0 1 2 0 3 0 5 4 8
9 7 6 8 4 5 3 2 1
7 1
0 0 0 1 3 0
2 4 1 6 5 3
6 1
0 0 1 1 3
4 5 2 3 1

output:

7ckgnn4wyi495puj3ibqf81dqvapyv6b
5
9
6
5

result:

ok 5 lines

Test #2:

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

input:

txy4h26c1rm1uv8tr3eonahd67u8h56x
4
7 1
0 1 0 2 4 0
3 6 5 2 4 1
10 1
0 0 0 0 2 1 3 3 6
5 9 6 4 7 2 3 8 1
7 1
0 0 2 0 2 2
3 5 6 2 1 4
6 1
0 0 1 2 0
3 4 2 1 5

output:

7ckgnn4wyi495puj3ibqf81dqvapyv6b
5
8
6
5

result:

ok 5 lines

Test #3:

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

input:

txy4h26c1rm1uv8tr3eonahd67u8h56x
4
7 1
0 0 1 3 4 5
6 2 5 4 3 1
10 1
0 0 2 3 4 4 6 7 8
5 9 1 8 7 6 3 4 2
7 1
0 1 1 3 4 4
2 6 5 4 3 1
6 1
0 1 2 2 3
3 5 4 1 2

output:

7ckgnn4wyi495puj3ibqf81dqvapyv6b
6
8
6
3

result:

ok 5 lines

Test #4:

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

input:

txy4h26c1rm1uv8tr3eonahd67u8h56x
4
7 1
0 0 1 2 4 4
6 5 4 1 3 2
10 1
0 1 2 3 4 5 6 7 7
8 9 7 5 6 2 4 3 1
7 1
0 1 2 2 4 5
3 6 4 5 1 2
6 1
0 0 1 2 4
5 4 2 3 1

output:

7ckgnn4wyi495puj3ibqf81dqvapyv6b
5
6
4
5

result:

ok 5 lines

Test #5:

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

input:

txy4h26c1rm1uv8tr3eonahd67u8h56x
4
7 1
0 1 0 2 0 4
5 3 6 4 1 2
10 1
0 1 0 3 4 1 1 1 2
9 6 7 5 4 3 8 2 1
7 1
0 0 2 0 4 5
6 3 1 2 5 4
6 1
0 0 1 3 1
5 3 1 2 4

output:

7ckgnn4wyi495puj3ibqf81dqvapyv6b
5
9
6
2

result:

ok 5 lines

Test #6:

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

input:

txy4h26c1rm1uv8tr3eonahd67u8h56x
4
7 1
0 1 2 2 2 5
6 4 5 3 1 2
10 1
0 0 1 0 1 2 4 4 4
7 9 6 5 3 2 4 1 8
7 1
0 1 1 0 2 5
6 4 2 5 3 1
6 1
0 0 2 2 1
3 5 4 2 1

output:

7ckgnn4wyi495puj3ibqf81dqvapyv6b
5
7
5
5

result:

ok 5 lines

Test #7:

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

input:

txy4h26c1rm1uv8tr3eonahd67u8h56x
4
7 1
0 0 2 2 3 4
1 5 6 3 4 2
10 1
0 0 2 3 3 4 6 7 7
8 1 9 5 6 7 4 3 2
7 1
0 0 1 2 4 4
6 3 5 1 4 2
6 1
0 0 2 2 3
3 1 5 4 2

output:

7ckgnn4wyi495puj3ibqf81dqvapyv6b
6
8
6
3

result:

ok 5 lines

Test #8:

score: 0
Accepted
time: 0ms
memory: 7632kb

input:

txy4h26c1rm1uv8tr3eonahd67u8h56x
4
7 1
0 0 1 2 4 5
6 3 5 1 2 4
10 1
0 0 2 2 3 4 5 6 8
9 7 8 6 5 4 1 3 2
7 1
0 1 1 2 3 5
4 6 2 3 5 1
6 1
0 0 2 3 3
5 4 1 3 2

output:

7ckgnn4wyi495puj3ibqf81dqvapyv6b
5
9
5
5

result:

ok 5 lines

Subtask #2:

score: 0
Wrong Answer

Dependency #1:

100%
Accepted

Test #9:

score: 0
Wrong Answer
time: 0ms
memory: 7624kb

input:

txy4h26c1rm1uv8tr3eonahd67u8h56x
4
7 5
0 0 2 2 3 1
4 5 6 3 1 2
4 5 6 1 3 2
4 5 6 3 1 2
4 5 6 3 1 2
4 5 6 3 1 2
10 5
0 1 1 2 4 5 0 2 0
9 6 5 7 8 4 3 1 2
9 6 7 5 4 8 1 2 3
6 9 7 5 4 8 2 1 3
6 9 7 5 4 2 1 8 3
6 9 7 5 4 2 1 8 3
7 5
0 0 0 3 1 4
6 5 4 1 3 2
5 6 1 4 3 2
5 6 1 3 4 2
5 1 6 4 2 3
5 1 4 2 6 3
...

output:

7ckgnn4wyi495puj3ibqf81dqvapyv6b
6
6
3
3

result:

wrong answer 2nd lines differ - expected: '5', found: '6'

Subtask #3:

score: 5
Accepted

Test #17:

score: 5
Accepted
time: 0ms
memory: 8008kb

input:

txy4h26c1rm1uv8tr3eonahd67u8h56x
53
10 1
0 1 2 3 4 5 6 7 8
9 8 7 6 5 4 3 2 1
10 1
0 1 2 3 4 5 6 7 8
9 7 8 5 6 4 3 2 1
10 1
0 1 2 3 4 5 6 7 8
8 9 7 5 6 3 2 4 1
10 1
0 1 2 3 4 5 6 7 8
8 9 6 7 5 4 3 2 1
10 1
0 1 2 3 4 5 6 7 8
8 9 7 5 6 3 4 2 1
10 1
0 1 2 3 4 5 6 7 8
9 8 7 6 5 4 2 3 1
10 1
0 1 2 3 4 5 6...

output:

7ckgnn4wyi495puj3ibqf81dqvapyv6b
9
7
5
7
6
8
6
8
7
6
4
5
8
6
9
7
7
6
8
7
30
29
24
20
22
59
567
58
33
25
30
37
34
7
3
8
4
8
7
6
4
5
7
6
6
8
4
6
5
7
6
9
6

result:

ok 54 lines

Test #18:

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

input:

txy4h26c1rm1uv8tr3eonahd67u8h56x
53
10 1
0 1 2 3 4 5 6 7 8
9 8 7 6 5 4 2 3 1
10 1
0 1 2 3 4 5 6 7 8
8 9 7 6 5 4 3 2 1
10 1
0 1 2 3 4 5 6 7 8
8 9 5 7 6 3 1 2 4
10 1
0 1 2 3 4 5 6 7 8
9 7 8 6 5 4 3 1 2
10 1
0 1 2 3 4 5 6 7 8
8 9 7 6 5 4 3 2 1
10 1
0 1 2 3 4 5 6 7 8
9 8 6 7 3 4 5 1 2
10 1
0 1 2 3 4 5 6...

output:

7ckgnn4wyi495puj3ibqf81dqvapyv6b
8
8
3
7
8
5
4
3
7
7
8
6
9
5
3
8
3
1
6
4
35
34
25
9
30
2
309
61
9
21
32
8
31
5
6
8
8
8
7
7
8
8
2
7
7
6
2
7
7
2
3
5
8

result:

ok 54 lines

Test #19:

score: 0
Accepted
time: 2ms
memory: 7928kb

input:

txy4h26c1rm1uv8tr3eonahd67u8h56x
53
10 1
0 1 2 3 4 5 6 7 8
9 8 7 6 5 4 2 3 1
10 1
0 1 2 3 4 5 6 7 8
9 7 6 8 4 3 2 1 5
10 1
0 1 2 3 4 5 6 7 8
9 8 7 6 5 4 3 2 1
10 1
0 1 2 3 4 5 6 7 8
9 8 6 7 5 3 4 2 1
10 1
0 1 2 3 4 5 6 7 8
9 7 8 5 6 4 3 2 1
10 1
0 1 2 3 4 5 6 7 8
9 8 7 6 5 4 3 2 1
10 1
0 1 2 3 4 5 6...

output:

7ckgnn4wyi495puj3ibqf81dqvapyv6b
8
3
9
7
7
9
6
4
5
6
5
7
6
8
7
7
6
7
7
5
19
23
33
38
27
75
833
80
21
30
34
17
30
6
3
7
7
6
8
5
4
9
7
7
7
8
4
8
6
6
8
8
8

result:

ok 54 lines

Test #20:

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

input:

txy4h26c1rm1uv8tr3eonahd67u8h56x
53
10 1
0 1 2 3 4 5 6 7 8
9 8 6 7 2 5 3 1 4
10 1
0 1 2 3 4 5 6 7 8
5 7 9 2 6 4 3 1 8
10 1
0 1 2 3 4 5 6 7 8
9 7 8 6 5 4 3 2 1
10 1
0 1 2 3 4 5 6 7 8
8 9 7 6 5 4 2 3 1
10 1
0 1 2 3 4 5 6 7 8
7 8 6 5 4 1 3 9 2
10 1
0 1 2 3 4 5 6 7 8
8 9 7 6 4 5 3 2 1
10 1
0 1 2 3 4 5 6...

output:

7ckgnn4wyi495puj3ibqf81dqvapyv6b
4
1
8
7
1
7
5
3
5
1
7
4
4
7
9
2
6
4
8
4
6
8
22
23
30
78
852
78
32
29
28
13
34
7
8
7
7
8
3
3
7
9
7
5
9
8
6
8
7
9
8
8
9

result:

ok 54 lines

Subtask #4:

score: 9
Accepted

Dependency #1:

100%
Accepted

Dependency #3:

100%
Accepted

Test #21:

score: 9
Accepted
time: 0ms
memory: 6164kb

input:

txy4h26c1rm1uv8tr3eonahd67u8h56x
53
10 1
0 0 1 0 4 2 6 4 5
8 9 5 7 3 4 1 6 2
10 1
0 1 2 0 3 1 6 5 2
4 9 8 5 7 3 6 2 1
10 1
0 0 2 0 0 4 6 0 6
8 7 5 1 2 3 9 6 4
10 1
0 1 2 2 2 1 3 0 4
8 5 6 7 4 3 9 2 1
10 1
0 0 0 0 3 5 6 0 5
1 9 4 8 7 2 6 3 5
10 1
0 1 2 1 0 1 3 5 1
4 7 6 3 8 5 2 9 1
10 1
0 0 2 2 3 0 3...

output:

7ckgnn4wyi495puj3ibqf81dqvapyv6b
9
9
8
7
8
9
9
9
9
9
8
7
8
9
9
9
9
5
8
9
38
38
38
38
37
89
998
99
39
38
38
39
37
8
9
5
6
9
9
8
9
9
8
9
8
5
7
8
8
9
9
8
9

result:

ok 54 lines

Test #22:

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

input:

txy4h26c1rm1uv8tr3eonahd67u8h56x
53
10 1
0 0 0 0 2 2 4 4 6
7 5 3 8 9 4 6 2 1
10 1
0 1 0 1 0 1 4 3 5
9 2 8 5 4 7 3 1 6
10 1
0 1 2 3 1 5 3 1 5
9 4 6 8 5 7 2 3 1
10 1
0 0 1 3 4 3 2 4 4
8 6 7 5 9 2 4 3 1
10 1
0 1 0 1 3 2 3 6 7
1 3 8 2 9 7 5 4 6
10 1
0 1 2 3 0 3 6 0 5
4 8 7 5 9 6 3 1 2
10 1
0 1 1 2 3 2 1...

output:

7ckgnn4wyi495puj3ibqf81dqvapyv6b
9
7
8
9
1
7
1
9
6
8
6
9
9
4
9
7
9
3
8
9
32
39
38
35
38
88
996
98
39
23
38
38
39
6
1
7
7
9
7
6
6
1
4
9
6
3
9
4
9
7
8
9
5

result:

ok 54 lines

Test #23:

score: 0
Accepted
time: 0ms
memory: 7900kb

input:

txy4h26c1rm1uv8tr3eonahd67u8h56x
53
10 1
0 1 1 3 4 4 5 7 7
2 8 6 9 7 4 5 1 3
10 1
0 1 1 2 3 4 5 6 8
5 7 3 9 8 4 2 6 1
10 1
0 1 2 3 3 5 6 7 7
9 4 8 7 6 5 2 3 1
10 1
0 0 2 2 3 4 6 7 8
1 5 9 8 7 6 3 4 2
10 1
0 0 2 2 4 5 6 6 8
3 9 1 7 8 6 5 4 2
10 1
0 0 1 3 3 4 6 6 7
2 9 8 5 7 4 6 3 1
10 1
0 0 2 3 4 5 6...

output:

7ckgnn4wyi495puj3ibqf81dqvapyv6b
7
6
8
9
9
8
7
6
9
8
6
8
7
7
6
7
7
8
9
9
35
34
36
32
32
95
957
93
30
32
30
34
36
4
7
7
8
6
8
8
7
9
8
7
8
8
9
8
9
8
8
8
8

result:

ok 54 lines

Test #24:

score: 0
Accepted
time: 0ms
memory: 7908kb

input:

txy4h26c1rm1uv8tr3eonahd67u8h56x
53
10 1
0 1 1 2 3 4 6 6 7
9 5 8 7 3 4 6 2 1
10 1
0 0 1 3 4 5 6 6 7
2 8 6 9 7 5 3 4 1
10 1
0 0 1 2 4 4 6 7 7
6 9 1 4 8 5 3 2 7
10 1
0 0 2 2 4 5 5 7 8
7 4 3 5 2 9 1 8 6
10 1
0 0 2 2 3 4 6 7 7
1 6 2 7 5 3 4 9 8
10 1
0 1 2 2 4 4 6 6 8
7 3 5 9 8 6 4 1 2
10 1
0 0 2 2 4 5 6...

output:

7ckgnn4wyi495puj3ibqf81dqvapyv6b
8
6
1
1
2
8
6
8
5
6
7
6
9
4
7
9
1
8
8
7
36
37
36
34
32
33
863
90
38
31
37
37
31
9
7
5
6
8
4
8
4
8
9
8
5
9
2
7
6
4
8
7
7

result:

ok 54 lines

Test #25:

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

input:

txy4h26c1rm1uv8tr3eonahd67u8h56x
53
10 1
0 0 2 1 3 5 5 4 1
6 7 5 8 2 3 9 1 4
10 1
0 1 0 3 0 2 6 5 5
9 7 8 6 2 5 4 1 3
10 1
0 0 1 2 2 1 1 6 3
8 9 5 7 6 3 4 2 1
10 1
0 0 1 3 4 2 0 5 5
8 7 6 2 5 4 3 9 1
10 1
0 0 1 3 2 1 0 5 7
9 7 8 6 3 4 1 5 2
10 1
0 0 0 0 2 5 0 0 7
6 3 9 8 1 5 4 2 7
10 1
0 0 0 0 2 0 6...

output:

7ckgnn4wyi495puj3ibqf81dqvapyv6b
7
9
9
6
8
9
9
8
9
8
8
9
9
9
9
7
9
8
9
9
36
38
37
39
37
93
998
97
38
38
39
39
39
8
9
9
7
8
9
6
5
7
9
8
8
9
9
8
9
8
8
9
8

result:

ok 54 lines

Test #26:

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

input:

txy4h26c1rm1uv8tr3eonahd67u8h56x
53
10 1
0 0 0 1 1 1 4 2 3
5 7 9 3 8 4 2 1 6
10 1
0 0 1 1 1 1 3 2 6
7 1 4 9 6 3 2 5 8
10 1
0 0 2 2 2 2 3 0 7
1 6 4 9 8 7 3 5 2
10 1
0 0 2 1 3 5 6 6 1
4 6 8 7 9 5 3 1 2
10 1
0 0 1 3 3 1 1 2 1
6 5 4 7 8 9 3 1 2
10 1
0 1 0 1 4 5 3 2 7
9 8 2 7 6 4 5 3 1
10 1
0 1 1 1 3 4 3...

output:

7ckgnn4wyi495puj3ibqf81dqvapyv6b
8
2
9
7
9
8
9
6
9
8
8
9
9
9
3
6
9
9
9
7
39
27
36
36
36
99
37
97
38
36
36
36
26
9
9
8
9
8
9
8
7
9
5
8
7
9
6
7
9
7
9
8
2

result:

ok 54 lines

Test #27:

score: 0
Accepted
time: 2ms
memory: 7948kb

input:

txy4h26c1rm1uv8tr3eonahd67u8h56x
53
10 1
0 1 1 3 4 4 6 6 7
5 8 7 9 6 4 3 2 1
10 1
0 1 2 3 4 4 5 7 7
8 6 9 7 4 5 3 2 1
10 1
0 1 2 3 3 4 6 7 7
5 9 7 6 4 3 8 1 2
10 1
0 1 1 3 4 5 5 7 7
2 8 6 9 5 7 4 3 1
10 1
0 0 2 2 3 5 6 6 8
4 1 7 9 8 6 5 3 2
10 1
0 1 1 3 4 5 6 6 8
7 9 2 8 6 5 3 4 1
10 1
0 0 1 3 3 4 6...

output:

7ckgnn4wyi495puj3ibqf81dqvapyv6b
8
8
4
8
9
8
7
9
7
9
5
9
5
7
8
9
9
9
7
9
37
38
36
33
32
86
917
82
36
37
38
35
37
7
9
8
9
9
9
6
8
7
5
7
8
7
7
8
7
6
9
8
6

result:

ok 54 lines

Test #28:

score: 0
Accepted
time: 2ms
memory: 8200kb

input:

txy4h26c1rm1uv8tr3eonahd67u8h56x
53
10 1
0 0 2 3 4 4 5 7 8
1 9 6 8 5 7 3 4 2
10 1
0 0 2 3 4 4 6 7 8
1 9 5 8 7 4 6 3 2
10 1
0 0 1 3 3 5 5 7 8
6 2 9 7 8 5 3 4 1
10 1
0 1 2 2 3 4 5 6 7
7 9 8 6 4 5 3 2 1
10 1
0 0 1 3 4 5 6 6 8
2 7 9 8 6 5 4 3 1
10 1
0 1 1 2 4 4 5 7 7
6 9 8 3 7 5 4 2 1
10 1
0 0 1 2 4 4 6...

output:

7ckgnn4wyi495puj3ibqf81dqvapyv6b
7
8
7
8
9
9
3
8
9
9
8
8
9
8
5
4
8
9
6
6
21
35
37
36
27
47
900
94
20
1
35
29
25
1
7
9
4
6
8
9
9
7
6
6
5
6
8
7
6
4
2
8
8

result:

ok 54 lines

Subtask #5:

score: 5
Accepted

Dependency #3:

100%
Accepted

Test #29:

score: 5
Accepted
time: 2ms
memory: 6224kb

input:

txy4h26c1rm1uv8tr3eonahd67u8h56x
53
10 5
0 1 2 3 4 5 6 7 8
9 7 6 8 5 3 4 1 2
9 7 6 8 5 4 3 1 2
9 7 6 8 5 3 4 1 2
9 6 8 7 5 3 4 2 1
9 6 8 7 5 4 3 2 1
10 5
0 1 2 3 4 5 6 7 8
9 8 7 6 5 4 3 2 1
9 8 7 5 4 6 3 1 2
9 8 7 5 6 4 3 2 1
9 8 7 5 6 4 3 1 2
9 8 7 6 4 5 3 2 1
10 5
0 1 2 3 4 5 6 7 8
8 9 7 5 6 4 2 3...

output:

7ckgnn4wyi495puj3ibqf81dqvapyv6b
5
6
4
5
5
7
7
6
1
6
4
4
4
5
6
5
5
5
2
5
2
30
25
31
2
71
619
33
29
15
27
21
23
6
6
4
7
8
3
6
4
4
4
7
4
2
5
4
1
7
7
5
6

result:

ok 54 lines

Test #30:

score: 0
Accepted
time: 2ms
memory: 8024kb

input:

txy4h26c1rm1uv8tr3eonahd67u8h56x
53
10 5
0 1 2 3 4 5 6 7 8
9 8 7 6 5 4 3 1 2
9 8 6 7 5 4 3 2 1
9 8 7 6 4 5 3 1 2
9 8 6 7 4 5 3 1 2
9 8 6 7 4 5 3 1 2
10 5
0 1 2 3 4 5 6 7 8
9 7 6 8 5 4 3 2 1
8 9 7 6 5 4 3 1 2
8 7 6 9 5 4 3 1 2
7 8 6 9 5 4 3 1 2
8 7 9 6 5 4 3 1 2
10 5
0 1 2 3 4 5 6 7 8
8 9 7 5 6 4 3 1...

output:

7ckgnn4wyi495puj3ibqf81dqvapyv6b
6
5
4
1
1
3
6
3
4
5
2
7
7
2
2
9
5
6
6
1
23
18
8
30
26
68
684
24
26
28
16
31
24
7
8
7
5
5
2
9
2
3
2
3
7
4
7
2
6
3
4
2
5

result:

ok 54 lines

Test #31:

score: 0
Accepted
time: 2ms
memory: 8032kb

input:

txy4h26c1rm1uv8tr3eonahd67u8h56x
53
10 5
0 1 2 3 4 5 6 7 8
9 8 7 6 5 4 2 3 1
8 9 7 6 4 5 3 2 1
8 9 7 6 5 4 3 2 1
9 8 7 6 5 4 3 2 1
9 8 7 6 4 5 2 3 1
10 5
0 1 2 3 4 5 6 7 8
9 8 7 6 5 4 3 1 2
8 7 9 5 6 4 3 2 1
7 8 9 5 6 4 3 2 1
7 8 9 6 5 4 3 2 1
8 7 9 5 6 4 3 2 1
10 5
0 1 2 3 4 5 6 7 8
9 8 7 5 6 4 2 1...

output:

7ckgnn4wyi495puj3ibqf81dqvapyv6b
6
5
3
8
4
1
5
2
6
7
4
1
2
3
5
6
4
6
2
5
27
7
14
26
29
68
721
69
29
28
20
18
20
6
6
6
6
5
1
8
6
5
2
8
5
4
2
7
8
6
4
5
3

result:

ok 54 lines

Test #32:

score: 0
Accepted
time: 0ms
memory: 8028kb

input:

txy4h26c1rm1uv8tr3eonahd67u8h56x
53
10 5
0 1 2 3 4 5 6 7 8
9 8 7 5 6 4 3 1 2
9 8 5 6 7 4 3 2 1
9 5 7 6 8 4 3 2 1
9 6 8 5 7 4 3 2 1
9 6 8 5 7 4 3 1 2
10 5
0 1 2 3 4 5 6 7 8
7 8 6 5 4 1 3 9 2
8 4 3 5 2 9 6 1 7
8 3 1 7 6 9 2 4 5
8 2 1 4 7 5 6 3 9
1 3 2 8 9 5 7 4 6
10 5
0 1 2 3 4 5 6 7 8
9 8 7 6 5 4 3 2...

output:

7ckgnn4wyi495puj3ibqf81dqvapyv6b
5
1
9
6
6
2
6
2
4
7
5
6
6
4
3
3
7
5
6
7
3
9
7
8
5
51
698
47
6
6
10
28
24
5
1
5
4
6
3
3
2
6
3
6
1
7
5
3
6
4
4
1
5

result:

ok 54 lines

Subtask #6:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%

Subtask #7:

score: 0
Memory Limit Exceeded

Dependency #3:

100%
Accepted

Test #41:

score: 0
Memory Limit Exceeded

input:

txy4h26c1rm1uv8tr3eonahd67u8h56x
2225
50 1
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
49 48 47 45 46 43 44 42 41 40 39 38 37 35 36 34 32 33 31 30 28 29 26 27 25 23 24 22 20 21 18 17 19 16 15 14 13 12 11 10 ...

output:

7ckgnn4wyi495puj3ibqf81dqvapyv6b
37
42
32
34
38
33
30
42
43
29
28
29
42
37
42
30
30
30
29
30
35
34
29
33
28
37
41
29
35
35
32
40
45
36
30
31
38
42
42
34
37
23
33
43
36
37
36
20
33
30
38
41
38
38
32
39
42
31
34
30
32
41
40
30
23
40
40
45
41
37
40
36
42
33
27
34
35
36
32
31
34
37
36
39
46
42
42
39
25
...

result:


Subtask #8:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #4:

100%
Accepted

Dependency #7:

0%

Subtask #9:

score: 0
Skipped

Dependency #3:

100%
Accepted

Dependency #5:

100%
Accepted

Dependency #7:

0%

Subtask #10:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%