QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#65910#2264. Secrets of Legendary Treasuredlg#AC ✓5ms3428kbC++171.8kb2022-12-04 11:56:292022-12-04 11:56:30

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-12-04 11:56:30]
  • 评测
  • 测评结果:AC
  • 用时:5ms
  • 内存:3428kb
  • [2022-12-04 11:56:29]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define sp ' '
#define endl '\n'
#define fi first
#define se second
#define loop(i, l, r) for(int i=(int)(l); i<=(int)(r); i++)
#define rloop(i, l, r) for(int i=(int)(l); i>=(int)(r); i--)
#define all(x) (x).begin(), (x).end()

template<typename T>
ostream &operator<<(ostream &os, vector<T> a) {
  os << "[";
  for (auto it : a)
    os << it << ",";
  os << "]";
  return os;
}

template<typename T, typename T2>
ostream &operator<<(ostream &os, pair<T, T2> a) {
  os << "{";
  os << a.fi << sp << a.se;
  os << "}";
};

const int INF = numeric_limits<int>::max() / 2;

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
#ifdef LOCAL
  freopen("1test.inp", "r", stdin);
#endif
  int n, m;
  cin >> n >> m;
  vector<int> a(n), b(m);
  for (auto &it : a)
    cin >> it;
  for (auto &it : b)
    cin >> it;

  vector<int> nxtA(n), nxtB(m);

  auto buildNxt = [](vector<int> &vec, vector<int> &nxt) {
    int lst = INF;
    rloop(i, nxt.size() - 1, 0) {
      if (vec[i] != 0)
        lst = vec[i];
      nxt[i] = lst;
    }
  };
  buildNxt(a, nxtA);
  buildNxt(b, nxtB);

  int L = 0, R = 0;
  loop(val, 1, n + m) {
    if (L < n && a[L] == val) {
      L++;
      continue;
    }
    if (R < m && b[R] == val) {
      R++;
      continue;
    }

    auto cond1 = (L < n && a[L] == 0);
    auto cond2 = (R < m && b[R] == 0);

    if (cond1 && cond2) {
      if (nxtA[L] < nxtB[R]) {
        a[L] = val;
        L++;
      } else {
        b[R] = val;
        R++;
      }
    } else if (cond1) {
      a[L] = val;
      L++;
    } else {
      assert(cond2);
      b[R] = val;
      R++;
    }
  }
  loop(i,0,n-1) cout << a[i] << sp;
  cout << endl;
  loop(i,0,m-1) cout << b[i] << sp;
  cout << endl;
}

詳細信息

Test #1:

score: 100
Accepted
time: 3ms
memory: 3204kb

input:

100 100
1 2 3 4 6 10 11 14 17 18 19 21 24 25 26 27 29 32 34 35 36 37 39 40 44 49 52 53 55 59 65 66 67 68 73 74 81 82 83 85 86 88 89 90 96 98 99 102 103 104 106 107 108 116 117 118 121 124 127 128 129 130 131 132 134 137 138 139 141 145 148 149 152 153 154 156 157 158 161 162 163 167 169 170 173 174 ...

output:

1 2 3 4 6 10 11 14 17 18 19 21 24 25 26 27 29 32 34 35 36 37 39 40 44 49 52 53 55 59 65 66 67 68 73 74 81 82 83 85 86 88 89 90 96 98 99 102 103 104 106 107 108 116 117 118 121 124 127 128 129 130 131 132 134 137 138 139 141 145 148 149 152 153 154 156 157 158 161 162 163 167 169 170 173 174 175 177 ...

result:

ok correct

Test #2:

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

input:

99 1
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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
37

output:

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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 
37 

result:

ok correct

Test #3:

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

input:

90 96
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 92
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:

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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 92 
90 91 93 94 95 96 97 98 99 100 101 102...

result:

ok correct

Test #4:

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

input:

97 83
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 0 0 0 ...

