QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#934416 | #10138. Signals | zhaohaikun | 100 ✓ | 304ms | 338680kb | C++23 | 4.2kb | 2025-03-14 19:12:01 | 2025-03-14 19:12:02 |
Judging History
answer
// MagicDark
#include <bits/stdc++.h>
#define debug cerr << "\33[32m[" << __LINE__ << "]\33[m "
#define SZ(x) ((int) x.size() - 1)
#define all(x) x.begin(), x.end()
#define ms(x, y) memset(x, y, sizeof x)
#define F(i, x, y) for (int i = (x); i <= (y); i++)
#define DF(i, x, y) for (int i = (x); i >= (y); i--)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template <typename T> T& chkmax(T &x, T y) {return x = max(x, y);}
template <typename T> T& chkmin(T &x, T y) {return x = min(x, y);}
template <typename T> T& read(T &x) {
x = 0; int f = 1; char c = getchar();
for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
return x *= f;
}
bool be;
const int N = 5e6 + 10;
int n, k, a[N], f[N], l[N], r[N];
int b[N];
// bool vis[N];
// vector <int> v[N];
// int cnt;
bool vis[N];
// bitset <N> vis;
void zhk() {
// cnt++;
read(n), read(k);
F(i, 1, n) read(a[i % n + 1]);
F(i, 1, n) b[i] = a[i];
vector <vector <int>> ans(n + 1, vector <int> (k, 0));
// F(j, 1, n) cout << a[j] << ' '; debug << endl;
F(i, 1, n) f[i] = i;
sort(f + 1, f + n + 1, [&] (int x, int y) {
return a[x] > a[y];
});
int sum = 0;
F(i, 1, n) sum += a[i];//, w.push_back(i);
if (a[f[1]] > sum - a[f[1]] || (sum & 1)) {
cout << "NO\n";
return;
}
vector <int> w;
// int cur = 0;
// F(i, 1, n) {
// sum -= a[f[i]];
// if (i != n) lim[i] = max(0, 2 * a[f[i + 1]] - sum), debug << i << " " << lim[i] << endl;
// }
l[n] = r[n] = 0;
DF(i, n, 1) {
l[i - 1] = l[i] - a[f[i]];
r[i - 1] = r[i] + a[f[i]];
chkmax(l[i - 1], a[f[i]] - r[i]);
chkmin(r[i - 1], 2 * k - l[i] - a[f[i]]);
chkmax(l[i - 1], 0);
chkmin(r[i - 1], k);
// chkmax(lim[i], a[i] - lim[i + 1]);
}
// F(i, 0, n) {
// debug << l[i] << " " << r[i] << endl;
// }
if (l[0]) {
cout << "NO\n";
return;
}
F(i, 1, n) {
int cur = w.size();
int g = l[i];//lim[i];
// if (i != n) {
// // chkmax(g, 2 * a[f[i + 1]] - sum);
// }
// debug << cur << " " << g << endl;
assert(cur + a[f[i]] >= g);
int x = (cur + a[f[i]] - g) / 2;
chkmin(x, a[f[i]]);
chkmin(x, cur);
// if (cur >= a[i]) {
// ll t = cur + a[i] - g;
// }
// debug << x << endl;
F(j, 1, k) vis[j] = false;
for (int j: w) vis[j] = true;
F(j, 1, x) {
assert(w.size());
int y = w.back(); w.pop_back();
// vis[y] = true;
// debug << "! " << y << endl;
ans[f[i]][y - 1] = 1;
}
// debug << a[f[i]] << " " << cur << " " << x << endl;
if (a[f[i]] > x) {
int t = a[f[i]] - x;
F(j, 1, k) {
if (!vis[j]) {
assert(!ans[f[i]][j - 1]);
ans[f[i]][j - 1] = 1;
w.push_back(j);
if (!--t) break;
}
}
// if (t) {
// cout << "NO\n";
// return;
// }
assert(!t);
}
// ll res = sum - a[i];
int gs = 0;
F(w, 0, k - 1) gs += ans[f[i]][w];
// debug << gs << " " << a[f[i]] << endl;
assert(gs == a[f[i]]);
}
F(i, 1, k) {
// F(j, 1, n) f[j] = j;
// ll sum = 0;
// F(j, 1, n) sum += a[j];
// // F(j, 1, n) cout << f[j] << ' '; debug << endl;
// DF(j, n, 1) {
// if (a[f[j]]) {
// // debug << j << endl;
// j = min((ll) j, sum - a[f[1]] + 2 - a[f[1]]);
// if (j & 1) j--;
// if (j <= 0) {
// cout << "NO\n";
// return;
// }
// // if (a[f[1]] > 1) {
// while (a[f[j - 1]] < a[f[1]]) {
// // assert(j >= 2);
// j -= 2;
// }
// // }
// F(k, 1, j) {
// ans[f[k]][i - 1] = 1;
// assert(a[f[k]]);
// a[f[k]]--;
// }
ans[1][i - 1] = 0;
F(j, 2, n) {
ans[j][i - 1] ^= ans[j - 1][i - 1];
}
// break;
// }
// }
// // F(j, 1, n) cout << a[j] << ' '; debug << endl;
}
// F(i, 1, n)
// if (a[i]) {
// cout << "NO\n";
// return;
// }
cout << "YES\n";
F(i, 1, n) {
F(j, 0, k - 1) cout << ans[i][j]; cout << '\n';
int s = 0;
F(j, 0, k - 1) {
s += ans[i][j] != ans[(i + n - 2) % n + 1][j];
}
assert(s == b[i]);
}
}
bool ed;
signed main() {
// debug << sizeof(&ed - &be) / 1024 / 1024 << endl;
int _ = 1;
cin >> _;
while (_--) zhk();
return 0;
}
/* why?
*/
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 5
Accepted
Test #1:
score: 5
Accepted
time: 0ms
memory: 13864kb
input:
5 5 4 1 0 0 1 4 5 4 2 1 3 4 0 5 4 4 3 3 1 1 5 4 2 3 1 2 0 5 4 2 4 4 2 0
output:
NO YES 0000 1100 1000 1111 0000 YES 0000 1111 1000 0110 0010 YES 0000 0110 1000 1100 0000 YES 0000 1100 0011 1100 0000
result:
ok All test cases validated successfully
Test #2:
score: 5
Accepted
time: 0ms
memory: 13904kb
input:
5 5 5 4 0 0 5 1 5 5 2 5 1 3 1 5 5 0 5 3 5 1 5 5 4 1 0 3 0 5 5 2 3 0 0 1
output:
YES 00000 01111 01111 01111 10000 YES 00000 11000 00111 10111 10000 NO YES 00000 11110 01110 01110 00000 YES 00000 01100 10000 10000 10000
result:
ok All test cases validated successfully
Test #3:
score: 5
Accepted
time: 0ms
memory: 13904kb
input:
5 4 4 4 4 3 3 4 4 4 3 3 2 4 4 4 3 1 4 4 4 0 0 2 4 4 4 1 3 4 2
output:
YES 0000 1111 0000 1110 YES 0000 1111 1000 0110 NO NO YES 0000 0100 0011 1100
result:
ok All test cases validated successfully
Test #4:
score: 5
Accepted
time: 0ms
memory: 13860kb
input:
5 5 5 0 0 3 0 3 5 5 3 5 0 1 5 5 5 4 1 5 5 3 5 5 0 5 1 0 2 5 5 4 0 5 5 5
output:
YES 00000 00000 00000 11100 11100 NO YES 00000 11110 01110 10001 01110 NO NO
result:
ok All test cases validated successfully
Subtask #2:
score: 2
Accepted
Test #5:
score: 2
Accepted
time: 95ms
memory: 23432kb
input:
10 100000 1 1 1 1 0 1 1 1 1 0 0 0 1 0 1 1 1 1 0 0 1 1 0 0 0 1 1 0 1 0 0 0 1 0 1 0 1 0 1 0 0 0 0 1 0 0 0 0 1 0 1 0 0 1 0 0 1 1 1 0 0 1 0 0 1 0 0 0 1 1 1 1 1 1 0 0 1 0 0 0 0 0 0 0 0 0 1 1 0 1 1 1 0 0 1 0 1 1 0 1 0 0 0 0 0 0 1 1 0 1 0 1 1 1 1 1 1 1 0 1 1 1 0 0 0 0 1 0 1 0 1 1 0 0 0 1 1 0 1 1 1 1 1 1 1 ...
output:
YES 0 1 0 1 1 0 1 0 1 1 1 1 0 0 1 0 1 0 0 0 1 0 0 0 0 1 0 0 1 1 1 1 0 0 1 1 0 0 1 1 1 1 1 0 0 0 0 0 1 1 0 0 0 1 1 1 0 1 0 0 0 1 1 1 0 0 0 0 1 0 1 0 1 0 0 0 1 1 1 1 1 1 1 1 1 1 0 1 1 0 1 0 0 0 1 1 0 1 1 0 0 0 0 0 0 0 1 0 0 1 1 0 1 0 1 0 1 0 0 1 0 1 1 1 1 1 0 0 1 1 0 1 1 1 1 0 1 1 0 1 0 1 0 1 0 0 0 0 ...
result:
ok All test cases validated successfully
Test #6:
score: 2
Accepted
time: 225ms
memory: 51420kb
input:
5 500000 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 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...
output:
YES 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 ...
result:
ok All test cases validated successfully
Test #7:
score: 2
Accepted
time: 243ms
memory: 338680kb
input:
1 5000000 1 1 0 0 1 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 1 1 1 1 1 1 0 0 1 1 0 0 1 0 1 1 1 0 0 1 0 1 0 1 0 1 1 1 1 0 0 1 0 1 1 1 1 1 0 1 0 0 0 0 1 1 1 0 0 0 0 0 1 1 1 1 1 0 1 0 0 0 0 0 0 1 0 0 0 0 1 1 0 0 1 0 1 1 1 1 1 0 1 0 0 0 1 1 1 0 1 1 0 0 1 0 1 0 1 0 1 0 1 0 0 0 1 1 1 0 1 1 0 1 1 1 1 1 1 0 1 1 0 0 0 ...
output:
NO
result:
ok All test cases validated successfully
Subtask #3:
score: 8
Accepted
Test #8:
score: 8
Accepted
time: 292ms
memory: 26812kb
input:
10 200000 2 2 2 1 0 0 2 0 2 1 2 2 2 0 1 0 1 1 1 0 2 1 2 2 1 2 2 1 2 0 0 0 2 2 0 0 0 1 0 0 0 1 0 0 2 2 1 0 1 2 2 2 0 2 0 2 0 0 0 0 0 0 1 1 2 1 1 0 0 2 0 2 2 2 2 2 0 2 0 2 0 0 0 1 0 2 2 0 0 2 0 1 1 1 2 0 0 0 2 2 0 0 2 0 0 2 0 0 0 1 1 2 1 0 1 0 1 0 0 2 0 1 0 1 2 0 1 2 0 2 1 2 1 2 2 2 0 0 2 0 0 2 1 0 2 ...
output:
YES 00 11 00 10 10 10 01 01 10 00 11 00 11 11 01 01 11 01 11 11 00 10 01 10 00 11 00 10 01 01 01 01 10 01 01 01 01 11 11 11 11 01 01 01 10 01 11 11 01 10 01 10 10 01 01 10 10 10 10 10 10 10 00 10 01 11 01 01 01 10 10 01 10 01 10 01 01 10 10 01 01 01 01 11 11 00 11 11 11 00 00 10 00 10 01 01 01 01 10...
result:
ok All test cases validated successfully
Test #9:
score: 8
Accepted
time: 304ms
memory: 89060kb
input:
2 1000000 2 0 0 0 2 2 2 0 2 2 0 2 0 0 0 2 2 2 0 0 2 2 0 2 2 0 0 0 0 0 0 2 0 0 2 2 0 0 2 0 0 0 0 0 2 2 0 0 0 2 0 2 0 0 2 2 2 2 2 2 0 2 2 2 0 2 2 2 2 0 2 0 0 0 0 2 0 2 0 0 0 2 0 2 0 2 2 2 2 2 2 0 2 0 2 2 2 0 0 2 0 0 2 0 2 0 0 2 0 2 2 2 2 0 0 2 2 0 0 0 2 2 2 0 2 0 0 0 0 0 0 0 2 0 0 0 0 0 2 0 2 0 2 2 0 ...
output:
YES 00 00 00 00 11 00 11 11 00 11 11 00 00 00 00 11 00 11 11 11 00 11 11 00 11 11 11 11 11 11 11 00 00 00 11 00 00 00 11 11 11 11 11 11 00 11 11 11 11 00 00 11 11 11 00 11 00 11 00 11 11 00 11 00 00 11 00 11 00 00 11 11 11 11 11 00 00 11 11 11 11 00 00 11 11 00 11 00 11 00 11 11 00 00 11 00 11 11 11...
result:
ok All test cases validated successfully
Test #10:
score: 8
Accepted
time: 261ms
memory: 30908kb
input:
10 200000 2 2 1 1 1 1 1 0 1 2 0 1 2 0 2 2 2 2 1 1 0 2 1 1 1 1 0 1 0 1 1 2 2 2 1 0 2 0 0 1 0 0 2 2 0 2 2 2 2 1 2 2 0 2 2 2 2 2 0 0 0 0 0 1 0 0 0 1 0 1 2 1 1 1 2 0 0 1 2 1 1 1 2 0 1 1 0 0 1 2 0 1 1 1 0 1 1 1 0 1 2 2 0 1 0 0 1 2 1 2 2 0 0 1 0 2 1 1 1 0 2 1 2 0 0 1 1 0 0 2 1 2 0 1 0 0 2 2 2 1 2 2 2 0 0 ...
output:
YES 00 11 01 11 01 11 01 01 11 00 00 10 01 01 10 01 10 01 11 01 01 10 00 10 00 10 10 00 00 10 00 11 00 11 01 01 10 10 10 00 00 00 11 00 00 11 00 11 00 10 01 10 10 01 10 01 10 01 01 01 01 01 01 11 11 11 11 01 01 11 00 10 00 10 01 01 01 11 00 10 00 10 01 01 11 01 01 01 11 00 00 10 00 10 10 00 10 00 00...
result:
ok All test cases validated successfully
Test #11:
score: 8
Accepted
time: 0ms
memory: 13900kb
input:
243 5 2 0 0 0 0 0 5 2 1 0 0 0 0 5 2 2 0 0 0 0 5 2 0 1 0 0 0 5 2 1 1 0 0 0 5 2 2 1 0 0 0 5 2 0 2 0 0 0 5 2 1 2 0 0 0 5 2 2 2 0 0 0 5 2 0 0 1 0 0 5 2 1 0 1 0 0 5 2 2 0 1 0 0 5 2 0 1 1 0 0 5 2 1 1 1 0 0 5 2 2 1 1 0 0 5 2 0 2 1 0 0 5 2 1 2 1 0 0 5 2 2 2 1 0 0 5 2 0 0 2 0 0 5 2 1 0 2 0 0 5 2 2 0 2 0 0 5 ...
output:
YES 00 00 00 00 00 NO NO NO YES 00 10 00 00 00 NO NO NO YES 00 11 00 00 00 NO YES 00 10 10 00 00 NO YES 00 00 10 00 00 NO YES 00 11 10 00 00 NO YES 00 01 10 00 00 NO NO NO YES 00 11 11 00 00 NO YES 00 01 11 00 00 NO YES 00 00 11 00 00 NO NO NO YES 00 10 10 10 00 NO YES 00 00 10 10 00 NO YES 00 11 10...
result:
ok All test cases validated successfully
Subtask #4:
score: 32
Accepted
Test #12:
score: 32
Accepted
time: 27ms
memory: 13820kb
input:
100 100 100 34 23 39 32 11 44 36 31 13 35 13 12 7 41 18 13 38 9 23 24 39 19 18 16 13 42 41 31 15 30 27 29 29 45 14 41 36 37 13 2 1 18 35 5 34 45 40 17 1 15 5 30 7 5 25 7 34 17 15 26 13 37 16 19 38 5 39 14 33 23 28 29 0 20 16 2 35 23 32 42 40 36 31 18 44 6 3 26 21 20 16 28 14 37 41 24 32 34 22 29 100...
output:
NO YES 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 1111111111111111111111111111111111111111111100000000000000000000000000000000000000000000000000000000 1111111111111111111111111111111111111111111100000000000000000000000000000000000000000000000...
result:
ok All test cases validated successfully
Test #13:
score: 32
Accepted
time: 36ms
memory: 14824kb
input:
5 10000 20 3 2 9 2 1 9 10 4 7 7 8 5 10 10 1 2 5 1 9 1 4 7 0 8 8 9 10 1 5 2 9 1 6 9 1 6 8 10 2 0 10 3 1 1 10 2 3 8 2 6 8 9 9 6 6 5 10 1 9 9 6 2 6 0 10 7 2 7 9 1 2 7 0 3 7 2 1 7 6 3 10 2 6 5 9 4 9 0 5 10 8 8 0 2 8 10 3 2 4 0 3 1 0 6 1 8 7 1 0 9 3 4 3 5 2 2 6 2 3 1 0 2 3 2 3 9 7 7 5 4 3 1 3 5 5 10 4 3 ...
output:
YES 00000000000000000000 11100000000000000000 00100000000000000000 11011111100000000000 00011111100000000000 10011111100000000000 01100000000000000000 10011111110000000000 01101111110000000000 10010001110000000000 01101111110000000000 10010000110000000000 01101000110000000000 10010111000000000000 01...
result:
ok All test cases validated successfully
Test #14:
score: 32
Accepted
time: 149ms
memory: 37388kb
input:
1 10 500000 122733 101855 211422 33006 148672 92613 233721 88551 142592 74649
output:
YES 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
ok All test cases validated successfully
Test #15:
score: 32
Accepted
time: 256ms
memory: 86640kb
input:
1 1000000 5 2 1 1 1 2 1 0 0 1 1 0 1 2 1 0 2 1 0 2 0 1 0 1 2 2 0 2 2 2 2 0 0 1 0 2 1 2 0 2 1 0 2 1 2 0 1 2 0 0 0 2 2 2 0 0 0 0 1 2 2 2 1 2 0 1 2 2 2 0 2 2 2 1 2 0 0 2 0 0 2 1 2 0 0 0 0 1 0 2 0 0 1 2 1 1 1 2 1 2 2 2 1 1 1 0 1 0 0 2 2 1 1 1 1 0 2 2 1 2 1 0 0 0 0 2 1 2 0 2 2 2 2 1 0 1 2 1 1 1 0 1 2 0 0 ...
output:
YES 00000 11000 01000 11000 01000 10000 00000 00000 00000 10000 00000 00000 10000 01000 11000 11000 00000 10000 10000 01000 01000 11000 11000 01000 10000 01000 01000 10000 01000 10000 01000 01000 01000 11000 11000 00000 10000 01000 01000 10000 00000 00000 11000 01000 10000 10000 00000 11000 11000 11...
result:
ok All test cases validated successfully
Test #16:
score: 32
Accepted
time: 152ms
memory: 43440kb
input:
1 5 1000000 461423 37927 182822 32106 316298
output:
YES 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
ok All test cases validated successfully
Subtask #5:
score: 24
Accepted
Test #17:
score: 24
Accepted
time: 0ms
memory: 13904kb
input:
3 5 3 2 1 3 0 2 10 6 3 2 1 4 3 2 1 3 2 1 2 3 2 1
output:
YES 000 110 100 011 011 YES 000000 011100 101100 001100 110000 001000 111000 011000 100000 010000 NO
result:
ok All test cases validated successfully
Test #18:
score: 24
Accepted
time: 2ms
memory: 13856kb
input:
3 1000 20 6 17 10 11 11 12 11 17 20 7 7 12 11 12 13 9 4 0 7 13 15 4 15 3 19 2 6 15 16 7 10 6 15 10 9 18 18 8 14 3 16 15 14 8 0 4 13 11 12 20 7 15 13 13 15 0 20 8 10 6 11 20 14 9 11 20 1 3 3 9 9 20 7 13 5 3 9 12 15 19 11 13 15 14 14 18 9 6 2 6 16 6 9 2 17 4 4 7 2 14 18 15 19 6 8 7 3 7 10 0 20 8 4 3 1...
output:
YES 00000000000000000000 11111100000000000000 00000011111111111000 11111100001111111000 00000011110111111000 11111100001111111000 00000011110011111000 11111100001011111000 00000011110100000000 11111100001011111111 00000010001011111111 01111101001011111111 10000010110111111111 01111101001111111111 10...
result:
ok All test cases validated successfully
Test #19:
score: 24
Accepted
time: 22ms
memory: 14820kb
input:
4 10000 15 0 13 5 15 2 9 5 8 15 3 9 6 15 2 9 12 3 14 13 7 12 13 0 13 5 14 6 0 9 0 13 8 1 0 2 0 5 1 8 9 14 12 15 1 8 1 10 12 1 12 5 0 6 14 9 8 6 13 8 11 12 10 15 2 9 4 8 14 14 2 10 9 10 14 13 14 15 13 10 4 6 5 0 7 4 9 3 4 3 8 4 6 2 5 10 7 12 14 0 2 0 6 0 14 14 13 9 5 11 3 8 0 13 15 3 3 3 2 8 2 2 7 11...
output:
YES 000000000000000 000000000000000 111111111111100 000001111111100 111110000000011 001110000000011 110001111000011 001111111000011 110000001000011 001111110111100 110111110111100 001000001111100 110111001111100 001000110000011 111000110000011 000111001000011 111000110111011 000000110111011 11111100...
result:
ok All test cases validated successfully
Test #20:
score: 24
Accepted
time: 165ms
memory: 19620kb
input:
5 50000 20 0 0 0 2 0 20 20 0 0 0 20 20 20 20 14 0 20 20 20 20 0 20 20 20 0 8 0 5 0 20 16 20 0 20 0 0 0 20 20 20 20 0 0 20 0 0 20 20 20 20 0 0 20 0 20 0 20 0 0 20 0 20 0 0 0 0 20 0 20 20 0 20 0 0 19 20 0 0 0 0 20 20 0 7 0 0 0 0 0 20 0 7 0 0 0 2 0 20 20 20 20 20 0 20 0 20 20 0 0 0 0 2 0 0 20 20 0 0 12...
output:
YES 00000000000000000000 00000000000000000000 00000000000000000000 00000000000000000000 11000000000000000000 11000000000000000000 00111111111111111111 11000000000000000000 11000000000000000000 11000000000000000000 11000000000000000000 00111111111111111111 11000000000000000000 00111111111111111111 11...
result:
ok All test cases validated successfully
Test #21:
score: 24
Accepted
time: 204ms
memory: 19540kb
input:
5 50000 20 4 0 0 17 1 11 2 14 0 18 5 0 5 19 20 2 14 4 15 15 18 20 15 4 14 14 4 16 16 15 19 6 12 20 16 17 0 16 20 10 16 13 1 9 9 6 7 6 5 10 9 8 11 8 18 6 7 5 5 6 13 20 3 1 15 20 10 7 9 13 14 11 12 4 1 8 8 12 15 5 19 13 3 11 17 20 8 7 12 3 0 4 2 2 6 8 5 4 16 6 4 8 6 3 17 11 8 6 6 0 10 13 8 1 20 0 5 6 ...
output:
YES 00000000000000000000 11110000000000000000 11110000000000000000 11110000000000000000 00001111111111111000 10001111111111111000 01110000000111111000 10110000000111111000 01001111111000111000 01001111111000111000 10110000000111000100 01001000000111000100 01001000000111000100 10110000000111000100 01...
result:
ok All test cases validated successfully
Test #22:
score: 24
Accepted
time: 51ms
memory: 13900kb
input:
67170 6 1 0 0 0 0 0 0 6 1 1 0 0 0 0 0 6 1 0 1 0 0 0 0 6 1 1 1 0 0 0 0 6 1 0 0 1 0 0 0 6 1 1 0 1 0 0 0 6 1 0 1 1 0 0 0 6 1 1 1 1 0 0 0 6 1 0 0 0 1 0 0 6 1 1 0 0 1 0 0 6 1 0 1 0 1 0 0 6 1 1 1 0 1 0 0 6 1 0 0 1 1 0 0 6 1 1 0 1 1 0 0 6 1 0 1 1 1 0 0 6 1 1 1 1 1 0 0 6 1 0 0 0 0 1 0 6 1 1 0 0 0 1 0 6 1 0 ...
output:
YES 0 0 0 0 0 0 NO NO YES 0 1 0 0 0 0 NO YES 0 1 1 0 0 0 YES 0 0 1 0 0 0 NO NO YES 0 1 1 1 0 0 YES 0 0 1 1 0 0 NO YES 0 0 0 1 0 0 NO NO YES 0 1 0 1 0 0 NO YES 0 1 1 1 1 0 YES 0 0 1 1 1 0 NO YES 0 0 0 1 1 0 NO NO YES 0 1 0 1 1 0 YES 0 0 0 0 1 0 NO NO YES 0 1 0 0 1 0 NO YES 0 1 1 0 1 0 YES 0 0 1 0 1 0...
result:
ok All test cases validated successfully
Subtask #6:
score: 29
Accepted
Test #23:
score: 29
Accepted
time: 160ms
memory: 17724kb
input:
5 1000 1000 536 976 595 207 649 413 554 75 920 836 797 771 516 298 865 279 244 80 969 598 403 12 504 608 206 107 339 877 17 69 839 372 811 900 509 139 616 133 822 963 62 892 819 980 434 632 956 965 666 66 555 378 492 54 654 779 972 754 579 571 80 971 21 553 293 570 814 983 967 507 534 511 382 993 60...
output:
YES 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
ok All test cases validated successfully
Test #24:
score: 29
Accepted
time: 152ms
memory: 17860kb
input:
5 1000 1000 0 5 991 0 996 0 1000 7 1000 0 1000 1000 0 0 0 1000 1000 1000 998 1 0 0 1000 1000 1000 0 0 1000 1000 1000 998 1 1000 0 994 1000 0 1000 992 0 1000 4 1000 6 995 1000 1000 7 1000 2 991 1000 1000 1 998 8 998 8 1000 0 997 0 0 7 1000 7 1000 1000 0 7 0 1000 994 1000 0 1000 1000 0 0 1000 1000 100...
output:
YES 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
ok All test cases validated successfully
Test #25:
score: 29
Accepted
time: 175ms
memory: 33424kb
input:
1 10000 500 352 368 47 0 291 411 328 171 139 258 31 205 443 68 41 411 26 302 51 299 81 289 285 194 390 200 410 283 289 322 23 334 29 153 380 291 495 100 207 406 230 63 4 349 170 337 435 439 339 263 224 33 76 189 130 49 362 499 187 497 353 22 494 12 182 261 393 468 308 382 149 94 413 257 250 73 371 9...
output:
YES 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
ok All test cases validated successfully
Test #26:
score: 29
Accepted
time: 161ms
memory: 33492kb
input:
1 10000 500 0 1 500 0 500 0 0 500 0 500 500 10 500 500 0 500 0 500 0 0 0 0 500 500 500 7 499 500 0 500 500 0 500 500 500 500 500 0 500 500 500 500 0 0 500 0 0 0 500 0 0 500 500 500 0 500 500 500 0 0 0 0 0 0 500 500 500 0 500 0 500 500 0 0 500 0 0 500 0 500 0 500 0 0 500 0 500 0 0 500 496 0 0 500 500...
output:
YES 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
ok All test cases validated successfully
Test #27:
score: 29
Accepted
time: 291ms
memory: 88816kb
input:
1 1000000 5 4 0 3 2 5 2 0 2 5 2 3 2 3 3 3 2 0 5 2 4 1 4 2 5 4 5 0 0 2 5 1 5 1 5 4 5 4 3 2 3 4 0 4 2 2 4 3 1 4 3 1 3 3 2 2 2 0 2 0 4 1 0 1 3 0 1 2 1 4 4 2 5 2 5 0 2 2 0 2 2 1 4 1 2 0 0 0 5 0 3 0 1 5 1 3 5 1 3 1 4 1 2 0 5 0 5 2 1 4 1 0 3 2 0 2 4 1 0 1 5 3 2 5 3 0 1 3 4 5 5 3 2 5 2 5 5 5 4 4 4 4 3 0 2 ...
output:
YES 00000 11110 11110 00010 11010 00101 11101 11101 00101 11010 00010 11110 00110 11010 00110 11010 00010 00010 11101 00101 11011 01011 10101 01101 10010 01100 10011 10011 10011 01011 10100 00100 11011 01011 10100 01010 10101 01011 10111 01111 10011 01101 01101 10011 01011 10011 01101 10001 00001 11...
result:
ok All test cases validated successfully
Test #28:
score: 29
Accepted
time: 252ms
memory: 86640kb
input:
1 1000000 5 0 5 0 0 0 0 5 0 0 5 0 5 5 0 5 5 2 0 5 5 5 5 5 5 5 1 5 0 5 5 5 0 0 5 0 5 0 5 0 5 5 0 4 5 5 5 0 5 5 5 5 5 5 0 5 5 5 0 5 5 5 5 0 0 0 5 5 0 5 5 0 0 5 0 0 5 0 2 5 5 5 5 5 0 0 5 0 5 5 2 5 0 5 5 0 0 5 0 5 0 0 5 5 0 0 5 5 0 5 0 0 5 5 5 5 0 5 5 4 0 4 5 0 0 5 5 5 0 0 5 5 5 0 5 3 5 5 5 0 5 0 5 5 5 ...
output:
YES 00000 00000 11111 11111 11111 11111 11111 00000 00000 00000 11111 11111 00000 11111 11111 00000 11111 00111 00111 11000 00111 11000 00111 11000 00111 11000 01000 10111 10111 01000 10111 01000 01000 01000 10111 10111 01000 01000 10111 10111 01000 10111 10111 01001 10110 01001 10110 10110 01001 10...
result:
ok All test cases validated successfully
Test #29:
score: 29
Accepted
time: 153ms
memory: 33648kb
input:
1 100 50000 15913 27037 24475 48873 4275 5205 39654 38109 36794 20938 16200 38603 26642 44507 39077 44556 18259 24294 6018 34753 39680 8676 41911 21924 4661 18294 40266 18574 16312 33557 34440 10169 48626 27570 15002 46112 12327 3393 17225 41101 21028 22032 49290 24256 37972 45845 47244 49593 16185 ...
output:
YES 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
ok All test cases validated successfully
Test #30:
score: 29
Accepted
time: 1ms
memory: 26016kb
input:
1 20 200000 164767 8392 112769 135744 18677 99960 40468 20328 162934 24119 22105 196147 68626 189629 128954 24815 64405 61136 436 164760
output:
NO
result:
ok All test cases validated successfully
Test #31:
score: 29
Accepted
time: 1ms
memory: 30936kb
input:
1 10 500000 464604 401750 476544 482463 8565 368095 214788 79598 442468 361426
output:
NO
result:
ok All test cases validated successfully
Test #32:
score: 29
Accepted
time: 2ms
memory: 31072kb
input:
1 10 500000 499990 10 499998 0 500000 8 500000 500000 0 5
output:
NO
result:
ok All test cases validated successfully
Test #33:
score: 29
Accepted
time: 157ms
memory: 34536kb
input:
1 50 100000 94709 33054 40334 27577 18748 76835 82644 58539 38094 73142 79654 50764 29877 60671 65268 32179 33880 25345 77671 5094 40597 78954 65492 7083 93904 22363 92158 33535 27319 43230 87759 62622 65173 63485 10362 70619 47772 67039 5025 89642 76727 74823 58732 98789 94912 53800 52182 56101 805...
output:
YES 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
ok All test cases validated successfully