Archive for 五月 4th, 2008

SPOJ 1846 — Project File Dependencies (code: PFDEP)

Posted on 五月 4th, 2008.

题意见下:
Killa.sqybi 20:01:20就是说Killa.sqybi 20:01:21有n个任务Killa.sqybi 20:01:24m个限制条件Killa.sqybi 20:01:37每个限制条件都这样描述:t0 k t1 t2 .. tkKilla.sqybi 20:01:46表示t0的完成需要他Killa.sqybi 20:01:52需要t1..tk的完成Killa.sqybi 20:02:03让你输出一个完成序列Killa.sqybi 20:02:12保证靠前的数越小越好Killa.sqybi 20:02:16没了
就这样…建立个有向图随便写个n^2的topsort就AC了.注意如果当前有多个点入度为0,那么选择编号最小的.
{ SPOJ 1846; Project File Dependencies; PFDEP - sqybi’s code - Topsort}//for my winstyprogram pfdep_sqybi;  const    nn = 100;
  var    n, m, i, j, k, x, y, t: longint;    ind: array[1..nn]of longint;    d: array[1..nn, 1..nn]of boolean;
  begin    readln(n, m);    […]

Read Full Post | Make a Comment ( None so far )

SPOJ 1436 — Is it a tree (code: PT07Y)

Posted on 五月 4th, 2008.

给出一个无向图,问是不是树.一个DFS完事,竟然0.4分…POJ 1308和这个只有输入格式不同.
不多解释.
{ SPOJ 1436; Is it a tree; PT07Y - sqybi’s code - DFS}//for my winstyprogram pt07y_sqybi;  const    nn = 10000;
  var    n, m, i, x, y, tot: longint;    f, head, adj, next: array[1..nn*2]of longint;
  procedure addEdge(x, y: longint);    begin      inc(tot);      adj[tot] := y;      next[tot] := head[x];      head[x] := tot;    end;
  function […]

Read Full Post | Make a Comment ( None so far )

Liked it here?
Why not try sites on the blogroll...