QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#528521#6398. Puzzle: Tapahnust_xiaoqi#WA 0ms3752kbC++202.3kb2024-08-23 15:42:472024-08-23 15:42:47

Judging History

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

  • [2024-08-23 15:42:47]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3752kb
  • [2024-08-23 15:42:47]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
#define endl "\n"

using namespace std;

const int N = 150;

typedef long long LL;
typedef pair<int, int> PII;

int n, m;
char a[N][N], b[N][N];

void solve() {
	cin >> n >> m;
	n = n * 2 - 1; m = m * 2 - 1;
	memset(a, '.', sizeof a);
	for(int i = 6; i <= n + 5; i++) {
		for(int j = 6; j <= m + 5; j++) {
			cin >> a[i][j];
			if(a[i][j] == '.') a[i][j] = '#';
			b[i][j] = a[i][j];
		}
	}
	
	// for(int i = 5; i <= n + 6; i++) {
		// for(int j = 5; j <= m + 6; j++) cout << a[i][j];
		// cout << endl;
	// }
	
	for(int i = 6; i <= n + 5; i++) {
		for(int j = 6; j <= m + 5; j++) {
			if(a[i][j] == '2' && (a[i][j + 2] == '4' || a[i][j + 2] == '2')) a[i][j + 1] = '.', a[i][j]++, a[i][j + 2]++;
			if(a[i][j] == '4' && (a[i][j + 2] == '4' || a[i][j + 2] == '7')) a[i][j + 1] = '.', a[i][j]++, a[i][j + 2]++;
			if(a[i][j] == '7' && (a[i][j + 2] == '7' || a[i][j + 2] == '4')) a[i][j + 1] = '.', a[i][j]++, a[i][j + 2]++;
		}
	}
	
	for(int i = 6; i <= n + 5; i++) {
		for(int j = 6; j <= m + 5; j++) {
			if(a[j][i] == '2' && (a[j + 2][i] == '4' || a[j + 2][i] == '2')) a[j + 1][i] = '.';
			if(a[j][i] == '4' && (a[j + 2][i] == '4' || a[j + 2][i] == '7')) a[j + 1][i] = '.';
			if(a[j][i] == '7' && (a[j + 2][i] == '7' || a[j + 2][i] == '4')) a[j + 1][i] = '.';
		}
	}
	
	// cout << endl;
	// for(int i = 5; i <= n + 6; i++) {
		// for(int j = 5; j <= m + 6; j++) cout << a[i][j];
		// cout << endl;
	// }
	
	for(int i = 6; i <= n + 5; i++) {
		for(int j = 6; j <= m + 5; j++) {
			if(a[i][j] == '#') {
				if(a[i - 1][j] != '#' && a[i + 1][j] != '#' && a[i][j - 1] != '#' && a[i][j + 1] != '#') {
					cout << "NO\n";
					return ;
				}
			}
			if(a[i][j] == '.') {
				if(a[i - 1][j] == '#' && a[i + 1][j] == '#') {
					cout << "NO\n";
					return ;
				}
				if(a[i][j - 1] == '#' && a[i][j + 1] == '#') {
					cout << "NO\n";
					return ;
				}
			}
		}
	}
	cout << "YES\n";
	for(int i = 6; i <= n + 5; i++) {
		for(int j = 6; j <= m + 5; j++) {
			if(a[i][j] >= '0' && a[i][j] <= '9') cout << b[i][j];
			else cout << a[i][j];
		}
		cout << endl;
	}
	
}

signed main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0);
	
	int t = 1;
	// cin >> t;
	while(t--) {
		solve();
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3 3
2.4.3
.....
5.8.5
.....
3.5.3

output:

YES
2.4#3
#####
5#8#5
#####
3#5#3

result:

ok Correct.

Test #2:

score: 0
Accepted
time: 0ms
memory: 3752kb

input:

3 3
3.4.3
.....
5.7.5
.....
3.5.3

output:

NO

result:

ok Correct.

Test #3:

score: 0
Accepted
time: 0ms
memory: 3672kb

input:

2 2
2.2
...
2.2

output:

YES
2.2
###
2.2

result:

ok Correct.

Test #4:

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

input:

2 50
2.4.4.4.4.5.5.5.5.5.5.5.5.4.5.5.4.4.5.5.5.5.4.5.5.5.5.5.4.4.5.4.5.5.5.5.5.5.5.5.5.5.5.4.4.5.5.4.5.3
...................................................................................................
2.5.5.4.4.5.5.5.4.4.5.5.5.4.5.5.5.5.5.5.5.5.4.4.4.5.5.5.5.5.5.4.4.4.5.5.5.5.5.5.5.4.4.5.5.5.5.4...

output:

YES
2.4#4.4#4#5#5#5#5#5#5#5#5#4#5#5#4.4#5#5#5#5#4#5#5#5#5#5#4.4#5#4#5#5#5#5#5#5#5#5#5#5#5#4.4#5#5#4#5#3
###################################################################################################
2#5#5#4.4#5#5#5#4.4#5#5#5#4#5#5#5#5#5#5#5#5#4.4#4#5#5#5#5#5#5#4.4#4#5#5#5#5#5#5#5#4.4#5#5#5#5#4#...

result:

wrong answer Clue not satisfied at (1,9)