Submission #1278627

#TimeUsernameProblemLanguageResultExecution timeMemory
1278627IBoryBitaro the Brave (JOI19_ho_t1)C++20
100 / 100
253 ms79792 KiB
#include <bits/stdc++.h> typedef long long ll; using namespace std; const int MAX = 3003; char C[MAX][MAX]; int Ocnt[MAX][MAX], Icnt[MAX][MAX]; int main() { ios::sync_with_stdio(0); cin.tie(0); int N, M; cin >> N >> M; for (int i = 1; i <= N; ++i) for (int j = 1; j <= M; ++j) cin >> C[i][j]; for (int i = 1; i <= N; ++i) for (int j = M; j > 0; --j) Ocnt[i][j] = Ocnt[i][j + 1] + (C[i][j] == 'O'); for (int j = 1; j <= M; ++j) for (int i = N; i > 0; --i) Icnt[i][j] = Icnt[i + 1][j] + (C[i][j] == 'I'); ll ans = 0; for (int i = 1; i <= N; ++i) for (int j = 1; j <= M; ++j) { if (C[i][j] == 'J') ans += Ocnt[i][j] * Icnt[i][j]; } cout << ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...