Submission #818771

#TimeUsernameProblemLanguageResultExecution timeMemory
818771ZaniteBitaro the Brave (JOI19_ho_t1)C++17
100 / 100
299 ms80236 KiB
#include <bits/stdc++.h> using namespace std; const int maxN = 3023; int H, W; char grid[maxN][maxN]; int O[maxN][maxN], I[maxN][maxN]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> H >> W; for (int i = 1; i <= H; i++) { for (int j = 1; j <= W; j++) { cin >> grid[i][j]; } } for (int i = 1; i <= H; i++) { for (int j = W; j >= 1; j--) { O[i][j] = O[i][j+1] + (grid[i][j] == 'O'); } } for (int j = 1; j <= W; j++) { for (int i = H; i >= 1; i--) { I[i][j] = I[i+1][j] + (grid[i][j] == 'I'); } } long long ans = 0; for (int i = 1; i <= H; i++) { for (int j = 1; j <= W; j++) { if (grid[i][j] == 'J') { ans += 1ll * O[i][j] * I[i][j]; } } } cout << ans << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...