Submission #807132

#TimeUsernameProblemLanguageResultExecution timeMemory
807132annabeth9680Bitaro the Brave (JOI19_ho_t1)C++17
100 / 100
307 ms161592 KiB
#include <bits/stdc++.h> #define ll long long using namespace std; int main() { int H,W; cin >> H >> W; vector<vector<ll>> suforbs(H,vector<ll>(W)), sufing(W,vector<ll>(H)); vector<string> grid(H); for(int i = 0;i<H;++i){ cin >> grid[i]; } for(int i = 0;i<H;++i){ suforbs[i][W-1] = ((grid[i][W-1] == 'O') ? 1 : 0); for(int j = W-2;j>=0;--j){ if(grid[i][j] == 'O') suforbs[i][j] = suforbs[i][j+1]+1; else suforbs[i][j] = suforbs[i][j+1]; } } for(int i = 0;i<W;++i){ sufing[i][H-1] = ((grid[H-1][i] == 'I') ? 1 : 0); //cout << "ok"; for(int j = H-2;j>=0;--j){ if(grid[j][i] == 'I') sufing[i][j] = sufing[i][j+1]+1; else sufing[i][j] = sufing[i][j+1]; } //cout << "ok"; } //cout << "ok"; ll ans = 0; for(int i = 0;i<H-1;++i){ for(int j = 0;j<W-1;++j){ if(grid[i][j] == 'J'){ ans += suforbs[i][j+1]*sufing[j][i+1]; } } } cout << ans << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...