Submission #747770

#TimeUsernameProblemLanguageResultExecution timeMemory
747770adrilenBitaro the Brave (JOI19_ho_t1)C++17
100 / 100
365 ms220384 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long; typedef pair<int, int> pii; constexpr int maxh = 3e3; ll typ[maxh][maxh] = { 0 }, orbs[maxh][maxh] = { 0 }, ingots[maxh][maxh] = { 0 }; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int h, w; cin >> h >> w; string s; for (int y = 0; y < h; y++) { cin >> s; for (int x = 0; x < w; x++) typ[x][y] = (s[x] == 'J' ? 1 : (s[x] == 'O' ? 2 : 3)); } // Calculate orbs for (int y = 0; y < h; y++) { orbs[w - 1][y] = (typ[w - 1][y] == 2); for (int x = w - 2; x >= 0; x--) orbs[x][y] = orbs[x + 1][y] + (typ[x][y] == 2); } // Calculate ingots for (int x = 0; x < w; x++) { ingots[x][h - 1] = (typ[x][h - 1] == 3); for (int y = h - 2; y >= 0; y--) ingots[x][y] = ingots[x][y + 1] + (typ[x][y] == 3); } ll output = 0; for (int x = 0; x < w; x++) { for (int y = 0; y < h; y++) { if (typ[x][y] == 1) output += ingots[x][y] * orbs[x][y]; } } cout << output << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...