QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#841600#8818. Colorful Graph 3Marcin_smu#AC ✓41ms14868kbC++234.0kb2025-01-03 20:58:162025-01-03 20:58:17

Judging History

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

  • [2025-01-03 20:58:17]
  • 评测
  • 测评结果:AC
  • 用时:41ms
  • 内存:14868kb
  • [2025-01-03 20:58:16]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')
    cerr<<*sdbg++;
  cerr<<'='<<h<<',';
  _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

struct Sol{
  void run(){
    int n,k;
    cin >> n >> k;
    int kt = -1;
    vector<int> jed;
    R(i,k){
      int c;
      cin >> c;
      if(c >= 2){
        kt = i;
      }
      if(c == 1)jed.PB(i);
    }
    if(kt != -1){
      cout << n - 1 << "\n";
      R(i,n-1){
        cout << "1 " << i + 2 << " " << kt + 1 << "\n";
      }
    }else {
      vector<vector<int>> res;
      if(SZ(jed) + 1 >= n){
        while(n > 1){
          n--;
          res.PB({n, 0, jed.back()});
          jed.pop_back();
        }


      }else{
        int a = k - SZ(jed);
        int b = SZ(jed);
        int id = 1;
        if(b){
          int naj = 1e9;
          int jak = -1;
          debug(a,b);
          for(int roz = 3; roz <= n; roz++){
            int ed = roz * (roz - 1) / 2;
            int mm = b * ed;
            int nn = roz + (b - 1) * ed;
            int to_add = (ed - roz + 1) * a;
            int dod = min(n - nn, to_add);
            debug(roz, ed, mm, nn, to_add, dod);
            nn += dod;
            mm += dod;
            int cyk = (n - nn + k - 2) / (k - 1);
            debug(cyk);
            int ress = mm + n - nn + cyk;
            if(naj > ress){
              naj = ress;
              jak = roz;
            }
          }
          debug(naj, jak);
          id = jak;
          R(po, jak)R(ko, po){
            if(ko == 0){
              vector<int> ak;
              ak.PB(po);
              while(SZ(ak) != SZ(jed) && id != n){
                ak.PB(id);
                id++;
              }
              ak.PB(ko);
              R(i,SZ(ak)-1){
                res.PB({ak[i], ak[i + 1], jed[i]});
              }
            }else{
              vector<int> ak;
              ak.PB(po);
              while(SZ(ak) != k && id != n){
                ak.PB(id);
                id++;
              }
              ak.PB(ko);
              R(i,SZ(ak)-1){
                res.PB({ak[i], ak[i + 1], i});
              }
            }
          }
        }
        debug(res);
        vector<int> ak;
        R(i,n)if(i >= id){
          ak.PB(i);
          if(SZ(ak) == k - 1 || i == n-1){
            R(j,SZ(ak)- 1){
              res.PB({ak[j], ak[j+1], j});
            }
            res.PB({ak[0], 0, k-2});
            res.PB({ak.back(), 0, k - 1});
            ak.clear();
          }
        }
      }
      cout << SZ(res) << "\n";
      for(auto el:res){
        for(auto x:el){
          cout << x + 1 << " ";
        }
        cout << "\n";
      }
    }
  }
};

int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  int t;
  cin >> t;
  while(t--){
    Sol sol;
    sol.run();
  }

}

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

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3520kb

input:

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

output:

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

result:

ok orz (3 test cases)

Test #2:

score: 0
Accepted
time: 23ms
memory: 3532kb

input:

4645
2 2
0 0
2 2
0 1
2 2
1 1
3 2
0 0
3 2
0 1
3 2
1 1
3 3
0 0 0
3 3
1 0 0
3 3
1 0 1
3 3
1 1 1
4 2
0 0
4 2
1 0
4 2
1 1
4 3
0 0 0
4 3
0 0 1
4 3
0 1 1
4 3
1 1 1
4 4
0 0 0 0
4 4
0 1 0 0
4 4
1 1 0 0
4 4
1 1 1 0
4 4
1 1 1 1
5 2
0 0
5 2
1 0
5 2
1 1
5 3
0 0 0
5 3
0 1 0
5 3
1 1 0
5 3
1 1 1
5 4
0 0 0 0
5 4
0 1...

output:

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

result:

ok orz (4645 test cases)

Test #3:

score: 0
Accepted
time: 25ms
memory: 3588kb

input:

2379
56 2
1 1
56 2
0 1
56 2
0 0
55 12
1 1 1 1 1 1 1 1 1 1 1 1
55 12
1 0 1 1 1 1 1 1 1 1 1 1
55 12
0 1 1 1 0 1 1 1 1 1 1 1
55 12
0 1 1 1 1 1 1 1 0 1 0 1
55 12
0 1 0 1 0 1 1 1 1 1 1 0
55 12
1 0 1 0 0 0 1 0 1 1 1 1
55 12
0 0 1 1 0 0 1 0 1 1 1 0
55 12
0 0 0 1 0 1 0 1 1 1 0 0
55 12
0 1 1 0 0 0 0 1 1 0 0 ...

output:

92
2 11 1 
11 1 2 
3 12 1 
12 1 2 
3 13 1 
13 2 2 
4 14 1 
14 1 2 
4 15 1 
15 2 2 
4 16 1 
16 3 2 
5 17 1 
17 1 2 
5 18 1 
18 2 2 
5 19 1 
19 3 2 
5 20 1 
20 4 2 
6 21 1 
21 1 2 
6 22 1 
22 2 2 
6 23 1 
23 3 2 
6 24 1 
24 4 2 
6 25 1 
25 5 2 
7 26 1 
26 1 2 
7 27 1 
27 2 2 
7 28 1 
28 3 2 
7 29 1 
2...

result:

ok orz (2379 test cases)

Test #4:

score: 0
Accepted
time: 28ms
memory: 3892kb

input:

1244
73 3
1 1 1
87 3
1 1 1
60 4
1 1 0 0
72 4
0 1 1 1
84 4
0 0 0 0
100 2
1 1
64 2
1 0
81 3
1 1 1
101 6
1 1 0 1 0 0
66 6
1 0 1 1 0 1
59 2
1 1
68 6
1 1 0 0 0 0
87 6
1 1 1 1 1 1
105 4
0 1 0 0
104 3
1 1 1
94 6
1 1 0 0 0 1
91 5
1 1 1 1 1
63 3
1 0 0
100 5
0 0 0 0 0
70 4
1 1 1 1
61 5
0 0 0 0 1
104 2
0 1
94 ...

output:

98
2 9 1 
9 10 2 
10 1 3 
3 11 1 
11 12 2 
12 1 3 
3 13 1 
13 14 2 
14 2 3 
4 15 1 
15 16 2 
16 1 3 
4 17 1 
17 18 2 
18 2 3 
4 19 1 
19 20 2 
20 3 3 
5 21 1 
21 22 2 
22 1 3 
5 23 1 
23 24 2 
24 2 3 
5 25 1 
25 26 2 
26 3 3 
5 27 1 
27 28 2 
28 4 3 
6 29 1 
29 30 2 
30 1 3 
6 31 1 
31 32 2 
32 2 3 ...

result:

ok orz (1244 test cases)

Test #5:

score: 0
Accepted
time: 27ms
memory: 3844kb

input:

739
105 2
0 0
105 2
1 0
105 2
1 1
105 3
0 0 0
105 3
0 0 1
105 3
0 1 1
105 3
1 1 1
105 4
0 0 0 0
105 4
0 1 0 0
105 4
0 1 1 0
105 4
1 0 1 1
105 4
1 1 1 1
106 2
0 0
106 2
0 1
106 2
1 1
106 3
0 0 0
106 3
1 0 0
106 3
0 1 1
106 3
1 1 1
106 4
0 0 0 0
106 4
0 0 0 1
106 4
1 0 1 0
106 4
0 1 1 1
106 4
1 1 1 1
...

output:

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

result:

ok orz (739 test cases)

Test #6:

score: 0
Accepted
time: 29ms
memory: 3912kb

input:

495
237 3
0 1 0
237 3
0 0 0
237 2
1 1
237 2
0 1
237 2
0 0
236 3
1 1 1
236 3
0 1 1
236 3
0 1 0
236 3
0 0 0
236 2
1 1
236 2
0 1
236 2
0 0
235 3
1 1 1
235 3
1 0 1
235 3
1 0 0
235 3
0 0 0
235 2
1 1
235 2
0 1
235 2
0 0
234 3
1 1 1
234 3
0 1 1
234 3
1 0 0
234 3
0 0 0
234 2
1 1
234 2
0 1
234 2
0 0
233 3
1 ...

