码迷,mamicode.com
首页 > 其他好文 > 详细

BZOJ 1603 Usaco 打谷机

时间:2017-09-08 20:27:02      阅读:147      评论:0      收藏:0      [点我收藏+]

标签:usaco   main   can   class   clu   struct   logs   div   nod   

感觉像是一道DFS图论的题目,建模并不难=w=

#include <cstdio>
#include <algorithm>

struct node{
    int u,v,val;
}Edge[10005];

int n,Out[10005];

void dfs(int x,int now){
    if(x>=n) return;
    int v = Edge[x].v;
    if(Edge[x].val)    now = (now+1)%2;
    Out[v] = now;
    dfs(v,now);
    return;
}

int main(){
    scanf("%d",&n);
    for(int i=1;i<n;i++){
        int x,y,z;
        scanf("%d%d%d",&x,&y,&z);
        Edge[x].v=y;
        Edge[x].val=z;
    }
    dfs(1,0);
    printf("%d\n",Out[n]);
}

 

BZOJ 1603 Usaco 打谷机

标签:usaco   main   can   class   clu   struct   logs   div   nod   

原文地址:http://www.cnblogs.com/OIerLYF/p/7496142.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!