QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#757686#7629. Make SYSU Great Again II-OfastWA 1ms10012kbC++111.1kb2024-11-17 12:13:492024-11-17 12:13:49

Judging History

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

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

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

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 7852kb

input:

4

output:

Yes
25 6 8 1 
2 8 1 20 
13 16 6 9 
2 13 16 2 

result:

ok 1

Test #2:

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

input:

1

output:

Yes
0 

result:

ok 1

Test #3:

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

input:

2

output:

Yes
0 4 
1 2 

result:

ok 1

Test #4:

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

input:

3

output:

Yes
12 1 0 
0 2 4 
7 0 9 

result:

ok 1

Test #5:

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

input:

5

output:

Yes
26 3 28 26 13 
7 22 27 5 16 
31 18 3 20 14 
5 28 2 13 19 
25 18 14 17 14 

result:

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