Submission #753895

#TimeUsernameProblemLanguageResultExecution timeMemory
753895emad234Bitaro the Brave (JOI19_ho_t1)C++17
100 / 100
365 ms159416 KiB
#include <bits/stdc++.h> #define all(v) ((v).begin(),(v).end()) #define ll long long using namespace std; const ll mod = 1e9 + 7; const ll mxN = 2e6 + 1; char a[3011][3011]; ll ing[3011][3011],orb[3011][3011]; signed main() { ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); ll n,m; cin >>n>>m; for(ll i = 1;i <= n;i++){ for(ll j = 1; j <= m;j++){ cin >>a[i][j]; } } for(ll j = 1;j <= m;j++){ for(ll i = n;i;i--){ ing[i][j] = ing[i + 1][j] + (a[i][j] == 'I'); } } for(ll i = 1;i <= n;i++){ for(ll j = m;j;j--){ orb[i][j] = orb[i][j + 1] + (a[i][j] == 'O'); } } ll ans = 0; for(ll i = 1;i<= n;i++){ for(ll j = 1;j <= m;j++){ if(a[i][j] == 'J'){ ans += orb[i][j] * ing[i][j]; } } } cout<<ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...