QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#737002#9574. StripsWedonotLikeStudying#WA 0ms3648kbC++231.2kb2024-11-12 14:13:272024-11-12 14:13:34

Judging History

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

  • [2024-11-12 14:13:34]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3648kb
  • [2024-11-12 14:13:27]
  • 提交

answer

#include<bits/stdc++.h>
#define up(a,b,c)for(int a=b;a<=c;++a)
#define dn(a,b,c)for(int a=b;a>=c;--a)
const int N=11e4;
using namespace std;
int T,n,m,k,w,a[N],b[N],cc;
bool ok;
vector<int>ccf;
int main()
{
    cin>>T;
    while(T--)
    {
        cin>>n>>m>>k>>w;
        up(i,1,n)cin>>a[i];
        up(i,1,m)cin>>b[i];
        b[0]=0,b[m+1]=w+1,cc=0,ccf.clear();
        sort(a+1,a+n+1),sort(b+1,b+m+1);
        int l=1,r=0;ok=1;
        up(i,0,m)
        {
            while(r<n&&a[r+1]<b[i+1])++r;
            if(l>r)continue;
            int L=b[i]-k+1,g=0;
            up(j,l,r)
                if(a[j]>=L+k)
                {
                    if(j>l)g=min(L+k-1-a[j-1],g);
                    g+=a[j]-(L+k),++cc;
                    if(j>l)ccf.push_back(L-g);
                    L=a[j];
                }
            g=min(L+k-1-a[r],g),ccf.push_back(L-g);
            if(L+k-1-g>=b[i+1])
            {
                ok=0;break;
            }
            l=r+1;
        }
        if(!ok)cout<<"-1\n";
        else 
        {
            cout<<cc<<'\n';
            for(int v:ccf)cout<<v<<' ';
            cout<<'\n';
        }
    }
    return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3648kb

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

result:

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