QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#859928#9965. Game MPOlzm0107WA 0ms3584kbC++141.7kb2025-01-18 08:35:352025-01-18 08:35:45

Judging History

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

  • [2025-01-18 08:35:45]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3584kb
  • [2025-01-18 08:35:35]
  • 提交

answer

#include <bits/stdc++.h>
#define lzm0107
using namespace std;
using LL = long long;
using AI2 = array<int, 2>;
using PII = pair<int, int>;
using ULL = unsigned long long;
const int N = 1e1 + 10;
const int dx[] = {-1, -1, 0, 1, 1, 1, 0, -1}, dy[] = {0, 1, 1, 1, 0, -1, -1, -1};

struct data{
	int x, y, pri;
	bool operator< (const data &a) const{return pri < a.pri;}
};

int n, val[N][N];
char mp[N][N];

int main(){
	ios::sync_with_stdio(false);
	*cin.tie(nullptr) << fixed << setprecision(20);
	
	cin >> n;
	priority_queue<data> heap;
	for(int i = 1; i <= n; i ++ ){
		for(int j = 1; j <= n; j ++ ){
			cin >> mp[i][j];
			if('A' <= mp[i][j] && mp[i][j] <= 'Z'){
				for(int nx, ny, k = 0; k < 8; k ++ ){
					nx = i + dx[k], ny = j + dy[k];
					if(1 <= nx && nx <= n && 1 <= ny && ny <= n){
						if(mp[nx][ny] == 'm' && mp[i][j] == 'P' || mp[nx][ny] == 'p' && mp[i][j] == 'M' || mp[nx][ny] == 'o' && mp[i][j] == 'O'){
							val[nx][ny] ++ ;
							heap.push(data{nx, ny, val[nx][ny]});
						}
					}
				}
			}
		}
	}
	while(!heap.empty()){
		int x = heap.top().x, y = heap.top().y, pri = heap.top().pri;
		heap.pop();
		if('A' <= mp[x][y] && mp[x][y] <= 'Z') continue;
		mp[x][y] -= 'a' - 'A';
		for(int nx, ny, k = 0; k < 8; k ++ ){
			nx = x + dx[k], ny = y + dy[k];
			if(1 <= nx && nx <= n && 1 <= ny && ny <= n){
				if(mp[nx][ny] == 'm' && mp[x][y] == 'P' || mp[nx][ny] == 'p' && mp[x][y] == 'M' || mp[nx][ny] == 'o' && mp[x][y] == 'o'){
					val[nx][ny] ++ ;
					heap.push(data{nx, ny, val[nx][ny]});
				}
			}
		}
	}
	for(int i = 1; i <= n; i ++ ){
		for(int j = 1; j <= n; j ++ ){
			cout << mp[i][j];
		}
		cout << '\n';
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3584kb

input:

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

output:

.PM.
MOM.
OOm.
p..p

result:

wrong answer 1st lines differ - expected: '4 13', found: '.PM.'