Submission #230160

#TimeUsernameProblemLanguageResultExecution timeMemory
230160Haunted_CppBitaro the Brave (JOI19_ho_t1)C++17
100 / 100
882 ms87160 KiB
#include <iostream> using namespace std; const int N = 3e3 + 5; int dp_orb [N][N]; int dp_ingot [N][N]; char g [N][N]; int main () { int r, c; cin >> r >> c; for (int i = 0; i < r; i++) { for (int j = 0; j < c; j++) { cin >> g[i][j]; } } for (int i = 0; i < r; i++) { for (int j = c - 1; j >= 0; j--) { dp_orb[i][j] = (g[i][j] == 'O'); if (j < c - 1) dp_orb[i][j] += dp_orb[i][j + 1]; } } for (int i = 0; i < c; i++) { for (int j = r - 1; j >= 0; j--) { dp_ingot[i][j] = (g[j][i] == 'I'); if (j < r - 1) dp_ingot[i][j] += dp_ingot[i][j + 1]; } } long long res = 0; for (int i = 0; i < r; i++) { for (int j = 0; j < c; j++) { if (g[i][j] != 'J') continue; int tot_orb = (j + 1 < c ? dp_orb[i][j + 1] : 0); int tot_ingot = (i + 1 < r ? dp_ingot[j][i + 1] : 0); res += tot_orb * tot_ingot; } } cout << res << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...