Submission #529128

#TimeUsernameProblemLanguageResultExecution timeMemory
529128GurbanBitaro the Brave (JOI19_ho_t1)C++17
100 / 100
186 ms88528 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; const int maxn=3e3+5; int n,m; char c[maxn][maxn]; int dp[2][maxn][maxn]; int main(){ ios::sync_with_stdio(false); cin.tie(0); cin >> n >> m; for(int i = 1;i <= n;i++){ for(int j = 1;j <= m;j++){ cin >> c[i][j]; dp[0][i][j] = dp[0][i - 1][j] + (c[i][j] == 'I'); dp[1][i][j] = dp[1][i][j - 1] + (c[i][j] == 'O'); } } ll ans = 0; for(int i = 1;i <= n;i++){ for(int j = 1;j <= m;j++){ if(c[i][j] != 'J') continue; // cout<<i<<' '<<j<<' '<<dp[0][n][j]<<' '<<dp[0][i][j]<<' '<<dp[1][i][m]<<' '<<dp[1][i][j]<<'\n'; ans += (dp[0][n][j] - dp[0][i][j]) * (dp[1][i][m] - dp[1][i][j]); } } cout<<ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...