output:

347
2 1 2 
3 1 2 
3 16 1 
16 17 2 
17 2 3 
4 1 2 
4 18 1 
18 19 2 
19 2 3 
4 20 1 
20 21 2 
21 3 3 
5 1 2 
5 22 1 
22 23 2 
23 2 3 
5 24 1 
24 25 2 
25 3 3 
5 26 1 
26 27 2 
27 4 3 
6 1 2 
6 28 1 
28 29 2 
29 2 3 
6 30 1 
30 31 2 
31 3 3 
6 32 1 
32 33 2 
33 4 3 
6 34 1 
34 35 2 
35 5 3 
7 1 2 
7 36...

result:

ok orz (495 test cases)

Test #7:

score: 0
Accepted
time: 39ms
memory: 3656kb

input:

339
259 2
1 1
270 2
1 0
348 2
0 0
336 2
0 1
275 2
1 1
279 2
0 1
340 2
1 1
283 2
0 0
292 2
0 0
327 2
1 1
316 2
0 0
328 2
0 0
244 2
1 1
302 2
0 0
264 2
0 0
291 2
1 1
266 2
0 1
320 2
0 1
317 2
1 0
336 2
0 0
310 2
0 0
240 2
0 0
345 2
0 0
292 2
1 1
267 2
1 1
340 2
1 0
291 2
0 1
312 2
1 1
269 2
1 1
278 2
...

output:

474
2 23 1 
23 1 2 
3 24 1 
24 1 2 
3 25 1 
25 2 2 
4 26 1 
26 1 2 
4 27 1 
27 2 2 
4 28 1 
28 3 2 
5 29 1 
29 1 2 
5 30 1 
30 2 2 
5 31 1 
31 3 2 
5 32 1 
32 4 2 
6 33 1 
33 1 2 
6 34 1 
34 2 2 
6 35 1 
35 3 2 
6 36 1 
36 4 2 
6 37 1 
37 5 2 
7 38 1 
38 1 2 
7 39 1 
39 2 2 
7 40 1 
40 3 2 
7 41 1 
...

result:

ok orz (339 test cases)

Test #8:

score: 0
Accepted
time: 13ms
memory: 4120kb

input:

15
5529 5529
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

output:

5529
2 3 1 
3 4 2 
4 5 3 
5 6 4 
6 7 5 
7 8 6 
8 9 7 
9 10 8 
10 11 9 
11 12 10 
12 13 11 
13 14 12 
14 15 13 
15 16 14 
16 17 15 
17 18 16 
18 19 17 
19 20 18 
20 21 19 
21 22 20 
22 23 21 
23 24 22 
24 25 23 
25 26 24 
26 27 25 
27 28 26 
28 29 27 
29 30 28 
30 31 29 
31 32 30 
32 33 31 
33 34 32 ...

result:

ok orz (15 test cases)

Test #9:

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

input:

35
2838 6
1 1 1 1 1 1
1516 73
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 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
1974 7
1 1 1 1 1 1 1
2499 4
1 1 1 1
1520 4
1 1 1 1
2235 224
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 ...

output:

3365
2 35 1 
35 36 2 
36 37 3 
37 38 4 
38 39 5 
39 1 6 
3 40 1 
40 41 2 
41 42 3 
42 43 4 
43 44 5 
44 1 6 
3 45 1 
45 46 2 
46 47 3 
47 48 4 
48 49 5 
49 2 6 
4 50 1 
50 51 2 
51 52 3 
52 53 4 
53 54 5 
54 1 6 
4 55 1 
55 56 2 
56 57 3 
57 58 4 
58 59 5 
59 2 6 
4 60 1 
60 61 2 
61 62 3 
62 63 4 
...

result:

ok orz (35 test cases)

Test #10:

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

input:

15
5017 4
1 1 1 1
5456 100
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 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 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
4186 4
1 1 1 1
6624 23
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
3667...

output:

