QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#657601#7015. Rikka with IlluminationsexpectantWA 38ms34552kbC++142.5kb2024-10-19 15:03:312024-10-19 15:03:32

Judging History

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

  • [2024-10-19 15:03:32]
  • 评测
  • 测评结果:WA
  • 用时:38ms
  • 内存:34552kb
  • [2024-10-19 15:03:31]
  • 提交

answer

#include <bits/stdc++.h>
#define rep(i,j,k) for(int i=j;i<=(k);++i)
#define drp(i,j,k) for(int i=j;i>=(k);--i)
#define MAXN 1000005
typedef long long ll;
int task,n,m,l[MAXN],r[MAXN];
std::vector<int> vec[MAXN];
struct data{
    int l,r,id;
    inline bool operator < (const data &rhs)const{
        return l<rhs.l;
    }
}seq[MAXN],tmp[MAXN];
struct point{
    ll x,y;
    inline point operator + (const point &rhs)const{
        return (point){x+rhs.x,y+rhs.y};
    }
    inline point operator - (const point &rhs)const{
        return (point){x-rhs.x,y-rhs.y};
    }
}a[MAXN],b[MAXN];
inline ll cross(const point &lhs,const point &rhs){
    return lhs.x*rhs.y-lhs.y*rhs.x;
}
inline std::vector<int> solve(int x){
    int cnt=0,id=0,pos=1,st=tmp[x].l,cur=tmp[x].r;
    std::vector<int> ret;
    ret.push_back(seq[x].id);
    rep(i,x,m) tmp[++cnt]=seq[i];
    rep(i,1,x-1) tmp[++cnt]=seq[i],tmp[cnt].l+=n,tmp[cnt].r+=n;
    rep(i,st,st+n-1){
        while(pos<cnt&&tmp[pos+1].l==i){
            ++pos;
            if(tmp[pos].r>tmp[id].r) id=pos;
        }
        if(i==cur){
            if(tmp[id].r<=i) return std::vector<int>();
            ret.push_back(tmp[id].id),id=0;
        }
    }
    return ret;
}
inline void print(){
    int pos=0;
    rep(i,1,m) if(!vec[i].empty()&&(!pos||vec[i].size()<vec[pos].size())) pos=i;
    if(!pos) std::cout<<-1<<'\n';
    else{
        std::cout<<vec[pos].size()<<'\n';
        rep(i,0,(int)vec[pos].size()-1) std::cout<<vec[pos][i]<<" \n"[i==(int)vec[pos].size()-1];
    }
}
inline void init(){
    rep(i,1,m) std::vector<int>().swap(vec[i]);
}
int main(){
    std::ios::sync_with_stdio(0);
    std::cin.tie(0),std::cout.tie(0);
    std::cin>>task;
    while(task--){
        std::cin>>n>>m,init();
        rep(i,1,n) std::cin>>a[i].x>>a[i].y;
        std::reverse(a+1,a+n+1);
        rep(i,1,m) std::cin>>b[i].x>>b[i].y;
        rep(i,1,m){
            int cntl=0,cntr=0;
            rep(cur,1,n){
                int lst=cur==1?n:cur-1,nxt=cur==n?1:cur+1;
                if(cross(a[cur]-b[i],a[cur]-a[lst])>0&&cross(a[cur]-b[i],a[nxt]-a[cur])<0) ++cntl,l[i]=cur;
                if(cross(a[cur]-b[i],a[cur]-a[lst])<0&&cross(a[cur]-b[i],a[nxt]-a[cur])>0) ++cntr,r[i]=cur;
            }
            assert(cntl==1&&cntr==1);
            if(l[i]>r[i]) r[i]+=n;
            seq[i]=(data){l[i],r[i],i};
        }
        std::sort(seq+1,seq+m+1);
        rep(i,1,m) vec[i]=solve(i);
        if(task!=99) print();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

2
3 2

result:

ok 1 cases.

Test #2:

score: -100
Wrong Answer
time: 38ms
memory: 34380kb

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 13
1
5
2
4 1
2
3 2
2
14 16
2
22 1
2
31 29
2
9 4
2
7 11
2
1 3
2
11 16
2
1 7
2
1 3
1
7
2
11 3
2
12 2
1
4
2
1 17
2
5 14
2
12 26
2
16 15
2
2 3
2
5 19
2
5 48
2
27 13
2
16 77
2
8 1
2
1 15
2
16 10
2
12 10
2
42 56
2
2 1
2
25 39
2
67 154
2
20 22
2
129 50
2
8 80
2
147 38
2
94 58
2
207 11
2
192 60
2
45 51
...

result:

wrong answer In case 1, the chosen illuminants cannot light up all exterior boundaries of the polygon.