QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#859934 | #9965. Game MPO | lzm0107 | WA | 1ms | 3712kb | C++14 | 2.2kb | 2025-01-18 08:39:37 | 2025-01-18 08:39:38 |
Judging History
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 calc_score(){
int res = 0;
for(int i = 1; i <= n; i ++ ){
for(int j = 1; j <= n; j ++ ){
res += 'A' <= mp[i][j] && mp[i][j] <= 'Z';
for(int nx, ny, k = 1; k < 5; k ++ ){
nx = i + dx[k], ny = j + dy[k];
if(1 <= nx && nx <= n && 1 <= ny && ny <= n){
if(mp[i][j] == 'M' && mp[nx][ny] == 'P' || mp[i][j] == 'P' && mp[nx][ny] == 'M' || mp[i][j] == 'O' && mp[nx][ny] == 'O') res ++ ;
}
}
}
}
return res;
}
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]});
}
}
}
}
}
}
cout << calc_score() << ' ';
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]});
}
}
}
}
cout << calc_score() << '\n';
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: 100
Accepted
time: 0ms
memory: 3712kb
input:
4 .pm. Mom. OOm. p..p
output:
4 13 .PM. MOM. OOm. p..p
result:
ok 5 lines
Test #2:
score: 0
Accepted
time: 1ms
memory: 3712kb
input:
2 .P P.
output:
2 2 .P P.
result:
ok 3 lines
Test #3:
score: 0
Accepted
time: 0ms
memory: 3712kb
input:
3 ... .pp .m.
output:
0 0 ... .pp .m.
result:
ok 4 lines
Test #4:
score: 0
Accepted
time: 0ms
memory: 3712kb
input:
4 .... .... .... ....
output:
0 0 .... .... .... ....
result:
ok 5 lines
Test #5:
score: -100
Wrong Answer
time: 0ms
memory: 3712kb
input:
5 m.... m.Mop OOpoo PMp.. Oo...
output:
8 11 m.... m.Mop OOPoo PMp.. Oo...
result:
wrong answer 1st lines differ - expected: '8 15', found: '8 11'