QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#721162#9574. Stripstablemoon#WA 21ms7764kbC++142.3kb2024-11-07 15:26:362024-11-07 15:26:36

Judging History

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

  • [2024-11-07 15:26:36]
  • 评测
  • 测评结果:WA
  • 用时:21ms
  • 内存:7764kb
  • [2024-11-07 15:26:36]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int M=2000005;
struct node{
    int id,w;
}t[M];
struct node2{
    int l,r;
};
bool cmp(node x,node y){
    return x.w<y.w;
}
string s;
int a[M],b[M],k,n,m,w;
vector<int>anss;
vector<node2>ans2;
int ans;
bool flag;
void rep(int l,int r){
    if(r-l==1) return ;
    int fl=l+1;
    for(int i=l+1;i<=r-1;i++)
    {
        while(i+1<=r-1&&t[fl].w+k>=t[i+1].w) i++;
        ans2.push_back({t[fl].w,t[fl].w+k});
        ans++;
        if(i+1==r) break;
        fl=i+1;
    }
    if(t[fl].w+k<t[r].w)
    {
        for(int i=0;i<ans2.size();i++) anss.push_back(ans2[i].l);
        ans2.clear();
        return ;
    }
    else
    {
        int len=ans2.size(),dlt=ans2[len-1].r-t[r].w+1;
        ans2[len-1].r-=dlt;
        ans2[len-1].l-=dlt;
        for(int i=len-1;i>=1;i--)
        {
            if(ans2[i].l<=ans2[i-1].r) dlt=ans2[i-1].r-ans2[i].l+1,ans2[i-1].l-=dlt,ans2[i-1].r-=dlt;
            else
            {
                for(int j=0;j<ans2.size();j++) anss.push_back(ans2[j].l);
                ans2.clear();
                return ;
            }
        }
        // cout<<ans2[0].l<<" ";
        if(ans2[0].l<=t[l].w)
        {
            flag=false;
            ans2.clear();
            return ;
        }
        return ;
    }
    return ;
}
void solve(){
    flag=true;
    anss.clear();
    int tot=0;
    ans=0;
    cin>>n>>m>>k>>w;
    k--;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        t[++tot].id=0;
        t[tot].w=a[i];
    }
    for(int i=1;i<=m;i++)
    {
        cin>>b[i];
        t[++tot].id=1;
        t[tot].w=b[i];
    }
    t[++tot].id=1,t[tot].w=0,t[++tot].id=1,t[tot].w=w+1;
    sort(t+1,t+tot+1,cmp);
    int l=1;
    for(int i=2;i<=tot;i++)
    {
        if(t[i].id==1)
        {
            // cout<<l<<" "<<i<<" "<<flag<<"\n";
            rep(l,i),l=i;
        }
    }
    if(!flag)
    {
        cout<<"-1\n";
        return ;
    }
    cout<<ans<<"\n";
    for(int i=0;i<ans;i++)
    {
        cout<<anss[i]<<" ";
    }
    cout<<"\n";
    return ;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int T;
    cin>>T;
    while(T--)
    {
        solve();
    }
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 2ms
memory: 7688kb

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: -100
Wrong Answer
time: 21ms
memory: 7764kb

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

result:

wrong answer There is no stripe covering red cell 69 (test case 11)