Submission #1036699

#TimeUsernameProblemLanguageResultExecution timeMemory
1036699andrewpBitaro the Brave (JOI19_ho_t1)C++14
100 / 100
143 ms89532 KiB
//Dedicated to my love, ivaziva #include <bits/stdc++.h> using namespace std; using pii = pair<int, int>; using ll = int64_t; #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define dbg(x) cerr << #x << ": " << x << '\n'; int32_t main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cerr.tie(nullptr); int n, m; cin >> n >> m; vector<string> a(n); for (int i = 0; i < n; i++) cin >> a[i]; vector<vector<int> > ps1(n, vector<int>(m, 0)), ps2(n, vector<int>(m, 0)); for (int i = 0; i < n; i++) { ps1[i][m - 1] = (a[i].back() == 'O'); for (int j = m - 2; j >= 0; j--) { ps1[i][j] = ps1[i][j + 1] + (a[i][j] == 'O'); } } for (int j = 0; j < m; j++) { ps2[0][j] = (a[0][j] == 'J' ? ps1[0][j] : 0); for (int i = 1; i < n; i++) { ps2[i][j] = ps2[i - 1][j] + (a[i][j] == 'J' ? ps1[i][j] : 0); } } ll ans = 0; for (int i = 1; i < n; i++) { for (int j = 0; j < m; j++) { ans += (a[i][j] == 'I' ? ps2[i - 1][j] : 0); } } cout << ans << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...