output:

83 84 85 86 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 ...

result:

ok correct

Test #5:

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

input:

92 90
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
89 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:

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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 179 180 181 182 
89 90 91 92 93 94 95 96 97 9...

result:

ok correct

Test #6:

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

input:

96 100
97 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 0 ...

output:

97 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 1...

result:

ok correct

Test #7:

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

input:

87 98
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 87
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:

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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102...

result:

ok correct

Test #8:

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

input:

83 83
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 0 0 0 ...

output:

84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 ...

result:

ok correct

Test #9:

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

input:

94 89
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
95 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:

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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 
95 96 97 98 99 100 101 102...

result:

ok correct

Test #10:

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

input:

95 99
100 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 0 ...

output:

100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 ...

result:

ok correct

Test #11:

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

input:

90 99
0 0 6 0 0 0 16 0 19 0 21 23 27 29 31 34 35 37 0 44 46 0 49 0 53 54 0 0 0 0 65 66 67 0 71 0 74 75 0 77 0 79 80 82 84 85 0 0 95 97 102 0 105 0 109 0 111 112 0 115 116 120 0 124 127 0 130 134 0 137 141 0 144 148 150 151 153 0 160 165 0 0 171 0 0 0 185 0 187 188
1 0 5 8 11 12 0 14 15 18 22 0 0 0 0...

output:

3 4 6 7 9 10 16 17 19 20 21 23 27 29 31 34 35 37 41 44 46 47 49 50 53 54 57 58 59 61 65 66 67 68 71 72 74 75 76 77 78 79 80 82 84 85 92 94 95 97 102 104 105 107 109 110 111 112 113 115 116 120 121 124 127 128 130 134 135 137 141 142 144 148 150 151 153 155 160 165 166 167 171 181 182 183 185 186 187...

result:

ok correct

Test #12:

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

input:

51 92
4 7 8 11 0 0 26 29 0 44 0 0 50 0 57 0 61 65 67 70 0 78 0 80 82 0 86 89 90 91 95 100 103 104 0 0 108 109 112 0 116 0 118 0 0 125 130 131 134 137 141
0 2 3 5 6 9 10 12 13 0 15 0 18 19 0 22 23 24 0 27 0 30 31 0 34 35 36 0 0 39 40 41 42 0 0 0 49 0 52 53 54 56 58 59 62 0 0 66 0 69 72 73 0 0 76 77 8...

output:

4 7 8 11 17 21 26 29 33 44 47 48 50 55 57 60 61 65 67 70 71 78 79 80 82 84 86 89 90 91 95 100 103 104 105 106 108 109 112 113 116 117 118 120 122 125 130 131 134 137 141 
1 2 3 5 6 9 10 12 13 14 15 16 18 19 20 22 23 24 25 27 28 30 31 32 34 35 36 37 38 39 40 41 42 43 45 46 49 51 52 53 54 56 58 59 62 ...

result:

ok correct

Test #13:

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

input:

79 87
0 0 4 5 7 10 0 12 0 17 24 27 28 0 30 31 32 0 0 0 0 0 43 45 0 50 51 54 56 62 63 65 67 0 70 71 0 0 75 0 0 80 0 89 91 92 0 0 102 104 0 106 107 108 110 112 117 119 120 0 123 125 132 135 0 139 140 141 142 0 0 145 0 149 0 154 0 157 0
1 0 8 9 13 15 16 0 19 20 21 0 0 25 26 0 35 0 38 42 44 0 0 0 0 53 5...

output:

2 3 4 5 7 10 11 12 14 17 24 27 28 29 30 31 32 34 37 39 40 41 43 45 46 50 51 54 56 62 63 65 67 68 70 71 72 73 75 76 78 80 81 89 91 92 98 100 102 104 105 106 107 108 110 112 117 119 120 121 123 125 132 135 138 139 140 141 142 143 144 145 146 149 150 154 155 157 161 
1 6 8 9 13 15 16 18 19 20 21 22 23 ...

