QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#318691#5446. 琪露诺的符卡交换KHIN100 ✓11ms4892kbC++172.4kb2024-01-31 17:06:302024-01-31 17:06:30

Judging History

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

  • [2024-01-31 17:06:30]
  • 评测
  • 测评结果:100
  • 用时:11ms
  • 内存:4892kb
  • [2024-01-31 17:06:30]
  • 提交

answer

# include <bits/stdc++.h>

using namespace std;

namespace kh {
  template <typename T>
    inline T get() {
      T tmp;
      cin >> tmp;
      return tmp;
    }
  constexpr int N(200);
  int n;
  int pl[N * N];
  int pr[N * N];
  pair<int, int> info[N * N];
  int il[N + 1][N + 1];
  int ir[N + 1][N + 1];
  void sel(int, int, int);
  void ser(int, int, int);
  void sel(int x, int s, int t) {
    // cerr << __func__ << ' ' << x << ' ' << s << ' ' << t << '\n';
    if (s == t) return;
    if (~il[x][s]) ser(pr[il[x][s]], t, s);
    swap(il[x][s], il[x][t]);
  }
  void ser(int y, int s, int t) {
    // cerr << __func__ << ' ' << y << ' ' << s << ' ' << t << '\n';
    if (s == t) return;
    if (~ir[y][s]) sel(pl[ir[y][s]], t, s);
    swap(ir[y][s], ir[y][t]);
  }
  void debug() {
    vector<int> col(n * n);
    for (int i(1); i <= n; ++i)
      for (int j(1); j <= n; ++j)
        if (~il[i][j]) col[il[i][j]] = j;
    for (int i(1); i <= n; ++i)
      for (int j(1); j <= n; ++j)
        if (~ir[i][j]) assert(col[ir[i][j]] == j);
    for (int i(0); i != n * n; ++i)
      cerr << pl[i] << ' ' << pr[i] << ' ' << col[i] << '\n';
  }
  void prec0() {
    cin >> n;
    vector<int> dl(n + 1);
    vector<int> dr(n + 1);
    int id(0);
    for (int i(1); i <= n; ++i)
      for (int j(1); j <= n; ++j) {
        pl[id] = i, cin >> pr[id];
        info[id++] = make_pair(i, j);
      }
  }
  void prec1() {
    memset(il, 0xff, sizeof il);
    memset(ir, 0xff, sizeof ir);
    for (int i(0); i != n * n; ++i) {
      int const x(pl[i]), y(pr[i]);
      int const c(find(il[x] + 1, il[x] + n + 1, ~0) - il[x]);
      for (int j(1); j <= n; ++j) if (!~ir[y][j]) {
        sel(x, j, c), assert(!~il[x][j]);
        il[x][j] = ir[y][j] = i;
        break;
      }
      // cerr << __func__ << ' ' << __LINE__ << '\n';
      // debug();
    }
  }
  void prec2() {
    vector<tuple<int, int, int, int>> ans;
    for (int i(1); i <= n; ++i) for (int j(1); j != i; ++j)
      ans.emplace_back(tuple_cat(info[il[i][j]], info[il[j][i]]));
    cout << ans.size() << '\n';
    for (auto const& [a, b, c, d] : ans)
      cout << a << ' ' << b << ' ' << c << ' ' << d << '\n';
  }
  void test() { prec0(), prec1(), prec2(); }
  void main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int const t(get<int>());
    for (int i(1); i <= t; ++i) test();
  }
}

int main() { kh::main(); }

这程序好像有点Bug,我给组数据试试?

详细

Subtask #1:

score: 20
Accepted

Test #1:

score: 20
Accepted
time: 4ms
memory: 4340kb

input:

7
132
96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 ...

output:

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

result:

ok your solution is correct.

Test #2:

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

input:

