131 条题解

  • 0
    @ 2009-09-05 12:11:17

    program p1446;

    var a:array[1..100,1..100] of longint;

    i,j,k,l,m,n,p,q,r,sum:longint;

    begin

    readln(n,m);

    for i:=1 to n do

    begin

    for j:=1 to n do

    a:=10000000;

    a:=0;

    end;

    for i:=1 to m do

    begin readln(p,q);

    if pq then begin a[p,q]:=1;a[q,p]:=1; end;

    end;

    for i:=1 to n do

    for j:=1 to n do

    if ij then begin

    for k:=1 to n do

    if (kj) and (ki) then

    if a+a[k,j]

  • 0
    @ 2009-09-01 23:03:51

    floyd+

    最短路只是代表权值最小,并不代表路径唯一(可以多路径)

  • 0
    @ 2009-08-27 19:29:05

    最后错的90分的注意最后一组数据有点猥琐

    初始化的时候i ==j也初始化成INTMAX 而不是0 否则最后一组会误输出0

    #include

    using namespace std;

    #define maxn 100

    #define INTMAX 20000000

    int map[maxn+10][maxn+10];

    int n,m,start,end;

    void floyd()

    {

    int i,j,k;

    for(k = 1;k n>>m;

    for(i = 1;i >b;

    map[a] =map[a]= 1;

    num++;}

    cin.clear();

    floyd();

    int tot;

    cin >> p;

    for(j=1; j>a>>b;

    for(int k=1;k

  • 0
    @ 2009-08-26 22:15:34

    Floyd~

  • 0
    @ 2009-08-19 20:14:29

    编译通过...

    ├ 测试数据 01:答案正确... 0ms

    ├ 测试数据 02:答案正确... 0ms

    ├ 测试数据 03:答案正确... 0ms

    ├ 测试数据 04:答案正确... 0ms

    ├ 测试数据 05:答案正确... 0ms

    ├ 测试数据 06:答案正确... 0ms

    ├ 测试数据 07:答案正确... 0ms

    ├ 测试数据 08:答案正确... 0ms

    ├ 测试数据 09:答案正确... 0ms

    ├ 测试数据 10:答案正确... 0ms

    ---|---|---|---|---|---|---|---|-

    Accepted 有效得分:100 有效耗时:0ms

    第188题

  • 0
    @ 2009-08-18 21:56:38

    编译通过...

    ├ 测试数据 01:答案正确... 0ms

    ├ 测试数据 02:答案正确... 0ms

    ├ 测试数据 03:答案正确... 0ms

    ├ 测试数据 04:答案正确... 0ms

    ├ 测试数据 05:答案正确... 0ms

    ├ 测试数据 06:答案正确... 0ms

    ├ 测试数据 07:答案正确... 0ms

    ├ 测试数据 08:答案正确... 0ms

    ├ 测试数据 09:答案正确... 0ms

    ├ 测试数据 10:运行超时|无输出...

    ---|---|---|---|---|---|---|---|-

    Unaccepted 有效得分:90 有效耗时:0ms

    请问各位为什么会最后一组数据出这问题,怎么改?

    var

    a:array[1..100,1..100] of integer;

    s:array[1..1000] of integer;

    n,m,p,i,j,k,x,y:integer;

    begin

    read(n);

    for i:=1 to n do

    for j:=1 to n do

    begin

    a:=0;

    end;

    readln(m);

    for i:=1 to m do

    begin

    read(x);readln(y);a[x,y]:=1;a[y,x]:=1;

    end;

    for k:=1 to n do

    for i:=1 to n do

    for j:=1 to n do

    begin

    if (ij) and (ik) and (jk) then

    if ((a+a[k,j]

  • 0
    @ 2009-08-14 17:20:10

    切。。。开始我给[RED]D[X,Y][/RED]赋的是[RED]MAXLONGINT[/RED]。结果改了半天都不知道是哪里的问题。后来才发现原来溢出了

  • 0
    @ 2009-08-10 21:37:30

    我5858585858

  • 0
    @ 2009-08-06 10:16:22

    program yu;

    var a:array[1..100,1..100] of integer;

    v:array[1..100] of boolean;

    n,m,i,j,min,k,p,x,y:integer;

    begin

    read(n,m);

    for i:=1 to m do

    begin

    read(x,y);

    if xy then

    begin

    a[x,y]:=1;

    a[y,x]:=1;

    end;

    end;

    for k:=1 to n do

    begin

    fillchar(v,sizeof(v),false);

    v[k]:=true;

    for i:=2 to n do

    begin

    min:=maxint;

    for j:=1 to n do

    if (not v[j]) and(a[k,j]0) and (a[k,j]a[k,p]+a[p,j]) or(a[k,j]=0) then

    a[k,j]:=a[k,p]+a[p,j];

    end;

    end;

    readln(n);

    for i:=1 to n do

    begin

    read(x,y);

    writeln(a[x,y]+1);

    end;

    end.

    请问错在哪?什么叫分流交汇?谢谢

  • 0
    @ 2009-08-04 22:55:32

    第一次用FLOYED,竟然一次AC。。。。

    汗。。。。

  • 0
    @ 2009-08-04 01:39:18

    题意太模糊了。。。

    然后某人称自己样例都没过,还ac

    让我误以为样例错了

    直接floyed交了上去

    吃个o分。。。。。。

    再看一下众牛解释才知题目怎么回事

    一遍ac。。。。。。

    无语。。。。。。。。。。。

  • 0
    @ 2009-08-02 19:08:11

    这个……看上去就是个Floyd……

  • 0
    @ 2009-08-02 15:04:00

    编译通过...

    ├ 测试数据 01:答案正确... 0ms

    ├ 测试数据 02:答案正确... 0ms

    ├ 测试数据 03:答案正确... 0ms

    ├ 测试数据 04:答案正确... 0ms

    ├ 测试数据 05:答案正确... 0ms

    ├ 测试数据 06:答案正确... 0ms

    ├ 测试数据 07:答案正确... 0ms

    ├ 测试数据 08:答案正确... 0ms

    ├ 测试数据 09:答案正确... 0ms

    ├ 测试数据 10:答案正确... 0ms

    ---|---|---|---|---|---|---|---|-

    Accepted 有效得分:100 有效耗时:0ms

    题意难懂啊

  • 0
    @ 2009-08-01 20:29:20

    样例什么意思啊?

    貌似不对呀

  • 0
    @ 2009-07-31 16:06:57

    哈哈 第 2008 个提交的

    算是最简单的题目了

    Floyd就可全过 ~~~

    虽然 测试数据都没过

    但AC了

    编译通过...

    ├ 测试数据 01:答案正确... 0ms

    ├ 测试数据 02:答案正确... 0ms

    ├ 测试数据 03:答案正确... 0ms

    ├ 测试数据 04:答案正确... 0ms

    ├ 测试数据 05:答案正确... 0ms

    ├ 测试数据 06:答案正确... 0ms

    ├ 测试数据 07:答案正确... 0ms

    ├ 测试数据 08:答案正确... 0ms

    ├ 测试数据 09:答案正确... 0ms

    ├ 测试数据 10:答案正确... 0ms

    ---|---|---|---|---|---|---|---|-

    Accepted 有效得分:100 有效耗时:0ms

  • 0
    @ 2009-07-26 00:36:59

    想起当年费了好大劲写了个dfs求最短路。。。。。

    如今会了Floyd,写起来实在太爽了。。。。就是此题的语文水平有点。。。。。

    101题留念~~

  • 0
    @ 2009-07-25 21:34:41

    var

    g:array[1..100,1..100] of integer;

    i,j,k,m,n,x,y,ans:longint;

    begin

    readln(n,m);

    for i:=1 to m do

    begin

    read(x,y);

    g[x,y]:=1;

    g[y,x]:=1;

    end;

    for k:=1 to n do

    for i:=1 to n do

    for j:=1 to n do

    if (ij) and (ki) and (ik) then

    if ((g+g[k,j]

  • 0
    @ 2009-07-25 15:55:41

    I'm NO.888,发发发.HAHA~

  • 0
    @ 2009-07-14 14:11:39

    莫名其妙的AC。。。

    这个bug很无奈,初值过大了,1e6就够了,maxlongint过大,导致计算错误 写的时候要写1000000,以免NO compiled

    还要注意:g[a,b]:=1; g:=1;因为是无向图

    ans初值为2,因为a,b都要在ans里

    继续努力!A快一点,A更多的题,A更多的好题!!

  • 0
    @ 2009-07-11 19:01:44

    编译通过...

    ├ 测试数据 01:答案正确... 0ms

    ├ 测试数据 02:答案正确... 0ms

    ├ 测试数据 03:答案正确... 0ms

    ├ 测试数据 04:答案正确... 0ms

    ├ 测试数据 05:答案正确... 0ms

    ├ 测试数据 06:答案正确... 0ms

    ├ 测试数据 07:答案正确... 0ms

    ├ 测试数据 08:答案正确... 0ms

    ├ 测试数据 09:答案正确... 0ms

    ├ 测试数据 10:答案正确... 0ms

    ---|---|---|---|---|---|---|---|-

    Accepted 有效得分:100 有效耗时:0ms

    program p1(input,output);

    const max=1000000;

    var

    i,j,k,n,m,ans,x,y,p:longint;

    f:array[1..100,1..100] of longint;

    begin

    assign(input,'p1.in');

    reset(input);

    assign(output,'p1.out');

    rewrite(output);

    readln(n,m);

    for i:=1 to n do

    for j:=1 to n do

    f:=max;

    for i:=1 to m do

    begin

    readln(x,y);

    f[x,y]:=1;

    f[y,x]:=1;

    end;

    for k:=1 to n do

    for i:=1 to n do

    for j:=1 to n do

    if (ki)and(ij)and(kj) then

    if f>f+f[k,j] then f:=f+f[k,j];

    readln(p);

    for i:=1 to p do

    begin

    readln(x,y);

    ans:=2;

    for j:=1 to n do

    if (f[x,j]max)and(f[j,y]max)and(f[x,y]=f[x,j]+f[j,y]) then inc(ans);

    writeln(ans);

    end;

    close(input);

    close(output);

    end.

    SO EASY!!!!!!!

信息

ID
1446
难度
5
分类
图结构 | 最短路 点击显示
标签
递交数
3509
已通过
1328
通过率
38%
被复制
10
上传者