6612
2 59 1 
59 60 2 
60 61 3 
61 1 4 
3 62 1 
62 63 2 
63 64 3 
64 1 4 
3 65 1 
65 66 2 
66 67 3 
67 2 4 
4 68 1 
68 69 2 
69 70 3 
70 1 4 
4 71 1 
71 72 2 
72 73 3 
73 2 4 
4 74 1 
74 75 2 
75 76 3 
76 3 4 
5 77 1 
77 78 2 
78 79 3 
79 1 4 
5 80 1 
80 81 2 
81 82 3 
82 2 4 
5 83 1 
83 84 2 
84 85 ...

result:

ok orz (15 test cases)

Test #11:

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

input:

35
2094 90
1 0 0 0 1 0 0 0 0 1 0 0 1 0 0 1 0 0 0 1 0 0 0 0 1 0 0 0 1 0 1 0 1 0 0 0 0 1 1 0 0 1 0 1 0 1 1 0 0 1 1 0 0 1 1 0 1 0 0 0 0 1 1 0 0 0 1 1 0 0 0 0 1 0 0 0 1 0 0 1 1 0 1 1 0 0 0 0 0 1
1931 82
1 0 0 0 1 0 1 0 0 0 0 1 1 0 0 1 0 1 1 0 1 1 0 0 0 0 1 0 0 0 1 0 0 1 0 0 1 0 1 1 1 1 1 0 1 0 0 0 0 0 1...

output:

2114
2 9 1 
9 10 5 
10 11 10 
11 12 13 
12 13 16 
13 14 20 
14 15 25 
15 16 29 
16 17 31 
17 18 33 
18 19 38 
19 20 39 
20 21 42 
21 22 44 
22 23 46 
23 24 47 
24 25 50 
25 26 51 
26 27 54 
27 28 55 
28 29 57 
29 30 62 
30 31 63 
31 32 67 
32 33 68 
33 34 73 
34 35 77 
35 36 80 
36 37 81 
37 38 83 
...

result:

ok orz (35 test cases)

Test #12:

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

input:

15
3844 3
0 1 0
4674 27
1 1 0 0 1 0 1 1 0 0 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0 0 1
5623 91
0 1 1 1 1 0 1 1 1 1 0 1 1 0 1 1 1 1 0 0 1 0 0 0 1 1 1 0 1 1 1 1 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 0 1 0 1 1 0 0 0 0 0 0 1 1 1 1 1 0 1 1 0 1 1 1 1 1 1 1 1 1 0 1 0 0 0 1 1 1 1 1 0 0
4276 340
0 1 0 1 1 0 0 1 1 1 1 1...

output:

5734
2 1 2 
3 1 2 
3 63 1 
63 64 2 
64 2 3 
4 1 2 
4 65 1 
65 66 2 
66 2 3 
4 67 1 
67 68 2 
68 3 3 
5 1 2 
5 69 1 
69 70 2 
70 2 3 
5 71 1 
71 72 2 
72 3 3 
5 73 1 
73 74 2 
74 4 3 
6 1 2 
6 75 1 
75 76 2 
76 2 3 
6 77 1 
77 78 2 
78 3 3 
6 79 1 
79 80 2 
80 4 3 
6 81 1 
81 82 2 
82 5 3 
7 1 2 
7 8...

result:

ok orz (15 test cases)

Test #13:

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

input:

35
2003 92
1 0 1 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 1 0 1 0 1 0 0 0 0 1 1 0 0 0 0 1 0 0 1 0 1 1 1 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 1 0 1 0 0 0 0 1 0 0 1 1 1 1 0 1 1 1 0 1 1 0 1 0 0 0 0 0 0 0 0
2282 24
0 1 1 1 0 0 0 0 0 0 0 0 1 0 0 0 1 0 1 1 0 1 1 1
1490 29
0 1 0 0 1 0 0 0 0 1 1 1 0 1 1 0 1 0 0 0 1...

output:

2023
2 6 1 
6 7 3 
7 8 10 
8 9 16 
9 10 20 
10 11 22 
11 12 24 
12 13 29 
13 14 30 
14 15 35 
15 16 38 
16 17 40 
17 18 41 
18 19 42 
19 20 51 
20 21 56 
21 22 61 
22 23 62 
23 24 64 
24 25 69 
25 26 72 
26 27 73 
27 28 74 
28 29 75 
29 30 77 
30 31 78 
31 32 79 
32 33 81 
33 34 82 
34 1 84 
3 35 1 ...

