QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#757694 | #7629. Make SYSU Great Again II | -Ofast | WA | 1488ms | 10024kb | C++11 | 1.2kb | 2024-11-17 12:17:08 | 2024-11-17 12:17:09 |
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;i++){
int x=b[i].fir,y=b[i].sec;
if(!vis[x][y]){
if(rnd()&1)continue;
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;
}
cout<<"No\n";
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 7936kb
input:
4
output:
Yes 28 0 16 11 0 10 1 16 8 0 16 4 5 10 5 18
result:
ok 1
Test #2:
score: 0
Accepted
time: 1ms
memory: 9836kb
input:
1
output:
Yes 1
result:
ok 1
Test #3:
score: 0
Accepted
time: 1ms
memory: 7876kb
input:
2
output:
Yes 4 2 0 1
result:
ok 1
Test #4:
score: 0
Accepted
time: 1ms
memory: 7984kb
input:
3
output:
Yes 6 8 0 8 1 6 1 0 8
result:
ok 1
Test #5:
score: 0
Accepted
time: 0ms
memory: 7984kb
input:
5
output:
Yes 19 12 16 0 28 8 1 0 16 0 4 2 4 9 2 17 0 9 2 21 2 5 18 12 0
result:
ok 1
Test #6:
score: 0
Accepted
time: 0ms
memory: 10024kb
input:
8
output:
Yes 64 1 60 1 64 42 81 0 27 100 1 14 32 17 4 122 4 8 32 81 4 10 80 0 34 17 68 8 96 4 42 81 76 34 24 68 11 32 20 34 3 16 71 48 64 14 96 8 20 40 0 72 7 112 7 32 0 83 0 53 72 5 32 87
result:
ok 1
Test #7:
score: -100
Wrong Answer
time: 1488ms
memory: 9896kb
input:
13
output:
No
result:
wrong answer Jury found answer but participant doesn't