Submission #542089

#TimeUsernameProblemLanguageResultExecution timeMemory
542089AJ00Bitaro the Brave (JOI19_ho_t1)C++14
20 / 100
12 ms9428 KiB
#include <bits/stdc++.h> using namespace std; int sufr[3000][3000],sufc[3000][3000],val[3000][3000]; char ch; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int t=1,n,m; // cin >> t; while (t--){ cin >> n >> m; for (int i = 0; i < n; i++){ for (int j = 0; j < m; j++){ cin >> ch; if (ch == 'J'){ val[i][j] = 0; } if (ch == 'O'){ val[i][j] = 1; } if (ch == 'I'){ val[i][j] = 2; } } } // sufr[i][j] orbs in row i, after j // sufc[i][j] ingots in column j, after i for (int i = 0; i < n; i++){ sufr[i][m-1] = (val[i][m-1] == 1); for (int j = m-2; j >= 0; j--){ sufr[i][j] = sufr[i][j+1] + (val[i][j] == 1); } } for (int j = 0; j < m; j++){ sufc[n-1][j] = (val[n-1][j] == 2); for (int i = n-2; i >= 0; i--){ sufc[i][j] = sufc[i+1][j] + (val[i][j] == 2); } } int ans = 0; for (int i = 0; i < n; i++){ for (int j = 0; j < m; j++){ if (!val[i][j]){ ans += (sufr[i][j]*sufc[i][j]); } } } cout << ans << "\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...