Submission #99164

#TimeUsernameProblemLanguageResultExecution timeMemory
99164dongwon0427Bitaro the Brave (JOI19_ho_t1)C++11
100 / 100
271 ms86864 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pii; int n,m; char A[3005][3005]; pii B[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>>A[i][j]; for(int i=1;i<=n;i++) { for(int j=m;j>=1;j--) { B[i][j].first = B[i][j+1].first + (A[i][j] == 'O'); } } for(int i=n;i>=1;i--) { for(int j=1;j<=m;j++) { B[i][j].second = B[i+1][j].second + (A[i][j] == 'I'); } } ll ans = 0; for(int i=1;i<=n;i++) { for(int j=1;j<=m;j++) { if(A[i][j] == 'J') { ans += B[i][j].first * B[i][j].second; } } } cout<<ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...