QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#604954#8724. Septemberliuziao#55 129ms6152kbC++231.7kb2024-10-02 14:45:352024-10-02 14:45:36

Judging History

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

  • [2024-10-02 14:45:36]
  • 评测
  • 测评结果:55
  • 用时:129ms
  • 内存:6152kb
  • [2024-10-02 14:45:35]
  • 提交

answer

#include "september.h"
#include <bits/stdc++.h>

#ifdef ORZXKR
#include "stub.cpp"
#endif

const int kMaxN = 1e5 + 5;

int n, m, cnt;
int p[kMaxN], dfn[kMaxN], sz[kMaxN];
bool del[kMaxN];
std::vector<int> G[kMaxN];

void dfs(int u) {
  dfn[u] = ++cnt, sz[u] = 1;
  for (auto v : G[u]) {
    dfs(v);
    sz[u] += sz[v];
  }
}

bool check(std::vector<int> &vec) {
  static int cnt[kMaxN];
  std::fill_n(cnt + 1, n, 0);
  for (auto x : vec) ++cnt[dfn[x]];
  for (int i = 1; i <= n; ++i) cnt[i] += cnt[i - 1];
  for (auto x : vec) {
    assert(sz[x]);
    if (cnt[dfn[x] + sz[x] - 1] - cnt[dfn[x] - 1] != sz[x])
      return 0;
  }
  return 1;
}

bool check(std::vector<std::vector<int>> &vec) {
  for (auto &v : vec) {
    if (!check(v)) return 0;
  }
  return 1;
}

bool equal(std::vector<int> v1, std::vector<int> v2) {
  if (v1.size() != v2.size()) return 0;
  std::sort(v1.begin(), v1.end());
  std::sort(v2.begin(), v2.end());
  for (int i = 0; i < (int)v1.size(); ++i)
    if (v1[i] != v2[i])
      return 0;
  return 1;
}

