Submission #747503

#TimeUsernameProblemLanguageResultExecution timeMemory
747503tch1cherinBitaro the Brave (JOI19_ho_t1)C++17
100 / 100
167 ms89548 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N, M; cin >> N >> M; vector<string> S(N); for (auto &v : S) { cin >> v; } vector row(N, vector<int>(M + 1)), col(M, vector<int>(N + 1)); for (int i = 0; i < N; i++) { for (int j = 0; j < M; j++) { row[i][j + 1] = row[i][j] + int(S[i][j] == 'O'); } } for (int i = 0; i < M; i++) { for (int j = 0; j < N; j++) { col[i][j + 1] = col[i][j] + int(S[j][i] == 'I'); } } long long ans = 0; for (int i = 0; i < N; i++) { for (int j = 0; j < M; j++) { if (S[i][j] == 'J') { ans += (row[i][M] - row[i][j]) * (col[j][N] - col[j][i]); } } } cout << ans << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...