QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#99240 | #6309. Aqre | Al_fly | WA | 2ms | 3328kb | C++17 | 1.3kb | 2023-04-21 18:32:07 | 2023-04-21 18:32:11 |
Judging History
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)