8
14
13 13 13 13 13 13 13 13 13 13 13 13 13 13
7 7 7 7 7 7 7 7 7 7 7 7 7 7
8 8 8 8 8 8 8 8 8 8 8 8 8 8
14 14 14 14 14 14 14 14 14 14 14 14 14 14
5 5 5 5 5 5 5 5 5 5 5 5 5 5
4 4 4 4 4 4 4 4 4 4 4 4 4 4
1 1 1 1 1 1 1 1 1 1 1 1 1 1
10 10 10 10 10 10 10 10 10 10 10 10 10 10
2 2 2 2 2 2 2 2 2 2 2 2 2 2
9...

output:

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

result:

ok your solution is correct.

Test #3:

score: 0
Accepted
time: 3ms
memory: 4092kb

input:

4
82
20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 1...

output:

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

result:

ok your solution is correct.

Test #4:

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

input:

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

output:

3
2 1 1 2
3 1 1 3
3 2 2 3
3
2 1 1 2
3 1 1 3
3 2 2 3
0
55
2 1 1 2
3 1 1 3
3 2 2 3
4 1 1 4
4 2 2 4
4 3 3 4
5 1 1 5
5 2 2 5
5 3 3 5
5 4 4 5
6 1 1 6
6 2 2 6
6 3 3 6
6 4 4 6
6 5 5 6
7 1 1 7
7 2 2 7
7 3 3 7
7 4 4 7
7 5 5 7
7 6 6 7
8 1 1 8
8 2 2 8
8 3 3 8
8 4 4 8
8 5 5 8
8 6 6 8
8 7 7 8
9 1 1 9
9 2 2 9
9 3...

result:

ok your solution is correct.

Subtask #2:

score: 20
Accepted

Dependency #1:

100%
Accepted

Test #5:

score: 20
Accepted
time: 4ms
memory: 4412kb

input:

5
17
9 9 9 9 9 9 9 9 9 9 9 9 9 2 9 9 9
5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 6
2 2 2 2 2 2 2 2 2 2 2 2 11 2 2 2 2
4 4 4 4 4 4 10 4 4 4 4 4 4 4 4 4 4
10 10 10 10 10 10 8 10 10 10 10 10 10 10 10 10 10
12 12 12 12 12 12 12 12 12 12 12 12 14 12 12 12 12
14 14 14 14 14 14 14 14 14 14 14 12 14 14 14 14 14
16 16...

output:

136
2 4 1 2
3 14 1 3
3 2 2 3
4 8 1 4
4 2 2 5
4 3 3 4
5 8 1 5
5 2 2 6
5 3 3 5
5 4 4 5
6 14 1 6
6 2 2 7
6 3 3 6
6 4 4 6
6 5 5 6
7 1 1 7
7 2 2 8
7 3 3 7
7 4 4 1
7 5 5 1
7 6 6 7
8 4 1 8
8 2 2 9
8 1 3 8
8 5 4 9
8 6 5 9
8 7 6 8
8 8 7 8
9 1 1 9
9 3 2 10
9 4 3 9
9 5 4 10
9 6 5 10
9 7 6 9
9 8 7 9
9 9 8 10
10...

result:

ok your solution is correct.

Test #6:

score: 0
Accepted
time: 4ms
memory: 4524kb

input:

9
1
1
28
2 2 2 2 5 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
7 24 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 8 13 13 13
8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 16 8 8 8 8 8 8 8 8 8 8 8 8
17 24 24 24 24 24 24 24 24 24 24 24 24...

output:

0
378
2 3 1 2
3 26 1 3
3 2 2 4
4 17 1 4
4 2 2 5
4 3 3 4
5 2 1 1
5 3 2 6
5 4 3 5
5 5 4 5
6 1 1 7
6 2 2 7
6 3 3 6
6 4 4 6
6 5 5 7
7 2 1 8
7 3 2 8
7 4 3 7
7 5 4 7
7 6 5 8
7 7 6 7
8 1 1 9
8 2 2 9
8 3 3 8
8 4 4 8
8 5 5 9
8 6 6 8
8 7 7 9
9 1 1 10
9 2 2 10
9 4 3 9
9 5 4 9
9 6 5 10
9 7 6 10
9 8 7 10
9 9 8 9...

result:

ok your solution is correct.

Test #7:

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

input:

