Submission #478917

#TimeUsernameProblemLanguageResultExecution timeMemory
478917IvnFBitaro the Brave (JOI19_ho_t1)C++14
100 / 100
450 ms153880 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define ull unsigned long long #define fi first #define se second #define ld long double ll n, m; char arr[3005][3005]; ll pi[3005][3005], po[3005][3005]; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m; for(int i=1;i<=n;++i){ for(int j=1;j<=m;++j){ cin >> arr[i][j]; } } for(int j=1;j<=m;++j){ for(int i=n;i>=1;--i){ pi[i][j]=pi[i+1][j]; pi[i][j]+=(arr[i][j]=='I'); } } for(int i=1;i<=n;++i){ for(int j=m;j>=1;--j){ po[i][j]=po[i][j+1]; po[i][j]+=(arr[i][j]=='O'); } } ll ans=0; for(int i=1;i<=n;++i){ for(int j=1;j<=m;++j){ if(arr[i][j]=='J'){ ans+=pi[i+1][j]*po[i][j+1]; } } } cout << ans << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...