Submission #754670

#TimeUsernameProblemLanguageResultExecution timeMemory
754670KN200711Bitaro the Brave (JOI19_ho_t1)C++14
100 / 100
338 ms88420 KiB
# include <bits/stdc++.h> # define ll long long using namespace std; char arr[3002][3002]; int O[3002][3002], I[3002][3002]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int N, M; cin>>N>>M; for(int i=1;i<=N;i++) { for(int k=1;k<=M;k++) { cin>>arr[i][k]; } } for(int i=1;i<=N;i++) { for(int k=M;k>=1;k--) { O[i][k] = O[i][k + 1]; if(arr[i][k] == 'O') O[i][k]++; } } for(int i=1;i<=M;i++) { for(int k=N;k>=1;k--) { I[k][i] = I[k+1][i]; if(arr[k][i] == 'I') I[k][i]++; } } ll ans = 0ll; for(int i=1;i<=N;i++) { for(int k=1;k<=M;k++) { if(arr[i][k] != 'J') continue; ans += 1ll * O[i][k] * 1ll * I[i][k]; // cout<<i<<" "<<k<<" "<<O[i][k]<<" "<<I[i][k]<<endl; } } cout<<ans<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...