result:

ok orz (35 test cases)

Test #14:

score: 0
Accepted
time: 20ms
memory: 4408kb

input:

15
5107 312
0 1 0 1 1 1 0 1 1 1 1 1 1 0 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 0 1 0 1 0 0 0 1 1 0 0 1 0 1 0 0 0 1 1 1 1 1 1 1 1 0 0 1 1 1 0 1 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 1 1 1 1 1 0 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 0 0 1 1 1 0 1 0 0 1 1 1 1 0 1 0 1 1 1 0 1 1 1 0 1 1 1 1 1 1 1 0 1 0 1 0 1 0 0 0 ...

output:

5120
2 6 2 
6 7 4 
7 8 5 
8 9 6 
9 10 8 
10 11 9 
11 12 10 
12 13 11 
13 14 12 
14 15 13 
15 16 15 
16 17 17 
17 18 18 
18 19 19 
19 20 20 
20 21 21 
21 22 22 
22 23 23 
23 24 24 
24 25 25 
25 26 26 
26 27 27 
27 28 28 
28 29 29 
29 30 30 
30 31 31 
31 32 34 
32 33 36 
33 34 38 
34 35 42 
35 36 43 
...

result:

ok orz (15 test cases)

Test #15:

score: 0
Accepted
time: 24ms
memory: 3704kb

input:

1000
64 5
1 0 1 1 1
25 4
0 0 0 0
53 11
0 0 1 1 1 1 0 1 1 1 0
69 10
0 0 0 0 0 0 1 1 0 0
23 3
1 1 0
103 13
0 1 1 1 0 0 1 0 1 1 0 0 0
104 7
0 0 0 0 0 0 0
72 9
0 0 0 0 0 1 0 0 1
144 12
1 0 1 1 1 0 1 1 0 1 0 0
23 6
0 1 1 0 0 0
137 14
0 0 1 0 0 0 0 0 0 1 1 0 0 0
56 9
1 1 0 1 1 1 1 0 1
52 7
0 0 0 0 0 0 0
3...

output:

74
2 7 1 
7 8 3 
8 9 4 
9 1 5 
3 10 1 
10 11 3 
11 12 4 
12 1 5 
3 13 1 
13 14 2 
14 15 3 
15 16 4 
16 2 5 
4 17 1 
17 18 3 
18 19 4 
19 1 5 
4 20 1 
20 21 2 
21 22 3 
22 23 4 
23 2 5 
4 24 1 
24 25 2 
25 26 3 
26 27 4 
27 3 5 
5 28 1 
28 29 3 
29 30 4 
30 1 5 
5 31 1 
31 32 2 
32 33 3 
33 34 4 
34 ...

result:

ok orz (1000 test cases)

Test #16:

score: 0
Accepted
time: 18ms
memory: 3952kb

input:

300
259 9
0 0 0 0 1 0 0 1 0
68 11
1 0 1 1 1 1 1 0 1 0 1
52 9
1 0 0 1 1 0 0 1 0
339 25
1 0 1 0 0 1 0 0 0 1 1 0 1 0 0 0 1 1 0 1 1 1 1 0 0
871 34
1 0 0 1 1 1 0 1 1 1 1 0 1 1 0 0 0 0 1 1 0 1 0 1 1 1 1 1 1 1 1 0 0 1
152 8
0 1 1 0 0 1 0 1
199 7
1 1 1 1 1 1 1
74 9
1 1 0 0 0 1 1 1 0
258 30
0 0 1 0 0 1 1 1 0...

output:

289
2 7 5 
7 1 8 
3 8 5 
8 1 8 
3 9 1 
9 10 2 
10 11 3 
11 12 4 
12 13 5 
13 14 6 
14 15 7 
15 16 8 
16 2 9 
4 17 5 
17 1 8 
4 18 1 
18 19 2 
19 20 3 
20 21 4 
21 22 5 
22 23 6 
23 24 7 
24 25 8 
25 2 9 
4 26 1 
26 27 2 
27 28 3 
28 29 4 
29 30 5 
30 31 6 
31 32 7 
32 33 8 
33 3 9 
5 34 5 
34 1 8 
5...

result:

ok orz (300 test cases)

