QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#859951#9965. Game MPOsherman2022#WA 1ms3840kbC++142.0kb2025-01-18 08:53:382025-01-18 08:53:39

Judging History

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

  • [2025-01-18 08:53:39]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3840kb
  • [2025-01-18 08:53:38]
  • 提交

answer

#include <bits/stdc++.h>

#define i64 long long int

#define pii pair<int, int>
#define mp make_pair
#define fi first
#define se second

#define eb emplace_back

using namespace std;

inline int Read() {int res; return scanf("%d", &res), res; }
inline i64 Read64() {i64 res; return scanf("%lld", &res), res; }

const int INF_32 = 1e9;
const i64 INF_64 = 1e18;

const int N = 10 + 5;

int n;
char s[N][N];

bool Check(char x, char y) {
	if(x == '.' || y == '.') return false;
	if(x == 'O' && y == 'O') return true;
	if(x == 'M' && y == 'P') return true;
	if(x == 'P' && y == 'M') return true;
}

int main() {
	n = Read();
	for(int i = 1; i <= n; ++ i) scanf("%s", s[i] + 1);
	
	int ans = 0;
	for(int i = 1; i <= n; ++ i) {
		for(int j = 1; j <= n; ++ j) {
			if('A' <= s[i][j] && s[i][j] <= 'Z') {
				ans ++;
				if(Check(s[i][j], s[i][j - 1])) ans ++;
				if(Check(s[i][j], s[i - 1][j])) ans ++;
				if(Check(s[i][j], s[i - 1][j - 1])) ans ++;
				if(Check(s[i][j], s[i + 1][j - 1])) ans ++;
				if(Check(s[i][j], s[i - 1][j + 1])) ans ++;
			}
		}
	}
	printf("%d ", ans);
	
	while(true) {
		int tt = 0, X, Y;
		for(int i = 1; i <= n; ++ i) {
			for(int j = 1; j <= n; ++ j) {
				if('a' <= s[i][j] && s[i][j] <= 'z') {
					s[i][j] += 'A' - 'a';
					int tmp = 1;
					if(Check(s[i][j], s[i][j - 1])) tmp ++;
					if(Check(s[i][j], s[i - 1][j])) tmp ++;
					if(Check(s[i][j], s[i][j + 1])) tmp ++;
					if(Check(s[i][j], s[i + 1][j])) tmp ++;
					if(Check(s[i][j], s[i - 1][j - 1])) tmp ++;
					if(Check(s[i][j], s[i - 1][j + 1])) tmp ++;
					if(Check(s[i][j], s[i + 1][j - 1])) tmp ++;
					if(Check(s[i][j], s[i + 1][j + 1])) tmp ++;
					if(tmp > tt) {
						tt = tmp;
						X = i, Y = j;
					}
					s[i][j] -= 'A' - 'a';
				}
			}
		}
		if(tt <= 1) break;
		ans += tt;
		s[X][Y] += 'A' - 'a';
	}
	
	printf("%d\n", ans);
	for(int i = 1; i <= n; ++ i) {
		for(int j = 1; j <= n; ++ j) printf("%c", s[i][j]);
		puts("");
	}
	
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3840kb

input:

4
.pm.
Mom.
OOm.
p..p

output:

17 66
.PM.
MOM.
OOM.
P..P

result:

wrong answer 1st lines differ - expected: '4 13', found: '17 66'