QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#528523#6396. Puzzle: Kusabihnust_xiaoqi#WA 0ms3736kbC++202.7kb2024-08-23 15:46:462024-08-23 15:46:46

Judging History

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

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

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 ;
				}
			}
		}
	}
	
	for(int i = 6; i <= n + 5; i++) {
		for(int j = 6; j <= m + 5; j++) {
			int x = b[i][j] - '0';
			int sum = 0;
			if(x >= 0 && x <= 9) {
				for(int k = -1; k <= 1; k++) {
					for(int l = -1; l <= 1; l++) {
						int xx = i + k, yy = j + l;
						if(a[xx][yy] == '#') {
							sum++;
						}
					}
				}
				if(sum != x) {
					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: 0
Wrong Answer
time: 0ms
memory: 3736kb

input:

8
2 1 -
3 1 -
4 2 Tong
5 2 Tong
6 3 Duan
7 3 -
8 7 Chang

output:

NO

result:

wrong answer Jury has answer but participant has not.