zoukankan      html  css  js  c++  java
  • usaco 月赛 2005 january watchcow

    2013-09-18 08:13

    //By BLADEVIL 
    var
        n, m                :longint;
        pre, other          :array[0..50010] of longint;
        last                :array[0..10010] of longint;
        flag                :array[0..50010] of boolean;
        tot                 :longint;
        ans                 :array[0..10010] of longint;
        i                   :longint;
        l                   :longint;
    
    procedure connect(x,y:longint);
    begin
        inc(l);
        pre[l]:=last[x];
        last[x]:=l;
        other[l]:=y;
    end;
    
    procedure init;
    var
        i                   :longint;
        x, y                :longint;
    begin
        read(n,m);
        for i:=1 to m do
        begin
            read(x,y);
            connect(x,y);
            connect(y,x);
        end;
    end;
    
    procedure dfs(x:longint);
    var
        p, q                :longint;
    begin
        q:=last[x];
        while q<>0 do
        begin
            p:=other[q];
            if not flag[q] then
            begin
                flag[q]:=true;
                dfs(p);
            end;
            q:=pre[q];
        end;
        inc(tot);
        ans[tot]:=x;
    end;
    
    begin
        assign(input,'watch.in'); reset(input);
        assign(output,'watch.out'); rewrite(output);
        init;
        dfs(1);
        for i:=tot downto 1 do writeln(ans[i]);
        close(input); close(output);
    end.
  • 相关阅读:
    AD读取Excel新建客户邮箱的测试环境部署有感
    云端转发邮箱
    AD活动目录操作软件设计节选
    14)
    13)
    行级,块级,空
    12)
    11)
    10)
    9)
  • 原文地址:https://www.cnblogs.com/BLADEVIL/p/3433509.html
Copyright © 2011-2022 走看看