int solve(int N, int M, std::vector<int> F, std::vector<std::vector<int>> S) {
  ::n = N, ::m = M, cnt = 0;
  for (int i = 1; i <= n; ++i) G[i].clear();
  for (int i = 1; i <= n; ++i) {
    p[i] = F[i - 1] + 1;
    if (p[i]) G[p[i]].emplace_back(i);
  }
  dfs(1);
  for (auto &vec : S) {
    for (auto &x : vec) ++x;
  }
  std::fill_n(del + 1, n, 0);
  int ans = 0;
  std::vector<std::vector<int>> now;
  now.resize(m);
  for (int i = 0; i < n - 1; ++i) {
    for (int j = 0; j < m; ++j) {
      now[j].emplace_back(S[j][i]);
    }
    bool fl = 1;
    for (int j = 0; j + 1 < m; ++j) fl &= equal(now[j], now[j + 1]);
    if (fl && check(now)) ++ans;
  }
  return ans;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 11
Accepted

Test #1:

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

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: 11
Accepted
time: 2ms
memory: 5904kb

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: 11
Accepted
time: 0ms
memory: 5676kb

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: 11
Accepted
time: 2ms
memory: 5708kb

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: 11
Accepted
time: 2ms
memory: 5656kb

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: 11
Accepted
time: 2ms
memory: 5916kb

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: 11
Accepted
time: 1ms
memory: 5676kb

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: 11
Accepted
time: 0ms
memory: 5584kb

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: 14
Accepted

Dependency #1:

100%
Accepted

Test #9:

score: 14
Accepted
time: 0ms
memory: 5908kb

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
5
3
1
1

result:

ok 5 lines

Test #10:

score: 14
Accepted
time: 2ms
memory: 5872kb

input:

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

output:

7ckgnn4wyi495puj3ibqf81dqvapyv6b
3
4
3
2

result:

ok 5 lines

Test #11:

score: 14
Accepted
time: 1ms
memory: 5876kb

input:

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

output:

7ckgnn4wyi495puj3ibqf81dqvapyv6b
4
1
2
1

result:

ok 5 lines

Test #12:

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

input:

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

output:

7ckgnn4wyi495puj3ibqf81dqvapyv6b
4
8
5
5

result:

ok 5 lines

Test #13:

score: 14
Accepted
time: 1ms
memory: 5844kb

input:

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

output:

7ckgnn4wyi495puj3ibqf81dqvapyv6b
3
5
2
4

result:

ok 5 lines

Test #14:

score: 14
Accepted
time: 1ms
memory: 3576kb

input:

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

output:

7ckgnn4wyi495puj3ibqf81dqvapyv6b
5
4
2
4

result:

ok 5 lines

Test #15:

score: 14
Accepted
time: 1ms
memory: 5716kb

input:

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

output:

7ckgnn4wyi495puj3ibqf81dqvapyv6b
4
6
1
3

result:

ok 5 lines

Test #16:

score: 14
Accepted
time: 1ms
memory: 5680kb

input:

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

output:

7ckgnn4wyi495puj3ibqf81dqvapyv6b
1
3
4
1

result:

ok 5 lines

Subtask #3:

score: 5
Accepted

Test #17:

score: 5
Accepted
time: 4ms
memory: 5836kb

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: 5
Accepted
time: 3ms
memory: 5784kb

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: 5
Accepted
time: 3ms
memory: 5820kb

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: 5
Accepted
time: 0ms
memory: 6044kb

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: 5728kb

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: 9
Accepted
time: 3ms
memory: 3960kb

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: 9
Accepted
time: 2ms
memory: 3676kb

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: 9
Accepted
time: 0ms
memory: 5740kb

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: 9
Accepted
time: 2ms
memory: 5756kb

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: 9
Accepted
time: 0ms
memory: 5772kb

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: 9
Accepted
time: 3ms
memory: 5700kb

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: 9
Accepted
time: 3ms
memory: 5752kb

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: 32ms
memory: 5872kb

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: 5
Accepted
time: 27ms
memory: 5980kb

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: 5
Accepted
time: 30ms
memory: 5936kb

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: 5
Accepted
time: 32ms
memory: 5908kb

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: 11
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #4:

100%
Accepted

Dependency #5:

100%
Accepted

Test #33:

score: 11
Accepted
time: 129ms
memory: 5892kb

input:

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

output:

7ckgnn4wyi495puj3ibqf81dqvapyv6b
9
6
6
3
2
6
6
6
6
4
5
6
7
3
1
3
2
4
6
7
26
21
32
7
9
7
592
16
10
21
16
14
26
4
6
1
5
6
7
4
6
2
7
1
3
9
6
1
2
6
5
4
2

result:

ok 54 lines

Test #34:

score: 11
Accepted
time: 124ms
memory: 6064kb

input:

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

output:

7ckgnn4wyi495puj3ibqf81dqvapyv6b
3
2
5
6
2
7
4
7
1
2
2
4
3
8
1
7
2
3
6
7
21
21
31
24
22
70
725
56
17
23
22
27
21
3
7
8
5
1
5
5
5
7
2
8
3
4
3
7
4
6
2
1
3

result:

ok 54 lines

Test #35:

score: 11
Accepted
time: 121ms
memory: 3808kb

input:

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

output:

7ckgnn4wyi495puj3ibqf81dqvapyv6b
6
6
4
5
6
6
3
8
4
3
8
2
6
3
5
7
4
4
5
6
13
7
32
32
20
9
582
27
30
25
9
27
18
2
2
7
7
7
2
5
4
6
1
6
5
6
7
3
3
6
2
5
4

result:

ok 54 lines

Test #36:

score: 11
Accepted
time: 119ms
memory: 5960kb

input:

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

output:

7ckgnn4wyi495puj3ibqf81dqvapyv6b
5
7
7
1
7
4
8
6
3
6
2
3
3
4
3
6
2
3
1
6
4
18
8
8
28
1
297
48
27
31
29
23
24
7
4
1
3
5
2
2
5
8
3
5
1
2
8
4
4
5
2
6
4

result:

ok 54 lines

Test #37:

score: 11
Accepted
time: 119ms
memory: 5880kb

input:

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

output:

7ckgnn4wyi495puj3ibqf81dqvapyv6b
4
6
5
5
4
3
8
4
5
7
5
6
5
8
9
2
5
7
2
5
19
24
3
13
18
54
739
41
18
12
16
19
19
6
1
2
5
8
6
3
2
6
7
3
4
4
1
6
5
3
1
2
3

result:

ok 54 lines

Test #38:

score: 11
Accepted
time: 122ms
memory: 5880kb

input:

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

output:

7ckgnn4wyi495puj3ibqf81dqvapyv6b
7
6
7
7
5
3
5
4
6
5
4
5
2
7
8
6
2
4
5
8
11
3
14
27
10
34
674
6
17
8
13
13
5
4
4
6
5
6
6
4
7
1
3
1
7
3
7
7
4
1
7
8
1

result:

ok 54 lines

Test #39:

score: 11
Accepted
time: 116ms
memory: 6152kb

input:

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

output:

7ckgnn4wyi495puj3ibqf81dqvapyv6b
8
8
9
6
5
4
8
8
5
7
3
7
3
7
2
2
8
4
7
2
7
17
18
12
29
71
432
43
31
11
14
20
23
2
4
4
2
2
7
6
4
2
5
3
5
5
4
5
2
7
6
1
6

result:

ok 54 lines

Test #40:

score: 11
Accepted
time: 121ms
memory: 3864kb

input:

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

output:

7ckgnn4wyi495puj3ibqf81dqvapyv6b
6
2
6
8
2
2
2
5
8
4
6
5
4
3
3
7
7
2
2
1
17
28
19
8
16
69
586
77
13
3
22
27
17
2
6
2
6
5
6
3
6
2
5
3
4
2
7
5
5
8
7
7
2

result:

ok 54 lines

Subtask #7:

score: 0
Time Limit Exceeded

Dependency #3:

100%
Accepted

Test #41:

score: 0
Time 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:


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:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #4:

100%
Accepted

Dependency #5:

100%
Accepted

Dependency #6:

100%
Accepted

Dependency #7:

0%