QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#99240#6309. AqreAl_flyWA 2ms3328kbC++171.3kb2023-04-21 18:32:072023-04-21 18:32:11

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 18:32:11]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3328kb
  • [2023-04-21 18:32:07]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=1e3+5;
int t,n,m,a[N][N];
inline int up(int i,int j){
    int sum=0;
    for(int p=i;p>=max(i-3,1);p--)sum+=a[p][j];
    return sum;
}
inline int down(int i,int j){
    int sum=0;
    for(int p=i;p<=min(n,i+3);p++)sum+=a[p][j];
    return sum;
}
inline int l(int i,int j){
    int sum=0;
    for(int p=j;p>=max(1,j-3);p--)sum+=a[i][p];
    return sum;
}
inline int r(int i,int j){
    int sum=0;
    for(int p=i;p<=min(m,i+3);p++)sum+=a[i][p];
    return sum;
}
inline bool check(int i,int j){
    return (up(i,j)+down(i,j)<3)&&(l(i,j)+r(i,j)<3);
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    cin>>t;
    while(t--){
        cin>>n>>m;int sum=0;
        for(int i=1;i<=n;i++){
            for(int j=1;j<=m;j++){
                if(i%4==j%4)a[i][j]=0;
                else a[i][j]=1,sum++;
            }
        }
        for(int i=1;i<=n;i++){
            for(int j=1;j<=m;j++){
                if(a[i][j])continue;
                if(check(i,j))a[i][j]=1,sum++;
            }
        }
        cout<<sum<<'\n';
        for(int i=1;i<=n;i++){
            for(int j=1;j<=m;j++)cout<<a[i][j];
            cout<<'\n';
        }
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 3328kb

input:

3
2 2
3 4
3 8

output:

4
11
11
9
0111
1011
1101
18
01110111
10111011
11011101

result:

wrong answer 1s are not connected. (test case 2)