Submission #765534

#TimeUsernameProblemLanguageResultExecution timeMemory
765534NK_Bitaro the Brave (JOI19_ho_t1)C++17
100 / 100
82 ms80740 KiB
// Success consists of going from failure to failure without loss of enthusiasm #include <bits/stdc++.h> using namespace std; #define nl '\n' template<class T> using V = vector<T>; using str = string; using ll = long long; int main() { cin.tie(0)->sync_with_stdio(0); int N, M; cin >> N >> M; V<str> A(N); for(auto& x : A) cin >> x; V<V<int>> I(N, V<int>(M, 0)), O(N, V<int>(M, 0)); ll ans = 0; for(int i = N - 1; i >= 0; i--) for(int j = M - 1; j >= 0; j--) { I[i][j] = (A[i][j] == 'I'); if (i+1 < N) I[i][j] += I[i+1][j]; O[i][j] = (A[i][j] == 'O'); if (j+1 < M) O[i][j] += O[i][j+1]; if (A[i][j] == 'J') ans += O[i][j] * 1LL * I[i][j]; } cout << ans << nl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...