QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#748500#9161. Naval battlemiaomiaomiaowu#Compile Error//C++207.5kb2024-11-14 20:34:472024-11-14 20:34:47

Judging History

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

  • [2024-11-14 20:34:47]
  • 评测
  • [2024-11-14 20:34:47]
  • 提交

answer

#include<bits/stdc++.h>
#include<ext/pb_ds/priority_queue.hpp>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MP make_pair
#define pii pair<int,int>
const double PI=acos(-1.0);
template <class Miaowu>
inline void in(Miaowu &x){
    char c;x=0;bool f=0;
    for(c=getchar();c<'0'||c>'9';c=getchar())f|=c=='-';
    for(;c>='0'&&c<='9';c=getchar())x=(x<<1)+(x<<3)+(c^48);
    x=f?-x:x;
}
struct fastmod{
    typedef unsigned long long u64;
    typedef __uint128_t u128;
    int m;u64 b;
    fastmod(int m):m(m),b(((u128)1<<64)/m){}
    int reduce(u64 a){
        u64 q=((u128)a*b)>>64;
        int r=a-q*m;
        return r<m?r:r-m;
    }
}z(2);
const int N=2e5+5;
const int M=2e7+5;
int n,numx[N],numy[N],num1[N],num2[N],num3[N],num4[N];
bool ban[N];
struct Ship{
    int x,y,nx,ny;
    int xx,yy,add,dec;
    char dir;
}a[N];
struct Node{
    int x,y,tim;
    bool operator < (const Node &rhs) const{
        return tim>rhs.tim;
    }
};
priority_queue<Node>Q;
inline int max3(int x,int y,int z){
    return max(max(x,y),z);
}
inline int min3(int x,int y,int z){
    return min(min(x,y),z);
}
struct SGT{
    int rtn[N][3],rts[N][3],rtw[N][3],rte[N][3];
    int ind,pl[M],vl[M],ls[M],rs[M],pr[M],vr[M];
    inline void pu(int u){
        if(!vl[ls[u]])vl[u]=vl[rs[u]],pl[u]=pl[rs[u]];
        else vl[u]=vl[ls[u]],pl[u]=pl[ls[u]];
        if(!vr[rs[u]])vr[u]=vr[ls[u]],pr[u]=pr[ls[u]];
        else vr[u]=vr[rs[u]],pr[u]=pr[rs[u]];
    }
    inline void upd(int &u,int l,int r,int v,int p,int op){
        if(!u)u=++ind;
        if(l==r){
            if(op==1)pl[u]=pr[u]=p,vl[u]=vr[u]=v;
            else pl[u]=pr[u]=vl[u]=vr[u]=0;
            return;
        }
        int mid=l+r>>1;
        mid>=v?upd(ls[u],l,mid,v,p,op):upd(rs[u],mid+1,r,v,p,op);
        pu(u);
    }
    inline pii binary1(int u,int l,int r,int p){
        if(!u)return MP(-1,-1);
        if(r<=p)return pr[u]?MP(pr[u],vr[u]):MP(-1,-1);
        int mid=l+r>>1;
        pii qwq=binary1(rs[u],mid+1,r,p);
        if(qwq.first!=-1)return qwq;
        return binary1(ls[u],l,mid,p);
    }
    inline pii binary2(int u,int l,int r,int p){
        if(!u)return MP(-1,-1);
        if(l>=p)return pl[u]?MP(pl[u],vl[u]):MP(-1,-1);
        int mid=l+r>>1;
        pii qwq=binary2(ls[u],l,mid,p);
        if(qwq.first!=-1)return qwq;
        return binary2(rs[u],mid+1,r,p);
    }
}sgt;
inline void upd(int i,int x){
    if(a[i].dir=='N'){
        sgt.upd(sgt.rtn[a[i].xx][0],1,n,a[i].ny,i,x);
        sgt.upd(sgt.rtn[a[i].dec][1],1,n,a[i].ny,i,x);
        sgt.upd(sgt.rtn[a[i].add][2],1,n,a[i].ny,i,x);
    }
    else if(a[i].dir=='S'){
        sgt.upd(sgt.rts[a[i].xx][0],1,n,a[i].ny,i,x);
        sgt.upd(sgt.rts[a[i].dec][1],1,n,a[i].ny,i,x);
        sgt.upd(sgt.rts[a[i].add][2],1,n,a[i].ny,i,x);
    }
    else if(a[i].dir=='W'){
        sgt.upd(sgt.rtw[a[i].xx][0],1,n,a[i].nx,i,x);
        sgt.upd(sgt.rtw[a[i].dec][1],1,n,a[i].nx,i,x);
        sgt.upd(sgt.rtw[a[i].add][2],1,n,a[i].nx,i,x);
    }
    else{
        sgt.upd(sgt.rte[a[i].xx][0],1,n,a[i].nx,i,x);
        sgt.upd(sgt.rte[a[i].dec][1],1,n,a[i].nx,i,x);
        sgt.upd(sgt.rte[a[i].add][2],1,n,a[i].nx,i,x);
    }
}
inline pii Find(int i){
    pii qwq0,qwq1,qwq2;
    if(a[i].dir=='N'){
        qwq0=sgt.binary1(sgt.rts[a[i].xx][0],1,n,a[i].ny);
        qwq1=sgt.binary1(sgt.rte[a[i].dec][1],1,n,a[i].nx);
        qwq2=sgt.binary2(sgt.rtw[a[i].add][2],1,n,a[i].nx);
        if(qwq0.first!=-1)qwq0.second=(a[i].y-numy[qwq0.second]>>1);
        if(qwq1.first!=-1)qwq1.second=a[i].x-numx[qwq1.second];
        if(qwq2.first!=-1)qwq2.second=numx[qwq2.second]-a[i].x;
    }
    else if(a[i].dir=='S'){
        qwq0=sgt.binary2(sgt.rtn[a[i].xx][0],1,n,a[i].ny);
        qwq1=sgt.binary1(sgt.rte[a[i].add][2],1,n,a[i].nx);
        qwq2=sgt.binary2(sgt.rtw[a[i].dec][1],1,n,a[i].nx);
        if(qwq0.first!=-1)qwq0.second=(numy[qwq0.second]-a[i].y>>1);
        if(qwq1.first!=-1)qwq1.second=a[i].x-numx[qwq1.second];
        if(qwq2.first!=-1)qwq2.second=numx[qwq1.second]-a[i].x;
    }
    else if(a[i].dir=='W'){
        qwq0=sgt.binary1(sgt.rte[a[i].yy][0],1,n,a[i].nx);
        qwq1=sgt.binary2(sgt.rtn[a[i].add][2],1,n,a[i].ny);
        qwq2=sgt.binary1(sgt.rts[a[i].dec][1],1,n,a[i].ny);
        if(qwq0.first!=-1)qwq0.second=(a[i].x-numx[qwq0.second]>>1);
        if(qwq1.first!=-1)qwq1.second=numy[qwq1.second]-a[i].y;
        if(qwq2.first!=-1)qwq2.second=a[i].y-numy[qwq2.second];
    }
    else{
        qwq0=sgt.binary2(sgt.rtw[a[i].yy][0],1,n,a[i].nx);
        qwq1=sgt.binary2(sgt.rtn[a[i].dec][1],1,n,a[i].ny);
        qwq2=sgt.binary1(sgt.rts[a[i].add][2],1,n,a[i].ny);
        if(qwq0.first!=-1)qwq0.second=(numx[qwq0.second]-a[i].x>>1);
        if(qwq1.first!=-1)qwq1.second=numy[qwq1.second]-a[i].y;
        if(qwq2.first!=-1)qwq2.second=a[i].y-numy[qwq2.second];
    }
    if(max3(qwq0.first,qwq1.first,qwq2.first)==-1)return MP(-1,-1);
    if(qwq0.first==-1)qwq0.second=2e9+5;
    if(qwq1.first==-1)qwq1.second=2e9+5;
    if(qwq2.first==-1)qwq2.second=2e9+5;
    int mn=min3(qwq0.second,qwq1.second,qwq2.second);
    if(mn==qwq0.second)return qwq0;
    if(mn==qwq1.second)return qwq1;
    return qwq2;
}
int main(){
    in(n);
    for(int i=1;i<=n;i++){
        in(a[i].x),in(a[i].y);
        char tuu[5];scanf("%s",tuu);a[i].dir=tuu[0];
        numx[++numx[0]]=a[i].x,numy[++numy[0]]=a[i].y;
        num1[++num1[0]]=a[i].x,num2[++num2[0]]=a[i].y;
        num3[++num3[0]]=a[i].x+a[i].y,num4[++num4[0]]=a[i].x-a[i].y;
    }
    stable_sort(num1+1,num1+num1[0]+1);
    num1[0]=unique(num1+1,num1+num1[0]+1)-num1-1;
    stable_sort(num2+1,num2+num2[0]+1);
    num2[0]=unique(num2+1,num2+num2[0]+1)-num2-1;
    stable_sort(num3+1,num3+num3[0]+1);
    num3[0]=unique(num3+1,num3+num3[0]+1)-num3-1;
    stable_sort(num4+1,num4+num4[0]+1);
    num4[0]=unique(num4+1,num4+num4[0]+1)-num4-1;
    stable_sort(numx+1,numx+numx[0]+1);
    stable_sort(numy+1,numy+numy[0]+1);
    numx[0]=unique(numx+1,numx+numx[0]+1)-numx-1;
    numy[0]=unique(numy+1,numy+numy[0]+1)-numy-1;
    for(int i=1;i<=n;i++){
        a[i].nx=lower_bound(numx+1,numx+numx[0]+1,a[i].x)-numx;
        a[i].ny=lower_bound(numy+1,numy+numy[0]+1,a[i].y)-numy;
        a[i].xx=lower_bound(num1+1,num1+num1[0]+1,a[i].x)-num1;
        a[i].yy=lower_bound(num2+1,num2+num2[0]+1,a[i].y)-num2;
        a[i].add=lower_bound(num3+1,num3+num3[0]+1,a[i].x+a[i].y)-num3;
        a[i].dec=lower_bound(num4+1,num4+num4[0]+1,a[i].x-a[i].y)-num4;
    }
    for(int i=1;i<=n;i++)upd(i,1);
    for(int i=1;i<=n;i++){
        pii qwq=Find(i);
        // cout<<"!! "<<i<<' '<<qwq.first<<" "<<qwq.second<<endl;
        if(qwq.first!=-1)Q.push(Node{i,qwq.first,qwq.second});
    }
    while(!Q.empty()){
        vector<Node>vc;
        vc.push_back(Q.top());Q.pop();
        while(!Q.empty()&&Q.top().tim==vc[0].tim){
            vc.push_back(Q.top()),Q.pop();
        }
        set<int>S,SS;
        for(Node xx:vc){
            if(!ban[xx.x]&&!ban[xx.y]){
                SS.insert(xx.x),SS.insert(xx.y);
            }
            else{
                if(!ban[xx.x])S.insert(xx.x);
                if(!ban[xx.y])S.insert(xx.y);
            }
        }
        for(int xx:SS){
            ban[xx]=1,upd(xx,-1);
            if(S.Find(xx)!=S.end())S.erase(xx);
        }
        for(int xx:S){
            pii qwq=Find(xx);
            if(qwq.first!=-1)Q.push(Node{xx,qwq.first,qwq.second});
        }
    }
    for(int i=1;i<=n;i++)if(!ban[i])printf("%d\n",i);
    return 0;
}

詳細信息

answer.code: In function ‘int main()’:
answer.code:204:18: error: ‘class std::set<int>’ has no member named ‘Find’; did you mean ‘find’?
  204 |             if(S.Find(xx)!=S.end())S.erase(xx);
      |                  ^~~~
      |                  find
answer.code:155:26: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
  155 |         char tuu[5];scanf("%s",tuu);a[i].dir=tuu[0];
      |                     ~~~~~^~~~~~~~~~