Submission #913704

#TimeUsernameProblemLanguageResultExecution timeMemory
913704__newbie__Bitaro the Brave (JOI19_ho_t1)C++17
100 / 100
291 ms207736 KiB
#include <bits/stdc++.h> #define pb push_back #define int ll using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<vi> vii; typedef pair<int, int> pii; typedef vector<pii> vpii; const int N = 3e3 + 1; int a[N][N], b[N][N]; char gr[N][N]; signed main() { int h, w; cin >> h >> w; vpii J(N); for (int i = 1; i <= h; i++) { string s; cin >> s; s = "$" + s; for (int j = 1; j <= w; j++) { gr[i][j] = s[j]; if (s[j] == 'J') J.pb({i, j}); } } for (int i = h; i >= 1; i--) { for (int j = w; j >= 1; j--) { a[i][j] = a[i][j + 1] + (gr[i][j] == 'O'); b[i][j] = b[i + 1][j] + (gr[i][j] == 'I'); } } int ans = 0; for (auto [i, j] : J) { ans += a[i][j] * b[i][j]; } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...