result:

ok correct

Test #14:

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

input:

53 85
0 5 7 8 22 0 27 0 0 33 34 0 40 0 45 48 51 0 55 57 0 59 63 64 0 69 0 0 80 81 0 84 0 88 0 103 104 105 106 0 113 0 116 117 121 122 0 127 130 0 135 137 0
0 2 3 6 0 0 0 0 13 14 0 0 17 0 19 20 21 23 0 26 29 0 0 35 36 37 0 0 0 0 46 47 49 0 0 54 56 60 61 0 0 0 0 70 71 73 75 76 77 78 79 83 0 87 89 0 91...

output:

4 5 7 8 22 25 27 28 30 33 34 38 40 41 45 48 51 53 55 57 58 59 63 64 65 69 72 74 80 81 82 84 86 88 101 103 104 105 106 110 113 115 116 117 121 122 125 127 130 132 135 137 138 
1 2 3 6 9 10 11 12 13 14 15 16 17 18 19 20 21 23 24 26 29 31 32 35 36 37 39 42 43 44 46 47 49 50 52 54 56 60 61 62 66 67 68 7...

result:

ok correct

Test #15:

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

input:

71 72
0 0 0 0 10 13 0 16 18 0 20 22 0 24 25 26 28 29 0 31 40 42 0 0 0 47 48 0 51 52 55 0 57 0 67 0 69 70 71 0 0 0 83 0 0 0 0 93 95 0 100 105 0 107 0 109 110 112 0 0 120 122 0 0 126 128 129 132 133 142 0
0 3 0 6 0 11 12 0 17 21 27 32 33 0 0 36 37 38 39 0 0 0 53 0 58 0 60 61 62 63 64 65 0 73 74 75 0 7...

output:

2 5 7 8 10 13 14 16 18 19 20 22 23 24 25 26 28 29 30 31 40 42 43 44 45 47 48 49 51 52 55 56 57 66 67 68 69 70 71 77 79 80 83 86 87 89 90 93 95 98 100 105 106 107 108 109 110 112 115 119 120 122 123 124 126 128 129 132 133 142 143 
1 3 4 6 9 11 12 15 17 21 27 32 33 34 35 36 37 38 39 41 46 50 53 54 58...

result:

ok correct

Test #16:

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

input:

78 58
0 0 0 0 9 0 0 0 16 0 0 19 21 0 0 24 0 26 0 0 0 0 38 0 0 42 45 0 50 53 0 0 0 0 0 0 66 0 0 71 0 0 74 0 0 78 0 0 82 0 0 0 0 0 91 0 0 0 0 0 0 0 0 0 0 0 0 0 120 121 0 0 125 0 0 0 0 0
0 0 0 0 0 13 0 0 28 0 0 0 0 35 0 41 43 0 0 0 0 0 0 0 59 0 0 0 64 0 0 0 0 0 0 0 0 0 97 0 100 0 0 106 0 0 109 113 0 0 ...

output:

1 2 3 4 9 11 12 14 16 17 18 19 21 22 23 24 25 26 27 33 34 36 38 39 40 42 45 46 50 53 55 56 57 58 63 65 66 67 68 71 72 73 74 75 76 78 79 80 82 83 84 85 86 87 91 94 95 96 99 103 104 105 110 111 112 114 115 116 120 121 123 124 125 128 133 134 135 136 
5 6 7 8 10 13 15 20 28 29 30 31 32 35 37 41 43 44 4...

result:

ok correct

Test #17:

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

input:

