QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#723082#9574. StripsSilverGodlyWA 30ms3576kbC++204.0kb2024-11-07 21:07:462024-11-07 21:07:50

Judging History

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

  • [2024-11-07 21:07:50]
  • 评测
  • 测评结果:WA
  • 用时:30ms
  • 内存:3576kb
  • [2024-11-07 21:07:46]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

#define int long long
#define endl '\n'
#define ll long long

signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin>>t;
    while(t--){
        int n,m,k,d;
        cin>>n>>m>>k>>d;
        m++;
        vector<int>arr(n);
        vector<int>brr(m);
        for(int i=0;i<=n-1;i++){
            cin>>arr[i];
        }
        for(int i=0;i<=m-2;i++){
            cin>>brr[i];
        }
        brr[m-1]=d+1;
        sort(arr.begin(),arr.end());
        sort(brr.begin(),brr.end());
        vector<int>ans;
        int flag=0;
        int z1=0,qi=0;
        vector<int>crr;
        function<void(int,int)>dfs = [&](int l,int r){
            if(r<l)return ;
            if(crr.size()==0)return ;
            crr.push_back(r+1);
            map<int,int>da;
            vector<int>trr;
            int len=crr.size();
            for(int i=0;i<=len-2;i++){
                if(crr[i]-k+1<=l){
                    int hou=l+k-1;
                    if(hou<crr[i+1]){
                        trr.push_back(hou);
                    }
                }
                else {
                    int l1=crr[i]-k+1,l2=crr[i+1]-1;
                    if(trr.size()==0){
                        trr.push_back(crr[i]);
                    }
                    else {
                        int w=lower_bound(trr.begin(),trr.end(),l1)-trr.begin();
                        if(w==0){
                            if(l1<=crr[0]){
                               trr.push_back(crr[i]);
                            }
                            else {
                                if(trr[w]+k<=l2){
                                    da[trr[w]+k]=trr[w];
                                    trr.push_back(trr[w]+k);
                                }
                            }
                        }
                        else {
                            trr.push_back(crr[i]);
                            da[crr[i]]=trr[w-1];
                        }
                    }
                }
            }
            if(trr.size()==0){
                flag=1;
            }
            else {
                int ten=trr.size();
                if(trr[ten-1]>=crr[len-2]){
                   int wei=trr[ten-1];
                   vector<int>pan;
                   while(1){
                       ans.push_back(wei);
                       pan.push_back(wei);
                       if(da[wei]!=0){
                          wei=da[wei];
                       }
                       else break;
                   }
                   sort(pan.begin(),pan.end());
                   int tag=0;
                   for(int i=0;i<=len-2;i++){
                       while(tag<=pan.size()-1){
                          int r1=pan[tag]-k+1,r2=pan[tag];
                          if(crr[i]>=r1&&crr[i]<=r2){
                            break;
                          }
                          else {
                            tag++;
                          }
                       }
                       if(tag>=pan.size()){
                          flag=1;
                          break;
                       }
                   }
                }
                else {
                    flag=1;
                }
            }
        };
        for(int i=0;i<=m-1;i++){
            int z2=brr[i];
            crr.clear();
            while(qi<=n-1){
                if(arr[qi]>=z2){
                    break;
                }
                else {
                    crr.push_back(arr[qi]);
                    qi++;
                }
            }
            dfs(z1+1,z2-1);
            z1=z2;
        }
        if(flag==1){
            cout<<-1<<endl;
        }
        else {
            sort(ans.begin(),ans.end());
            cout<<ans.size()<<endl;
            for(auto x:ans){
                cout<<x-k+1<<' ';
            }
            cout<<endl;
        }
    }
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3536kb

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
1 6 9 14 
-1
2
1 4 
-1

result:

ok ok 4 cases (4 test cases)

Test #2:

score: -100
Wrong Answer
time: 30ms
memory: 3576kb

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
2 32 
7
3 4 14 22 28 36 40 
3
22 46 64 
8
1 7 20 24 30 36 54 63 
3
3 14 30 
6
1 7 11 30 41 47 
4
14 27 34 47 
2
42 65 
1
27 
1
9 
1
62 
5
24 33 42 47 60 
2
3 31 
3
11 19 29 
3
2 15 33 
3
25 30 42 
3
2 17 59 
-1
2
53 65 
3
49 58 65 
3
43 60 78 
1
78 
4
1 11 15 21 
5
3 7 17 36 48 
2
1 44 
2
7 25 
1
...

result:

wrong answer Participant didn't find a solution but the jury found one. (test case 18)