Submission #1026284

# Submission time Handle Problem Language Result Execution time Memory
1026284 2024-07-17T18:53:48 Z overwatch9 Bitaro the Brave (JOI19_ho_t1) C++17
0 / 100
0 ms 348 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    int n, m;
    cin >> n >> m;
    vector <string> grid(n+1);
    for (int i = 1; i <= n; i++) {
        cin >> grid[i];
        grid[i] = "0" + grid[i];
    }
    map <char, vector <vector <int>>> pfx;
    pfx['O'] = pfx['I'] = vector <vector <int>> (n+1, vector <int> (m+1));
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (grid[i][j] != 'J')
                pfx[grid[i][j]][i][j]++;
            pfx['O'][i][j] += pfx['O'][i-1][j] + pfx['O'][i][j-1] - pfx['O'][i-1][j-1];
            pfx['I'][i][j] += pfx['I'][i-1][j] + pfx['I'][i][j-1] - pfx['I'][i-1][j-1];
        }
    }
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (grid[i][j] != 'J')
                continue;
            ll a = pfx['O'][i][n] - pfx['O'][i][j] - pfx['O'][i-1][n] + pfx['O'][i-1][j];
            ll b = pfx['I'][n][j] - pfx['I'][n][j-1] - pfx['I'][i][j] + pfx['I'][i][j-1];
            ans += a * b;
        }
    }
    cout << ans << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -