Submission #305453

#TimeUsernameProblemLanguageResultExecution timeMemory
305453vipghn2003Bitaro the Brave (JOI19_ho_t1)C++14
100 / 100
378 ms159100 KiB
#include<bits/stdc++.h> using namespace std; const int N=3005; int n,m,sRow[N][N][2],sCol[N][N][2]; char a[N][N]; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cin>>n>>m; for(int i=1;i<=n;i++) { for(int j=1;j<=m;j++) { cin>>a[i][j]; for(int k=0;k<2;k++) { sRow[i][j][k]=sRow[i][j-1][k]; sCol[i][j][k]=sCol[i-1][j][k]; } if(a[i][j]=='O') sRow[i][j][0]++,sCol[i][j][0]++; if(a[i][j]=='I') sRow[i][j][1]++,sCol[i][j][1]++; } } long long res=0; for(int i=1;i<=n;i++) { for(int j=1;j<=m;j++) { if(a[i][j]!='J') continue; int numO=sRow[i][m][0]-sRow[i][j][0]; int numI=sCol[n][j][1]-sCol[i][j][1]; res+=1ll*numI*numO; } } cout<<res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...