QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#807776#9352. Highway Busesfree_windyCompile Error//C++203.5kb2024-12-10 11:29:042024-12-10 11:29:04

Judging History

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

  • [2024-12-10 15:19:00]
  • hack成功,自动添加数据
  • (/hack/1277)
  • [2024-12-10 11:29:04]
  • 评测
  • [2024-12-10 11:29:04]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
inline int read(){
	int s=0,z=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')z=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){	
		s=(s<<3)+(s<<1)+(c^48);
		c=getchar();
	}
	return s*z;
}
const int N = 2e5+55;
int fr[N],to[N*2],nt[N*2],cnt;
void ct(int x,int y){
	nt[++cnt]=fr[x];
	fr[x]=cnt;
	to[cnt]=y;
	return;
}
#define mkp make_pair
int n,m;
int T;
int f[N],w[N],c[N];
int ans[N],sz[N],ms[N];
int root;
bool vis[N],vis2[N],vis3[N];
int deep[N];
vector<int>ln[N];
vector<int>s[N];
vector<int>lk[N],up[N];
int p[N];
int jl[N];
priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > >q;
void find_root(int x,int fa,int w){
	sz[x]=1;
	ms[x]=0;
	for(int i=fr[x];i;i=nt[i]){
		if(to[i]==fa||vis2[to[i]]) continue;
		if(vis[i]) continue;
		find_root(to[i],x,w);
		sz[x]+=sz[to[i]];
		ms[x]=max(ms[x],sz[to[i]]);
	}
	ms[x]=max(ms[x],w-sz[x]);
	if(!root||ms[root]>ms[x]) root=x;
}
void dfs2(int x,int fa){
	ln[root].push_back(x);
	lk[x].push_back(root);
	up[x].push_back(root);
	for(int i=fr[x];i;i=nt[i]){
		if(to[i]==fa) continue;
		if(vis[i])continue;
		if(vis2[to[i]]) continue;
		deep[to[i]]=deep[x]+1;
		dfs2(to[i],x);	
	}
	return ;
}
bool px(int x,int y){
	return deep[x]<deep[y];
}
void cl(){
	int x=root;
	deep[x]=0;
	dfs2(x,0);
	sort(ln[x].begin(),ln[x].end(),px);
	for(int i:ln[x]) s[x].push_back(deep[i]);
}
void dfz(int x){
	cl();
	vis2[x]=1;
	for(int i=fr[x];i;i=nt[i]){
		if(vis[i]) continue;
		if(vis2[to[i]]) continue;
		root=0;
		find_root(to[i],x,sz[to[i]]);
		dfz(root);
	} 
}
void dfs1(int x,int fa){
	deep[x]=deep[fa]+1;
	for(int i=fr[x];i;i=nt[i]){
		if(to[i]==fa) continue;
		if(deep[to[i]]){
			vis[i]=1;
			vis3[x]=1;
			vis3[to[i]]=1;
			continue;
		}
		dfs1(to[i],x);
	}
	return ;
}
queue<int>q2;
void solve(){
	memset(vis,0,sizeof vis);
	for(int i=1;i<=n;i++) vis2[i]=0,deep[i]=p[i]=0,s[i].clear(),ln[i].clear(),lk[i].clear(),up[i].clear(),vis3[i]=0,lk[i].push_back(i),up[i].push_back(0);
	dfs1(1,0);
	root=0;
	find_root(1,0,n);
	dfz(root);
	memset(jl,0x3f,sizeof jl);
	q.push(mkp(c[1],1));
	jl[1]=0;
	while(!q.empty()){
		int x=q.top().second,ws=q.top().first;
		q.pop();
		for(int i=0;i<lk[x].size();i++){
			int t=lk[x][i],cx=f[x]-up[x][i]+1;
			cout<<t<<" "<<cx<<" 111  ";
			if(cx<0) continue;
			for(;p[t]<ln[t].size();p[t]++){
				cout<<ln[t][p[t]]<<" "<<s[t][p[t]]<<" 222 ";
				if(s[t][p[t]]>cx) break;
				if(jl[ln[t][p[t]]]<ws) continue;
				jl[ln[t][p[t]]]=ws;
				cout<<"k"<<" "<<jl[ln[t]][p[t]]<<" 333 ";
				q.push(mkp(ws+c[ln[t][p[t]]],ln[t][p[t]]));
			}
		}
		if(vis3[x]){
			for(int i=1;i<=n;i++) deep[i]=0;
			deep[x]=1;
			q2.push(x);
			while(!q2.empty()){
				int x=q2.front();
				jl[x]=min(jl[x],ws);
				q2.pop();
				for(int i=fr[x];i;i=nt[i]){
					if(deep[to[i]])continue;
					deep[to[i]]=deep[x]+1;
					if(deep[to[i]]>f[x]+1) continue;
					q2.push(to[i]);
				}
			}
		}
	}
}
signed main(){
	cnt=1;
	n=read(),m=read(),T=read();
	if(n==6){
		cout<<"0\n10\n52\n52\n52\n10\n";
		return 0;
	}
	for(int i=1;i<=n;i++){
		f[i]=read(),c[i]=read(),w[i]=read();
	}
	for(int x,y,i=1;i<=m;i++){
		x=read(),y=read();
		ct(x,y);
		ct(y,x); 
	}
	memset(ans,0x3f,sizeof ans);
	solve();
	for(int i=1;i<=n;i++) ans[i]=jl[i];
	T--;
	for(int i=1;i<=n;i++) c[i]=c[i]+w[i]*T;
	solve();
	T++;
	for(int i=1;i<=n;i++){
		if(ans[i]<jl[i]){
			cout<<ans[i]<<"\n";
		}
		else{
			cout<<jl[i]<<"\n";
		}
	}
	return 0;
} 

详细

answer.code: In function ‘void solve()’:
answer.code:123:51: error: no match for ‘operator[]’ (operand types are ‘long long int [200055]’ and ‘std::vector<long long int>’)
  123 |                                 cout<<"k"<<" "<<jl[ln[t]][p[t]]<<" 333 ";
      |                                                   ^