QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#99075#6309. AqreFanch100WA 2ms5580kbC++141.2kb2023-04-21 10:20:082023-04-21 10:20:31

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-21 10:20:31]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:5580kb
  • [2023-04-21 10:20:08]
  • 提交

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)