QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#94400#6189. Full Clue ProblemHOLIC#AC ✓2ms3772kbC++202.2kb2023-04-05 20:02:542023-04-05 20:02:57

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-05 20:02:57]
  • 评测
  • 测评结果:AC
  • 用时:2ms
  • 内存:3772kb
  • [2023-04-05 20:02:54]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N = 100;
int ans1[N][N], ans2[N][N], ans3[N][N];
int dx[4] = {0, 0, -1, 1};
int dy[4] = {1, -1, 0, 0};
int main(){
	int n;
	scanf("%d", &n);
	if(n & 1){
		int a = 1;
		while(a != n){
			for(int i = 0; i < 3; ++i){
				for(int j = 0; j < 3; ++j){
					ans2[a + i][a + j] = 1;
				}
			}
			a += 2;
		}
		ans2[1][1] = ans2[n][n] = 0;
		a = 2;
		ans3[1][1] = ans3[1][2] = ans3[2][1] = ans3[2][2] = 1;
		while(a != n - 1){
			for(int i = 0; i < 3; ++i){
				for(int j = 0; j < 3; ++j){
					ans3[a + i][a + j] = 1;
				}
			}
			a += 2;
		}
		ans3[a][a] = ans3[a + 1][a] = ans3[a][a + 1] = ans3[a + 1][a + 1] = 1;
	}else{
		int a = 2;
		ans3[1][1] = ans3[1][2] = ans3[2][1] = ans3[2][2] = 1;
		while(a != n){
			for(int i = 0; i < 3; ++i){
				for(int j = 0; j < 3; ++j){
					ans3[a + i][a + j] = 1;
				}
			}
			a += 2;
		}
		ans3[n][n] = 0;
		a = 1;
		while(a != n - 1){
			for(int i = 0; i < 3; ++i){
				for(int j = 0; j < 3; ++j){
					ans2[a + i][a + j] = 1;
				}
			}
			a += 2;
		}
		ans2[a][a] = ans2[a + 1][a] = ans2[a][a + 1] = ans2[a + 1][a + 1] = 1;
		ans2[1][1] = 0;
	}
	for(int i = 1; i <= n; ++i){
		for(int j = 1; j <= n; ++j){
			if(ans2[i][j]){
				for(int k = 0; k < 4; ++k){
					int xx = i + dx[k], yy = j + dy[k];
					if(xx == 0 || xx == n + 1 || yy == 0 || yy == n + 1) ++ ans1[i][j];
					else if(!ans2[xx][yy]) ++ ans1[i][j];
				}
			}else{
				for(int k = 0; k < 4 ; ++ k){
					int xx = i + dx[k], yy = j + dy[k];
					if(xx == 0 || xx == n + 1 || yy == 0 || yy == n + 1) continue;
					else if(ans2[xx][yy]) ++ ans1[i][j];
				}
			}
		}
	}
	if(n == 3){
		for(int i = 1; i <= n; ++i){
			for(int j = 1; j <= n; ++j){
				ans3[i][j] = 1;
			}
		}
		ans3[1][3] = ans3[3][1] = 0;
	}
	for(int i = 1; i <= n; ++i){
		for(int j = 1; j <= n; ++j){
			printf("%d ", ans1[i][j]);
		}
		puts("");
	}
	puts("");
	for(int i = 1; i <= n; ++i){
		for(int j = 1; j <= n; ++j){
			printf("%d ", ans2[i][j]);
		}
		puts("");
	}
	puts("");
	for(int i = 1; i <= n; ++i){
		for(int j = 1; j <= n; ++j){
			printf("%d ", ans3[i][j]);
		}
		puts("");
	}
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 2ms
memory: 3516kb

input:

5

output:

2 2 2 1 0 
2 0 1 2 1 
2 1 0 1 2 
1 2 1 0 2 
0 1 2 2 2 

0 1 1 0 0 
1 1 1 0 0 
1 1 1 1 1 
0 0 1 1 1 
0 0 1 1 0 

1 1 0 0 0 
1 1 1 1 0 
0 1 1 1 0 
0 1 1 1 1 
0 0 0 1 1 

result:

ok ok

Test #2:

score: 0
Accepted
time: 2ms
memory: 3512kb

input:

2

output:

2 3 
3 2 

0 1 
1 1 

1 1 
1 0 

result:

ok ok

Test #3:

score: 0
Accepted
time: 2ms
memory: 3740kb

input:

3

output:

2 2 2 
2 0 2 
2 2 2 

0 1 1 
1 1 1 
1 1 0 

1 1 0 
1 1 1 
0 1 1 

result:

ok ok

Test #4:

score: 0
Accepted
time: 2ms
memory: 3532kb

input:

4

output:

2 2 2 1 
2 0 1 2 
2 1 0 2 
1 2 2 2 

0 1 1 0 
1 1 1 0 
1 1 1 1 
0 0 1 1 

1 1 0 0 
1 1 1 1 
0 1 1 1 
0 1 1 0 

result:

ok ok

Test #5:

score: 0
Accepted
time: 2ms
memory: 3520kb

input:

10

output:

2 2 2 1 0 0 0 0 0 0 
2 0 1 2 1 0 0 0 0 0 
2 1 0 1 2 1 0 0 0 0 
1 2 1 0 1 2 1 0 0 0 
0 1 2 1 0 1 2 1 0 0 
0 0 1 2 1 0 1 2 1 0 
0 0 0 1 2 1 0 1 2 1 
0 0 0 0 1 2 1 0 1 2 
0 0 0 0 0 1 2 1 0 2 
0 0 0 0 0 0 1 2 2 2 

0 1 1 0 0 0 0 0 0 0 
1 1 1 0 0 0 0 0 0 0 
1 1 1 1 1 0 0 0 0 0 
0 0 1 1 1 0 0 0 0 0 
0 0 1...

result:

ok ok

Test #6:

score: 0
Accepted
time: 2ms
memory: 3596kb

input:

19

output:

2 2 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
2 0 1 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
2 1 0 1 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 
1 2 1 0 1 2 1 0 0 0 0 0 0 0 0 0 0 0 0 
0 1 2 1 0 1 2 1 0 0 0 0 0 0 0 0 0 0 0 
0 0 1 2 1 0 1 2 1 0 0 0 0 0 0 0 0 0 0 
0 0 0 1 2 1 0 1 2 1 0 0 0 0 0 0 0 0 0 
0 0 0 0 1 2 1 0 1 2 1 0 0 0...

result:

ok ok

Test #7:

score: 0
Accepted
time: 2ms
memory: 3772kb

input:

20

output:

2 2 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
2 0 1 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
2 1 0 1 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
1 2 1 0 1 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 
0 1 2 1 0 1 2 1 0 0 0 0 0 0 0 0 0 0 0 0 
0 0 1 2 1 0 1 2 1 0 0 0 0 0 0 0 0 0 0 0 
0 0 0 1 2 1 0 1 2 1 0 0 0 0 0 0 0 0 0 0 
0 0 0 0 1 2 1...

result:

ok ok