Submission #1207925

#TimeUsernameProblemLanguageResultExecution timeMemory
1207925onbertTower (JOI24_tower)C++20
0 / 100
17 ms1352 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int maxn = 2e5 + 5, INF = 1e15; int n, q, d, a, b; vector<pair<int,int>> block, space; vector<int> qry; int belong(int i) { int id = lower_bound(block.begin(), block.end(), make_pair(i+1, -INF)) - block.begin() - 1; if (id >= 0 && i <= block[id].second) return id; else return -1; } signed main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n >> q >> d >> a >> b; n++; block.resize(n); block[0] = {-(d-1), -1}; for (int i=1;i<n;i++) cin >> block[i].first >> block[i].second; vector<pair<int,int>> vec; for (int i=0;i<n;i++) { auto [l, r] = block[i]; if (vec.size()) { if (r <= vec.back().second) continue; else if (l - 1 <= vec.back().second) { l = vec.back().first; vec.pop_back(); } } int id = belong(r+1 - d); if (id != -1) { if (id == i) r = INF; else r = block[id].second + d; } vec.push_back({l, r}); // cout << i << " " << l << " " << r << endl; } block = vec, n = vec.size(); // for (auto [l, r]:vec) cout << l << " " << r << endl; while (q--) { int x; cin >> x; // cout << belong(x) << endl; if (belong(x) == -1) cout << x << "\n"; else cout << "-1\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...