QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#738406#9621. 连方chnwjdAC ✓10ms7784kbC++141.5kb2024-11-12 18:59:192024-11-12 18:59:20

Judging History

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

  • [2024-11-12 18:59:20]
  • 评测
  • 测评结果:AC
  • 用时:10ms
  • 内存:7784kb
  • [2024-11-12 18:59:19]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
int T,n,u,d;
int a[maxn][10];
void Print(int x){
	if (x) putchar('#');
	 else putchar('.');
} 
int main(){
	scanf("%d",&T);
	while (T--){
		scanf("%d",&n); int cnt1=0,cnt2=0;
		for (int i=1; i<=n; i++){
			char ch=getchar();
			while (ch!='#'&&ch!='.') ch=getchar();
			a[i][1]=(ch=='#'); cnt1+=a[i][1];
		}
		for (int i=1; i<=n; i++){
			char ch=getchar();
			while (ch!='#'&&ch!='.') ch=getchar();
			a[i][7]=(ch=='#'); cnt2+=a[i][7];
		}
		if (cnt1==n||cnt2==n){
			if (cnt1==n&&cnt2==n){
				printf("Yes\n");
				for (int i=1; i<=7; i++){
					for (int j=1; j<=n; j++) Print(1);
					putchar(10);
				}
			} else printf("No\n");
			continue;
		}
		for (int i=1; i<=n; i++) a[i][2]=1-a[i][1],a[i][6]=1-a[i][7],a[i][3]=a[i][4]=a[i][5]=0;
		if (a[1][2]==1){
			int now=1;
			while (now<=n&&a[now][2]==1) a[now][2]=0,now++;
			a[now-1][2]=1; a[now-1][3]=1; u=now-1;
		} else{
			int now=1;
			while (now<=n&&a[now][2]==0) now++;
			a[now-1][3]=1; u=now-1;
		}
		if (a[1][6]==1){
			int now=1;
			while (now<=n&&a[now][6]==1) a[now][6]=0,now++;
			a[now-1][6]=1; a[now-1][5]=1; d=now-1;
		} else{
			int now=1;
			while (now<=n&&a[now][6]==0) now++;
			a[now-1][5]=1; d=now-1;
		}
		if (abs(d-u)<=1){
			a[d][4]=1;
		} else {
			int l=min(u,d),r=max(u,d);
			for (int i=l+1; i<=r-1; i++) a[i][4]=1;
		}
		printf("Yes\n");
		for (int i=1; i<=7; i++){
			for (int j=1; j<=n; j++) Print(a[j][i]);
			putchar(10);
		}
	}
	return 0;
} 

詳細信息

Test #1:

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

input:

5
4
#..#
.##.
5
##.#.
.#.##
6
######
.####.
27
.######.######.####.#.#####
.####...####..#.......#####
10
##########
##########

output:

Yes
#..#
.##.
#...
#...
#...
#..#
.##.
Yes
##.#.
..#.#
.#...
#....
#....
#.#..
.#.##
No
Yes
.######.######.####.#.#####
#......#......#....#.#.....
#..........................
#..........................
#..........................
#....###....##.#######.....
.####...####..#.......#####
Yes
########...

result:

ok Correct.

Test #2:

score: 0
Accepted
time: 10ms
memory: 4088kb

input:

10000
6
.#..##
..#...
5
#..#.
##...
6
.###.#
...###
17
.####..#######..#
###########.#####
6
..##.#
#.##.#
25
#.##.##############.####.
####################.##.#
9
##.#..##.
##..#####
6
.###.#
##.###
6
###..#
#.####
25
#####################.#.#
######.##################
6
.#.###
.##..#
6
..####
#......

output:

Yes
.#..##
#.##..
#.....
.#....
.#....
.#.###
..#...
Yes
#..#.
.##.#
#....
.#...
.#...
..###
##...
Yes
.###.#
#...#.
#.....
.#....
..#...
..#...
...###
Yes
.####..#######..#
#....##.......##.
#................
.#########.......
..........#......
...........#.....
###########.#####
Yes
..##.#
.#..#.
...

result:

ok Correct.

Test #3:

score: 0
Accepted
time: 10ms
memory: 4128kb

input:

10000
41
#######.#######.#########################
################.###.#######.############
6
..#..#
#..##.
6
#.#...
#...#.
6
.#.##.
....##
6
...#.#
##..#.
33
#####.###########################
###########.#####################
6
.##.##
.##.#.
5
..##.
####.
17
#.###.##########.
####.##.#####.##.
5
....

output:

Yes
#######.#######.#########################
.......#.......#.........................
......#..................................
.......########..........................
...............#.........................
................#...#.......#............
################.###.#######.############
Ye...

result:

ok Correct.

Test #4:

score: 0
Accepted
time: 10ms
memory: 3988kb

input:

10000
6
..####
.#....
6
...#.#
#..##.
9
..####.##
######..#
33
#######################.#####..##
######.######.###########.#######
6
####.#
#..##.
6
...###
##.###
25
######.#.#.##############
.#########.##########.###
17
############.####
###############.#
6
#..#.#
#####.
6
.#.###
..#...
49
########...

output:

Yes
..####
.#....
.#....
#.....
#.....
#.####
.#....
Yes
...#.#
..#.#.
..#...
.#....
#.....
.##..#
#..##.
Yes
..####.##
.#....#..
.#.......
..###....
.....#...
......##.
######..#
Yes
#######################.#####..##
.......................#.....##..
......................#..........
......########...

result:

ok Correct.

Test #5:

score: 0
Accepted
time: 10ms
memory: 4056kb

input:

10000
5
...#.
#####
6
###...
##..#.
9
.#.######
#.#..####
49
######.##########################################
########.#############.##########################
41
###########.#######.#####################
##############.##########################
6
###..#
###.##
49
#################################...

output:

No
Yes
###...
...###
..#...
.#....
.#....
..##.#
##..#.
Yes
.#.######
#.#......
#........
#........
#........
.#.##....
#.#..####
Yes
######.##########################################
......#..........................................
.....#...........................................
......#............

result:

ok Correct.

Test #6:

score: 0
Accepted
time: 4ms
memory: 7728kb

input:

2
100000
###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.#...

output:

Yes
###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.##.#.....

result:

ok Correct.

Test #7:

score: 0
Accepted
time: 8ms
memory: 7784kb

input:

2
100000
##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##...

output:

Yes
##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##........

result:

ok Correct.