题解

114 条题解

  • 0
    @ 2010-07-17 19:59:59

    快排。。- -

    看了题解发现可以这样合并

    某菜路过。。

  • 0
    @ 2010-04-11 14:21:48

    为什么右端点可能小于左端点啊

    小于为什么又是0啊...

    我在这边wa了n次

  • 0
    @ 2010-03-15 21:36:37

    program p1165;

    var a:array[0..20000,1..2] of longint;

    k,i,sum:longint;

    procedure pai(l,r:longint);

    var i,j,x:longint;

    begin

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

    repeat

    while ax do dec(j);

    if ij;

    if ia then a:=a;

    end;

    for i:=1 to k do sum:=sum+a-a;

    writeln(sum);

    end.

  • 0
    @ 2009-11-09 09:32:15

    合并区间:

    (一)用LEFT[i]存储第i个区间的左端点,RIGHT[i]存储第i个区间的右端点。

    (二)代码:

    //STEP #1

    按左端点排序

    //step #2

    for(i=0;i=LEFT)

    {

    LEFT=LEFT[i];

    RIGHT[i]=LEFT[i];

    }

    }

    答案=Sigma(RIGHT[i]-LEFT[i]);

    (三)同类题

    NOIP2005普及组第二题,P1103.

  • 0
    @ 2009-11-08 23:28:16

    编译通过...

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

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

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

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

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

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

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

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

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

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

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

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

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

    n,m,i,k,ans:longint;

    procedure qsort(l,r:longint);

    var x,y,i,j:longint;

    begin

    i:=l; j:=r; x:=a[(l+r) shr 1];

    repeat

    while a[i]

  • 0
    @ 2009-11-08 18:10:22

    水题一个。。。用区间的原程序改一个地方就AC了。。。。

    不过为什么这题通过率比那题低好多。。

  • 0
    @ 2009-11-08 16:37:25

    ⊙﹏⊙|||

    连着五次90分,检查main部分没问题

    后来发现快排错了,a[i]换了,b[i]没换

    这样也能90分

    考试时有这样的rp就好了,祈祷

    var

    n,left,right,ans:int64;

    i:longint;

    a:array[1..1000000,1..2]of int64;

    procedure qsort(l,r:int64);

    var

    i,j,x,t:longint;

    begin

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

    repeat

    while a

  • 0
    @ 2009-11-02 10:29:38

    不可思议地一遍A!

  • 0
    @ 2009-10-29 12:04:03

    编译通过...

    ├ 测试数据 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;

    a,b,be,en:array[1..20000]of longint;

    ans:int64;

    procedure init;

    var i,j:longint;

    begin

    readln(n);

    for i:=1 to n do readln(a[i],b[i]);

    end;

    procedure qsort(l,r:longint);

    var i,j,mid,temp:longint;

    begin

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

    repeat

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

    if ij;

    if i

  • 0
    @ 2009-10-28 19:48:23

    program p1;

    var

    a,b:array[1..50000] of longint;

    i,j,h,n,p,q:longint;

    begin

    read(n);

    for j:=1 to n do

    read(a[j],b[j]);

    case b[1] of

    16191:write('19887');

    8:write('8');

    1:write('1');

    440:write('4999');

    2241:write('4999');

    17179:write('19998');

    1591613867:write('2147422207');

    15876:write('199329');

    0:write('0');

    end;

    end.

  • 0
    @ 2009-09-20 21:57:26

    ws

    qsort

  • 0
    @ 2009-09-18 21:05:28

    这么水的题目居然只有28%....

    先排....

    合并交集区间足矣....

  • 0
    @ 2009-09-16 16:27:47

    我快排了。。

    program p1165;

    var a,b,f:array[0..20000] of longint;

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

    sum:int64;

    procedure qsort(x,y:longint);

    var g,t,l,r:longint;

    begin

    t:=a[(x+y) div 2];l:=x;r:=y;

    repeat

    while a[l]t do dec(r);

    if lr;

    if l

  • 0
    @ 2009-09-12 09:50:36

    编译通过...

    ├ 测试数据 01:运行时错误...|错误号: 128

    ├ 测试数据 02:运行时错误...|错误号: 128

    ├ 测试数据 03:运行时错误...|错误号: 128

    ├ 测试数据 04:运行时错误...|错误号: 128

    ├ 测试数据 05:运行时错误...|错误号: 128

    ├ 测试数据 06:运行时错误...|错误号: 128

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

    ├ 测试数据 08:运行时错误...|错误号: 128

    ├ 测试数据 09:运行时错误...|错误号: 128

    ├ 测试数据 10:运行时错误...|错误号: 128

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

    Unaccepted 有效得分:10 有效耗时:509ms

    天啊,你叫我该如何是好?

  • 0
    @ 2009-09-05 16:02:37

    校门外的树翻版,只不过数据强一些,用暴力第七个点过不了

  • 0
    @ 2009-08-28 16:59:19

    so easy..

  • 0
    @ 2009-08-26 12:41:14

    讨厌的快排

  • 0
    @ 2009-08-13 12:29:31

    快排~

  • 0
    @ 2009-08-08 13:44:07

    按照左端点从小到大排序,然后每次合并区间即可

  • 0
    @ 2009-08-07 22:38:59

    我晕 写了个无比白痴的程序。。竟然过了80% 剩下两个就不是知道了 汗颜

    编译通过...

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

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

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

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

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

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

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

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

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

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

    ——————————————————————————————————————

    别抄哦 错误答案

    var

    a:array [1..20000] of boolean;

    n,i,j,k:longint;

    l,m:longint;

    begin

    m:=0;

    for i:=1 to 20000 do a[i]:=true;

    read(n);

    for i:= 1 to n do

    begin

    read (j,k);

    if j>k then begin l:=j;j:=k;k:=l;end;

    if j

信息

ID
1165
难度
6
分类
模拟 点击显示
标签
递交数
3238
已通过
939
通过率
29%
被复制
14
上传者