QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#658541#7015. Rikka with IlluminationsMu_SilkWA 18ms3532kbC++202.3kb2024-10-19 17:00:442024-10-19 17:00:45

Judging History

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

  • [2024-10-19 17:00:45]
  • 评测
  • 测评结果:WA
  • 用时:18ms
  • 内存:3532kb
  • [2024-10-19 17:00:44]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

struct vec{
    ll x,y;
    vec operator-(vec a){
        return {x-a.x,y-a.y};
    }
    ll dist2(){
        return x*x+y*y;
    }
};

ll cross(vec a,vec b){
    return a.x*b.y-a.y*b.x;
}

int add(int a,int b,int p){
    int t=a+b;
    return t>=p?t-p:t;
}

int sub(int a,int b,int p){
    int t=a-b;
    return t<0?t+p:t;
}

const int N=1010;
vec a[N],b[N];
int nxta[N],use[N];

void solve(){
    int n,m;cin>>n>>m;
    auto pre=[&](int x){
        return x==0?n-1:x-1;
    };
    auto nxt=[&](int x){
        return x==n-1?0:x+1;
    };
    for(int i=0;i<n;i++){
        cin>>a[i].x>>a[i].y;
        nxta[i]=use[i]=0;
    }
    for(int i=0;i<m;i++){
        cin>>b[i].x>>b[i].y;
        int minp=0;
        for(int j=0;j<n;j++){
            if((b[i]-a[j]).dist2()<(b[i]-a[minp]).dist2())minp=i;
        }
        int l=minp,r=minp;
        while(cross(a[pre(l)]-b[i],a[l]-b[i])<0)l=pre(l);
        while(cross(a[nxt(r)]-b[i],a[r]-b[i])>0)r=nxt(r);

        if(sub(r,l,n)>nxta[l]){
            nxta[l]=sub(r,l,n);
            use[l]=i;
        }
    }
    const int inf=1e9;
    int ansv=inf,ansp=-1;
    for(int i=0;i<n;i++){
        int ans=0;
        int l=0,r=0;

        while(1){
            ans++;
            int p=0;
            for(int j=l;j<=r;j++){
                int d=nxta[add(j,i,n)];
                if(j+d>p)p=j+d;
            }
            if(p>=n)break;
            if(p<r+1){
                ans=inf;
                break;
            }
            l=r+1,r=p;
        }
        if(ansv>ans){
            ansv=ans;
            ansp=i;
        }
    }
    if(ansv==inf){
        cout<<"-1\n";
        return;
    }
    cout<<ansv<<"\n";

    vector<int> vv;
    int l=0,r=0;
    while(1){
        int p=0;
        int usep=0;
        for(int j=l;j<=r;j++){
            int d=nxta[add(j,ansp,n)];
            if(j+d>p){
                p=j+d;
                usep=use[add(j,ansp,n)];
            }
        }
        vv.push_back(usep);
        if(p>=n)break;
        l=r+1,r=p;
    }
    for(int i=0;i<ansv;i++){
        cout<<vv[i]+1<<" \n"[i==ansv-1];
    }
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n=1;
    cin>>n;
    while(n--)solve();
    return 0;
}

詳細信息

Test #1:

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

input:

1
3 3
0 0
1 0
0 1
-1 -1
3 -1
-1 3

output:

2
2 1

result:

ok 1 cases.

Test #2:

score: -100
Wrong Answer
time: 18ms
memory: 3532kb

input:

100
13 17
-976 -766
-628 -956
462 -987
967 -997
981 -123
919 115
847 336
692 789
350 908
-558 996
-843 944
-944 400
-974 -476
-41876798 919231678
-375313647 26070145
-288061228 527643156
-93144407 730297
93699145 -260606010
-393321698 -339399089
644245933 784344503
-731740672 525632046
-32141854 114...

output:

2
5 1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
5
11 22 38 46 49
-1
-1
-1
-1
-1
-1
4
38 40 81 87
-1
-1
5
10 44 61 79 91
-1
-1
4
9 58 92 36
4
16 57 125 7
-1
5
66 91 93 110 162
4
8 101 147 9
-1
-1
6
50 99 98 122 189 197
-1
-1
-1
-1
-1
-1
-1
-1
-1
4
85 133 176 260
4
62 154 23...

result:

wrong answer In case 6, there is solution but output no.