Submission #1049592

#TimeUsernameProblemLanguageResultExecution timeMemory
1049592vjudge1Bitaro the Brave (JOI19_ho_t1)C++11
100 / 100
133 ms151376 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define fi first #define se second #define pb push_back #define skdkdjfkv ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); void solve(){ ll h, w; cin >> h >> w; string s[h+1]; for(int i=1; i<=h; i++){ cin >> s[i]; } ll sufho[h+5][w+5], sufvi[w+5][h+5]; for(int i=1; i<=h; i++){ sufho[i][w+1]=0; for(int j=w; j>=1; j--){ sufho[i][j]=sufho[i][j+1]+(s[i][j-1]=='O'); } } for(int j=1; j<=w; j++){ sufvi[j][h+1]=0; for(int i=h; i>=1; i--){ sufvi[j][i]=sufvi[j][i+1]+(s[i][j-1]=='I'); } } ll ans=0; for(int i=1; i<=h; i++){ for(int j=1; j<=w; j++){ if(s[i][j-1]=='J'){ ans+=sufho[i][j+1]*sufvi[j][i+1]; } } } cout << ans; } int main(){ skdkdjfkv ll tc=1; //cin >> tc; while(tc--){ solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...