QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#444400 | #8648. Tower | bashkort# | 0 | 172ms | 14156kb | C++20 | 2.3kb | 2024-06-15 18:47:21 | 2024-06-15 18:47:22 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, q;
cin >> n >> q;
ll D, A, B;
cin >> D >> A >> B;
vector<pair<ll, ll>> s(n);
for (auto &[l, r] : s) {
cin >> l >> r;
}
n += 1;
s.push_back({3e18, 3e18});
vector<ll> X(q);
for (int i = 0; i < q; ++i) {
cin >> X[i];
}
set<pair<ll, ll>> t;
t.insert({0, 0});
auto add = [&](ll l, ll r) {
auto it = t.lower_bound({l + 1, -1});
if (it != t.begin() && prev(it)->second >= r) {
return;
}
ll nxr = r;
while (it != t.end()) {
if (it->first > nxr + 1) {
break;
}
nxr = it->second;
it = t.erase(it);
}
it = t.lower_bound({l + 1, -1});
if (it != t.begin()) {
ll nxl = l;
while (it != t.begin()) {
--it;
if (it->second + 1 < nxl) {
break;
}
nxl = it->first;
it = t.erase(it);
}
l = nxl;
}
t.emplace(l, nxr);
};
for (int i = 0; i < n; ++i) {
ll L = s[i].first;
ll P = (i == 0 ? 0 : s[i - 1].second + 1);
auto it = t.lower_bound(pair(P, -1));
ll mn = 3e18;
if (it != t.end()) {
mn = min(mn, it->first);
}
if (it != t.begin()) {
--it;
if (it->second >= P) {
mn = min(mn, P);
}
}
if (mn >= L) {
continue;
}
ll l = mn, r = L - 1;
add(l, r);
add(l + D, r + D);
}
for (int i = 0; i < q; ++i) {
ll x = X[i];
auto it = std::lower_bound(s.begin(), s.end(), pair<ll, ll>(x + 1, -1)) - s.begin();
if (it != 0 && s[it - 1].second >= x) {
cout << "-1\n";
} else {
auto f = t.lower_bound({x + 1, -1});
if (f != t.begin() && prev(f)->second >= x) {
cout << x << '\n';
} else {
cout << "-1\n";
}
}
}
return 0;
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 37ms
memory: 5120kb
input:
2000 200000 500 66309 387245 91 122 793 1029 1127 1131 1304 1611 2007 2039 2601 2701 2906 3052 3253 3263 3495 3609 4157 4225 4283 4283 4757 4766 4786 4847 4885 5086 5326 5342 5607 5750 5847 5877 6093 6230 6548 6793 7206 7308 7413 7419 7752 7780 8244 8410 8501 8515 9335 9447 9512 9514 9602 9906 10076...
output:
-1 -1 518454 -1 460739 -1 -1 516869 397951 277462 97062 -1 103083 46781 218958 500518 422729 231379 205830 468529 283073 528355 23490 -1 198511 287802 351204 357532 153033 -1 77262 90964 14867 -1 257627 517911 -1 -1 -1 363664 247441 -1 16410 289148 81378 13540 66595 -1 388036 177970 517361 -1 -1 -1 ...
result:
wrong answer 3rd lines differ - expected: '1545376776', found: '518454'
Subtask #2:
score: 0
Wrong Answer
Test #29:
score: 0
Wrong Answer
time: 2ms
memory: 3664kb
input:
1938 1960 999999 47694 9291 2883622 3085639 3674880 3745876 9982198101 9982517489 19960889157 19960925795 19962228551 19962276101 19964301694 19964730442 19964826417 19965369252 19965984922 19966442459 19968019821 19968213820 19968334967 19968392242 19968426638 19968840337 19969017519 19969109591 19...
output:
600068416509 449910545782 -1 -1 -1 249945231892 59944483446 -1 800037846701 79997408529 319895606463 59946012179 39957395086 499995615624 640062070774 790043447181 469950866293 459937041572 -1 710049962817 -1 -1 -1 129951143928 630060713146 -1 750024638948 -1 -1 600058146469 500006743612 24993696514...
result:
wrong answer 1st lines differ - expected: '2629532778036', found: '600068416509'
Subtask #3:
score: 0
Wrong Answer
Test #44:
score: 0
Wrong Answer
time: 172ms
memory: 14156kb
input:
198085 196577 999999 1 999999 562622 895604 1799586 1975565 2518299 2941986 4934097 5403130 5755102 5996130 6036200 6112534 6391882 6431514 6451793 6555786 6613625 6621089 7130933 7204522 7335426 7522555 7748545 7784568 8184979 8494887 9066856 9178094 9303615 9384897 9716200 9719420 11693951 1183563...
output:
27793636591 139076373265 -1 -1 164554928593 340203577240 767735640886 -1 808488370439 777661458222 428941062963 -1 756913262477 860152123456 -1 734774231229 724225013316 184932545705 418133621292 -1 890908770677 450977017227 806542610691 -1 898938307262 536837237896 805921470285 -1 588880769556 -1 4...
result:
wrong answer 143rd lines differ - expected: '638030562602', found: '-1'
Subtask #4:
score: 0
Skipped
Dependency #1:
0%