Test #17:

score: 0
Accepted
time: 21ms
memory: 4124kb

input:

100
1046 22
1 0 0 1 0 0 0 0 1 1 1 1 0 1 0 0 1 0 0 1 0 0
153 18
1 0 0 1 1 0 0 0 1 1 1 1 1 0 1 1 0 0
1068 30
0 1 0 1 0 1 0 1 1 1 0 1 1 1 1 1 1 0 1 0 1 1 1 1 1 1 1 0 1 1
326 20
1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1
927 28
0 1 1 1 0 0 1 0 1 0 0 1 0 1 1 0 1 1 1 1 1 1 1 1 0 1 1 1
2382 56
1 1 1 1 0 0 1 1...

output:

1091
2 11 1 
11 12 4 
12 13 9 
13 14 10 
14 15 11 
15 16 12 
16 17 14 
17 18 17 
18 1 20 
3 19 1 
19 20 4 
20 21 9 
21 22 10 
22 23 11 
23 24 12 
24 25 14 
25 26 17 
26 1 20 
3 27 1 
27 28 2 
28 29 3 
29 30 4 
30 31 5 
31 32 6 
32 33 7 
33 34 8 
34 35 9 
35 36 10 
36 37 11 
37 38 12 
38 39 13 
39 40...

result:

ok orz (100 test cases)

Test #18:

score: 0
Accepted
time: 21ms
memory: 4164kb

input:

50
1661 20
0 1 1 1 1 1 0 0 1 1 1 1 1 0 1 1 0 1 1 1
1602 45
0 0 1 0 1 1 1 1 0 1 0 0 1 1 0 1 1 0 0 0 1 0 0 0 0 1 1 1 1 1 1 1 0 1 0 0 0 1 1 0 0 0 1 0 1
124 7
0 1 0 1 1 1 1
2537 19
0 0 1 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 1
4030 93
1 0 0 1 0 1 0 1 0 0 0 1 1 1 0 0 1 1 1 1 0 1 0 1 1 1 1 0 0 0 0 1 0 1 0 1 0 1 0...

output:

1738
2 14 2 
14 15 3 
15 16 4 
16 17 5 
17 18 6 
18 19 9 
19 20 10 
20 21 11 
21 22 12 
22 23 13 
23 24 15 
24 25 16 
25 26 18 
26 27 19 
27 1 20 
3 28 2 
28 29 3 
29 30 4 
30 31 5 
31 32 6 
32 33 9 
33 34 10 
34 35 11 
35 36 12 
36 37 13 
37 38 15 
38 39 16 
39 40 18 
40 41 19 
41 1 20 
3 42 1 
42 ...

result:

ok orz (50 test cases)

Test #19:

score: 0
Accepted
time: 10ms
memory: 4364kb

input:

20
7855 37
1 0 1 1 1 0 1 1 0 1 1 1 1 1 1 1 1 1 0 1 0 1 1 1 1 0 0 0 1 0 1 1 1 0 1 0 1
4327 92
0 1 1 1 1 1 1 1 1 0 1 1 1 0 0 1 1 0 0 1 1 1 1 0 1 0 1 1 1 0 0 1 0 1 1 0 0 1 0 1 1 0 0 1 1 1 1 1 1 1 1 1 1 1 0 1 1 0 0 1 1 1 0 0 1 0 0 0 0 0 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 0 1
4125 64
1 1 1 1 1 1 1 0...

output:

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

result:

ok orz (20 test cases)

Test #20:

score: 0
Accepted
time: 21ms
memory: 5088kb

input:

10
1446 13
1 0 1 0 0 0 0 0 0 0 0 0 0
19759 95
0 0 0 0 0 1 1 1 1 0 0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 1 1 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 1 1 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 1 0 1 0 0 1 1 0 0 0 0 1 1 0 0 0 0 1 0 0
13321 134
0 0 1 0 1 0 0 1 0 1 0 1 1 1 1 1 1 1 0 0 1 1 1 0 0 0 1 ...

output:

