QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#843500 | #9965. Game MPO | ucup-team3584# | WA | 0ms | 3688kb | C++23 | 2.4kb | 2025-01-04 19:48:05 | 2025-01-04 19:48:08 |
Judging History
answer
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) { return (ull)rng() % B; }
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
int n;
cin >> n;
vector<string> s(n);
vector<pair<int, int>> que;
int score = 0, cnt = 0;
map<char, char> mp;
mp['O'] = 'O';
mp['M'] = 'P';
mp['P'] = 'M';
mp['.'] = 'X';
mp['o'] = 'O';
mp['m'] = 'P';
mp['p'] = 'M';
for (int i = 0; i < n; ++i) {
cin >> s[i];
for (int j = 0; j < n; ++j) {
if (s[i][j] != '.' and islower(s[i][j])) {
que.emplace_back(i, j);
} else if (s[i][j] != '.' and isupper(s[i][j])) {
score += 1;
if (j and s[i][j - 1] == mp[s[i][j]]) score += 1;
if (i and j + 1 < n and s[i - 1][j + 1] == mp[s[i][j]]) score += 1;
if (i and s[i - 1][j] == mp[s[i][j]]) score += 1;
if (i and j and s[i - 1][j - 1] == mp[s[i][j]]) score += 1;
}
}
}
while (true) {
int idx = -1, mx = -1;
for (int i = 0; i < que.size(); ++i) {
int x = que[i].first, y = que[i].second;
int add = 1;
if (y and s[x][y - 1] == mp[s[x][y]]) add += 1;
if (x and y + 1 < n and s[x - 1][y + 1] == mp[s[x][y]]) add += 1;
if (x and s[x - 1][y] == mp[s[x][y]]) add += 1;
if (x and y and s[x - 1][y - 1] == mp[s[x][y]]) add += 1;
if (y + 1 < n and s[x][y + 1] == mp[s[x][y]]) add += 1;
if (x + 1 < n and y and s[x + 1][y - 1] == mp[s[x][y]]) add += 1;
if (x + 1 < n and s[x + 1][y] == mp[s[x][y]]) add += 1;
if (x + 1 < n and y + 1 < n and s[x + 1][y + 1] == mp[s[x][y]]) add += 1;
if (add > mx) {
mx = add;
idx = i;
}
}
if (mx <= 1) break;
score += mx;
cnt += 1;
int x = que[idx].first, y = que[idx].second;
s[x][y] += 'A' - 'a';
swap(que[idx], que.back());
que.pop_back();
}
cout << cnt << ' ' << score << '\n';
for (int i = 0; i < n; ++i) {
cout << s[i] << '\n';
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3608kb
input:
4 .pm. Mom. OOm. p..p
output:
4 13 .PM. MOM. OOm. p..p
result:
ok 5 lines
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3688kb
input:
2 .P P.
output:
0 2 .P P.
result:
wrong answer 1st lines differ - expected: '2 2', found: '0 2'