题解

163 条题解

  • 0
    @ 2008-10-04 20:27:33

    数据范围绝对有问题de说。。。(╰_╯)

    大家都放心大胆地改500000吧。。。-_-!

  • 0
    @ 2008-10-01 10:48:20

    我居然WA了两边……快排多了就会乱套……qsort1...qsort2...qsort3...@%$%@水题多了就会变成大海。

    编译通过...

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

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

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

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

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

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

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

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

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

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

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

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

    三次快排居然都秒杀 while 1+1=2 do inc(RP);

    赞美 lora templer

  • 0
    @ 2008-09-30 09:57:51

    3次快排 秒杀掉

    自己感觉麻烦了 不知有没有更简单的方法

  • 0
    @ 2008-09-26 16:13:54

    我原来开100000 80分啊

    开成500000 就AC了

    什么破数据啊

    var

    a,b,c,f:array[1..500000]of longint;

    i,j,k,p,n,m:longint;

    procedure sort(l,r: longint);

    var

    i,j,x,y: longint;

    begin

    i:=l; j:=r; x:=a[(l+r) div 2];

    repeat

    while a[i]>x do inc(i);

    while x>a[j] do dec(j);

    if not(i>j) then

    begin

    y:=a[i]; a[i]:=a[j]; a[j]:=y;

    inc(i); dec(j);

    end;

    until i>j;

    if lb[j] do dec(j);

    if not(i>j) then

    begin

    y:=b[i]; b[i]:=b[j]; b[j]:=y;

    y:=c[i]; c[i]:=c[j]; c[j]:=y;

    inc(i); dec(j);

    end;

    until i>j;

    if l

  • 0
    @ 2008-09-25 17:40:40

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

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

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

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

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

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

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

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

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

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

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

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

  • 0
    @ 2008-09-24 15:39:40

    编译通过...

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

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

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

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

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

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

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

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

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

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

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

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

    两个猥琐的快排

    然后就是累加

    测试官方数据时发现

    貌似输出最后要加一个空格

    我把加空格后的程序发上来

    过了

    不知道不加会不会过

    为了AC

    大家慎重考虑

  • 0
    @ 2008-09-23 15:39:31

    var

    a,b,c,d:array[1..1000000] of longint;

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

    procedure qsort(l,r:longint);

    var

    i,j,k,t,mid:longint;

    begin

    mid:=a[(l+r) shr 1];

    i:=l;

    j:=r;

    repeat

    while a[i]mid do dec(j);

    if ij;

    if il then qsort(l,j);

    end;

    begin

    read(n,m);

    for i:=1 to n do

    read(A[i]);

    qsort(1,n);

    for i:=1 to m do

    begin

    read(b[i]);

    c[i]:=b[i];

    end;

    sort(1,m);

    for i:=1 to m do

    d[b[i]]:=m-i+1;

    for i:=1 to m do

    begin

    j:=n-d[c[i]]+1;

    s:=0;

    while j>0 do

    begin

    s:=s+a[j];

    j:=j-m;

    end;

    write(s,' ');

    end;

    end.

    排1次就够了。 。。。

  • 0
    @ 2008-09-22 23:32:51

    编译通过...

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

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

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

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

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

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

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

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

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

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

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

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

    郁闷中,居然有两组不是秒杀...

  • 0
    @ 2008-09-22 16:36:57

    编译通过...

    ├ 测试数据 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-18 15:02:29

    就是多次排序

  • 0
    @ 2008-09-21 21:23:57

    编译通过...

    ├ 测试数据 01:运行时错误...| 错误号: 216 | 存取非法

    ├ 测试数据 02:运行时错误...| 错误号: 216 | 存取非法

    ├ 测试数据 03:运行时错误...| 错误号: 216 | 存取非法

    ├ 测试数据 04:运行时错误...| 错误号: 216 | 存取非法

    ├ 测试数据 05:运行时错误...| 错误号: 216 | 存取非法

    ├ 测试数据 06:运行时错误...| 错误号: 216 | 存取非法

    ├ 测试数据 07:运行时错误...| 错误号: 216 | 存取非法

    ├ 测试数据 08:运行时错误...| 错误号: 216 | 存取非法

    ├ 测试数据 09:运行时错误...| 错误号: 216 | 存取非法

    ├ 测试数据 10:运行时错误...| 错误号: 216 | 存取非法

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

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

    program p1445;

    type

    point=^node;

    node=record

    z:longint;

    data:longint;

    m:longint;

    next:point;

    end;

    var

    head1,p1,q1,g1:point;

    head2,p2,q2,g2:point;

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

    procedure creat(t:integer;var head:point);

    var

    p,q,g:point;

    x,a:integer;

    begin

    for a:=1 to t do

    begin

    read(x);

    new(q);

    q^.z:=a;

    q^.data:=x;

    q^.next:=nil;

    p:=head;

    g:=nil;

    while (p^.data > x) and (pnil) do

    begin

    g:=p;

    p:=p^.next;

    end;

    if g=nil then

    begin

    head:=q;

    q^.next:=p;

    end

    else

    if p=nil then

    g^.next:=q

    else

    if p=head then

    begin

    q^.next:=head;

    head:=q;

    end

    else

    begin

    q^.next:=p;

    g^.next:=q;

    end;

    end;

    end;

    begin

    head1:=nil;

    head2:=nil;

    readln(n,m);

    creat(n,head1);

    creat(m,head2);

    p2:=head2;

    if p2nil then

    p2:=p2^.next

    else

    p2^.next:=head2;

    p1:=head1;

    p2:=head2;

    while p1nil do

    begin

    if p2=nil then

    p2:=head2;

    p2^.m:=p2^.m+p1^.data;

    p1:=p1^.next;

    p2:=p2^.next;

    end;

    p2:=head2;

    j:=1;

    while j

  • 0
    @ 2008-09-21 19:51:25

    猥琐的快排

  • 0
    @ 2008-09-21 14:23:07

    编译通过...

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

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

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

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

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

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

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

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

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

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

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

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

    两次快排的简单程序,我是第500个过的人!!!

  • 0
    @ 2008-09-21 00:23:17

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

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

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

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

    ├ 测试数据 05:答案错误... ├ 标准行输出

     ├ 错误行输出

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

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

    ├ 测试数据 08:运行时错误...| 错误号: 216 | 存取非法

    ├ 测试数据 09:运行时错误...| 错误号: 216 | 存取非法

    ├ 测试数据 10:运行时错误...| 错误号: 216 | 存取非法

    为什么我的qsort*3出现错误??

    program q_apple;

    type arr=record

    id,weight,s:integer;

    end;

    var

    n,m:integer;

    a,b:integer;

    apple:array [1..100000] of integer;

    taotao:array[1..100000] of arr;

    procedure qsort_id(l,r:integer);

    var

    i,j,x:integer;

    k:arr;

    begin

    i:=l;

    j:=r;

    x:=taotao[(i+j) div 2].id;

    repeat

    while taotao[i].idx do dec(j);

    if ij;

    if i

  • 0
    @ 2008-09-20 19:31:35

    编译通过...

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

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

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

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

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

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

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

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

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

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

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

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

    为什么用堆排就全过了……用快排就后面4个都堆栈溢出呢?哪个大牛解释一下?

    ========我的快排========

    program p1445;

    var

    a,b,c,r:array[1..100000] of qword;

    i,n,m:longint;

    k:qword;

    procedure ready;

    begin

    readln(n,m);

    for i:=1 to n do read(a[i]);

    for i:=1 to m do

    begin

    read(b[i]);

    c[i]:=i;

    end;

    end;

    procedure pai1(x,y:longint);

    var

    o,p,e,f,w:longint;

    begin

    o:=x;

    p:=y;

    w:=random(y-x)+x;

    k:=a[w];

    a[w]:=a[x];

    a[x]:=k;

    while p>o do

    begin

    while (p>o) and (a[p]>=a[x]) do dec(p);

    while (p>o) and (a[o]o then

    begin

    k:=a[p];

    a[p]:=a[o];

    a[o]:=k;

    end;

    end;

    if (x>o-20) and (xa[f] then

    begin

    k:=a[e];

    a[e]:=a[f];

    a[f]:=k;

    end;

    end

    else

    if xy) and (p+1a[f] then

    begin

    k:=a[e];

    a[e]:=a[f];

    a[f]:=k;

    end;

    end

    else

    if p+1o do

    begin

    while (p>o) and (b[p]o) and (b[o]>b[x]) do inc(o);

    if p>o then

    begin

    k:=b[p];

    b[p]:=b[o];

    b[o]:=k;

    k:=c[p];

    c[p]:=c[o];

    c[o]:=k;

    end;

    end;

    if (x>o-20) and (x

  • 0
    @ 2008-09-20 14:14:55

    编译通过...

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

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

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

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

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

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

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

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

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

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

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

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

    结果还可以,就是程序猥琐了点……

  • 0
    @ 2008-09-20 08:46:25

    program p1;

    const maxn=100000;

    var t,i,j,n,m:longint;

      wa,wb:array[1..maxn] of longint;

      id:array[1..maxn] of longint;

      sum:array[1..maxn] of longint;

    procedure qsort_wa(s,t:longint);

    var i,j,x,y:longint;

    begin

    i:=s;j:=t;x:=wa[(i+j) div 2];

    repeat

      while wa[i]>x do inc(i);

      while wa[j]x do inc(i);

      while wb[j]

  • 0
    @ 2008-09-19 19:35:33

    编译通过...

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

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

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

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

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

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

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

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

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

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

    两次才AC......

  • 0
    @ 2008-09-19 16:17:16

    编译通过...

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

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

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

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

    ├ 测试数据 05:答案错误... ├ 标准行输出

     ├ 错误行输出

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

    ├ 测试数据 07:运行时错误...| 错误号: 103 | 文件未打开

    ├ 测试数据 08:运行时错误...| 错误号: 103 | 文件未打开

    ├ 测试数据 09:运行时错误...| 错误号: 103 | 文件未打开

    ├ 测试数据 10:运行时错误...| 错误号: 103 | 文件未打开

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

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

    何为“文件未打开”???

  • 0
    @ 2008-09-19 15:37:40

    哎 数据定义小了 连者3个超时

    终于AC了

信息

ID
1445
难度
5
分类
模拟 点击显示
标签
递交数
2844
已通过
879
通过率
31%
被复制
6
上传者