Submission #1034955

#TimeUsernameProblemLanguageResultExecution timeMemory
1034955sunboiBitaro the Brave (JOI19_ho_t1)C++17
100 / 100
289 ms159200 KiB
#include <bits/stdc++.h> using namespace std; #define int long long signed main() { int h, w; cin >> h >> w; vector<vector<char>> a(h, vector<char> (w)); for (int i = 0; i < h; i++){ string s; cin >> s; for (int j = 0; j < w; j++){ a[i][j] = s[j]; } } vector<vector<int>> col(h, vector<int> (w)); vector<vector<int>> fil(h, vector<int> (w)); for (int i = 0; i < h; i++){ for (int j = 0; j < w; j++){ if (j == 0) fil[i][j] += (a[i][j] == 'O'); else { fil[i][j] = (a[i][j] == 'O'); fil[i][j] += fil[i][j - 1]; } } } for (int i = 0; i < w; i++){ for (int j = 0; j < h; j++){ if (j == 0)col[j][i] = (a[j][i] == 'I'); else { col[j][i] = (a[j][i] == 'I'); col[j][i] += col[j-1][i]; } } } int ans = 0; for (int i = 0; i < h; i++){ for (int j = 0; j < w; j++){ if (a[i][j] == 'J') ans += (fil[i][w - 1] - fil[i][j]) * (col[h - 1][j] - col[i][j]); } } cout << ans << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...