83 82
0 0 0 0 0 0 0 0 23 0 0 29 0 0 0 39 0 0 0 43 0 0 0 0 0 51 0 0 0 0 0 0 65 0 0 0 0 0 0 0 0 0 0 0 0 0 0 98 0 0 102 103 0 107 0 0 110 0 0 0 0 120 0 0 123 0 0 0 0 0 0 136 0 0 0 0 148 0 0 0 0 161 165
0 0 0 0 11 0 0 0 0 0 0 0 0 0 25 0 28 0 32 0 0 0 0 44 0 0 55 0 0 0 0 0 0 67 0 69 0 0 0 81 0 0 0 85 0 0...

output:

5 6 7 8 9 10 12 13 23 24 27 29 31 33 34 39 40 41 42 43 45 46 47 48 49 51 53 54 56 57 58 59 65 73 74 75 76 77 78 79 80 88 89 90 91 93 94 98 99 100 102 103 104 107 108 109 110 115 116 118 119 120 121 122 123 129 130 131 132 133 134 136 142 143 144 146 148 149 150 151 152 161 165 
1 2 3 4 11 14 15 16 1...

result:

ok correct

Test #18:

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

input:

84 77
0 0 6 0 9 10 14 0 18 0 0 32 0 0 0 42 47 0 50 51 0 0 55 0 0 0 0 0 0 73 0 0 0 0 80 0 0 83 0 0 0 87 0 0 0 0 96 0 0 0 102 0 104 0 0 108 110 112 0 0 0 0 119 0 121 122 0 0 0 0 0 0 0 0 0 0 0 145 148 153 156 157 0 159
0 0 0 0 0 0 0 0 0 0 20 0 0 0 0 0 0 0 0 31 34 0 0 39 0 0 0 0 0 0 0 0 0 0 0 0 0 64 0 0...

output:

1 2 6 7 9 10 14 15 18 29 30 32 33 37 38 42 47 48 50 51 52 53 55 61 62 63 68 69 70 73 74 75 76 77 80 81 82 83 84 85 86 87 90 92 93 94 96 98 99 100 102 103 104 105 107 108 110 112 113 114 116 117 119 120 121 122 123 124 130 135 136 137 138 139 140 141 143 145 148 153 156 157 158 159 
3 4 5 8 11 12 13 ...

result:

ok correct

Test #19:

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

input:

56 51
0 0 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 50 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 74 0 0 80 81 0 0 0 87 0 0 93 0 0 0 0 101 103 104 0
0 0 0 0 10 11 0 0 0 19 0 0 0 0 0 30 0 0 0 0 0 0 0 0 0 0 0 0 0 0 52 0 57 0 0 71 0 0 0 0 83 0 0 0 0 0 0 0 0 105 0

output:

1 2 5 8 9 15 16 17 18 25 26 27 28 29 31 32 33 34 35 36 50 54 55 56 60 61 62 63 64 65 66 67 68 69 70 72 74 75 76 80 81 82 84 85 87 88 89 93 94 95 96 97 101 103 104 107 
3 4 6 7 10 11 12 13 14 19 20 21 22 23 24 30 37 38 39 40 41 42 43 44 45 46 47 48 49 51 52 53 57 58 59 71 73 77 78 79 83 86 90 91 92 9...

result:

ok correct

Test #20:

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

input:

100 81
0 0 0 0 10 11 0 0 0 0 17 0 0 0 23 0 0 29 0 0 34 0 0 0 0 0 0 0 48 0 0 0 0 0 0 0 0 0 0 0 0 69 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 115 0 120 0 122 0 124 0 0 0 0 0 133 0 0 141 0 0 0 0 151 0 0 156 0 0 0 161 0 0 0 0 0 0 0 176 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 56 57 0 0 0 0 0 0 0 0...

output:

1 2 3 4 10 11 12 13 14 15 17 18 19 20 23 24 25 29 30 31 34 35 36 37 38 39 40 41 48 52 53 54 55 58 59 60 61 62 63 64 65 69 75 76 77 78 79 83 84 93 94 95 96 97 100 101 102 103 107 108 109 111 115 116 120 121 122 123 124 127 129 130 131 132 133 135 136 141 143 145 146 148 151 152 153 156 157 158 159 16...