9
22
19 19 19 19 19 19 19 19 19 10 19 19 19 19 19 19 19 19 19 19 19 19
17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 8
21 21 21 21 21 21 21 21 5 21 21 21 21 21 21 21 21 21 21 21 21 21
12 12 12 12 12 12 12 22 12 12 12 12 12 12 12 12 12 12 12 12 12 12
3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3...

output:

231
2 14 1 2
3 10 1 3
3 2 2 3
4 9 1 4
4 2 2 4
4 3 3 4
5 22 1 5
5 2 2 5
5 3 3 5
5 4 4 5
6 4 1 6
6 2 2 6
6 1 3 6
6 5 4 6
6 6 5 6
7 3 1 7
7 1 2 7
7 4 3 7
7 5 4 7
7 6 5 7
7 7 6 8
8 1 1 8
8 2 2 8
8 3 3 8
8 4 4 1
8 5 5 8
8 6 6 9
8 7 7 9
9 1 1 9
9 2 2 9
9 3 3 1
9 4 4 10
9 5 5 9
9 6 6 10
9 7 7 10
9 8 8 9
10...

result:

ok your solution is correct.

Test #8:

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

input:

8
29
3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 6 3 3 3 3
11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 3 11 11 11 11 11 11 11 11
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 23 1 1 1 1 1 1 1
20 20 20 20 20 20 20 20 20 20 20 25 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
26 26...

output:

406
2 1 1 2
3 23 1 3
3 2 2 3
4 25 1 4
4 2 2 4
4 3 3 4
5 25 1 5
5 2 2 5
5 3 3 5
5 4 4 5
6 8 1 6
6 2 2 6
6 3 3 6
6 4 4 6
6 5 5 6
7 1 1 7
7 2 2 7
7 3 3 7
7 4 4 7
7 5 5 7
7 6 6 1
8 10 1 8
8 2 2 8
8 3 3 8
8 4 4 8
8 5 5 8
8 6 6 9
8 7 7 8
9 24 1 9
9 2 2 9
9 3 3 9
9 4 4 9
9 5 5 9
9 6 6 10
9 7 7 9
9 8 8 1
10...

result:

ok your solution is correct.

Subtask #3:

score: 60
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Test #9:

score: 60
Accepted
time: 1ms
memory: 4156kb

input:

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

output:

0
1
2 1 1 1
3
2 3 1 1
3 1 1 3
3 3 2 2
6
2 2 1 1
3 4 1 2
3 1 2 1
4 3 1 3
4 1 2 4
4 4 3 3
10
2 2 1 1
3 4 1 2
3 1 2 1
4 5 1 3
4 4 2 3
4 2 3 3
5 3 1 4
5 1 2 4
5 4 3 5
5 5 4 3
15
2 3 1 3
3 4 1 1
3 6 2 1
4 6 1 2
4 1 2 6
4 2 3 3
5 5 1 4
5 3 2 4
5 4 3 5
5 6 4 4
6 6 1 5
6 2 2 5
6 3 3 2
6 4 4 5
6 1 5 1
21
2 2...

result:

ok your solution is correct.

Test #10:

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

input:

19
1
1
2
2 1
1 2
3
2 1 2
3 3 3
1 2 1
4
1 2 3 4
1 2 3 4
2 3 1 4
4 1 2 3
5
1 2 3 3 3
4 4 1 2 3
5 2 4 5 1
1 4 5 5 2
5 2 1 4 3
6
1 3 6 6 4 4
5 2 4 6 5 2
3 6 5 6 5 2
1 5 1 4 2 4
3 1 6 3 3 2
3 2 1 4 5 1
7
4 4 1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3 1
6 5 4 2
6 6 5 5
21
2 7...

result:

ok your solution is correct.

Test #12:

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

input:

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

output:

