Submission #924056

#TimeUsernameProblemLanguageResultExecution timeMemory
924056an22inkleExamination (JOI19_examination)C++17
0 / 100
434 ms1048576 KiB
#include <bits/stdc++.h> using ll = long long; using ull = unsigned long long; using pair = std::array<int, 2>; using pairll = std::array<ll, 2>; using tri = std::array<int, 3>; using trill = std::array<ll, 3>; constexpr long long MOD = 998244353; constexpr int SIZE = 1e5 + 10; int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int N, Q; std::cin >> N >> Q; std::function<bool(pair,pair)> cmp = [](pair a, pair b) { // large to small if (a[0] != b[0]) { return a[0] > b[0]; } else { return a[1] > b[1]; } }; std::set<pair, decltype(cmp)> points(cmp); std::vector<std::vector<int>> v(SIZE, std::vector<int>(SIZE)); std::vector<int> col, row; for (int i = 0; i < N; i++) { int a, b; std::cin >> a >> b; pair score = {a, b}; points.insert(score); v[a][b]++; row.push_back(a); col.push_back(b); } for (auto it = std::next(points.begin(), 1); it != points.end(); it++) { pair prevpoint = *std::next(it, -1); pair point = *it; v[point[0]][point[1]] += v[prevpoint[0]][prevpoint[1]]; } while (Q--) { int x, y ,z; std::cin >> x >> y >> z; auto nrow = std::upper_bound(row.begin(), row.end(), x, [](int val, int el) {return el >= val;}); if (nrow == row.end()) { std::cout << "0aa\n"; continue; } auto ncol = std::upper_bound(col.begin(), col.end(), *nrow, [](int val, int el) {return el >= val;}); if (ncol == col.end()) { std::cout << "0aa\n"; continue; } // std::cout << *nrow << ' ' << *ncol << '\n'; std::cout << v[*nrow][*ncol] << '\n'; } return 0; for (int i = 0; i < SIZE; i++) { for (int j = 0; j < SIZE; j++) { std::cout << v[i][j] << ' '; } std::cout << "\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...