Submission #1027176

#TimeUsernameProblemLanguageResultExecution timeMemory
1027176vjudge1Bitaro the Brave (JOI19_ho_t1)C++17
100 / 100
254 ms150624 KiB
#include <bits/stdc++.h> #define ll long long #define nikah ios_base::sync_with_stdio(0); cin.tie(0); const ll maxn = 3e3+7; using namespace std; ll t,n,m; char a[maxn][maxn]; ll pref1[maxn][maxn], pref2[maxn][maxn]; int main () { nikah cin>>n>>m; for (ll i=1; i<=n; i++) { for (ll j=1; j<=m; j++) { cin>>a[i][j]; } } ll ans = 0; for (ll i=1; i<=n; i++) { for (ll j=m; j>=1; j--) { if (a[i][j] == 'O') pref1[i][j]++; pref1[i][j] += pref1[i][j+1]; } } for (ll j=1; j<=m; j++) { for (ll i=n; i>=1; i--) { if (a[i][j] == 'I') pref2[i][j]++; pref2[i][j] += pref2[i+1][j]; } } for (ll i=1; i<=n; i++) { for (ll j=1; j<=m; j++) { if (a[i][j] == 'J') { ans += (pref1[i][j] * pref2[i][j]); } } } cout<<ans<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...