QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#842157 | #9965. Game MPO | ucup-team896# | AC ✓ | 0ms | 3868kb | C++20 | 1.8kb | 2025-01-04 10:35:27 | 2025-01-04 10:35:34 |
Judging History
answer
#include <bits/stdc++.h>
#define rep(i, j, k) for (int i = (j); i <= (k); ++i)
#define per(i, j, k) for (int i = (j); i >= (k); --i)
#define SZ(v) int((v).size())
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
using ll = long long;
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;
template<class T> void chkmn(T &x, T y) { if (y < x) x = y; }
template<class T> void chkmx(T &x, T y) { if (y > x) x = y; }
using namespace std;
const int maxn = 20;
int n;
string s[maxn];
char opt(char x) {
if (x == 'O') return 'O';
if (x == 'M') return 'P';
if (x == 'P') return 'M';
}
bool check(int x, int y, char c) {
rep (dx, x - 1, x + 1) rep (dy, y - 1, y + 1) {
if (dx == x && dy == y) continue;
if (dx >= 1 && dx <= n && dy >= 1 && dy <= n && s[dx][dy] == c) return true;
}
return false;
}
int calc() {
int ans = 0;
rep (i, 1, n) rep (j, 1, n) if (isupper(s[i][j])) ans++;
rep (i, 1, n) rep (j, 1, n - 1) if (isupper(s[i][j]) && opt(s[i][j]) == s[i][j + 1]) ans++;
rep (i, 1, n - 1) rep (j, 1, n) if (isupper(s[i][j]) && opt(s[i][j]) == s[i + 1][j]) ans++;
rep (i, 1, n - 1) rep (j, 1, n - 1) if (isupper(s[i][j]) && opt(s[i][j]) == s[i + 1][j + 1]) ans++;
rep (i, 1, n - 1) rep (j, 1, n - 1) if (isupper(s[i + 1][j]) && opt(s[i + 1][j]) == s[i][j + 1]) ans++;
return ans;
}
int main() {
cin.tie(nullptr) -> ios::sync_with_stdio(false);
cin >> n;
rep (i, 1, n) cin >> s[i], s[i] = " "s + s[i];
int cost = calc();
while (true) {
int ok = 0;
rep (i, 1, n) rep (j, 1, n) if (islower(s[i][j]) && check(i, j, opt(s[i][j] - 'a' + 'A'))) s[i][j] = s[i][j] - 'a' + 'A', ok = 1;
if (!ok) break;
}
cout << cost << " " << calc() << '\n';
rep (i, 1, n) {
rep (j, 1, n) cout << s[i][j];
cout << '\n';
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3800kb
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: 0ms
memory: 3628kb
input:
2 .P P.
output:
2 2 .P P.
result:
ok 3 lines
Test #3:
score: 0
Accepted
time: 0ms
memory: 3628kb
input:
3 ... .pp .m.
output:
0 0 ... .pp .m.
result:
ok 4 lines
Test #4:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
4 .... .... .... ....
output:
0 0 .... .... .... ....
result:
ok 5 lines
Test #5:
score: 0
Accepted
time: 0ms
memory: 3624kb
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: 0ms
memory: 3832kb
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: 0
Accepted
time: 0ms
memory: 3868kb
input:
7 .M.O.M. .PM...M MO.MMP. O.O.P.P POOOOM. MO...MP ..MOP.O
output:
53 53 .M.O.M. .PM...M MO.MMP. O.O.P.P POOOOM. MO...MP ..MOP.O
result:
ok 8 lines
Test #8:
score: 0
Accepted
time: 0ms
memory: 3564kb
input:
8 m.mm..p. .oo.op.p .op.pm.. ...p.pmp .o.ooo.. m.momo.o omp.pmmo mp.mmo..
output:
0 0 m.mm..p. .oo.op.p .op.pm.. ...p.pmp .o.ooo.. m.momo.o omp.pmmo mp.mmo..
result:
ok 9 lines
Test #9:
score: 0
Accepted
time: 0ms
memory: 3572kb
input:
9 pp...p.pP ...PmOM.o .MOM.M.Mm O.op.pppP Oo..opMp. .pPM..p.p .m.M.o.m. pPP.PO.O. mopMooom.
output:
31 93 pp...P.PP ...PMOM.o .MOM.M.MM O.OP.PPPP OO..oPMP. .PPM..P.P .M.M.O.M. PPP.PO.O. MoPMOOOm.
result:
ok 10 lines
Test #10:
score: 0
Accepted
time: 0ms
memory: 3604kb
input:
10 M.oMppo..p Pp...pmMp. o..mp.P.m. OMm..M..M. OPPmM.o.M. .pO..mOm.p O..o..P.m. .m..OOp.m. p..Oomm... .p.oMpmmp.
output:
30 86 M.oMPPo..p PP...PMMP. O..MP.P.M. OMM..M..M. OPPMM.O.M. .pO..MOM.P O..O..P.M. .m..OOP.m. p..OOMM... .p.OMPMmp.
result:
ok 11 lines
Test #11:
score: 0
Accepted
time: 0ms
memory: 3564kb
input:
10 P.o.OoP... Mpm.PmPpMm p.....O..M MpOM..Ompp .m.Oo.pM.P ....mOmmPo Ppoo.mm... ..OM.o.P.p OPO....M.P P.ooo.mP.p
output:
36 89 P.o.OOP... MPM.PMPPMm P.....O..M MPOM..OMPP .M.OO.PM.P ....mOMMPo PpOO.mM... ..OM.o.P.p OPO....M.P P.OOO.MP.p
result:
ok 11 lines
Test #12:
score: 0
Accepted
time: 0ms
memory: 3660kb
input:
10 .m..Oooomo .......... MOMoomp.Pp .......... mMP..omOoM .........O mmOmoOm.PM m......... PmM.O.Mpp. .........o
output:
20 37 .m..OOOOmo .......... MOMoomp.Pp .......... mMP..omOOM .........O mmOmOOm.PM M......... PMM.O.MPp. .........o
result:
ok 11 lines
Test #13:
score: 0
Accepted
time: 0ms
memory: 3572kb
input:
10 Oooooooooo oooooooooo oooooooooo oooooooooo oooooooooo oooooooooo oooooooooo oooooooooo oooooooooo oooooooooo
output:
1 442 OOOOOOOOOO OOOOOOOOOO OOOOOOOOOO OOOOOOOOOO OOOOOOOOOO OOOOOOOOOO OOOOOOOOOO OOOOOOOOOO OOOOOOOOOO OOOOOOOOOO
result:
ok 11 lines
Test #14:
score: 0
Accepted
time: 0ms
memory: 3800kb
input:
10 Oooooooooo .........o oooooooooo o......... oooooooooo .........o oooooooooo o......... oooooooooo .........o
output:
1 118 OOOOOOOOOO .........O OOOOOOOOOO O......... OOOOOOOOOO .........O OOOOOOOOOO O......... OOOOOOOOOO .........O
result:
ok 11 lines
Test #15:
score: 0
Accepted
time: 0ms
memory: 3572kb
input:
10 Mm.Op.OM.m oP.o..mO.m .......... pm....oo.P pm.mp..O.o .......... .p.m.....M Mm.M..pM.o .......... OP.Mp.oP.P
output:
19 36 MM.Op.OM.m oP.O..mO.m .......... pm....OO.P pm.mp..O.o .......... .P.m.....M MM.M..PM.o .......... OP.MP.oP.P
result:
ok 11 lines
Test #16:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
10 mpm.mpmpmp pmpmpm..pm mpmpm.mpmp .mpmpmpmpm mpmpmpmpm. pmpm..p.p. mpmpmpmpmp ..pmpmpm.m mpmpmpmpmp pmpmpmpmpM
output:
1 224 MPM.MPMPMP PMPMPM..PM MPMPM.MPMP .MPMPMPMPM MPMPMPMPM. PMPM..P.P. MPMPMPMPMP ..PMPMPM.M MPMPMPMPMP PMPMPMPMPM
result:
ok 11 lines
Test #17:
score: 0
Accepted
time: 0ms
memory: 3832kb
input:
10 OM.op.MO.o po.MO.op.O .......... OP.om.po.O mO.Po.OM.o .......... PO.mo.pp.P Om.oP.mm.m ........O. Oo.oO.Mp.o
output:
25 63 OM.OP.MO.O PO.MO.OP.O .......... OP.oM.PO.O MO.Po.OM.O .......... PO.Mo.pp.P OM.oP.mm.M ........O. OO.OO.MP.O
result:
ok 11 lines
Extra Test:
score: 0
Extra Test Passed