题意:
方法:暴力
解析:
搜1到n路径上的边权异或和….
这几个水题刷的我有点…..
代码:
#include #include #include #include #define N 1010using namespace std;int n,cnt;struct node{ int from,to,val,next;}edge[N<<1];int head[N];void init(){ memset(head,-1,sizeof(head)); cnt=1;}void edgeadd(int from,int to,int val){ edge[cnt].from=from,edge[cnt].to=to,edge[cnt].val=val; edge[cnt].next=head[from]; head[from]=cnt++;}void dfs(int now,int fa,int worth){ if(now==n) { printf("%d\n",worth); exit(0); } for(int i=head[now];i!=-1;i=edge[i].next) { int to=edge[i].to; if(to==fa)continue; dfs(to,now,worth^edge[i].val); }}int main(){ init(); scanf("%d",&n); for(int i=1;i