QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#20672#2426. The Xana coupAlinxesterCompile Error//C2.2kb2022-02-17 15:29:062022-05-18 04:09:54

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-05-18 04:09:54]
  • 评测
  • [2022-02-17 15:29:06]
  • 提交

answer

#include<bits/stdc++.h>
#define Alinxester qwq
#define int long long
#define N ((int)1e5+2)
using namespace std;
namespace STD{
	inline int read(){
		int s=0,t=1;
		char ch=getchar();
		while(ch<'0'||ch>'9'){if(ch=='-') t=-1;ch=getchar();}
		while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+ch-'0',ch=getchar();
		return s*t;
	}
	inline void write(int x){
	    if(x<0) x=~(x-1),putchar('-');
	    if(x>9) write(x/10);
	    putchar(x%10+'0');
	}
	inline void swap(int &a,int &b){a^=b^=a^=b;}
	inline int min(int a,int b){return ((a<b)?a:b);}
	inline int max(int a,int b){return ((a>b)?a:b);}
	struct Pair{int fir,sec;};
	inline bool Pair_cmp(Pair x,Pair y){
		if(x.fir==y.fir) return x.sec<y.sec;
		return x.fir<y.fir;
	}
	#define EDGE_N ((int)2e5+2)
	#define INF ((int)1e18+2)
	struct Edge{int to,next,dis;}edge[EDGE_N];
	int head[EDGE_N],pos;
	inline void add_edge(int u,int v,int w){edge[++pos]=(Edge){v,head[u],w},head[u]=pos;}
	inline void add_edge(int u,int v){edge[++pos]=(Edge){v,head[u],0},head[u]=pos;}
	inline void pre_max_0(int *a,int len){for(int i=0;i<len;++i) a[i]=INF;}
	inline void pre_min_0(int *a,int len){for(int i=0;i<len;++i) a[i]=-INF;}
	inline void pre_max(int *a,int len){for(int i=1;i<=len;++i) a[i]=INF;}
	inline void pre_min(int *a,int len){for(int i=1;i<=len;++i) a[i]=-INF;}
}
using namespace STD;
int n,col[N],ans;
int f[N][2][2],g[N][2][2],h[2][2];
inline void dfs(int u,int fa){
	for(int i=0;i<2;++i)
		for(int j=0;j<2;++j)
			g[u][i][j]=INF;
	g[u][0][0]=g[u][1][0]=0;
	for(int i=head[u];i;i=edge[i].next){
		int v=edge[i].to;
		if(v==fa) continue;
		dfs(v,u);
		for(int j=0;j<2;++j)
			for(int k=0;k<2;++k)
				h[j][k]=g[u][j][k];
		for(int j=0;j<2;++j)
			for(int k=0;k<2;++k)
				g[u][j][k]=min(h[j][k]+f[v][0][j],h[j][1-k]+f[v][1][j]);
	}
	for(int j=0;j<2;++j)
		for(int k=0;k<2;++k)
			f[u][j][col[u]^j^k]=g[u][j][k]+j;
}
signed main(){
	n=read();
	int u,v;
	for(int i=1;i<n;++i) u=read(),v=read(),add_edge(u,v);
	for(int i=1;i<=n;++i) col[i]=read();
	for(int i=0;i<N;++i)
		for(int j=0;j<2;++j)
			for(int k=0;k<2;++k)
				f[i][j][k]=INF;
	dfs(1,0);
	ans=min(f[1][0][0],f[1][1][0]);
	if(ans>n) return printf("impossible\n"),0;
	printf("%lld\n",ans);
return 0;
}

详细

answer.code:1:9: fatal error: bits/stdc++.h: No such file or directory
 #include<bits/stdc++.h>
         ^~~~~~~~~~~~~~~
compilation terminated.