QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#98768 | #6309. Aqre | JohnAlfnov | WA | 2ms | 9860kb | C++14 | 3.4kb | 2023-04-19 22:38:17 | 2023-04-19 22:38:21 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int a[1100][1100];
int b[1100][1100];
int main(){
int _;
cin>>_;
for(int i=0;i<=1050;i++)for(int j=0;j<=1050;j++){
if(i%4==0&&j%4==0)a[i][j]=1;
if(i%4==1&&j%4==2)a[i][j]=1;
if(i%4==2&&j%4==1)a[i][j]=1;
if(i%4==3&&j%4==3)a[i][j]=1;
}
for(int i=0;i<3;i++)for(int j=0;j<=1050;j++){
if(i==0&&j%4==1)b[i][j]=1;
if(i==1&&j%4==3)b[i][j]=1;
if(i==2&&j%4==3)b[i][j]=1;
}
while(_--){
int n,m;
cin>>n>>m;
if(n%4==0||m%4==0){
int ans=0;
for(int i=0;i<n;i++){
for(int j=0;j<m;j++)ans+=1-a[i][j];
}
cout<<ans<<endl;
for(int i=0;i<n;i++){
for(int j=0;j<m;j++)printf("%d ",1-a[i][j]);
printf("\n");
}
continue;
}
if(n<=3&&m<=3){
cout<<n*m<<endl;
for(int i=0;i<n;i++){
for(int j=0;j<m;j++)printf("1 ");
printf("\n");
}
continue;
}
if(n==2){
int ans=0;
for(int i=0;i<2;i++){
for(int j=3;j<m+3;j++)ans+=1-a[i][j];
}
cout<<ans<<endl;
for(int i=0;i<2;i++){
for(int j=3;j<m+3;j++)printf("%d ",1-a[i][j]);
printf("\n");
}
continue;
}
if(m==2){
int ans=0;
for(int i=3;i<n+3;i++){
for(int j=0;j<2;j++)ans+=1-a[i][j];
}
cout<<ans<<endl;
for(int i=3;i<n+3;i++){
for(int j=0;j<2;j++)printf("%d ",1-a[i][j]);
printf("\n");
}
continue;
}
if(n%4==1){
int ans=0;
for(int i=0;i<n;i++){
for(int j=1;j<m+1;j++)ans+=1-a[i][j];
}
cout<<ans<<endl;
for(int i=0;i<n;i++){
for(int j=1;j<m+1;j++)printf("%d ",1-a[i][j]);
printf("\n");
}
continue;
}
if(m%4==1){
int ans=0;
for(int i=1;i<n+1;i++){
for(int j=0;j<m;j++)ans+=1-a[i][j];
}
cout<<ans<<endl;
for(int i=1;i<n+1;i++){
for(int j=0;j<m;j++)printf("%d ",1-a[i][j]);
printf("\n");
}
continue;
}
if(n%4==2&&m%4==3){
int ans=0;
for(int i=0;i<n;i++){
for(int j=1;j<m+1;j++)ans+=1-a[i][j];
}
cout<<ans<<endl;
for(int i=0;i<n;i++){
for(int j=1;j<m+1;j++)printf("%d ",1-a[i][j]);
printf("\n");
}
continue;
}
if(n%4==3&&m%4==2){
int ans=0;
for(int i=1;i<n+1;i++){
for(int j=0;j<m;j++)ans+=1-a[i][j];
}
cout<<ans<<endl;
for(int i=1;i<n+1;i++){
for(int j=0;j<m;j++)printf("%d ",1-a[i][j]);
printf("\n");
}
continue;
}
if(n%4==2&&m%4==2){
int ans=0;
for(int i=1;i<n+1;i++){
for(int j=3;j<m+3;j++)ans+=1-a[i][j];
}
cout<<ans<<endl;
for(int i=1;i<n+1;i++){
for(int j=3;j<m+3;j++)printf("%d ",1-a[i][j]);
printf("\n");
}
continue;
}
if(n==3){
int ans=0;
for(int i=0;i<3;i++){
for(int j=0;j<m;j++)ans+=1-b[i][j];
}
cout<<ans<<endl;
for(int i=0;i<3;i++){
for(int j=0;j<m;j++)printf("%d ",1-b[i][j]);
printf("\n");
}
continue;
}
if(m==3){
int ans=0;
for(int i=0;i<n;i++){
for(int j=0;j<3;j++)ans+=1-b[j][i];
}
cout<<ans<<endl;
for(int i=0;i<n;i++){
for(int j=0;j<3;j++)printf("%d ",1-b[j][i]);
printf("\n");
}
}
if(n%4==3&&m%4==3){
int ans=0;
for(int i=1;i<n+1;i++){
for(int j=2;j<m+2;j++)ans+=1-a[i][j];
}
cout<<ans<<endl;
for(int i=1;i<n+1;i++){
for(int j=2;j<m+2;j++)printf("%d ",1-a[i][j]);
printf("\n");
}
continue;
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 9860kb
input:
3 2 2 3 4 3 8
output:
4 1 1 1 1 9 0 1 1 1 1 1 0 1 1 0 1 1 18 0 1 1 1 0 1 1 1 1 1 0 1 1 1 0 1 1 0 1 1 1 0 1 1
result:
wrong answer Length must be equal to m (test case 1)