QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#724939#9574. StripsTime_stopWA 55ms3520kbC++143.1kb2024-11-08 15:38:032024-11-08 15:38:04

Judging History

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

  • [2024-11-08 15:38:04]
  • 评测
  • 测评结果:WA
  • 用时:55ms
  • 内存:3520kb
  • [2024-11-08 15:38:03]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int M =2e5+5;
int  n,m;
struct s{
    long long x;
    bool flag;
};
s input[M];
bool cmp(s x,s y){
    return x.x<y.x;
}
long long k,rr;
int main(){
    int t;
    cin>>t;
    while(t--){
        cin>>n>>m>>k>>rr;
        int fl=0;
        for(int i=1;i<=n;i++){
        cin>>input[i].x;
        input[i].flag=0;    
        } 
        for(int i=n+1;i<=n+m;i++){
        cin>>input[i].x;
        input[i].flag=1;    
        }
        input[n+m+1].x=rr+1;
        input[n+m+1].flag=1;
        sort(input+1,input+n+m+2,cmp);
        vector<long long> sum;
        int l=0,r=0;
        for(int i=1;i<=n+m+1;i++){
            if(input[i].flag==1){
                    vector<long long> ans;
                    vector<long long> re;
                    r=i;
                    long long res=0;
                    int tot=0,pop=input[l].x;
                    for(int j=l+1;j<r;j++){
                        
                        
                        if(input[j].x>pop){
                            res+=(input[j].x-pop-1);
                            re.push_back(input[j].x-pop-1);
                            ans.push_back(input[j].x);
//                                cout<<"||:"<<res<<' '<<input[j].x<<" "<<input[j].x-pop-1<<endl;
                            pop=input[j].x+k-1;                            
                        
                            
                            
                            if(input[r].x<=pop){
                                int sn=pop-input[r].x+1;
                                if(sn>res){
                                    fl=1;
//                                    cout<<"#:"<<pop<<' '<<l<<' '<<r<<endl;
                                    break;
                                }
                                else{
                                    tot=sn;
                                    break;
                                }
                                
                                
                                
                            }

                            
                        }
                    }
                    
                    if(fl){
                        break;
                    }
                    long long ff=tot;
                    for(int k=ans.size()-1;k>=0;k--){
                    	
                    	if(ff>0)sum.push_back(ans[k]-tot);
                    	else sum.push_back(ans[k]);
//                        cout<<"ff:"<<ff<<endl;
                        
                    	ff-=re[k];
                        
                    }
                    
                    
                    l=i;
                    
                    
                
            }
        }
        
        if(fl){
            cout<<-1<<endl;
        }
        else{
            cout<<sum.size()<<endl;
            for(int i=0;i<sum.size();i++){
                cout<<sum[i]<<' ';
            }
            cout<<endl;
        }
        
        
        
    }
}

詳細信息

Test #1:

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

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: 55ms
memory: 3520kb

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
20 11 31 
3
3 16 33 
3
30 25 42 
3
3 17 60 
4
21 11 -2 33 
2
66 54 
3
50 59 65 
3
62 50 78 
1
81 
4
2 11 23 16 
5
3 7 36 17 49 
2
1 4...

result:

wrong answer Integer parameter [name=l_i] equals to -2, violates the range [1, 36] (test case 18)