result:

ok correct

Test #21:

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

input:

77 92
1 2 3 4 6 10 0 13 15 17 19 21 23 25 30 31 34 37 41 43 45 49 51 52 56 57 58 62 63 65 69 71 72 74 75 78 83 84 86 89 90 92 95 96 100 0 103 104 107 108 110 111 113 114 116 118 119 0 123 124 0 126 127 128 133 134 136 141 142 143 146 148 153 156 160 162 166
5 7 8 9 11 14 16 18 20 22 24 0 27 28 29 32...

output:

1 2 3 4 6 10 12 13 15 17 19 21 23 25 30 31 34 37 41 43 45 49 51 52 56 57 58 62 63 65 69 71 72 74 75 78 83 84 86 89 90 92 95 96 100 102 103 104 107 108 110 111 113 114 116 118 119 121 123 124 125 126 127 128 133 134 136 141 142 143 146 148 153 156 160 162 166 
5 7 8 9 11 14 16 18 20 22 24 26 27 28 29...

result:

ok correct

Test #22:

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

input:

75 92
2 4 8 13 14 16 17 20 23 27 31 35 37 38 40 43 44 49 50 51 54 55 0 57 60 61 62 63 65 71 73 74 76 82 85 88 89 90 91 92 93 95 0 99 100 101 107 108 109 113 116 119 122 124 130 133 134 135 138 139 143 145 146 147 148 151 0 154 155 157 158 159 160 164 166
1 3 5 6 7 9 10 11 12 15 18 19 21 22 0 25 26 2...

output:

2 4 8 13 14 16 17 20 23 27 31 35 37 38 40 43 44 49 50 51 54 55 56 57 60 61 62 63 65 71 73 74 76 82 85 88 89 90 91 92 93 95 97 99 100 101 107 108 109 113 116 119 122 124 130 133 134 135 138 139 143 145 146 147 148 151 152 154 155 157 158 159 160 164 166 
1 3 5 6 7 9 10 11 12 15 18 19 21 22 24 25 26 2...

result:

ok correct

Test #23:

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

input:

99 61
0 0 6 0 0 0 12 0 0 0 0 20 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 50 0 0 0 55 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 124 0 0 0 0 0 0 0 0 0 0 0 141 0 0 0 0 0 148 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 102 ...

output:

1 2 6 7 8 9 12 13 14 15 16 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 50 51 52 53 55 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 103 104 105 106 107 108 109 110 111 112 113 114 124 125 126 128 129 130 131 132 133 134 135 136 141 142 143 144 145 146 148 ...

result:

ok correct

Test #24:

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

input:

70 79
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 98 0 0 0 0 0 0 0 0 0 0 0 0 0 135 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 51 0 0 0 0 0 0 62 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 114 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

output:

29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 58 59 60 61 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 98 108 109 110 111 112 113 115 116 117 118 119 120 121 135 142 143 144 145 146 147 148 149 
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 2...

result:

ok correct

Test #25:

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

input:

5 5
0 0 6 0 0
0 0 3 0 0

output:

4 5 6 9 10 
1 2 3 7 8 

result:

ok correct

Test #26:

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

input:

2 2
1 0
0 4

output:

1 3 
2 4 

result:

ok correct

Test #27:

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

input:

6 3
0 0 0 5 0 0
3 0 7

output:

1 2 4 5 8 9 
3 6 7 

result:

ok correct

Test #28:

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

input:

5 5
3 0 0 0 8
1 0 0 0 10

output:

3 4 5 6 8 
1 2 7 9 10 

result:

ok correct

Test #29:

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

input:

97 97
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 0 0 0 ...

output:

98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 17...

result:

ok correct

Test #30:

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

input:

99 1
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:

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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 
1 

result:

ok correct

Test #31:

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

input:

1 98
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:

99 
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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 

result:

ok correct