QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#78065 | #5438. Half Mixed | magicduck# | WA | 2ms | 3360kb | C++14 | 1.9kb | 2023-02-16 16:21:30 | 2023-02-16 16:21:33 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
template <typename T> inline void read(T &F) {
int R = 1; F = 0; char CH = getchar();
for(; !isdigit(CH); CH = getchar()) if(CH == '-') R = -1;
for(; isdigit(CH); CH = getchar()) F = F * 10 + CH - 48;
F *= R;
}
inline void file(string str) {
freopen((str + ".in").c_str(), "r", stdin);
freopen((str + ".out").c_str(), "w", stdout);
}
vector<int> R;
void calc(int cnt, LL x) {
if(cnt == 0) {
assert(x == 0);
return;
}
int l = 1, r = cnt, res = 0;
while(l <= r) {
LL mid = (l + r) >> 1;
if(x - 1LL * mid * (mid + 1) >= (cnt - mid) * 2)
res = mid, l = mid + 1;
else r = mid - 1;
}
R.emplace_back(res); calc(cnt - 1, x - 1LL * res * (res + 1));
}
int main() {
//file("");
int T; read(T);
while(T--) {
int n, m; read(n), read(m); R.clear();
if(n % 4 == 0 || (n + 1) % 4 == 0) {
puts("Yes");
calc(n, 1LL * n * (n + 1) / 2);
int f = 0;
for(auto i : R) {
f ^= 1;
for(int j = 1; j <= i; j++, puts(""))
for(int k = 1; k <= m; k++)
putchar('0' + f);
}
}
else if(m % 4 == 0 || (m + 1) % 4 == 0) {
puts("Yes");
calc(m, 1LL * m * (m + 1) / 2);
for(int i = 1; i <= n; i++, puts("")) {
int f = 0;
for(auto j : R) {
f ^= 1;
for(int k = 1; k <= j; k++)
putchar('0' + f);
}
}
}
else puts("No");
}
#ifdef _MagicDuck
fprintf(stderr, "# Time: %.3lf s", (double)clock() / CLOCKS_PER_SEC);
#endif
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 3360kb
input:
2 2 3 1 1
output:
Yes 101 101 No
result:
wrong answer Integer parameter [name=M[i][j]] equals to 101, violates the range [0, 1] (test case 1)