Submission #818714

#TimeUsernameProblemLanguageResultExecution timeMemory
818714vjudge1Bitaro the Brave (JOI19_ho_t1)C++17
100 / 100
263 ms200876 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long const ll MX = 3e3 + 5; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ll h, w; cin >> h >> w; vector<vector<ll>> Ohere(MX, vector<ll>(MX, 0)); vector<vector<ll>> Ihere(MX, vector<ll>(MX, 0)); char tmp; queue<pair<ll, ll>> q; for (int i = 1; i <= h; i++) { for (int j = 1; j <= w; j++) { cin >> tmp; if (tmp == 'J') { q.push({i, j}); } else if (tmp == 'O') { Ohere[i][j]++; } else { Ihere[i][j]++; } Ohere[i][j] += Ohere[i][j - 1]; Ihere[i][j] += Ihere[i - 1][j]; } } ll ans = 0; while (!q.empty()) { ll x = q.front().first; ll y = q.front().second; q.pop(); ll Othere = Ohere[x][w] - Ohere[x][y - 1]; ll Ithere = Ihere[h][y] - Ihere[x - 1][y]; ans += Othere * Ithere; } // for (int i = 1; i <= h; i++) // { // for (int j = 1; j <= w; j++) // { // cout << Ohere[i][j]; // } // cout << "\n"; // } cout << ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...