Submission #831037

#TimeUsernameProblemLanguageResultExecution timeMemory
831037OAleksaBitaro the Brave (JOI19_ho_t1)C++14
100 / 100
238 ms88516 KiB
#include <bits/stdc++.h> #define f first #define s second using namespace std; #define int long long signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int tt = 1; //cin >> tt; while(tt--) { int n, m; cin >> n >> m; char a[n][m]; for(int i = 0;i < n;i++) for(int j = 0;j < m;j++) cin >> a[i][j]; vector<vector<int>> v(n, vector<int>(m)); for(int i = 0;i < n;i++) { int p = 0; for(int j = m - 1;j >= 0;j--) { p += (a[i][j] == 'O'); if(a[i][j] == 'J') v[i][j] = p; } } for(int i = 0;i < m;i++) { int p = 0; for(int j = n - 1;j >= 0;j--) { p += (a[j][i] == 'I'); if(a[j][i] == 'J') v[j][i] *= p; } } int ans = 0; for(int i = 0;i < n;i++) for(int j = 0;j < m;j++) ans += v[i][j]; cout << ans; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...