QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#724796#9574. StripsTime_stopWA 0ms3640kbC++142.6kb2024-11-08 15:05:582024-11-08 15:05:58

Judging History

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

  • [2024-11-08 15:05:58]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3640kb
  • [2024-11-08 15:05:58]
  • 提交

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;
                    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;
                            ans.push_back(input[j].x);
                            pop=input[j].x+k-1;                            
                            
                            
                            
                            if(input[r].x-input[j].x<k){
                                int sn=input[r].x-input[j].x;
                                if(k-sn>res){
                                    fl=1;
                                    break;
                                }
                                else{
                                    tot=k-sn;
                                    break;
                                }
                                
                                
                                
                            }

                            
                        }
                    }
                    
                    if(fl){
                        break;
                    }
                    
                    for(int k=0;k<ans.size();k++){
                        sum.push_back(ans[k]-tot);
                    }
                    
                    
                    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: 0
Wrong Answer
time: 0ms
memory: 3640kb

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)