Submission #1046637

#TimeUsernameProblemLanguageResultExecution timeMemory
1046637DeathIsAweBitaro the Brave (JOI19_ho_t1)C++14
100 / 100
248 ms91220 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long 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>> numsbelow, numsright; vector<int> bruh(w); for (int i=0;i<h;i++) { numsbelow.push_back(bruh); numsright.push_back(bruh); } int counter; for (int i=0;i<w;i++) { counter = 0; for (int j=h-1;j>-1;j--) { if (grid[j][i] == 'I') { counter++; } else if (grid[j][i] == 'J') { numsbelow[j][i] = counter; } } } for (int i=0;i<h;i++) { counter = 0; for (int j=w-1;j>-1;j--) { if (grid[i][j] == 'O') { counter++; } else if (grid[i][j] == 'J') { numsright[i][j] = counter; } } } ll ans = 0; for (int i=0;i<h;i++) { for (int j=0;j<w;j++) { if (grid[i][j] == 'J') { ans += numsbelow[i][j] * numsright[i][j]; } } } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...