QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#757687 | #7629. Make SYSU Great Again II | -Ofast | WA | 1485ms | 9920kb | C++11 | 1.1kb | 2024-11-17 12:14:44 | 2024-11-17 12:14:45 |
Judging History
answer
#include <bits/stdc++.h>
#define mp make_pair
#define fir first
#define sec second
using namespace std;
const int N=2010;
int n,a[N][N],buk[N*N*4];
pair <int,int> b[N*N];
mt19937 rnd(time(0));
bitset <N> vis[N];
int main(){
ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
cin>>n;int lg=log2(n*n)+1;
for(int i=1;i<=n;i++)
for(int j=1;j<=n;j++)b[(i-1)*n+j]=mp(i,j);
while(1.0*clock()/CLOCKS_PER_SEC<1.5){
for(int k=0;k<lg;k++){
shuffle(b+1,b+1+n*n,rnd);
for(int i=1;i<=n;i++)vis[i].reset();
for(int i=1;i<=n*n/2;i++){
int x=b[i].fir,y=b[i].sec;
if(!vis[x][y]){
vis[x][y]=1;
vis[x-1][y]=1;
vis[x+1][y]=1;
vis[x][y-1]=1;
vis[x][y+1]=1;
a[x][y]|=(1<<k);
}
}
}
int flg=0;
for(int i=0;i<4*n*n;i++)buk[i]=0;
for(int i=1;i<=n;i++)
for(int j=1;j<=n;j++){
buk[a[i][j]]++;
if(buk[a[i][j]]>5)flg=1;
}
if(!flg){
cout<<"Yes\n";
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++)
cout<<a[i][j]<<" ";
cout<<"\n";
}
return 0;
}
for(int i=1;i<=n;i++)
for(int j=1;j<=n;j++)a[i][j]=0;
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 7808kb
input:
4
output:
Yes 2 24 5 16 9 4 24 6 0 3 0 8 22 8 16 4
result:
ok 1
Test #2:
score: 0
Accepted
time: 1ms
memory: 5712kb
input:
1
output:
Yes 0
result:
ok 1
Test #3:
score: 0
Accepted
time: 1ms
memory: 7940kb
input:
2
output:
Yes 7 0 0 0
result:
ok 1
Test #4:
score: 0
Accepted
time: 1ms
memory: 7908kb
input:
3
output:
Yes 1 0 8 4 1 2 8 6 0
result:
ok 1
Test #5:
score: 0
Accepted
time: 1ms
memory: 7916kb
input:
5
output:
Yes 1 16 0 30 1 6 9 20 0 8 1 6 8 16 1 4 8 18 8 22 16 3 12 18 1
result:
ok 1
Test #6:
score: 0
Accepted
time: 1ms
memory: 8000kb
input:
8
output:
Yes 10 0 84 42 16 34 17 6 16 7 40 0 76 1 14 112 70 16 68 18 32 6 96 9 32 76 33 12 3 32 17 0 80 2 20 3 92 1 8 38 0 56 67 52 1 4 0 65 22 65 16 2 120 1 90 4 64 24 103 24 4 90 4 49
result:
ok 1
Test #7:
score: -100
Wrong Answer
time: 1485ms
memory: 9920kb
input:
13
output:
result:
wrong answer Unexpected Ans