Submission #468232

#TimeUsernameProblemLanguageResultExecution timeMemory
468232chirathnirodhaBitaro the Brave (JOI19_ho_t1)C++17
100 / 100
488 ms158700 KiB
//Coded by Chirath Nirodha #include<bits/stdc++.h> #define F first #define S second #define PB push_back #define MP make_pair typedef long long ll; typedef long double ld; typedef unsigned long long ull; using namespace std; const ll mod=1e9+7; inline void io(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } void solve(){ ll h,w;cin>>h>>w; char arr[h][w]; for(int i=0;i<h;i++)for(int j=0;j<w;j++)cin>>arr[i][j]; ll hor[h][w]; ll ver[h][w]; for(int i=0;i<h;i++){ if(arr[i][w-1]=='O')hor[i][w-1]=1; else hor[i][w-1]=0; for(int j=w-2;j>=0;j--){ hor[i][j]=hor[i][j+1]; if(arr[i][j]=='O')hor[i][j]++; } } for(int j=0;j<w;j++){ if(arr[h-1][j]=='I')ver[h-1][j]=1; else ver[h-1][j]=0; for(int i=h-2;i>=0;i--){ ver[i][j]=ver[i+1][j]; if(arr[i][j]=='I')ver[i][j]++; } } ll ans=0; for(int i=0;i<h-1;i++){ for(int j=0;j<w-1;j++){ if(arr[i][j]!='J')continue; ans+=hor[i][j+1]*ver[i+1][j]; } } cout<<ans<<endl; } int main(){ io(); solve(); //int t;cin>>t;for(int i=0;i<t;i++)solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...