QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#821083#9574. StripsredbluetulipRE 21ms3788kbC++172.9kb2024-12-19 12:53:442024-12-19 12:53:44

Judging History

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

  • [2024-12-19 12:53:44]
  • 评测
  • 测评结果:RE
  • 用时:21ms
  • 内存:3788kb
  • [2024-12-19 12:53:44]
  • 提交

answer

#include<iostream>
#include<algorithm>
#include<cstring>
#include<vector>
using namespace std;
using pi = pair<int,int>;
const int N=2e2+100;
int T,n,m,k,w;
int ans_list[N];
int tmp_list[N];
pi node[N];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    cin>>T;
    while(T--)
    {
        cin>>n>>m>>k>>w;
        int tmp,cnt=0,idx=0;
        for(int i=1;i<=n;i++) cin>>tmp,node[++cnt]={tmp,1};
        for(int i=1;i<=m;i++) cin>>tmp,node[++cnt]={tmp,0};
        node[++cnt]={0,0},node[++cnt]={w+1,0};
        sort(node+1,node+cnt+1);
        int last=0,ft=0,l=1;
        bool ok=1;
        int ans=0;
        vector<int> vec;
        for(int i=2;i<=cnt;i++)
        {
            if(node[i].second==0){
                if(!ft) {
                    int len=vec.size()-1;
                    int ix=0;
                    int nt=node[i].first;
                    for(int j=len;j>=0;j--)
                    {
                        tmp_list[++ix]=min(vec[j],nt-k);
                        nt=tmp_list[ix];
                    }
                    for(int j=ix;j;j--) ans_list[++idx]=tmp_list[j];
                    last=node[i].first;
                    l=i;
                    ft=0;
                    vec.clear();
                    last=node[i].first;
                    continue;}
                else{
                    if(last+k>=node[i].first){
                        ok=0;
                        break;
                    }
                    else{
                        ans++;
                        int ix=0;
                        int nt=0;
                        tmp_list[++ix]=nt=min(ft,node[i].first-k);
                        int len=vec.size()-1;
                        for(int j=len;j>=0;j--)
                        {
                            tmp_list[++ix]=min(vec[j],nt-k);
                            nt=tmp_list[ix];
                        }
                        for(int j=ix;j;j--) ans_list[++idx]=tmp_list[j];
                        last=node[i].first;
                        l=i;
                        ft=0;
                        vec.clear();
                    }
                }

            }
            else{
                if(!ft) ft=node[i].first;
                if(node[i].first-ft+1==k){
                    ans++;
                    last=max(ft,last+k);
                    vec.push_back(ft);
                    ft=0;
                }
                else if(node[i].first-ft+1>k){
                    ans++;
                    last=max(ft,last+k);
                    vec.push_back(ft);
                    ft=node[i].first;
                }
            }
        }
        if(!ok) cout<<-1<<'\n';
        else {
            cout<<ans<<"\n";
            for(int i=1;i<=idx;i++) cout<<ans_list[i]<<' ';
            cout<<'\n';
            }
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

result:

ok ok 4 cases (4 test cases)

Test #2:

score: 0
Accepted
time: 21ms
memory: 3588kb

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
3 4 14 22 28 36 40 
3
32 48 66 
8
3 9 22 26 31 38 54 65 
3
5 15 30 
6
1 8 12 31 41 47 
4
17 30 39 49 
2
52 67 
1
27 
1
22 
1
62 
5
24 33 43 48 60 
2
4 31 
3
11 20 31 
3
3 16 33 
3
25 30 42 
3
3 17 60 
4
1 11 21 33 
2
54 66 
3
50 59 65 
3
50 62 78 
1
81 
4
2 11 16 23 
5
3 7 17 36 49 
2
1 45...

result:

ok ok 11000 cases (11000 test cases)

Test #3:

score: -100
Runtime Error

input:

2
62980 100000 9859 200000
132897 135912 27509 54599 183887 53114 127233 138596 120860 52471 83158 110644 114040 34102 100501 94779 188044 118947 57443 93009 179886 117863 142316 103026 133746 181956 88732 133751 178946 135462 99588 142382 116231 142902 98641 93039 34860 180746 34292 64655 31584 265...

output:


result: