Submission #1037340

#TimeUsernameProblemLanguageResultExecution timeMemory
1037340vaneaBitaro the Brave (JOI19_ho_t1)C++14
100 / 100
86 ms89684 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int h, w; cin >> h >> w; vector<string> v(h+1); vector<vector<int>> prefI(h+1, vector<int>(w+1)), prefO(h+1, vector<int>(w+1)); for(int i = 1; i <= h; i++) { cin >> v[i]; } for(int i = 1; i <= h; i++) { for(int j = 1; j <= w; j++) { prefO[i][j] = prefO[i][j-1]+(v[i][j-1] == 'O'); prefI[i][j] = prefI[i-1][j]+(v[i][j-1] == 'I'); } } ll ans = 0; for(int i = 1; i <= h; i++) { for(int j = 1; j <= w; j++) { if(v[i][j-1] == 'J') { ll curr = prefO[i][w]-prefO[i][j]; curr *= prefI[h][j]-prefI[i][j]; ans += curr; } } } cout << ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...