Submission #949346

#TimeUsernameProblemLanguageResultExecution timeMemory
949346tnknguyen_Bitaro the Brave (JOI19_ho_t1)C++14
100 / 100
179 ms160080 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define endl '\n' const int sz = 3005; char a[sz][sz]; int s[3][sz][sz]; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); //freopen("JOI19_ho_t1.inp","r",stdin); //freopen("JOI19_ho_t1.out","w",stdout); int n, m; cin>>n>>m; for(int i=1; i<=n; ++i){ for(int j=1; j<=m; ++j){ cin>>a[i][j]; s[0][i][j] = s[0][i][j-1] + (a[i][j] == 'O'); s[1][i][j] = s[1][i-1][j] + (a[i][j] == 'I'); } } int ans = 0; for(int i=1; i<=n; ++i){ for(int j=1; j<=m; ++j){ if(a[i][j] == 'J'){ int x = s[1][n][j] - s[1][i][j]; int y = s[0][i][m] - s[0][i][j]; ans += (x * y); } } } cout<<ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...