QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#879965#9965. Game MPOturkhuuTL 1ms3712kbC++201.5kb2025-02-02 19:08:482025-02-02 19:08:58

Judging History

This is the latest submission verdict.

  • [2025-02-02 19:08:58]
  • Judged
  • Verdict: TL
  • Time: 1ms
  • Memory: 3712kb
  • [2025-02-02 19:08:48]
  • Submitted

answer

#include <bits/stdc++.h>
#define FOR(i, a, b) for (auto i = (a); i <= (b); i++)
#define ROF(i, a, b) for (auto i = (a); i >= (b); i--)
using namespace std;
using ll = long long;
char s[12][12];
int f(int a, int b) {
    if (!isupper(s[a][b])) return 0;
    int cnt = 2;
    FOR(i, a - 1, a + 1) {
        FOR(j, b - 1, b + 1) {
            if (!isupper(s[i][j]) || i == a && j == b) continue;
            if (tolower(s[a][b]) == 'o' && tolower(s[i][j]) == 'o') cnt++;
            if (tolower(s[a][b]) == 'm' && tolower(s[i][j]) == 'p') cnt++;
            if (tolower(s[a][b]) == 'p' && tolower(s[i][j]) == 'm') cnt++;
        }
    }
    return cnt;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    FOR(i, 1, n) FOR(j, 1, n) cin >> s[i][j];
    int initial = 0;
    FOR(i, 1, n) FOR(j, 1, n) initial += f(i, j);
    initial /= 2;
    int final = initial;
    while (1) {
        int mx = 0, a = 0, b = 0;
        FOR(i, 1, n) {
            FOR(j, 1, n) {
                if (islower(s[i][j])) {
                    s[i][j] += 'A' - 'a';
                    int cnt = f(i, j) - 1;
                    if (cnt > mx) mx = cnt, a = i, b = j;
                    s[i][j] -= 'A' - 'a';
                }
            }
        }
        if (mx == 1) break;
        final += mx;
        s[a][b] += 'A' - 'a';
    }
    cout << initial << " " << final << "\n";
    FOR(i, 1, n) {
        FOR(j, 1, n) cout << s[i][j];
        cout << "\n";
    }
    return 6/22;
}

詳細信息

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: -100
Time Limit Exceeded

input:

2
.P
P.

output:


result: