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.
  • 相关阅读:
    Asp.Net Core- 配置组件详解
    ASP.Net Core-依赖注入IoC
    ASP.Net Core-TagHelpers
    Selenium-等待
    Selenium-js
    Selenium-actions
    Selenium-基础操作
    Selenium-简介
    装饰者模式
    设计模式-策略者模式
  • 原文地址:https://www.cnblogs.com/BLADEVIL/p/3433509.html
Copyright © 2011-2022 走看看