QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#77558#1878. No Rest for the WickedCharlieVinnieCompile Error//C++174.8kb2023-02-15 08:37:552023-02-15 08:37:57

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-02-15 08:37:57]
  • 评测
  • [2023-02-15 08:37:55]
  • 提交

answer

#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2")
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Rev(i,a,b) for(int i=a;i>=b;i--)
#define Fin(file) freopen(file,"r",stdin)
#define Fout(file) freopen(file,"w",stdout)
#define assume(expr) ((!!(expr))||(exit((fprintf(stderr,"Assumption Failed: %s on Line %d\n",#expr,__LINE__),-1)),false))
using namespace std;
#define fi first
#define se second
#define k1 k<<1
#define k2 k<<1|1
namespace FastIO{
    const int BUF_COUNT=1000000,BUF_SIZ=1<<25;
    char in_buf[BUF_SIZ],*got_pos=in_buf,*read_pos=in_buf,out_buf[BUF_SIZ],*write_pos=out_buf;
    inline char get_next_char(){if(read_pos==got_pos){got_pos=read_pos=in_buf;got_pos+=fread(got_pos,sizeof(char),BUF_COUNT,stdin);}return*(read_pos++);}
    inline void flush_output(){fwrite(out_buf,sizeof(char),write_pos-out_buf,stdout);write_pos=out_buf;}
    inline void put_char(char ch){*(write_pos++)=ch;if(write_pos==out_buf+BUF_SIZ)flush_output();}
#ifndef FASTIO_READ_NEGATIVE
    template<typename T> inline void read(T& res){char ch;while(!isdigit(ch=get_next_char()));res=ch^'0';while(isdigit(ch=get_next_char()))res=(res<<3)+(res<<1)+(ch^'0');}
#else
    template<typename T> inline void read(T& res){char ch;bool flg=0;while(!isdigit(ch=get_next_char()))flg|=ch=='-';res=ch^'0';while(isdigit(ch=get_next_char()))res=(res<<3)+(res<<1)+(ch^'0');if(flg)res=-res;}
#endif
    template<typename T> inline void write(T x){if(!x){put_char('0');return;}static int lis[25],*lp=lis;while(x){*(++lp)=x%10;x/=10;}while(lp!=lis)put_char((*(lp--))+'0');}
    template<typename T> inline void writeln(const T& x){write(x);put_char('\n');}
    template<typename T> inline void writesp(const T& x){write(x);put_char(' ');}
    class _IO_Flusher{public:~_IO_Flusher(){flush_output();}}__Flusher;
    class IStream{public:
        template<typename T> inline IStream& operator>>(T& x){read(x);return *this;}
        inline IStream& operator>>(char* str){char ch;while(isspace(ch=get_next_char()));(*(str++))=ch;while(!isspace(ch=get_next_char())){if(ch==EOF)break;(*(str++))=ch;}return *this;}
    }Cin;
    class OStream{public:
        inline OStream& operator<< (const int& x){write(x);return *this;}
        inline OStream& operator<< (const long long& x){write(x);return *this;}
        inline OStream& operator<< (const char& ch){put_char(ch);return *this;}
        inline OStream& operator<< (const char* str){for(const char* p=str;*p;put_char(*(p++)));return *this;}
    }Cout;
}
using namespace FastIO;
#define cin Cin
#define cout Cout
const int N=4e5+5; typedef long long ll; using pii = pair<int,int>;
class DSU{
    int tot,fa[N],siz[N],mx[N],tp; pii st[N];
    inline int getfa(int x) { while(x!=fa[x]) __FaCnt++,x=fa[x];; return x; }
public:  
    inline int newnode(int x) { tot++; mx[tot]=x; siz[tot]=1; fa[tot]=tot; return tot; }
    inline void add_edge(int x,int y){
        x=getfa(x),y=getfa(y); if(siz[x]<siz[y]) swap(x,y);; if(x==y) return st[++tp]=pii(0,0),void();
        fa[y]=x; siz[x]+=siz[y]; st[++tp]=pii(y,mx[x]); mx[x]=max(mx[x],mx[y]);
    }
    inline void undo(){
        if(st[tp].fi==0) return tp--,void();
        int y=st[tp].fi,x=fa[y]; mx[x]=st[tp].se; siz[x]-=siz[y]; fa[y]=y; tp--;
    }
    inline int getval(int u) { return mx[getfa(u)]; }
}S;
struct Cpdd { int c,t,s; } cp[N] ;
int n,m,tmp[N],tcnt,ans[N]; vector<pii> lis[N<<2]; vector<int> to[N],Nd[N];
void add(int k,int l,int r,int ql,int qr,int x,int y) { if(ql<=l&&r<=qr) return lis[k].emplace_back(x,y),void();; int mid=(l+r)>>1; if(ql<=mid) add(k1,l,mid,ql,qr,x,y);; if(mid+1<=qr) add(k2,mid+1,r,ql,qr,x,y); }
inline void addedge(int l,int r,int x,int y) { if(l<=r) add(1,1,tcnt,l,r,x,y); }
void solve(int k,int l,int r){
    for(auto pr:lis[k]) S.add_edge(pr.fi,pr.se);
    if(l==r) for(int u:Nd[l]) { ans[u]=S.getval(u); for(int v:to[u]) addedge(cp[v].c,min(cp[u].c-1,cp[v].t),v,S.newnode(ans[u]));; }
    else { int mid=(l+r)>>1; solve(k2,mid+1,r); solve(k1,l,mid); }
    int sz=lis[k].size(); For(_,0,sz-1) S.undo();
}
signed main(){
    cin>>n>>m; For(i,1,n) cin>>cp[i].c>>cp[i].t>>cp[i].s,tmp[++tcnt]=cp[i].c,tmp[++tcnt]=cp[i].t;
    sort(tmp+1,tmp+1+tcnt); tcnt=unique(tmp+1,tmp+1+tcnt)-(tmp+1); 
    For(i,1,n) cp[i].c=lower_bound(tmp+1,tmp+1+tcnt,cp[i].c)-tmp,cp[i].t=lower_bound(tmp+1,tmp+1+tcnt,cp[i].t)-tmp;
    For(i,1,tcnt*2) lis[i].reserve(20);
    For(i,1,m) { int x,y; cin>>x>>y; if(cp[x].c>cp[y].c) swap(x,y);; addedge(max(cp[x].c,cp[y].c),min(cp[x].t,cp[y].t),x,y); to[y].push_back(x); }
    For(i,1,n) S.newnode(cp[i].s);; For(i,1,n) Nd[cp[i].c].push_back(i);; solve(1,1,tcnt);
    For(i,1,n) cout<<ans[i]<<' ';; cout<<'\n';
    cerr<<"Time = "<<clock()<<" ms"<<endl;
    return 0;
}

// START TYPING IF YOU DON'T KNOW WHAT TO DO

詳細信息

answer.code: In member function ‘int DSU::getfa(int)’:
answer.code:46:47: error: ‘__FaCnt’ was not declared in this scope
   46 |     inline int getfa(int x) { while(x!=fa[x]) __FaCnt++,x=fa[x];; return x; }
      |                                               ^~~~~~~