QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#495048 | #9114. Black or White 2 | ucup-team4361# | AC ✓ | 27ms | 12376kb | C++14 | 3.5kb | 2024-07-27 18:18:08 | 2024-07-27 18:18:08 |
Judging History
answer
#include <bits/stdc++.h>
#define LL long long
#define ull unsigned long long
#define F(i, j, k) for (int i = j; i <= k; ++i)
#define DF(i, j, k) for (int i = j; i >= k; --i)
using namespace std;
template <typename T> inline void read(T &n) {
T w = 1;
n = 0;
char ch = getchar();
while (!isdigit(ch) && ch != EOF) {
if (ch == '-') w = -1;
ch = getchar();
}
while (isdigit(ch) && ch != EOF) {
n = (n << 3) + (n << 1) + (ch & 15);
ch = getchar();
}
n *= w;
}
template <typename T> inline void write(T x) {
T l = 0;
ull y = 0;
if (!x) { putchar(48); return; }
if (x < 0) { x = -x; putchar('-'); }
while (x) { y = y * 10 + x % 10; x /= 10; ++l; }
while (l) { putchar(y % 10 + 48); y /= 10; --l; }
}
template <typename T> inline void writes(T x) {
write(x);
putchar(' ');
}
template <typename T> inline void writeln(T x) {
write(x);
puts("");
}
template <typename T> inline void checkmax(T &a, T b) { a = a > b ? a : b; }
template <typename T> inline void checkmin(T &a, T b) { a = a < b ? a : b; }
int n, m, K, f[1501], ans[1501][1501], now;
inline void out() {
if (now > K) ans[1][1] = 0;
F(i, 1, n) {
F(j, 1, m)
putchar(ans[i][j] + 48);
puts("");
}
}
inline void solve() {
read(n); read(m); read(K);
now = 0;
for (int i = 1; i <= n; i ++) f[i] = 0;
F(i, 1, n)
F(j, 1, m)
ans[i][j] = 0;
if (K == 0) {
out();
return;
}
if (K == 1) {
ans[1][1] = 1;
out();
return;
}
if (K == 2) {
if (n > 2)
ans[1][1] = ans[3][1] = 1;
else
if (m > 2)
ans[1][1] = ans[1][3] = 1;
else
ans[1][1] = ans[1][2] = 1;
out();
return;
}
if (K == 3) {
ans[1][1] = ans[1][2] = ans[2][1] = 1;
out();
return;
}
for (int i = 1; i <= n; i += 2) {
ans[i][1] = f[i] = 1;
++ now;
if (now >= K) {
out();
return;
}
for (int j = i - 1; j >= 1; j --) {
if (f[j] == m) continue;
if (f[j] + 2 > m) {
ans[j][m] = 1;
f[j] = m;
++ now;
if (now >= K) {
out();
return;
}
}
else {
ans[j][f[j] + 1] = ans[j][f[j] + 2] = 1;
f[j] += 2;
now += 2;
if (now >= K) {
out();
return;
}
}
}
}
while (1) {
for (int j = n; j >= 1; j --) {
if (f[j] == m) continue;
if (f[j] + 2 > m) {
ans[j][m] = 1;
f[j] = m;
++ now;
if (now >= K) {
out();
return;
}
}
else {
ans[j][f[j] + 1] = ans[j][f[j] + 2] = 1;
f[j] += 2;
now += 2;
if (now >= K) {
out();
return;
}
}
}
}
}
int main() {
//freopen(".in", "r", stdin);
//freopen(".out", "w", stdout);
int t;
read(t);
while (t--) solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3612kb
input:
2 2 2 2 2 3 0
output:
11 00 000 000
result:
ok Output is valid. OK.
Test #2:
score: 0
Accepted
time: 15ms
memory: 3708kb
input:
27520 2 2 0 2 2 1 2 2 2 2 2 3 2 2 4 2 3 0 2 3 1 2 3 2 2 3 3 2 3 4 2 3 5 2 3 6 3 2 0 3 2 1 3 2 2 3 2 3 3 2 4 3 2 5 3 2 6 3 3 0 3 3 1 3 3 2 3 3 3 3 3 4 3 3 5 3 3 6 3 3 7 3 3 8 3 3 9 2 4 0 2 4 1 2 4 2 2 4 3 2 4 4 2 4 5 2 4 6 2 4 7 2 4 8 3 4 0 3 4 1 3 4 2 3 4 3 3 4 4 3 4 5 3 4 6 3 4 7 3 4 8 3 4 9 3 4 10...
output:
00 00 10 00 11 00 11 10 11 11 000 000 100 000 101 000 110 100 011 110 111 110 111 111 00 00 00 10 00 00 10 00 10 11 10 00 10 11 10 11 11 10 11 11 11 000 000 000 100 000 000 100 000 100 110 100 000 100 110 100 011 110 100 111 110 100 011 110 111 111 110 111 111 111 111 0000 0000 1000 0000 1010 0000 1...
result:
ok Output is valid. OK.
Test #3:
score: 0
Accepted
time: 12ms
memory: 12056kb
input:
162 2 2 2 2 3 2 2 3 3 2 3 4 3 2 2 3 2 3 3 2 4 3 3 2 3 3 3 3 3 4 3 3 5 3 3 6 3 3 7 2 4 2 2 4 3 2 4 4 2 4 5 2 4 6 3 4 2 3 4 3 3 4 4 3 4 5 3 4 6 3 4 7 3 4 8 3 4 9 3 4 10 4 2 2 4 2 3 4 2 4 4 2 5 4 2 6 4 3 2 4 3 3 4 3 4 4 3 5 4 3 6 4 3 7 4 3 8 4 3 9 4 3 10 4 4 2 4 4 3 4 4 4 4 4 5 4 4 6 4 4 7 4 4 8 4 4 9 ...
output:
11 00 101 000 110 100 011 110 10 00 10 11 10 00 10 11 10 100 000 100 110 100 000 100 110 100 011 110 100 111 110 100 011 110 111 1010 0000 1100 1000 0110 1100 1110 1100 0110 1111 1000 0000 1000 1100 1000 0000 1000 1100 1000 0110 1100 1000 1110 1100 1000 0110 1100 1110 1110 1100 1110 0110 1111 1110 1...
result:
ok Output is valid. OK.
Test #4:
score: 0
Accepted
time: 8ms
memory: 12012kb
input:
163 2 2 2 2 3 2 2 3 3 2 3 4 3 2 2 3 2 3 3 2 4 3 3 2 3 3 3 3 3 4 3 3 5 3 3 6 3 3 7 2 4 2 2 4 3 2 4 4 2 4 5 2 4 6 3 4 2 3 4 3 3 4 4 3 4 5 3 4 6 3 4 7 3 4 8 3 4 9 3 4 10 4 2 2 4 2 3 4 2 4 4 2 5 4 2 6 4 3 2 4 3 3 4 3 4 4 3 5 4 3 6 4 3 7 4 3 8 4 3 9 4 3 10 4 4 2 4 4 3 4 4 4 4 4 5 4 4 6 4 4 7 4 4 8 4 4 9 ...
output:
11 00 101 000 110 100 011 110 10 00 10 11 10 00 10 11 10 100 000 100 110 100 000 100 110 100 011 110 100 111 110 100 011 110 111 1010 0000 1100 1000 0110 1100 1110 1100 0110 1111 1000 0000 1000 1100 1000 0000 1000 1100 1000 0110 1100 1000 1110 1100 1000 0110 1100 1110 1110 1100 1110 0110 1111 1110 1...
result:
ok Output is valid. OK.
Test #5:
score: 0
Accepted
time: 8ms
memory: 12376kb
input:
165 2 2 2 2 3 2 2 3 3 2 3 4 3 2 2 3 2 3 3 2 4 3 3 2 3 3 3 3 3 4 3 3 5 3 3 6 3 3 7 2 4 2 2 4 3 2 4 4 2 4 5 2 4 6 3 4 2 3 4 3 3 4 4 3 4 5 3 4 6 3 4 7 3 4 8 3 4 9 3 4 10 4 2 2 4 2 3 4 2 4 4 2 5 4 2 6 4 3 2 4 3 3 4 3 4 4 3 5 4 3 6 4 3 7 4 3 8 4 3 9 4 3 10 4 4 2 4 4 3 4 4 4 4 4 5 4 4 6 4 4 7 4 4 8 4 4 9 ...
output:
11 00 101 000 110 100 011 110 10 00 10 11 10 00 10 11 10 100 000 100 110 100 000 100 110 100 011 110 100 111 110 100 011 110 111 1010 0000 1100 1000 0110 1100 1110 1100 0110 1111 1000 0000 1000 1100 1000 0000 1000 1100 1000 0110 1100 1000 1110 1100 1000 0110 1100 1110 1110 1100 1110 0110 1111 1110 1...
result:
ok Output is valid. OK.
Test #6:
score: 0
Accepted
time: 26ms
memory: 11576kb
input:
1020 2 2 2 2 3 2 2 3 3 2 3 4 3 2 2 3 2 3 3 2 4 3 3 2 3 3 3 3 3 4 3 3 5 3 3 6 3 3 7 2 4 2 2 4 3 2 4 4 2 4 5 2 4 6 3 4 2 3 4 3 3 4 4 3 4 5 3 4 6 3 4 7 3 4 8 3 4 9 3 4 10 4 2 2 4 2 3 4 2 4 4 2 5 4 2 6 4 3 2 4 3 3 4 3 4 4 3 5 4 3 6 4 3 7 4 3 8 4 3 9 4 3 10 4 4 2 4 4 3 4 4 4 4 4 5 4 4 6 4 4 7 4 4 8 4 4 9...
output:
11 00 101 000 110 100 011 110 10 00 10 11 10 00 10 11 10 100 000 100 110 100 000 100 110 100 011 110 100 111 110 100 011 110 111 1010 0000 1100 1000 0110 1100 1110 1100 0110 1111 1000 0000 1000 1100 1000 0000 1000 1100 1000 0110 1100 1000 1110 1100 1000 0110 1100 1110 1110 1100 1110 0110 1111 1110 1...
result:
ok Output is valid. OK.
Test #7:
score: 0
Accepted
time: 18ms
memory: 11564kb
input:
1012 2 2 2 2 3 2 2 3 3 2 3 4 3 2 2 3 2 3 3 2 4 3 3 2 3 3 3 3 3 4 3 3 5 3 3 6 3 3 7 2 4 2 2 4 3 2 4 4 2 4 5 2 4 6 3 4 2 3 4 3 3 4 4 3 4 5 3 4 6 3 4 7 3 4 8 3 4 9 3 4 10 4 2 2 4 2 3 4 2 4 4 2 5 4 2 6 4 3 2 4 3 3 4 3 4 4 3 5 4 3 6 4 3 7 4 3 8 4 3 9 4 3 10 4 4 2 4 4 3 4 4 4 4 4 5 4 4 6 4 4 7 4 4 8 4 4 9...
output:
11 00 101 000 110 100 011 110 10 00 10 11 10 00 10 11 10 100 000 100 110 100 000 100 110 100 011 110 100 111 110 100 011 110 111 1010 0000 1100 1000 0110 1100 1110 1100 0110 1111 1000 0000 1000 1100 1000 0000 1000 1100 1000 0110 1100 1000 1110 1100 1000 0110 1100 1110 1110 1100 1110 0110 1111 1110 1...
result:
ok Output is valid. OK.
Test #8:
score: 0
Accepted
time: 27ms
memory: 11684kb
input:
1033 2 2 2 2 3 2 2 3 3 2 3 4 3 2 2 3 2 3 3 2 4 3 3 2 3 3 3 3 3 4 3 3 5 3 3 6 3 3 7 2 4 2 2 4 3 2 4 4 2 4 5 2 4 6 3 4 2 3 4 3 3 4 4 3 4 5 3 4 6 3 4 7 3 4 8 3 4 9 3 4 10 4 2 2 4 2 3 4 2 4 4 2 5 4 2 6 4 3 2 4 3 3 4 3 4 4 3 5 4 3 6 4 3 7 4 3 8 4 3 9 4 3 10 4 4 2 4 4 3 4 4 4 4 4 5 4 4 6 4 4 7 4 4 8 4 4 9...
output:
11 00 101 000 110 100 011 110 10 00 10 11 10 00 10 11 10 100 000 100 110 100 000 100 110 100 011 110 100 111 110 100 011 110 111 1010 0000 1100 1000 0110 1100 1110 1100 0110 1111 1000 0000 1000 1100 1000 0000 1000 1100 1000 0110 1100 1000 1110 1100 1000 0110 1100 1110 1110 1100 1110 0110 1111 1110 1...
result:
ok Output is valid. OK.
Test #9:
score: 0
Accepted
time: 23ms
memory: 3672kb
input:
100000 2 2 2 2 3 2 2 3 3 2 3 4 3 2 2 3 2 3 3 2 4 3 3 2 3 3 3 3 3 4 3 3 5 3 3 6 3 3 7 2 4 2 2 4 3 2 4 4 2 4 5 2 4 6 3 4 2 3 4 3 3 4 4 3 4 5 3 4 6 3 4 7 3 4 8 3 4 9 3 4 10 4 2 2 4 2 3 4 2 4 4 2 5 4 2 6 4 3 2 4 3 3 4 3 4 4 3 5 4 3 6 4 3 7 4 3 8 4 3 9 4 3 10 4 4 2 4 4 3 4 4 4 4 4 5 4 4 6 4 4 7 4 4 8 4 4...
output:
11 00 101 000 110 100 011 110 10 00 10 11 10 00 10 11 10 100 000 100 110 100 000 100 110 100 011 110 100 111 110 100 011 110 111 1010 0000 1100 1000 0110 1100 1110 1100 0110 1111 1000 0000 1000 1100 1000 0000 1000 1100 1000 0110 1100 1000 1110 1100 1000 0110 1100 1110 1110 1100 1110 0110 1111 1110 1...
result:
ok Output is valid. OK.
Test #10:
score: 0
Accepted
time: 16ms
memory: 3664kb
input:
100000 2 2 2 2 3 2 2 3 3 2 3 4 3 2 2 3 2 3 3 2 4 3 3 2 3 3 3 3 3 4 3 3 5 3 3 6 3 3 7 2 4 2 2 4 3 2 4 4 2 4 5 2 4 6 3 4 2 3 4 3 3 4 4 3 4 5 3 4 6 3 4 7 3 4 8 3 4 9 3 4 10 4 2 2 4 2 3 4 2 4 4 2 5 4 2 6 4 3 2 4 3 3 4 3 4 4 3 5 4 3 6 4 3 7 4 3 8 4 3 9 4 3 10 4 4 2 4 4 3 4 4 4 4 4 5 4 4 6 4 4 7 4 4 8 4 4...
output:
11 00 101 000 110 100 011 110 10 00 10 11 10 00 10 11 10 100 000 100 110 100 000 100 110 100 011 110 100 111 110 100 011 110 111 1010 0000 1100 1000 0110 1100 1110 1100 0110 1111 1000 0000 1000 1100 1000 0000 1000 1100 1000 0110 1100 1000 1110 1100 1000 0110 1100 1110 1110 1100 1110 0110 1111 1110 1...
result:
ok Output is valid. OK.
Test #11:
score: 0
Accepted
time: 16ms
memory: 3644kb
input:
100000 2 2 2 2 3 2 2 3 3 2 3 4 3 2 2 3 2 3 3 2 4 3 3 2 3 3 3 3 3 4 3 3 5 3 3 6 3 3 7 2 4 2 2 4 3 2 4 4 2 4 5 2 4 6 3 4 2 3 4 3 3 4 4 3 4 5 3 4 6 3 4 7 3 4 8 3 4 9 3 4 10 4 2 2 4 2 3 4 2 4 4 2 5 4 2 6 4 3 2 4 3 3 4 3 4 4 3 5 4 3 6 4 3 7 4 3 8 4 3 9 4 3 10 4 4 2 4 4 3 4 4 4 4 4 5 4 4 6 4 4 7 4 4 8 4 4...
output:
11 00 101 000 110 100 011 110 10 00 10 11 10 00 10 11 10 100 000 100 110 100 000 100 110 100 011 110 100 111 110 100 011 110 111 1010 0000 1100 1000 0110 1100 1110 1100 0110 1111 1000 0000 1000 1100 1000 0000 1000 1100 1000 0110 1100 1000 1110 1100 1000 0110 1100 1110 1110 1100 1110 0110 1111 1110 1...
result:
ok Output is valid. OK.
Test #12:
score: 0
Accepted
time: 20ms
memory: 12344kb
input:
3 1500 1500 2250000 1322 1322 1747684 1158 2 2316
output:
111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...
result:
ok Output is valid. OK.
Test #13:
score: 0
Accepted
time: 12ms
memory: 12344kb
input:
3 1500 1500 1125000 1322 1322 873842 1158 2 1158
output:
111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...
result:
ok Output is valid. OK.
Extra Test:
score: 0
Extra Test Passed