QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#77498 | #1878. No Rest for the Wicked | CharlieVinnie | Compile Error | / | / | C++17 | 2.8kb | 2023-02-14 21:20:49 | 2023-02-14 21:20:51 |
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-14 21:20:51]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-02-14 21:20:49]
- 提交
answer
#include "bits/stdc++.h"
#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
#define printf(...) (0==0)
#define puts(...) (0==0)
const int N=4e5+5; typedef long long ll; using pii = pair<int,int>;
class DSU{
int tot,fa[N],siz[N],his[N],mx[N],tp; pii st[N];
int getfa(int x) { return x==fa[x]?x:getfa(fa[x]); }
public:
int newnode(int x) { tot++; his[tot]=mx[tot]=x; siz[tot]=1; fa[tot]=tot; return tot; }
void add_edge(int x,int y){
printf("S.add_edge(%d,%d)\n",x,y);
x=getfa(x),y=getfa(y); if(siz[x]<siz[y]) swap(siz[x],siz[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]); his[x]=max(his[x],mx[x]); his[y]=max(his[y],mx[x]);
}
void undo(){
printf("S.undo()\n");
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--;
}
int getval(int u) { return his[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);; 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); }
void addedge(int l,int r,int x,int y) { if(l<=r) printf("addedge(%d,%d,%d,%d)\n",l,r,x,y),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(){
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
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,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 function ‘void add(int, int, int, int, int, int, int)’: answer.code:34:100: error: return-statement with a value, in function returning ‘void’ [-fpermissive] 34 | 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);; 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); } | ~~~~~~~~~~~~~~~~~~~^~~~~