QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#74671#2264. Secrets of Legendary TreasureXKErrorAC ✓2ms3744kbC++141.7kb2023-02-03 10:52:442023-02-03 10:52:47

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-02-03 10:52:47]
  • 评测
  • 测评结果:AC
  • 用时:2ms
  • 内存:3744kb
  • [2023-02-03 10:52:44]
  • 提交

answer

#include <bits/stdc++.h>

#define maxn 100005

using namespace std;

int n, m;
int a[maxn];
int b[maxn];
int p[maxn];
int q[maxn];

int fx, fy;

int main() {
//	srand(time(0));
//	int t;
//	scanf("%d", &t);
//	for (int i = 1; i <= t; i++) {
//		if (rand() & 1) a[++n] = i;
//		else b[++m] = i;
//	}
//	for (int i = 1; i <= t / 2; i++) {
//		if (rand() & 1) a[rand() % n + 1] = 0;
//		else b[rand() % m + 1] = 0;
//	}
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
	for (int i = 1; i <= m; i++) scanf("%d", &b[i]);
//	for (int i = 1; i <= n;)
	a[n + 1] = n + m + 1;
	b[m + 1] = n + m + 2;
	++n, ++m;
	fx = fy = 1;
	for (int x = 1; x <= n + m; x++) {
		if (a[fx] == x) ++fx;
		else if (b[fy] == x) ++fy;
		else {
			int l1, i1;
			for (int i = fx; i <= n; i++) {
				if (a[i]) {
					l1 = a[i];
					i1 = i;
					break;
				}
			}
			int l2, i2;
			for (int i = fy; i <= m; i++) {
				if (b[i]) {
					l2 = b[i];
					i2 = i;
					break;
				}
			}
//			cout<<l1<<" "<<i1<<" "<<l2<<" "<<i2<<endl;
			if (l1 < l2) {
				if (i1 - fx == l1 - x) a[fx++] = x;
				else b[fy++] = x;
			}
			else {
				if (i2 - fy == l2 - x) b[fy++] = x;
				else a[fx++] = x;
			}
		}
	}
	for (int i = 1; i < n; i++) printf("%d ", a[i]); puts("");
	for (int i = 1; i < m; i++) printf("%d ", b[i]); puts("");
//	for (int i = 1; i < n; i++) printf("%d ", a[i]), assert(a[i] < a[i + 1]); puts("");
//	for (int i = 1; i < m; i++) printf("%d ", b[i]), assert(b[i] < b[i + 1]); puts("");
//	for (int x = 1; x <= n + m; x++) {
//		for (int i = 1; i <= n; i++) {
//			if (a[i] == x) goto B;
//		}
//		for (int i = 1; i <= m; i++) {
//			if (b[i] == x) goto B;
//		}
//		cout<<"@"<<x<<endl;
//		B:;
//	}
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 2ms
memory: 3548kb

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: 2ms
memory: 3492kb

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: 0ms
memory: 3676kb

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:

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 
1 2 93 94 95 96 97 98 99 100 101 102...

result:

ok correct

Test #4:

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

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:

1 2 3 4 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 163 ...

result:

ok correct

Test #5:

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

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: 1ms
memory: 3552kb

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: 2ms
memory: 3564kb

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: 2ms
memory: 3564kb

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: 2ms
memory: 3496kb

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: 2ms
memory: 3584kb

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: 2ms
memory: 3740kb

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:

2 3 6 7 9 10 16 17 19 20 21 23 27 29 31 34 35 37 38 44 46 47 49 50 53 54 57 58 59 61 65 66 67 70 71 73 74 75 76 77 78 79 80 82 84 85 92 94 95 97 102 104 105 106 109 110 111 112 114 115 116 120 123 124 127 129 130 134 136 137 141 143 144 148 150 151 153 154 160 165 166 167 171 179 180 181 185 186 187...

result:

ok correct

Test #12:

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

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

result:

ok correct

Test #13:

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

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 33 36 39 40 41 43 45 49 50 51 54 56 62 63 65 67 69 70 71 73 74 75 76 79 80 81 89 91 92 96 101 102 104 105 106 107 108 110 112 117 119 120 122 123 125 132 135 138 139 140 141 142 143 144 145 148 149 153 154 155 157 160 
1 6 8 9 13 15 16 18 19 20 21 22 23 ...

result:

ok correct

Test #14:

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

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

result:

ok correct

Test #15:

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

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:

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

result:

ok correct

Test #16:

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

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:

5 6 7 8 9 10 11 15 16 17 18 19 21 22 23 24 25 26 27 29 30 37 38 39 40 42 45 49 50 53 54 55 56 57 60 65 66 69 70 71 72 73 74 76 77 78 80 81 82 86 87 88 89 90 91 92 93 94 98 101 102 103 110 111 112 117 118 119 120 121 123 124 125 127 133 134 135 136 
1 2 3 4 12 13 14 20 28 31 32 33 34 35 36 41 43 44 4...

result:

ok correct

Test #17:

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

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:

1 2 3 4 5 6 21 22 23 24 26 29 30 37 38 39 40 41 42 43 46 47 48 49 50 51 52 53 61 62 63 64 65 70 71 72 73 74 75 76 77 86 87 88 89 96 97 98 100 101 102 103 106 107 108 109 110 111 112 118 119 120 121 122 123 125 126 127 128 129 130 136 142 143 144 147 148 157 158 159 160 161 165 
7 8 9 10 11 12 13 14 ...

result:

ok correct

Test #18:

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

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:

4 5 6 8 9 10 14 17 18 21 22 32 33 35 36 42 47 49 50 51 53 54 55 56 57 58 65 66 67 73 76 77 78 79 80 81 82 83 84 85 86 87 88 93 94 95 96 99 100 101 102 103 104 105 107 108 110 112 113 114 117 118 119 120 121 122 123 124 128 132 133 134 135 136 137 138 144 145 148 153 156 157 158 159 
1 2 3 7 11 12 13...

result:

ok correct

Test #19:

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

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:

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

result:

ok correct

Test #20:

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

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:

6 7 8 9 10 11 13 14 15 16 17 20 21 22 23 27 28 29 32 33 34 41 42 43 44 45 46 47 48 49 50 51 52 61 62 63 64 65 66 67 68 69 70 71 72 73 74 81 82 89 90 91 92 93 99 100 101 102 105 106 107 111 115 116 120 121 122 123 124 125 129 130 131 132 133 139 140 141 142 145 146 150 151 154 155 156 158 159 160 161...

result:

ok correct

Test #21:

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

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: 2ms
memory: 3740kb

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: 0ms
memory: 3576kb

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:

4 5 6 9 10 11 12 16 17 18 19 20 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 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 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 132 133 134 135 136 137 138 139 140 141 143 144 145 146 147 148 ...

result:

ok correct

Test #24:

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

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:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 52 53 54 55 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 103 104 128 129 130 131 132 133 134 135 142 143 144 145 146 147 148 149 
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...

result:

ok correct

Test #25:

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

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: 2ms
memory: 3588kb

input:

2 2
1 0
0 4

output:

1 2 
3 4 

result:

ok correct

Test #27:

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

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: 0ms
memory: 3708kb

input:

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

output:

3 5 6 7 8 
1 2 4 9 10 

result:

ok correct

Test #29:

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

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: 2ms
memory: 3508kb

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: 0ms
memory: 3588kb

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