Submission #1279564

#TimeUsernameProblemLanguageResultExecution timeMemory
1279564peanutBitaro the Brave (JOI19_ho_t1)C++20
100 / 100
525 ms75280 KiB
#include <bits/stdc++.h> using namespace std; #define all(x) (x).begin(), (x).end() const int maxn = 3005; char grid[maxn][maxn]; int main() { ios::sync_with_stdio(false); cin.tie(0); int h, w; cin >> h >> w; vector<pair<int, int>> jewels; vector<vector<int>> orbs(h+1); vector<vector<int>> ingots(w+1); for (int i = 1; i <= h; ++i) { for (int j = 1; j <= w; ++j) { cin >> grid[i][j]; if (grid[i][j] == 'J') jewels.emplace_back(i, j); if (grid[i][j] == 'O') orbs[i].push_back(j); if (grid[i][j] == 'I') ingots[j].push_back(i); } } long long cnt = 0; for (auto j : jewels) { int ocnt = orbs[j.first].size() - (upper_bound(all(orbs[j.first]), j.second) - orbs[j.first].begin()); int icnt = ingots[j.second].size() - (upper_bound(all(ingots[j.second]), j.first) - ingots[j.second].begin()); cnt += ocnt * icnt; } cout << cnt; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...