Submission #1127001

#TimeUsernameProblemLanguageResultExecution timeMemory
1127001mfmmeBitaro the Brave (JOI19_ho_t1)C++20
0 / 100
0 ms324 KiB
#include <iostream> #include <vector> #include <string> using namespace std; int main() { int H, W; cin >> H >> W; vector<string> grid(H); for (int i = 0; i < H; ++i) { cin >> grid[i]; } vector<vector<int>> countI(H + 1, vector<int>(W, 0)); for (int j = 0; j < W; ++j) { for (int i = H - 1; i >= 0; --i) { countI[i][j] = countI[i + 1][j] + (grid[i][j] == 'I'); } } long long result = 0; for (int i = 0; i < H; ++i) { for (int k = i + 1; k < H; ++k) { vector<int> prefixO(W + 1, 0); for (int j = 0; j < W; ++j) { prefixO[j + 1] = prefixO[j] + (grid[i][j] == 'O') + (grid[k][j] == 'O'); } long long totalJ = 0; for (int j = 0; j < W; ++j) { if (grid[i][j] == 'J') { totalJ += countI[k + 1][j]; } if (grid[i][j] == 'O') { result += totalJ * (prefixO[W] - prefixO[j + 1]); } } } } cout << result << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...