QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#757683#7629. Make SYSU Great Again II-OfastWA 1ms10020kbC++111.1kb2024-11-17 12:13:132024-11-17 12:13:14

Judging History

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

  • [2024-11-17 12:13:14]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:10020kb
  • [2024-11-17 12:13:13]
  • 提交

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){
		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;
		}
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 10020kb

input:

4

output:

Yes
12 2 16 6 
17 8 0 17 
12 2 17 10 
18 12 2 5 

result:

ok 1

Test #2:

score: 0
Accepted
time: 1ms
memory: 5656kb

input:

1

output:

Yes
0 

result:

ok 1

Test #3:

score: 0
Accepted
time: 1ms
memory: 7828kb

input:

2

output:

Yes
0 3 
2 4 

result:

ok 1

Test #4:

score: 0
Accepted
time: 1ms
memory: 7964kb

input:

3

output:

Yes
5 8 4 
0 2 8 
9 4 3 

result:

ok 1

Test #5:

score: -100
Wrong Answer
time: 0ms
memory: 9904kb

input:

5

output:

Yes
1 31 18 8 7 
30 16 14 5 17 
1 23 6 29 14 
25 5 6 8 8 
22 25 9 31 13 

result:

wrong answer There exist two adjacent numbers whose bitwise AND value is greater than 0.