QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#726369#9574. StripsXiaoMo247WA 0ms3556kbC++201.5kb2024-11-08 23:22:562024-11-08 23:22:57

Judging History

你现在查看的是最新测评结果

  • [2024-11-08 23:22:57]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3556kb
  • [2024-11-08 23:22:56]
  • 提交

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;
    ll move_cnt = max(0ll, tmp.back() + k - 1 - r + 1);
    for(auto it : tmp){
        if(it - move_cnt <= l) return 0;
        ans.push_back(it - move_cnt);
    }
    
    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;
        }
    }
    cout << ans.size() << "\n";
    for(auto it : ans){
        cout << it << " ";
    }
    cout << "\n";
}
int main(){
    // freopen("K.in", "r", stdin);
    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: 0
Wrong Answer
time: 0ms
memory: 3556kb

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 6 10 14 
-1
2
1 5 
-1

result:

wrong answer There is no stripe covering red cell 9 (test case 1)