Submission #208395

#TimeUsernameProblemLanguageResultExecution timeMemory
208395YJUBitaro the Brave (JOI19_ho_t1)C++14
100 / 100
165 ms184052 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll,ll> pll; typedef long double ld; const ll MOD=1e9+7; const ll N=5e3+5; const ld pi=3.14159265359; #define REP(i,n) for(ll i=0;i<n;i++) #define REP1(i,n) for(ll i=1;i<=n;i++) #define pb push_back #define mp make_pair #define X first #define Y second #define setp setprecision #define lwb lower_bound #define SZ(a) (ll)a.size() ll n,m,O[N][N],I[N][N],ans; string s[N]; int main(){ ios_base::sync_with_stdio(0);cin.tie(0); cin>>n>>m; REP1(i,n)cin>>s[i]; REP1(i,n)REP(j,m){ O[i][j]=(j==0?0:O[i][j-1])+(s[i][j]=='O'); I[i][j]=I[i-1][j]+(s[i][j]=='I'); } REP1(i,n){ REP(j,m){ if(s[i][j]=='J'){ ans+=(I[n][j]-I[i][j])*(O[i][m-1]-O[i][j]); } } } cout<<ans<<"\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...