一周内写完P9141 [THUPC 2023 初赛] 乱西星上的空战
11.18晚:开坑
11.20晚:写完plane部分
11.22晚:主函数,启动
11.22 22:00:超越镇楼代码(猪国杀)
11.22 22.35:主体代码完成(205lines,7.27kb,少许压行)。调试,启动(鸽明天)
11.24 最后的调试
11.25晚:AC(正好一周)
源代码(带调试):248lines,9.93kb
#include<bits/stdc++.h>
using namespace std;
#define I int
#define D double
#define V void
#define B bool
int n,t; B lcd[205];
//part 1:3-D geograhpic calculation
const double eps=1e-9;
bool equal(D x,D y){return fabs(x-y)<eps;}
D prc(D x){return min(max(x,-1.0),1.0);}//precision problem!!
struct vec{
D xl,yl,zl;
vec operator-(){vec a;a.xl=-xl,a.yl=-yl,a.zl=-zl;return a;}
vec operator+(vec a)const{a.xl+=xl,a.yl+=yl,a.zl+=zl;return a;}
vec operator-(vec a){a.xl=xl-a.xl,a.yl=yl-a.yl,a.zl=zl-a.zl;return a;}
vec operator*(D w){vec a;a.xl=w*xl,a.yl=w*yl,a.zl=w*zl;return a;}
vec operator/(D w){vec a;a.xl=xl/w,a.yl=yl/w,a.zl=zl/w;return a;}
bool operator<(const vec &a)const{return xl+eps<a.xl||equal(xl,a.xl)&&yl+eps<a.yl||equal(xl,a.xl)&&equal(yl,a.yl)&&zl+eps<a.zl;}
D len(){return sqrt(xl*xl+yl*yl+zl*zl);}
vec uni(vec a){D w=a.len();return a/w;}
D dot(vec a){return a.xl*xl+a.yl*yl+a.zl*zl;}//numeric multiply
vec crs(vec a){vec b;b.xl=yl*a.zl-zl*a.yl,b.yl=zl*a.xl-xl*a.zl,b.zl=xl*a.yl-yl*a.xl;return b;}//directed area&left-hand direction
D ang(vec a){return acos(prc(dot(a)/(len()*a.len())));}
void in(){cin>>xl>>yl>>zl;}
void out(){cout<<xl<<" "<<yl<<" "<<zl<<"\n";}
};
D dis(vec a,vec b,vec c){
vec p1=a-c,p2=b-c,p3=b-a;
if(p1.dot(p3)>0) return p1.len();
if(p3.dot(p2)<0) return p2.len();
return p1.crs(p2).len()/p3.len();
}
pair<D,D> shd(vec a,vec b,vec c){return{a.dot(c),b.dot(c)};}
//part 2:plane movement
struct plane{
vec p,d,u,l,mvt;
D anl,anr,rot,mx,rdl,rdr;
B alv; I tp,tg;
}p[205];
V snake(plane &x){swap(x.d,x.u),x.u=-x.u;}
D timp(plane x,vec to){
D tmp=to.len(); //cout<<tmp<<"\n";
vec ll=x.d.crs(to.uni(to));//rotate first,get the middle position to spin to
if(equal(ll.len(),0)) ll=x.l;
else{ll=ll.uni(ll);if(ll.dot(x.l)<0) ll=-ll;}
//cout<<ll.ang(x.l)/x.rot<<" "<<to.ang(x.d)/(x.u.dot(to)>0?x.anl:x.anr)<<" "<<tmp/x.mx<<"\n";
return ll.ang(x.l)/x.rot+to.ang(x.d)/(x.u.dot(to)>=0?x.anl:x.anr)+tmp/x.mx;//side to side,up and down,straight foward
}
V movp(plane &x,vec to){
if(equal(to.len(),0)){snake(x);return;}
vec ll=x.d.crs(to.uni(to));
if(equal(ll.len(),0)) ll=x.l;
else{ll=ll.uni(ll);if(ll.dot(x.l)<0) ll=-ll;}
x.p=x.p+to,x.d=to.uni(to),x.l=ll,x.u=x.d.crs(x.l);
}
B seeable(plane x,plane y){return x.d.dot(y.p-x.p)>eps;}
B findable(plane x,plane y){
if(!seeable(x,y)) return 0;
pair<D,D> res=shd(x.l,x.u,y.p-x.p);
return fabs(res.first)+eps<x.rdl&&fabs(res.second)+eps<x.rdr;
}
V tgt(plane &x){
D mil=2e9,idl=-1,mir=2e9,idr=-1;vec tmp;pair<D,D> res;
for(int i=1;i<=2*n;i++){
if(!p[i].alv||p[i].tp==x.tp) continue;
else if(x.tg==i&&seeable(x,p[i])) return;
else if(findable(x,p[i])){
tmp=p[i].p-x.p; //cout<<i<<" 111\n";
if(tmp.len()+eps<mil) mil=tmp.len(),idl=i;
}
else if(seeable(x,p[i])){
res=shd(x.l,x.u,p[i].p-x.p); //cout<<i<<" 222\n";
if(min(fabs(x.rdl-res.first),fabs(x.rdl+res.first))+min(fabs(x.rdr-res.second),fabs(x.rdr+res.second))+eps<mir){
mir=min(fabs(x.rdl-res.first),fabs(x.rdl+res.first))+min(fabs(x.rdr-res.second),fabs(x.rdr+res.second)); idr=i;
}
}
}
if(idl>0) x.tg=idl;else if(idr>0) x.tg=idr;else x.tg=0;
//cout<<x.tg<<"\n";
}
V strategp(plane &x){
if(x.tg==0){x.mvt=x.p;return;}
I len=x.mx;vec to;D l,mi=2e9,ml=2e9,mr=2e9,mil=2e9;pair<D,D> res;plane ch,id,idl;B v=0;
//cout<<x.mx<<"\n";
for(I i=-len;i<=len;i++){
for(I j=-len;j<=len;j++){
for(I k=-len;k<=len;k++){
//cout<<i<<" "<<j<<" "<<k<<"\n";
if(i==0&&j==0&&k==0) continue;
to.xl=i;to.yl=j;to.zl=k;ch=x;movp(ch,to);//cout<<timp(x,to)<<"\n";
//if(j==0&&k==0)cout<<i<<" "<<timp(x,to)<<"\n",to.out(),ch.p.out(),ch.d.out(),(p[x.tg].p-ch.p).out();
if(timp(x,to)>1.0+eps) continue;
if(seeable(ch,p[x.tg])){
//x.p.out();x.d.out();x.u.out();x.l.out();
l=(p[x.tg].p-ch.p).len();//cout<<i<<" "<<j<<" "<<k<<" "<<l<<"\n"; //ch.p.out();
res=shd(ch.l,ch.u,p[x.tg].p-ch.p);
if(l+eps<mi){mi=l,id=ch;if(findable(ch,p[x.tg]))ml=sqrt(res.first*res.first+res.second*res.second),mr=2e9;else mr=min(fabs(x.rdl-res.first),fabs(x.rdl+res.first))+min(fabs(x.rdr-res.second),fabs(x.rdr+res.second));}
else if(equal(l,mi)){
if(findable(ch,p[x.tg])){
//cout<<"xxx"<<"\n";
//cout<<ml<<" "<<sqrt(res.first*res.first+res.second*res.second)<<"\n";cout<<"xxx"<<"\n",
if(sqrt(res.first*res.first+res.second*res.second)+eps<ml) id=ch,ml=sqrt(res.first*res.first+res.second*res.second);
else if(equal(sqrt(res.first*res.first+res.second*res.second),ml)&&ch.p<id.p) id=ch;
}
else if(ml==2e9){
if(min(fabs(x.rdl-res.first),fabs(x.rdl+res.first))+min(fabs(x.rdr-res.second),fabs(x.rdr+res.second))+eps<mr) mr=min(fabs(x.rdl-res.first),fabs(x.rdl+res.first))+min(fabs(x.rdr-res.second),fabs(x.rdr+res.second)),id=ch;
else if(equal(min(fabs(x.rdl-res.first),fabs(x.rdl+res.first))+min(fabs(x.rdr-res.second),fabs(x.rdr+res.second)),mr)&&ch.p<id.p) id=ch;
}
}
}
else{
l=(to-x.d*x.mx).len();
if(l+eps<mil) mil=l,idl=ch;
else if(equal(l,mil)&&ch.p<idl.p) idl=ch;
}
}
}
}
if(mi<2e9) x.mvt=id.p;
else x.mvt=idl.p;
//x.mvt.out();
}
//part 3:missile movement
struct missle{
vec p,d,mvt;
D an,mx,ds,dp,anb;
B act,exp,use,lst;
I bel,lft,tg;
}mdl[205];
D timm(missle x,vec to){
return x.d.ang(to)/x.an+to.len()/x.mx;
}
V movm(missle &x,vec to){
x.p=x.p+to; x.d=to.uni(to); x.lft--;
}
B mfind(missle x,plane y){
if(!y.alv) return 0; //x.p.out();y.p.out();
if(equal((x.p-y.p).len(),0)) return 1;
//cout<<x.d.dot(y.p-x.p)<<" "<<x.d.ang(y.p-x.p)<<"\n";
if(x.d.dot(y.p-x.p)<0||x.d.ang(y.p-x.p)>x.anb) return 0;
return 1;
}
V strategm(missle &x){
//cout<<x.tg<<"\n";
if(!x.tg||x.lft<=0) return;
I len=x.mx;vec to;D l,mi=2e9,ml=2e9,mil=2e9;missle ch,id,idl;plane y=p[x.tg];//y.p.out();y.mvt.out();
movp(y,y.mvt-y.p);
for(I i=-len;i<=len;i++){
for(I j=-len;j<=len;j++){
for(I k=-len;k<=len;k++){
if(i==0&&j==0&&k==0) continue;
to.xl=i;to.yl=j;to.zl=k;ch=x;movm(ch,to);
if(timm(x,to)+eps<1.0){
//cout<<i<<" "<<j<<" "<<k<<"\n";
if(mfind(ch,y)){
l=(y.p-ch.p).len();//cout<<i<<" "<<j<<" "<<k<<" "<<l<<"\n";
if(l+eps<mi) mi=l,ml=ch.d.ang(y.p-ch.p),id=ch;
else if(equal(l,mi)){
if(ch.d.ang(y.p-ch.p)+eps<ml) ml=ch.d.ang(y.p-ch.p),id=ch;
else if(equal(ch.d.ang(y.p-ch.p),ml)&&ch.p<id.p) id=ch;
}
}
else{
l=(to-x.d*x.mx).len();
if(l+eps<mil) mil=l,idl=ch;
else if(equal(l,mil)&&ch.p<idl.p) idl=ch;
}
}
}
}
}
if(mi==2e9) x.mvt=idl.p;
else x.mvt=id.p;
//x.mvt.out();
}
vector<missle> on,nxt;
vector<int> kid[205],sm;
vector<pair<int,int> > k1,k2;
vector<vector<int> > k3;
V fire(plane x,I id){
if(!x.alv||!findable(x,p[x.tg])||lcd[id]) return; //cout<<id<<"\n";
lcd[id]=1; missle y=mdl[id]; y.p=x.p,y.d=(p[x.tg].p-x.p).uni(p[x.tg].p-x.p); y.tg=x.tg,on.push_back(y);
}
V out(vector<pair<int,int> > x){
for(int i=1;i<=2*n;i++) kid[i].clear();
for(int i=0;i<x.size();i++) kid[x[i].first].push_back(x[i].second);
for(int i=1;i<=2*n;i++){
if(!kid[i].size()) continue; sort(kid[i].begin(),kid[i].end());
cout<<i<<" "<<kid[i].size()<<" "; for(int j=0;j<kid[i].size();j++) cout<<kid[i][j]<<" "; cout<<"\n";
}
}
I main(){
//freopen("ou.out","w",stdout);
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0); cin>>n>>t;
for(int i=1;i<=2*n;i++){
cin>>p[i].p.xl>>p[i].p.yl>>p[i].p.zl>>p[i].d.xl>>p[i].d.yl>>p[i].d.zl>>p[i].u.xl>>p[i].u.yl>>p[i].u.zl;p[i].l=p[i].u.crs(p[i].d);
cin>>p[i].anl>>p[i].anr>>p[i].rot>>p[i].mx>>p[i].rdl>>p[i].rdr; p[i].alv=1; p[i].tp=i>n;
cin>>mdl[i].an>>mdl[i].mx>>mdl[i].ds>>mdl[i].dp>>mdl[i].anb>>mdl[i].lft; mdl[i].bel=i; mdl[i].lft++;
}
for(int o=1;o<=t;o++){
k1.clear();k2.clear();k3.clear(); vec tmp; I ans1=0,ans2=0;
//for(int i=1;i<=2*n;i++) p[i].p.out(),p[i].d.out(),p[i].u.out(),p[i].l.out();
for(int i=1;i<=2*n;i++) if(p[i].alv) tgt(p[i]),strategp(p[i]);//cout<<p[i].tg<<"\n";
for(int i=1;i<=2*n;i++) if(p[i].alv) fire(p[i],i);
for(int i=0;i<on.size();i++){
strategm(on[i]); tmp=on[i].p; movm(on[i],on[i].mvt-on[i].p); //on[i].mvt.out();
for(int j=1;j<=2*n;j++){
if(!p[j].alv) continue;
if(!on[i].act&&equal((p[j].p-on[i].p).len(),0)) k1.push_back({j,on[i].bel}),on[i].exp=1;
if(on[i].act&&dis(tmp,on[i].p,p[j].p)<on[i].dp) k1.push_back({j,on[i].bel}),on[i].exp=1;
}
if(on[i].exp&&!on[i].use) on[i].use=1,lcd[on[i].bel]=0;
}
//cout<<"\n";
for(int i=0;i<k1.size();i++) if(p[k1[i].first].alv) p[k1[i].first].alv=0,ans1++;
for(int i=1;i<=2*n;i++){
if(!p[i].alv) continue; tmp=p[i].p; movp(p[i],p[i].mvt-p[i].p); //p[i].mvt.out();
for(int j=0;j<on.size();j++){
if(on[j].use) continue; //cout<<dis(tmp,p[i].p,on[j].p)<<"\n";
if(on[j].act&&dis(tmp,p[i].p,on[j].p)<on[j].dp) k2.push_back({i,on[j].bel}),on[j].exp=1;
if(!on[j].act&&equal((p[i].p-on[j].p).len(),0)) k2.push_back({i,on[j].bel}),on[j].exp=1;
}
}
for(int i=0;i<on.size();i++) if(on[i].exp&&!on[i].use) on[i].use=1,lcd[on[i].bel]=0;
for(int i=0;i<k2.size();i++) if(p[k2[i].first].alv) p[k2[i].first].alv=0,ans2++;
for(int i=1;i<=2*n;i++){
if(!p[i].alv) continue; sm.clear(); sm.push_back(i);
for(int j=i+1;j<=2*n;j++) if(p[j].alv&&equal((p[j].p-p[i].p).len(),0)) sm.push_back(j);
if(sm.size()>1){k3.push_back(sm);for(int j=0;j<sm.size();j++) p[sm[j]].alv=0;}
}
for(int i=0;i<on.size();i++){
if(on[i].use) continue;
if(!mfind(on[i],p[on[i].tg])) on[i].lst=1;
if(!on[i].lft||on[i].act&&on[i].lst) on[i].use=1,lcd[on[i].bel]=0;
}
for(int i=0;i<on.size();i++){
if(on[i].use) continue;
if(!p[on[i].bel].alv||(on[i].p-p[on[i].bel].p).len()>on[i].ds) on[i].act=1;nxt.push_back(on[i]);
}
on=nxt; nxt.clear();cout<<ans1<<" "<<ans2<<" "<<k3.size()<<"\n"; out(k1); out(k2);
for(int i=0;i<k3.size();i++){
cout<<k3[i].size()<<" "; for(int j=0;j<k3[i].size();j++) cout<<k3[i][j]<<" "; cout<<"\n";
}
}
return 0;
}
纯享版:228lines,8.85kb
#include<bits/stdc++.h>
using namespace std;
#define I int
#define D double
#define V void
#define B bool
int n,t; B lcd[205];
//part 1:3-D geograhpic calculation
const double eps=1e-9;
bool equal(D x,D y){return fabs(x-y)<eps;}
D prc(D x){return min(max(x,-1.0),1.0);}//precision problem!!
struct vec{
D xl,yl,zl;
vec operator-(){vec a;a.xl=-xl,a.yl=-yl,a.zl=-zl;return a;}
vec operator+(vec a)const{a.xl+=xl,a.yl+=yl,a.zl+=zl;return a;}
vec operator-(vec a){a.xl=xl-a.xl,a.yl=yl-a.yl,a.zl=zl-a.zl;return a;}
vec operator*(D w){vec a;a.xl=w*xl,a.yl=w*yl,a.zl=w*zl;return a;}
vec operator/(D w){vec a;a.xl=xl/w,a.yl=yl/w,a.zl=zl/w;return a;}
bool operator<(const vec &a)const{return xl+eps<a.xl||equal(xl,a.xl)&&yl+eps<a.yl||equal(xl,a.xl)&&equal(yl,a.yl)&&zl+eps<a.zl;}
D len(){return sqrt(xl*xl+yl*yl+zl*zl);}
vec uni(vec a){D w=a.len();return a/w;}
D dot(vec a){return a.xl*xl+a.yl*yl+a.zl*zl;}//numeric multiply
vec crs(vec a){vec b;b.xl=yl*a.zl-zl*a.yl,b.yl=zl*a.xl-xl*a.zl,b.zl=xl*a.yl-yl*a.xl;return b;}//directed area&left-hand direction
D ang(vec a){return acos(prc(dot(a)/(len()*a.len())));}
void in(){cin>>xl>>yl>>zl;}
void out(){cout<<xl<<" "<<yl<<" "<<zl<<"\n";}
};
D dis(vec a,vec b,vec c){
vec p1=a-c,p2=b-c,p3=b-a;
if(p1.dot(p3)>0) return p1.len();
if(p3.dot(p2)<0) return p2.len();
return p1.crs(p2).len()/p3.len();
}
pair<D,D> shd(vec a,vec b,vec c){return{a.dot(c),b.dot(c)};}
//part 2:plane movement
struct plane{
vec p,d,u,l,mvt;
D anl,anr,rot,mx,rdl,rdr;
B alv; I tp,tg;
}p[205];
V snake(plane &x){swap(x.d,x.u),x.u=-x.u;}
D timp(plane x,vec to){
D tmp=to.len(); vec ll=x.d.crs(to.uni(to));//rotate first,get the middle position to spin to
if(equal(ll.len(),0)) ll=x.l;
else{ll=ll.uni(ll);if(ll.dot(x.l)<0) ll=-ll;}
return ll.ang(x.l)/x.rot+to.ang(x.d)/(x.u.dot(to)>=0?x.anl:x.anr)+tmp/x.mx;//side to side,up and down,straight foward
}
V movp(plane &x,vec to){
if(equal(to.len(),0)){snake(x);return;}
vec ll=x.d.crs(to.uni(to));
if(equal(ll.len(),0)) ll=x.l;
else{ll=ll.uni(ll);if(ll.dot(x.l)<0) ll=-ll;}
x.p=x.p+to,x.d=to.uni(to),x.l=ll,x.u=x.d.crs(x.l);
}
B seeable(plane x,plane y){return x.d.dot(y.p-x.p)>eps;}
B findable(plane x,plane y){
if(!seeable(x,y)) return 0;
pair<D,D> res=shd(x.l,x.u,y.p-x.p);
return fabs(res.first)+eps<x.rdl&&fabs(res.second)+eps<x.rdr;
}
V tgt(plane &x){
D mil=2e9,idl=-1,mir=2e9,idr=-1;vec tmp;pair<D,D> res;
for(int i=1;i<=2*n;i++){
if(!p[i].alv||p[i].tp==x.tp) continue;
else if(x.tg==i&&seeable(x,p[i])) return;
else if(findable(x,p[i])){
tmp=p[i].p-x.p; if(tmp.len()+eps<mil) mil=tmp.len(),idl=i;
}
else if(seeable(x,p[i])){
res=shd(x.l,x.u,p[i].p-x.p);
if(min(fabs(x.rdl-res.first),fabs(x.rdl+res.first))+min(fabs(x.rdr-res.second),fabs(x.rdr+res.second))+eps<mir){
mir=min(fabs(x.rdl-res.first),fabs(x.rdl+res.first))+min(fabs(x.rdr-res.second),fabs(x.rdr+res.second)); idr=i;
}
}
}
if(idl>0) x.tg=idl;else if(idr>0) x.tg=idr;else x.tg=0;
}
V strategp(plane &x){
if(x.tg==0){x.mvt=x.p;return;}
I len=x.mx;vec to;D l,mi=2e9,ml=2e9,mr=2e9,mil=2e9;pair<D,D> res;plane ch,id,idl;B v=0;
for(I i=-len;i<=len;i++){
for(I j=-len;j<=len;j++){
for(I k=-len;k<=len;k++){
if(i==0&&j==0&&k==0) continue;
to.xl=i;to.yl=j;to.zl=k;ch=x;movp(ch,to);
if(timp(x,to)>1.0+eps) continue;
if(seeable(ch,p[x.tg])){
l=(p[x.tg].p-ch.p).len(); res=shd(ch.l,ch.u,p[x.tg].p-ch.p);
if(l+eps<mi){mi=l,id=ch;if(findable(ch,p[x.tg]))ml=sqrt(res.first*res.first+res.second*res.second),mr=2e9;else mr=min(fabs(x.rdl-res.first),fabs(x.rdl+res.first))+min(fabs(x.rdr-res.second),fabs(x.rdr+res.second));}
else if(equal(l,mi)){
if(findable(ch,p[x.tg])){
if(sqrt(res.first*res.first+res.second*res.second)+eps<ml) id=ch,ml=sqrt(res.first*res.first+res.second*res.second);
else if(equal(sqrt(res.first*res.first+res.second*res.second),ml)&&ch.p<id.p) id=ch;
}
else if(ml==2e9){
if(min(fabs(x.rdl-res.first),fabs(x.rdl+res.first))+min(fabs(x.rdr-res.second),fabs(x.rdr+res.second))+eps<mr) mr=min(fabs(x.rdl-res.first),fabs(x.rdl+res.first))+min(fabs(x.rdr-res.second),fabs(x.rdr+res.second)),id=ch;
else if(equal(min(fabs(x.rdl-res.first),fabs(x.rdl+res.first))+min(fabs(x.rdr-res.second),fabs(x.rdr+res.second)),mr)&&ch.p<id.p) id=ch;
}
}
}
else{
l=(to-x.d*x.mx).len();
if(l+eps<mil) mil=l,idl=ch;
else if(equal(l,mil)&&ch.p<idl.p) idl=ch;
}
}
}
}
if(mi<2e9) x.mvt=id.p;
else x.mvt=idl.p;
}
//part 3:missile movement
struct missle{
vec p,d,mvt;
D an,mx,ds,dp,anb;
B act,exp,use,lst;
I bel,lft,tg;
}mdl[205];
D timm(missle x,vec to){
return x.d.ang(to)/x.an+to.len()/x.mx;
}
V movm(missle &x,vec to){
x.p=x.p+to; x.d=to.uni(to); x.lft--;
}
B mfind(missle x,plane y){
if(!y.alv) return 0; if(equal((x.p-y.p).len(),0)) return 1;
if(x.d.dot(y.p-x.p)<0||x.d.ang(y.p-x.p)>x.anb) return 0;
return 1;
}
V strategm(missle &x){
if(!x.tg||x.lft<=0) return;
I len=x.mx;vec to;D l,mi=2e9,ml=2e9,mil=2e9;missle ch,id,idl;plane y=p[x.tg];
movp(y,y.mvt-y.p);
for(I i=-len;i<=len;i++){
for(I j=-len;j<=len;j++){
for(I k=-len;k<=len;k++){
if(i==0&&j==0&&k==0) continue;
to.xl=i;to.yl=j;to.zl=k;ch=x;movm(ch,to);
if(timm(x,to)+eps<1.0){
if(mfind(ch,y)){
l=(y.p-ch.p).len();
if(l+eps<mi) mi=l,ml=ch.d.ang(y.p-ch.p),id=ch;
else if(equal(l,mi)){
if(ch.d.ang(y.p-ch.p)+eps<ml) ml=ch.d.ang(y.p-ch.p),id=ch;
else if(equal(ch.d.ang(y.p-ch.p),ml)&&ch.p<id.p) id=ch;
}
}
else{
l=(to-x.d*x.mx).len();
if(l+eps<mil) mil=l,idl=ch;
else if(equal(l,mil)&&ch.p<idl.p) idl=ch;
}
}
}
}
}
if(mi==2e9) x.mvt=idl.p;
else x.mvt=id.p;
}
vector<missle> on,nxt;
vector<int> kid[205],sm;
vector<pair<int,int> > k1,k2;
vector<vector<int> > k3;
V fire(plane x,I id){
if(!x.alv||!findable(x,p[x.tg])||lcd[id]) return;
lcd[id]=1; missle y=mdl[id]; y.p=x.p,y.d=(p[x.tg].p-x.p).uni(p[x.tg].p-x.p); y.tg=x.tg,on.push_back(y);
}
V out(vector<pair<int,int> > x){
for(int i=1;i<=2*n;i++) kid[i].clear();
for(int i=0;i<x.size();i++) kid[x[i].first].push_back(x[i].second);
for(int i=1;i<=2*n;i++){
if(!kid[i].size()) continue; sort(kid[i].begin(),kid[i].end());
cout<<i<<" "<<kid[i].size()<<" "; for(int j=0;j<kid[i].size();j++) cout<<kid[i][j]<<" "; cout<<"\n";
}
}
I main(){
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0); cin>>n>>t;
for(int i=1;i<=2*n;i++){
cin>>p[i].p.xl>>p[i].p.yl>>p[i].p.zl>>p[i].d.xl>>p[i].d.yl>>p[i].d.zl>>p[i].u.xl>>p[i].u.yl>>p[i].u.zl;p[i].l=p[i].u.crs(p[i].d);
cin>>p[i].anl>>p[i].anr>>p[i].rot>>p[i].mx>>p[i].rdl>>p[i].rdr; p[i].alv=1; p[i].tp=i>n;
cin>>mdl[i].an>>mdl[i].mx>>mdl[i].ds>>mdl[i].dp>>mdl[i].anb>>mdl[i].lft; mdl[i].bel=i; mdl[i].lft++;
}
for(int o=1;o<=t;o++){
k1.clear();k2.clear();k3.clear(); vec tmp; I ans1=0,ans2=0;
for(int i=1;i<=2*n;i++) if(p[i].alv) tgt(p[i]),strategp(p[i]);
for(int i=1;i<=2*n;i++) if(p[i].alv) fire(p[i],i);
for(int i=0;i<on.size();i++){
strategm(on[i]); tmp=on[i].p; movm(on[i],on[i].mvt-on[i].p);
for(int j=1;j<=2*n;j++){
if(!p[j].alv) continue;
if(!on[i].act&&equal((p[j].p-on[i].p).len(),0)) k1.push_back({j,on[i].bel}),on[i].exp=1;
if(on[i].act&&dis(tmp,on[i].p,p[j].p)<on[i].dp) k1.push_back({j,on[i].bel}),on[i].exp=1;
}
if(on[i].exp&&!on[i].use) on[i].use=1,lcd[on[i].bel]=0;
}
for(int i=0;i<k1.size();i++) if(p[k1[i].first].alv) p[k1[i].first].alv=0,ans1++;
for(int i=1;i<=2*n;i++){
if(!p[i].alv) continue; tmp=p[i].p; movp(p[i],p[i].mvt-p[i].p);
for(int j=0;j<on.size();j++){
if(on[j].use) continue;
if(on[j].act&&dis(tmp,p[i].p,on[j].p)<on[j].dp) k2.push_back({i,on[j].bel}),on[j].exp=1;
if(!on[j].act&&equal((p[i].p-on[j].p).len(),0)) k2.push_back({i,on[j].bel}),on[j].exp=1;
}
}
for(int i=0;i<on.size();i++) if(on[i].exp&&!on[i].use) on[i].use=1,lcd[on[i].bel]=0;
for(int i=0;i<k2.size();i++) if(p[k2[i].first].alv) p[k2[i].first].alv=0,ans2++;
for(int i=1;i<=2*n;i++){
if(!p[i].alv) continue; sm.clear(); sm.push_back(i);
for(int j=i+1;j<=2*n;j++) if(p[j].alv&&equal((p[j].p-p[i].p).len(),0)) sm.push_back(j);
if(sm.size()>1){k3.push_back(sm);for(int j=0;j<sm.size();j++) p[sm[j]].alv=0;}
}
for(int i=0;i<on.size();i++){
if(on[i].use) continue;
if(!mfind(on[i],p[on[i].tg])) on[i].lst=1;
if(!on[i].lft||on[i].act&&on[i].lst) on[i].use=1,lcd[on[i].bel]=0;
}
for(int i=0;i<on.size();i++){
if(on[i].use) continue;
if(!p[on[i].bel].alv||(on[i].p-p[on[i].bel].p).len()>on[i].ds) on[i].act=1;nxt.push_back(on[i]);
}
on=nxt; nxt.clear();cout<<ans1<<" "<<ans2<<" "<<k3.size()<<"\n"; out(k1); out(k2);
for(int i=0;i<k3.size();i++){
cout<<k3[i].size()<<" "; for(int j=0;j<k3[i].size();j++) cout<<k3[i][j]<<" "; cout<<"\n";
}
}
return 0;
}
标签:return,mdl,ll,不能,plane,vec,乱西星,tg,模拟
From: https://www.cnblogs.com/skh504535/p/18009523