QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#911516 | #9965. Game MPO | .5 ulp (Maxim Plyushkin, Egor Belousov, Maxim Inyutin)# | WA | 1ms | 3712kb | C++23 | 1.1kb | 2025-02-22 17:21:33 | 2025-02-22 17:21:34 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int score(char a, char b) { return a == 'O' || b == 'O'? a == b: a != b; }
char a[12][12];
int main() {
cin.tie(0)->sync_with_stdio(0);
int n, s0 = 0, s = 0; cin >> n;
for (int i = 1; i <= n; ++i)
for (int j = 1; j <= n; ++j) cin >> a[i][j];
for (int i = 1; i <= n; ++i)
for (int j = 1; j <= n; ++j) if (isupper(a[i][j]))
for (++s; auto di: {0, 1})
for (auto dj: {0, 1}) if ((di || dj) && isupper(a[i + di][j + dj])) s += score(a[i][j], a[i + di][j + dj]);
cout << s << ' ';
while (1) {
int bi, bj, bs = 0;
for (int i = 1; i <= n; ++i)
for (int j = 1; j <= n; ++j) if (islower(a[i][j])) {
int ds = 0;
for (auto di: {-1, 0, 1})
for (auto dj: {-1, 0, 1}) if (isupper(a[i + di][j + dj])) ds += score(a[i][j] ^ 32, a[i + di][j + dj]);
if (ds > bs) bs = ds, bi = i, bj = j;
}
s += bs;
if (bs) a[bi][bj] ^= 32, ++s;
else break;
}
cout << s << '\n';
for (int i = 1; i <= n; ++i, cout << '\n')
for (int j = 1; j <= n; ++j) cout << a[i][j];
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
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: 3584kb
input:
3 ... .pp .m.
output:
0 0 ... .pp .m.
result:
ok 4 lines
Test #4:
score: 0
Accepted
time: 1ms
memory: 3584kb
input:
4 .... .... .... ....
output:
0 0 .... .... .... ....
result:
ok 5 lines
Test #5:
score: 0
Accepted
time: 0ms
memory: 3712kb
input:
5 m.... m.Mop OOpoo PMp.. Oo...
output:
8 15 m.... m.Mop OOPoo PMP.. OO...
result:
ok 6 lines
Test #6:
score: 0
Accepted
time: 1ms
memory: 3584kb
input:
6 Mo..Op ..P.p. p.MopP mMpO.P ..mp.p OM.Mo.
output:
12 26 Mo..Op ..P.p. P.MOpP MMPO.P ..MP.p OM.Mo.
result:
ok 7 lines
Test #7:
score: -100
Wrong Answer
time: 0ms
memory: 3712kb
input:
7 .M.O.M. .PM...M MO.MMP. O.O.P.P POOOOM. MO...MP ..MOP.O
output:
46 46 .M.O.M. .PM...M MO.MMP. O.O.P.P POOOOM. MO...MP ..MOP.O
result:
wrong answer 1st lines differ - expected: '53 53', found: '46 46'