Submission #364465

#TimeUsernameProblemLanguageResultExecution timeMemory
364465tushar_2658Bitaro the Brave (JOI19_ho_t1)C++14
100 / 100
475 ms150392 KiB
#include "bits/stdc++.h" using namespace std; const int maxn = 3005; using ll = long long; char s[maxn][maxn]; ll pref[maxn][maxn], pref1[maxn][maxn]; int main(int argc, char const *argv[]) { ios::sync_with_stdio(false); cin.tie(0); int n, m; cin >> n >> m; for(int i = 1; i <= n; ++i){ for(int j = 1; j <= m; ++j){ cin >> s[i][j]; } } for(int i = 1; i <= n; ++i){ for(int j = 1; j <= m; ++j){ pref[i][j] = pref[i][j - 1] + (s[i][j] == 'O'); } } for(int i = 1; i <= m; ++i){ for(int j = 1; j <= n; ++j){ pref1[j][i] = pref1[j - 1][i] + (s[j][i] == 'I'); } } ll ans = 0; for(int i = 1; i <= n; ++i){ for(int j = 1; j <= m; ++j){ if(s[i][j] == 'J'){ ll x = (pref[i][m] - pref[i][j]) * (pref1[n][j] - pref1[i][j]); ans += x; } } } cout << ans << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...