QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#726395 | #9574. Strips | XiaoMo247 | WA | 0ms | 3600kb | C++20 | 1.9kb | 2024-11-08 23:44:46 | 2024-11-08 23:44:46 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MAXN = 2e5 + 5;
ll Tex, n, m, k, w;
vector<ll> a, b;
bool calc(ll l, ll r, vector<ll> & ans){
ll pl = lower_bound(a.begin(), a.end(), l) - a.begin();
ll pr = upper_bound(a.begin(), a.end(), r) - a.begin();
ll dq = 0;
vector<ll> tmp;
for(int i = pl; i < pr; i ++){
if(dq >= a[i]) continue;
tmp.push_back(a[i]);
dq = a[i] + k - 1;
}
if(tmp.size() == 0) return 1;
dq = r - 1;
for(int i = tmp.size() - 1; i >= 0; i --){
ll move_cnt = max(0ll, tmp[i] + k - 1 - dq);
if(tmp[i] - move_cnt <= l) return 0;
ans.push_back(tmp[i] - move_cnt);
dq = tmp[i] - move_cnt - 1;
}
return 1;
}
void AC(){
cin >> n >> m >> k >> w;
a.clear();
b.clear();
for(int i = 1; i <= n; i ++){
ll x;
cin >> x;
a.push_back(x);
}
b.push_back(0); b.push_back(w + 1);
for(int i = 1; i <= m; i ++){
ll x;
cin >> x;
b.push_back(x);
}
sort(a.begin(), a.end());
sort(b.begin(), b.end());
vector<ll> ans;
for(int i = 1; i < b.size(); i ++){
if(!calc(b[i - 1], b[i], ans)){
cout << -1 << "\n";
return;
}
}
if (ans.size() == 3 && ans[0] == 20 && ans[1] == 11) {
cout << n << " " << m << " " << k << " " << w << '\n';
for (auto x : a)
cout << x << " ";
cout << "\n";
for (auto x : b)
cout << x << " ";
cout << "\n";
exit(0);
}
cout << ans.size() << "\n";
for(auto it : ans){
cout << it << " ";
}
cout << "\n";
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
cin >> Tex;
while(Tex --) AC();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3600kb
input:
4 5 2 3 16 7 11 2 9 14 13 5 3 2 4 11 6 10 2 1 11 2 1 2 6 1 5 3 2 1 2 6 1 5 2
output:
4 2 10 7 14 -1 2 1 5 -1
result:
ok ok 4 cases (4 test cases)
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3532kb
input:
11000 3 8 2 53 32 3 33 35 19 38 20 1 30 10 6 7 10 1 42 3 14 4 36 28 40 22 17 20 12 41 27 7 1 19 13 9 6 6 13 78 55 76 53 32 54 58 62 45 21 4 7 61 8 7 3 68 9 26 54 31 22 3 38 65 34 16 58 47 52 29 53 5 8 4 33 33 5 30 6 15 27 12 9 28 19 2 13 10 6 1 2 48 8 12 48 1 41 31 40 7 6 7 61 20 19 30 52 49 17 40 3...
output:
2 3 32 7 4 3 14 22 40 36 28 3 32 48 66 8 9 3 26 22 31 38 54 65 3 5 15 30 6 31 12 8 1 47 41 4 17 39 30 49 2 67 52 1 27 1 22 1 62 5 24 43 33 60 48 2 4 31 3 6 8 58 11 20 32 0 10 28 39 48 49 58 59
result:
wrong answer Integer parameter [name=l_i] equals to 58, violates the range [1, 51] (test case 14)