0
1
2 1 1 2
3
2 3 1 2
3 2 1 3
3 1 2 2
6
2 3 1 4
3 1 1 1
3 2 2 4
4 1 1 3
4 3 2 2
4 4 3 4
10
2 5 1 3
3 5 1 4
3 3 2 3
4 2 1 2
4 4 2 2
4 5 3 2
5 4 1 5
5 3 2 4
5 1 3 4
5 5 4 1
15
2 4 1 4
3 4 1 3
3 5 2 6
4 5 1 5
4 2 2 2
4 6 3 1
5 4 1 6
5 1 2 1
5 2 3 6
5 5 4 1
6 2 1 2
6 1 2 3
6 3 3 3
6 4 4 3
6 6 5 6
21
2 6...

result:

ok your solution is correct.

Test #13:

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

input:

5
156
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 95 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 34 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 14 17 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 130 1 42 1 1 1 1 1 1 1 1 1 1 1 1 90 1 64 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

12090
2 127 1 2
3 105 1 3
3 2 2 1
4 98 1 4
4 2 2 5
4 3 3 4
5 9 1 5
5 2 2 8
5 3 3 5
5 4 4 5
6 46 1 6
6 2 2 4
6 3 3 6
6 4 4 6
6 5 5 6
7 75 1 7
7 2 2 9
7 3 3 7
7 4 4 7
7 5 5 1
7 6 6 7
8 1 1 8
8 51 2 10
8 3 3 8
8 4 4 8
8 5 5 10
8 6 6 8
8 7 7 8
9 65 1 9
9 101 2 11
9 3 3 9
9 4 4 9
9 5 5 11
9 6 6 9
9 7 7 9...

result:

ok your solution is correct.

Test #14:

score: 0
Accepted
time: 4ms
memory: 4308kb

input:

7
2
1 2
1 2
4
1 4 4 1
2 3 2 4
1 4 3 3
3 1 2 2
39
1 31 38 1 22 35 1 32 36 19 33 1 1 1 4 14 24 35 33 4 1 31 34 1 1 27 1 1 34 8 35 1 1 38 10 1 6 8 10
22 14 2 2 2 20 9 26 2 8 26 23 2 36 36 2 38 2 2 18 27 29 3 28 2 3 31 33 36 2 20 2 11 33 32 2 2 2 32
34 39 11 34 35 3 3 3 16 3 3 3 34 39 3 27 17 30 33 11 3...

output:

1
2 1 1 1
6
2 4 1 3
3 3 1 1
3 4 2 2
4 3 1 2
4 2 2 3
4 4 3 1
741
2 31 1 24
3 5 1 4
3 14 2 16
4 4 1 5
4 3 2 14
4 21 3 22
5 31 1 12
5 10 2 1
5 8 3 16
5 25 4 2
6 31 1 39
6 8 2 25
6 3 3 4
6 11 4 5
6 18 5 33
7 10 1 28
7 33 2 4
7 21 3 7
7 20 4 18
7 6 5 24
7 30 6 36
8 20 1 7
8 12 2 20
8 2 3 3
8 30 4 25
8 1 ...

result:

ok your solution is correct.

Test #15:

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

input:

7
9
3 8 8 5 7 7 2 5 2
5 9 4 9 8 3 5 7 5
1 2 6 6 9 3 9 6 4
7 6 9 1 7 7 1 4 7
2 7 6 3 8 1 2 9 8
3 8 2 2 4 6 1 6 1
1 5 2 6 4 8 4 6 4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3
8 6 5 6
8 4 6 3
8 5 7 6
15
2 6 1 6
3 5 1 1
3 4 2 4
4 4 1 3
4 6 2 2
4 2 3 2
5 6 1 5
5 1 2 3
5 4 3 ...

result:

ok your solution is correct.

Test #17:

score: 0
Accepted
time: 11ms
memory: 4732kb

input:

1
200
10 98 86 3 124 117 19 6 74 143 48 196 32 33 15 5 23 56 138 65 150 46 125 157 43 162 48 141 161 93 179 175 163 1 144 183 105 65 158 195 102 112 69 194 142 177 182 135 60 77 140 117 47 171 5 157 14 115 17 163 130 55 134 74 10 108 117 181 75 154 14 138 106 60 127 25 162 196 172 156 66 41 20 127 1...

output:

