QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#99075 | #6309. Aqre | Fanch100 | WA | 2ms | 5580kb | C++14 | 1.2kb | 2023-04-21 10:20:08 | 2023-04-21 10:20:31 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N = 1010;
int a[4][4]={
{1,1,1,0},
{1,0,1,1},
{1,1,0,1},
{0,1,1,1}
};
int n, m;
int b[N][N], c[N][N];
int solve(int x,int y){
int ans=0;
for (int i=1;i<=n;++i){
for (int j=1;j<=m;++j){
b[i][j]=a[(i+x)%4][(j+y)%4];
ans+=b[i][j];
}
}
return ans;
}
void solve(){
cin>>n>>m;
if (n<=3 && m<=3){
printf("%d\n",n*m);
for (int i=1;i<=n;++i){
for (int j=1;j<=m;++j) printf("%d ",1); puts("");
}
return;
}
int ans=0;
for (int i=0;i<4;++i){
for (int j=0;j<4;++j){
int mx=solve(i,j);
if (mx>ans){
ans=mx;
for (int k=1;k<=n;++k){
for (int l=1;l<=m;++l) c[k][l]=b[k][l];
}
}
}
}
printf("%d\n",ans);
for (int i=1;i<=n;++i){
for (int j=1;j<=m;++j) printf("%d ",c[i][j]);
puts("");
}
}
int main(){
// for (int i=0;i<4;++i){
// for (int j=0;j<4;++j) printf("%d ",a[i][j]); puts("");
// }
int t; cin>>t;
while(t--) solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 5580kb
input:
3 2 2 3 4 3 8
output:
4 1 1 1 1 9 0 1 1 1 1 0 1 1 1 1 1 0 18 0 1 1 1 0 1 1 1 1 0 1 1 1 0 1 1 1 1 1 0 1 1 1 0
result:
wrong answer Length must be equal to m (test case 1)