Submission #1084063

#TimeUsernameProblemLanguageResultExecution timeMemory
1084063May27_thBitaro the Brave (JOI19_ho_t1)C++17
100 / 100
197 ms159316 KiB
#include<bits/stdc++.h> using namespace std; #define i64 long long #define int long long #define mp make_pair #define pb push_back #define all(x) (x).begin(), (x).end() void Solve(void) { int N, M; cin >> N >> M; vector<vector<char>> g(N + 2, vector<char> (M + 2)); vector<vector<int>> prefI(N + 2, vector<int> (M + 2, 0)); vector<vector<int>> prefO(N + 2, vector<int> (M + 2, 0)); for (int i = 1; i <= N; i ++) { for (int j = 1; j <= M; j ++) { cin >> g[i][j]; prefO[i][j] = prefO[i][j - 1] + (g[i][j] == 'O'); prefI[i][j] = prefI[i - 1][j] + (g[i][j] == 'I'); } } i64 ans = 0; for (int i = 1; i <= N; i ++) { for (int j = 1; j <= M; j ++) { if (g[i][j] == 'J') { ans = ans + 1LL * (prefO[i][M] - prefO[i][j]) * (prefI[N][j] - prefI[i][j]); } } } cout << ans << "\n"; } signed main() { ios_base::sync_with_stdio(false); cin.tie(0); int Tests = 1; // cin >> Tests; while (Tests --) { Solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...