题解

58 条题解

  • 0
    @ 2009-09-05 17:10:00

    就是一个递归啊,用数组存一下。。。。要细心点T^T

    话说hoi这三题真是好啊~~增长信心~~

  • 0
    @ 2009-09-03 23:38:35

    Vijos Sunny 0ms Accepted

    简单的一个递归吖 没什么特别的技巧

  • 0
    @ 2009-08-30 00:32:43

    发现一个目录就递归就去查找。

    为什么要用ansistring呢?

    每行不超过25是对的,数据是没错。。。

    但是我们递归的时候要把路径也迭代进去,就这么加呀加,加呀加,就超过string了。

    像这样的结果

    vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\vijos\I_LOVE_U.pas

    string肯定力不从心了啦。

    考试的时候没想到……………………

  • 0
    @ 2009-08-26 14:27:11

    seekeof有罪么

  • 0
    @ 2009-08-26 09:04:31

    编译通过...

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

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

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

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

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

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

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

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

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

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

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

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

    递归做,之前竟然WA了几次……

    var

    s:string;

    ss:array[1..3000]of string;

    k:longint;

    procedure make;

    var st:string;num,i:longint;

    begin

    if not(eof)then

    begin

    readln(st);

    if pos(' ',st)0 then

    begin

    val(copy(st,pos(' ',st)+1,length(st)-pos(' ',st)),num);

    st:=copy(st,1,pos(' ',st)-1);

    if num>0then

    begin

    k:=k+1;

    ss[k]:=st;

    for i:=1 to num do

    make;

    k:=k-1;

    end;

    end

    else begin

    if st=s then

    begin

    for i:=1 to k do

    write(ss[i],'\');

    writeln(st);

    end;

    end;

    end;

    end;

    begin

    readln(s);

    k:=0;

    while not(eof)do

    make;

    end.

  • 0
    @ 2009-08-25 22:32:42

    晕死....没用ansistring...50分..

  • 0
    @ 2009-08-25 22:11:57

    procedure ice(k:longint);

    var i,l,len:longint;

    t:string;

    begin

    if k1 then readln(x[k]);

    if pos('.',x[k])0 then

    begin

    if x[k]=s then

    for i:=1 to k do

    if i=k then writeln(x[i])

    else write(x[i],'\');

    exit;

    end;

    l:=pos(' ',x[k]);

    t:=copy(x[k],1,l-1);

    val(copy(x[k],l+1,length(x[k])-l+1),len);

    x[k]:=t;

    for i:=1 to len do ice(k+1);

    end;

    10分钟 ...

    MS

    果然很水

  • 0
    @ 2009-08-24 21:58:04

    被此题囧死,在此提醒大家,Vijos上万万不可用seekeof啊!!!

  • 0
    @ 2009-08-24 18:20:09

    此题太BT了……必须到3000才能ac

  • 0
    @ 2009-08-24 13:58:47

    我0分

    编译失败。。

    真没rp

    去掉一个分号就a了

  • 0
    @ 2009-08-24 09:33:46

    为什么啊,我把seekeof改成eof10分变20分了...我是用栈做的。

  • 0
    @ 2009-08-24 09:25:54

    编译通过...

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

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

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

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

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

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

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

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

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

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

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

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

    program ex;

    var i,j,n,count:longint;

    goal:string;

    ss:string;

    s:array[1..3000]of string;

    procedure print(t:longint);

    var i,j:longint;

    temp:string;

    begin

    for i:=1 to t-1 do

    begin

    temp:=copy(s[i],1,pos(' ',s[i])-1);

    write(temp,'\');

    end;

    writeln(s[t]);

    end;

    procedure search(a:longint);

    var i,j,n:longint;

    begin

    val(copy(s[a],pos(' ',s[a])+1,length(s[a])-pos(' ',s[a])),n);

    for i:=1 to n do

    begin

    readln(s[a+1]);

    if (pos('.',s[a+1])=0) and(copy(s[a+1],pos(' ',s[a+1])+1,length(s[a+1])-pos(' ',s[a+1]))'0')

    then search(a+1);

    if s[a+1]=goal then print(a+1);

    end;

    end;

    begin

    readln(goal);

    while not eof do

    begin

    readln(s[1]);

    if pos('.',s[1])=0 then search(1);

    if s[1]=goal then writeln(s[1]);

    end;

    end.

    递归=AC

    开始题目看的不全啊。。。

    无语。。。

  • 0
    @ 2009-08-24 09:14:14

    不用eof还不行,害我搞了N久才AC,用seekeof只有40

  • 0
    @ 2009-08-24 08:42:18

    栈的版本,调了好久,rp差

    readln(obj);

    top:=0;

    with stk[top] do

    begin

    path:='';

    shen:=maxn+1;

    end;

    while not eof do

    begin

    if stk[top].shen>0 then

    begin

    readln(s);

    dec(stk[top].shen);

    if pos('.',s)0 then

    begin

    with stk[top] do

    begin

    if s=obj then

    writeln(path+obj);

    end;

    end

    else

    begin

    i:=pos(' ',s);

    t1:=copy(s,1,i-1);

    t2:=copy(s,i+1,maxint);

    inc(top);

    with stk[top] do

    begin

    path:=stk[top-1].path+t1+'\';

    val(t2,shen);

    continue;

    end;

    end;

    end

    else

    dec(top);

    end;

  • 0
    @ 2009-08-24 08:15:07

    [red]

    飞过海可见光后果

  • 0
    @ 2009-08-24 07:31:26

    每行均少于25个字符

    这句有明显的误导作用。我想大概是指文件或文件夹名不超过25字符。加上数字就不止了。

  • 0
    @ 2009-08-23 23:13:47

    --b||

    在字符串处理中看有没有超过25位咯

    改了一下就AC了

  • 0
    @ 2009-08-23 22:01:08

    rp啊 ansistring才可以过啊

  • 0
    @ 2009-08-23 21:52:46

    请教&求助

    题目中的数据范围规定 每行字符数小于25,所以我用string[25]

    但是只有40分

    换成 string 就AC

    这是为什么??

  • 0
    @ 2009-08-23 21:09:19

    编译通过...

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

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

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

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

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

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

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

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

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

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

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

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

    第91个AC 的 ~ ~

    貌似都没代码的~ ~我贴个递归过程吧~ ~

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

    procedure init(str : string; tt,k : longint);

    var i , n , t : longint; s , ss : string; ch : char;

    begin

    if pos('.',str) 0 then

    begin

    a[tt] := str;

    f[tt] := k;

    end else

    begin

    s := str;

    n := pos(' ',s);

    ss := copy(s,1,n-1);

    a[tt] := ss;

    f[tt] := k;

    s := copy(s,n+1,length(s)-n);

    val(s,n);

    t := tot;

    for i := 1 to n do

    begin

    readln(s);

    inc(tot);

    init1(s,tot,tt);

    end;

    end;

    end;

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

    PS. 在读入一个新文件夹时要在递归过程外先处理一次,不然就会50~50~50~50……

信息

ID
1622
难度
5
分类
模拟 | 数据结构 | 点击显示
标签
递交数
1826
已通过
613
通过率
34%
被复制
3
上传者