19900
2 174 1 71
3 94 1 157
3 141 2 18
4 124 1 3
4 35 2 167
4 53 3 165
5 18 1 53
5 110 2 53
5 98 3 66
5 94 4 61
6 123 1 173
6 30 2 72
6 172 3 155
6 25 4 80
6 105 5 14
7 132 1 7
7 159 2 67
7 124 3 25
7 148 4 43
7 194 5 26
7 127 6 146
8 107 1 38
8 19 2 124
8 142 3 163
8 95 4 150
8 176 5 158
8 193 6 16...

result:

ok your solution is correct.

Test #18:

score: 0
Accepted
time: 7ms
memory: 4684kb

input:

1
200
42 73 47 35 98 195 170 82 124 40 112 112 80 136 155 167 74 76 68 175 89 120 162 78 36 65 58 93 75 42 173 84 148 52 29 59 10 32 34 87 101 176 48 36 139 197 170 149 77 157 122 68 96 95 190 130 97 125 36 4 107 61 174 121 48 166 103 182 96 96 128 200 44 188 32 1 196 61 141 123 153 18 181 199 101 5...

output:

19900
2 7 1 165
3 22 1 74
3 58 2 44
4 120 1 157
4 173 2 66
4 84 3 111
5 57 1 178
5 151 2 74
5 97 3 152
5 133 4 98
6 133 1 88
6 138 2 16
6 124 3 115
6 85 4 90
6 77 5 92
7 159 1 41
7 39 2 86
7 44 3 183
7 7 4 172
7 200 5 110
7 154 6 176
8 184 1 183
8 36 2 131
8 1 3 101
8 108 4 78
8 126 5 139
8 53 6 158...

result:

ok your solution is correct.

Test #19:

score: 0
Accepted
time: 11ms
memory: 4892kb

input:

1
200
50 94 96 46 14 72 8 114 112 20 65 181 26 198 1 48 129 163 61 44 64 53 39 18 119 183 32 138 194 35 14 24 117 21 136 59 136 63 55 177 106 7 192 127 139 41 171 171 143 62 74 134 110 125 74 197 23 173 159 165 178 70 99 68 42 5 68 172 179 34 38 47 196 194 115 83 20 128 156 79 4 90 151 133 107 164 8...

output:

19900
2 34 1 152
3 136 1 10
3 3 2 85
4 80 1 82
4 42 2 132
4 126 3 165
5 108 1 191
5 195 2 181
5 143 3 148
5 50 4 178
6 191 1 155
6 11 2 9
6 108 3 177
6 111 4 22
6 186 5 21
7 45 1 160
7 193 2 127
7 170 3 65
7 147 4 130
7 121 5 179
7 21 6 70
8 188 1 118
8 163 2 74
8 28 3 156
8 189 4 111
8 131 5 96
8 8...

result:

ok your solution is correct.

Test #20:

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

input:

1
200
1 1 1 1 1 1 1 1 169 1 1 1 1 9 1 1 1 1 1 1 1 1 1 1 99 1 196 90 1 1 1 1 1 83 174 1 1 1 83 1 1 73 1 59 1 153 1 1 1 1 1 1 1 1 1 1 28 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 175 1 1 1 1 1 1 1 63 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 102 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 37 1 1...

output:

19900
2 11 1 2
3 98 1 3
3 1 2 3
4 47 1 4
4 2 2 4
4 3 3 5
5 97 1 5
5 178 2 5
5 3 3 6
5 4 4 5
6 52 1 6
6 2 2 6
6 3 3 7
6 4 4 6
6 5 5 1
7 193 1 7
7 183 2 7
7 3 3 8
7 4 4 7
7 5 5 8
7 6 6 7
8 14 1 8
8 60 2 8
8 1 3 9
8 5 4 8
8 6 5 9
8 7 6 8
8 8 7 8
9 92 1 1
9 67 2 9
9 3 3 10
9 5 4 9
9 6 5 10
9 7 6 9
9 8 7...

result:

ok your solution is correct.

Extra Test:

score: 0
Extra Test Passed