QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#285412 | #5438. Half Mixed | ushg8877# | WA | 1ms | 3512kb | C++14 | 793b | 2023-12-16 18:59:12 | 2023-12-16 18:59:13 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MP make_pair
mt19937 rnd(time(0));
const int MAXN=1e6+5;
bool flag[MAXN];
void solve(){
ll n,m;cin>>n>>m;
if((n*(n+1)/2&1)&&(m*(m+1)/2&1)){cout<<"No"<<endl;return;}
cout<<"Yes"<<endl;
if(n*(n+1)%4==0){
ll k=n*(n+1)/4;
for(int i=1,lst=0,op=0;i<=n;i++){
if(lst+1+n-i<=k) lst++,k-=lst;
else op^=1,lst=1,k--;
for(int j=1;j<=m;j++) cout<<op;
cout<<endl;
}
}else{
ll k=m*(m+1)/4;
for(int i=1,lst=0,op=0;i<=m;i++){
if(lst+1+m-i<=k) lst++,k-=lst;
else op^=1,lst=1,k--;
flag[i]=op;
}
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++) cout<<flag[j];
cout<<endl;
}
}
}
int main(){
ios::sync_with_stdio(false);
int _;cin>>_;
while(_--) solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3512kb
input:
2 2 3 1 1
output:
Yes 010 010 No
result:
wrong output format Expected integer, but "010" found (test case 1)