제출 #704039

#제출 시각아이디문제언어결과실행 시간메모리
7040391075508020060209tcBitaro the Brave (JOI19_ho_t1)C++14
100 / 100
273 ms159440 KiB
//#pragma GCC optimize("O3") #include<bits/stdc++.h> using namespace std; #define int long long #define X first #define Y second int n;int m; string gr[5010]; int pso[3010][3010]; int psi[3010][3010]; signed main(){ cin.tie(0); ios_base::sync_with_stdio(0); cin>>n>>m; for(int i=1;i<=n;i++){ cin>>gr[i]; gr[i]="*"+gr[i]; } for(int j=1;j<=m;j++){ for(int i=1;i<=n;i++){ psi[i][j]=psi[i-1][j]; if(gr[i][j]=='I'){ psi[i][j]++; } } } for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ pso[i][j]=pso[i][j-1]; if(gr[i][j]=='O'){ pso[i][j]++; } } } int ans=0; for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ if(gr[i][j]!='J'){continue;} ans+=(pso[i][m]-pso[i][j])*(psi[n][j]-psi[i][j]); } } cout<<ans<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...