Submission #763661

#TimeUsernameProblemLanguageResultExecution timeMemory
763661BlagojBitaro the Brave (JOI19_ho_t1)C++17
100 / 100
221 ms89392 KiB
#include <bits/stdc++.h> #pragma GCC optimize("Ofast,unroll-loops") using namespace std; #define endl '\n' #define ll long long #define all(x) x.begin(), x.end() int col[3002][3002], row[3002][3002]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, m; cin >> n >> m; vector<string> v(n); for (int i = 0; i < n; i++) cin >> v[i]; for (int i = 0; i < n; i++) { for (int j = m - 1; j >= 0; j--) { row[i][j] = row[i][j + 1]; row[i][j] += (v[i][j] == 'O'); } } for (int j = 0; j < m; j++) { for (int i = n - 1; i >= 0; i--) { col[i][j] += col[i + 1][j]; col[i][j] += (v[i][j] == 'I'); } } ll ans = 0; for (int i = 0; i < n - 1; i++) { for (int j = 0; j < m - 1; j++) { if (v[i][j] == 'J') ans += row[i][j + 1] * col[i + 1][j]; } } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...