Submission #702672

#TimeUsernameProblemLanguageResultExecution timeMemory
702672speedyArdaBitaro the Brave (JOI19_ho_t1)C++14
100 / 100
363 ms157944 KiB
#include "bits/stdc++.h" using namespace std; const int MAXN = 3005; char board[MAXN][MAXN]; long long pref_orb[MAXN][MAXN]; long long pref_ingot[MAXN][MAXN]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int h, w; cin >> h >> w; for(int i = 1; i <= h; i++) { pref_orb[i][0] = 0; for(int a = 1; a <= w; a++) { cin >> board[i][a]; pref_orb[i][a] = pref_orb[i][a-1] + (board[i][a] == 'O' ? 1 : 0); } } for(int col = 1; col <= w; col++) { for(int row = 1; row <= h; row++) { pref_ingot[row][col] = pref_ingot[row-1][col] + (board[row][col] == 'I' ? 1 : 0); } } long long ans = 0; for(int row = 1; row <= h; row++) { for(int col = 1; col <= w; col++) { if(board[row][col] == 'J') { ans += (pref_orb[row][w] - pref_orb[row][col]) * (pref_ingot[h][col] - pref_ingot[row][col]); } //cout << row << " " << col << " " << ans << "\n"; } } cout << ans << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...