QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#292240 | #6309. Aqre | fstqwq# | WA | 1ms | 3768kb | C++14 | 1.4kb | 2023-12-27 21:40:06 | 2023-12-27 21:40:06 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=1e3+5;
char st[N][N],ans[N][N];
int dt[][4]={{0,2,1,3},{0,1,3,2},{0,2,0}};
void solve(int n,int m){
if(n<=3 && m<=3){
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++)st[i][j]='1';
}
}
if(n==2){
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
st[i][j]=((dt[0][i-1]+j)%4!=0)+'0';
}
}
}
if(n==3){
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
st[i][j]=((dt[2][i-1]+j)%4!=0)+'0';
}
}
}
if(n>=4){
int typ=0;
if(n%4==2 && m%4==2)typ=1;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
st[i][j]=((dt[typ][(i-1)%4]+j)%4!=0)+'0';
}
}
}
}
int main(){
int T;scanf("%d",&T);
while(T--){
int n,m;scanf("%d%d",&n,&m);
int type=0;
if(n>m)swap(n,m),type=1;
solve(n,m);
int cnt=0;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
if(type)ans[j][i]=st[i][j];
else ans[i][j]=st[i][j];
cnt+=st[i][j]-'0';
}
}
if(type)swap(n,m);
printf("%d\n",cnt);
for(int i=1;i<=n;i++){
ans[i][m+1]='\0';
printf("%s\n",ans[i]+1);
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3768kb
input:
3 2 2 3 4 3 8
output:
3 11 10 9 1110 1011 1110 18 11101110 10111011 11101110
result:
wrong answer ans finds a larger answer (test case 1)