Submission #971114

#TimeUsernameProblemLanguageResultExecution timeMemory
971114Roumak77Bitaro the Brave (JOI19_ho_t1)C++17
100 / 100
94 ms160140 KiB
#pragma GCC optimize ("O3") #pragma GCC optimize ("unroll-loops") #pragma GCC optimize("-Ofast") #include <bits/stdc++.h> #include <algorithm> #include <iostream> #include <vector> #include <limits> #include <cmath> #include <stack> #include <queue> #include <map> #include <math.h> using namespace std; using ll = long long; void solve(){ ll h, w; cin >> h >> w; vector<string> grid(h); for(ll i = 0; i < h; i++){ cin >> grid[i]; } ll total = 0; vector<vector<pair<ll, ll>>> grid_val(h + 1, vector<pair<ll, ll>>(w + 1, pair<ll,ll>{0, 0})); // Orbs, Ignots for(ll i = h - 1; i >= 0; i--){ for(ll j = w - 1; j >= 0; j--){ grid_val[i][j].first = grid_val[i][j + 1].first; grid_val[i][j].second = grid_val[i + 1][j].second; if(grid[i][j] == 'O'){ grid_val[i][j].first += 1; }else if(grid[i][j] == 'I'){ grid_val[i][j].second += 1; }else{ total += grid_val[i][j].first * grid_val[i][j].second; } } } cout << total << endl; } int main(){ ios_base::sync_with_stdio(false); cout.tie(0); cin.tie(0); ll t = 1; while(t--){ solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...