Submission #1262563

#TimeUsernameProblemLanguageResultExecution timeMemory
1262563sohamsen15Bitaro the Brave (JOI19_ho_t1)C++20
100 / 100
257 ms150624 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); ll h, w, ans = 0; cin >> h >> w; vector<vector<char>> a(h + 1, vector<char>(w + 1)); for (ll i = 1; i <= h; i++) { string s; cin >> s; for (ll j = 1; j <= w; j++) a[i][j] = s[j - 1]; } vector<vector<ll>> orbs(h + 1, vector<ll>(w + 1)); for (ll i = 1; i <= h; i++) for (ll j = 1; j <= w; j++) orbs[i][j] = orbs[i][j - 1] + (a[i][j] == 'O'); vector<vector<ll>> ingots(h + 1, vector<ll>(w + 1)); for (ll j = 1; j <= w; j++) for (ll i = 1; i <= h; i++) ingots[i][j] = ingots[i - 1][j] + (a[i][j] == 'I'); for (ll i = 1; i <= h; i++) for (ll j = 1; j <= w; j++) if (a[i][j] == 'J') ans += (orbs[i][w] - orbs[i][j]) * (ingots[h][j] - ingots[i][j]); cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...