1563
2 17 1 
17 1 3 
3 18 1 
18 1 3 
3 19 1 
19 20 2 
20 21 3 
21 22 4 
22 23 5 
23 24 6 
24 25 7 
25 26 8 
26 27 9 
27 28 10 
28 29 11 
29 30 12 
30 2 13 
4 31 1 
31 1 3 
4 32 1 
32 33 2 
33 34 3 
34 35 4 
35 36 5 
36 37 6 
37 38 7 
38 39 8 
39 40 9 
40 41 10 
41 42 11 
42 43 12 
43 2 13 
4 44 1 
4...

result:

ok orz (10 test cases)

Test #21:

score: 0
Accepted
time: 10ms
memory: 6504kb

input:

3
41501 278
0 0 1 0 1 1 0 1 1 1 0 0 1 0 0 0 0 0 1 0 0 0 0 1 1 0 1 0 0 0 1 0 0 0 0 1 0 0 1 1 1 0 1 0 0 1 0 1 0 0 0 1 1 0 0 0 1 1 0 0 1 1 0 0 1 0 1 1 1 1 0 1 1 1 0 0 1 1 0 1 0 0 1 1 1 1 0 1 0 0 0 1 0 0 0 1 1 0 0 0 0 1 0 1 0 0 1 0 0 1 0 0 1 1 0 0 0 0 0 1 0 0 0 0 0 1 1 1 1 0 0 1 1 0 0 0 1 0 0 0 0 0 0 0 ...

output:

41643
2 18 3 
18 19 5 
19 20 6 
20 21 8 
21 22 9 
22 23 10 
23 24 13 
24 25 19 
25 26 24 
26 27 25 
27 28 27 
28 29 31 
29 30 36 
30 31 39 
31 32 40 
32 33 41 
33 34 43 
34 35 46 
35 36 48 
36 37 52 
37 38 53 
38 39 57 
39 40 58 
40 41 61 
41 42 62 
42 43 65 
43 44 67 
44 45 68 
45 46 69 
46 47 70 
...

result:

ok orz (3 test cases)

Test #22:

score: 0
Accepted
time: 39ms
memory: 14868kb

input:

1
100000 2
0 0

output:

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

result:

ok orz (1 test case)

Test #23:

score: 0
Accepted
time: 41ms
memory: 14684kb

input:

1
100000 2
0 1

output:

199552
2 1 2 
3 1 2 
3 448 1 
448 2 2 
4 1 2 
4 449 1 
449 2 2 
4 450 1 
450 3 2 
5 1 2 
5 451 1 
451 2 2 
5 452 1 
452 3 2 
5 453 1 
453 4 2 
6 1 2 
6 454 1 
454 2 2 
6 455 1 
455 3 2 
6 456 1 
456 4 2 
6 457 1 
457 5 2 
7 1 2 
7 458 1 
458 2 2 
7 459 1 
459 3 2 
7 460 1 
460 4 2 
7 461 1 
461 5 2 ...

result:

ok orz (1 test case)

Test #24:

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

input:

1
100000 2
1 1

output:

199108
2 447 1 
447 1 2 
3 448 1 
448 1 2 
3 449 1 
449 2 2 
4 450 1 
450 1 2 
4 451 1 
451 2 2 
4 452 1 
452 3 2 
5 453 1 
453 1 2 
5 454 1 
454 2 2 
5 455 1 
455 3 2 
5 456 1 
456 4 2 
6 457 1 
457 1 2 
6 458 1 
458 2 2 
6 459 1 
459 3 2 
6 460 1 
460 4 2 
6 461 1 
461 5 2 
7 462 1 
462 1 2 
7 463...

result:

ok orz (1 test case)

Test #25:

score: 0
Accepted
time: 10ms
memory: 3636kb

input:

1
100000 2
0 2

output:

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

result:

ok orz (1 test case)

Test #26:

score: 0
Accepted
time: 12ms
memory: 3844kb

input:

1
100000 100000
100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 1000...

output:

99999
1 2 100000
1 3 100000
1 4 100000
1 5 100000
1 6 100000
1 7 100000
1 8 100000
1 9 100000
1 10 100000
1 11 100000
1 12 100000
1 13 100000
1 14 100000
1 15 100000
1 16 100000
1 17 100000
1 18 100000
1 19 100000
1 20 100000
1 21 100000
1 22 100000
1 23 100000
1 24 100000
1 25 100000
1 26 100000
1 ...

result:

ok orz (1 test case)

Extra Test:

score: 0
Extra Test Passed