题解

203 条题解

  • 0
    @ 2008-10-29 21:45:01

    编译通过...

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

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

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

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

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

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

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

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

    我真是太太太太太蠢了。。。。。。。第二问居然用贪心去做。。。

  • 0
    @ 2008-10-29 00:36:09

    晕.1999年给的测试数据比这个多1...就按多一个交的...

    为啥第二问是不降-1啊??没想明白...

  • 0
    @ 2008-10-28 22:25:59

    #include

    using namespace std ;

    int main(){

    short int a[100] , i , j , s , n ;

    char c ;

    for ( n = 0 ; cin >> a[n] ; n++ ) cin >> c ;

    short int f[n] , g[n] , topf , topg ; //f是最长非递增子序列,g是最长递增子序列

    topf = topg = 0 ;

    for ( i = 0 ; i < n ; i++ ) {

    for ( j = 0 ; j < topf ; j++ )

    if ( f[j] < a[i] ) { f[j] = a[i] ; break ; }

    if ( j == topf ) f[topf++] = a[i] ; }

    for ( i = 0 ; i < n ; i++ ) {

    for ( j = 0 ; j < topg ; j++ )

    if ( g[j] > a[i] ) { g[j] = a[i] ; break ; }

    if ( j == topg ) g[topg++] = a[i] ; }

    cout

  • 0
    @ 2008-10-26 20:04:52

    编译通过...

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

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

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

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

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

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

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

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

    第一次少读了一个数

    竟然有分

    汗。。。

    我用dp+贪心

    不懂为什么是最长非升序列+最长非降序列

  • 0
    @ 2008-10-22 14:56:35

    严重鄙视出题者~~~~

    为什么输出要加逗号

  • 0
    @ 2008-10-20 21:24:57

    严重鄙视出题者:

    为什么要加字符串处理?!

  • 0
    @ 2008-10-13 18:33:17

    program Project1;

    var mis,dp:array[1..20]of integer;

    c:char;

    s:string;

    i,temp,temp1,n,j:integer;

    function max(a,b:integer):integer;

    begin

    if a>b

    then exit(a)

    else exit(b);

    end;

    begin

    temp1:=1;

    n:=1;

    i:=1;

    s:='';

    fillchar(mis,sizeof(mis),0);

    while not eoln do

    begin

    read(c);

    s:=s+c;

    if c=','

    then inc(n);

    end;

    i:=length(s);

    temp:=0;

    j:=n;

    while i>=1 do

    begin

    if s[i]','

    then begin

    inc(temp,temp1*(ord(s[i])-48));

    temp1:=temp1*10;

    end

    else begin

    mis[j]:=temp;

    dec(j);

    temp:=0;

    temp1:=1;

    end;

    dec(i);

    end;

    mis[1]:=temp;

    fillchar(dp,sizeof(dp),0);

    dp[1]:=1;

    for i:=1 to n do

    begin

    for temp:=i-1 downto 1 do

    if mis[i]=mis[temp]

    then dp[i]:=max(dp[i],dp[temp]+1);

    if dp[i]=0

    then dp[i]:=1;

    end;

    temp1:=0;

    for i:=1 to n do

    temp1:=max(temp1,dp[i]);

    write(temp1-1);

    end.

    累死人了...

  • 0
    @ 2008-10-13 17:20:04

    编译通过...

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

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

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

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

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

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

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

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

  • 0
    @ 2008-10-12 09:12:52

    虽然数据范围很小,但是为了练习算法,用了NlogN的DP。

    第一问就是最长非升序列

    第二问就是最长非降序列

  • 0
    @ 2008-10-09 15:55:08

    #include

    using namespace std;

    int main()

    {

    int i,j,n,x[100],d[100]; //x[]表示各个导弹高度,d[i]记录为第 i 枚导弹被拦截之后,

    //这套系统最多还能拦截的导弹数(包含被拦截的第 i 枚)。

    int dmax=0,xh=0; //记录拦截的最大个数以及第一个被拦截的序号

    cin>>n; //输入拦截的导弹数

    for(i=0;i>x[i]; //输入每个导弹的高度

    d[i]=1; //初始值都设为1

    }

    for(i=n-2;i>=0;i--) //动态规划算法,递归实现,从后面向前循环

    {

    for(j=i+1;j

  • 0
    @ 2008-10-06 11:17:59

    本人学C语言的,很是笨,看到了大家都AC了,可自己能想到方法就是过不了,现求一个C语言AC的程序,哪个大牛能发给我呀。

  • 0
    @ 2008-10-04 14:53:07

    最长不升子序列

  • 0
    @ 2008-10-03 18:24:24

    编译通过...

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

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

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

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

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

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

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

    一次ac,呵呵,第一问用是求最长递减数列用动规!!第二问用贪心,呵呵,真有意思,两问竟然没联系。

  • 0
    @ 2008-10-08 18:43:06

    编译通过...

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

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

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

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

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

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

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

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

    最长不升子序列 + 字符串处理。这是提高组的,小学生也会做。

  • 0
    @ 2008-10-01 19:51:46

    水啊

    15,16,15,16,16

    dp+贪心应该不能过的啊 !!!!

  • 0
    @ 2008-09-24 14:58:22

    编译通过...

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

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

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

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

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

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

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

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

    幽默的第二问。。。

    最长非降子序列,最长上升子序列-1

    。。。

  • 0
    @ 2008-09-23 19:39:41

    编译通过...

    ├ 测试数据 01:答案错误...

     ├ Hint: 注意观察样例数据 ├ 标准行输出

     ├ 错误行输出

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

    ├ 测试数据 03:答案错误...

     ├ Hint: 注意考虑边界情况 ├ 标准行输出

     ├ 错误行输出

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

     ├ 错误行输出

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

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

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

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

    type arr=set of 1..20;

    var z,z1:string;

    a,b:array[1..20] of integer;

    i,j,jj,ii,l,x,x1,xx,max,k:integer;v:boolean;

    s:array[1..20] of arr;

    ch:char; kk:arr;

    begin

    i:=1; x:=0;

    readln(z);

    l:=length(z);

    for j:=1 to l do

    if z[j]=',' then

    begin

    inc(x); z1:='';

    for jj:=1 to j-i do

    begin

    z1:=z1+z;

    end;

    val(z1,a[x]);

    i:=j+1;

    end;

    inc(x); z1:='';

    for jj:=1 to l-i+1 do

    begin

    z1:=z1+z;

    end;

    val(z1,a[x]); {======================================= }

    for i:=1 to x do begin b[i]:=1;s[i]:=[i];end;

    for i:=x-1 downto 1 do

    begin

    max:=0; v:=false;

    for j:=i+1 to x do

    if (a[i]>=a[j])and (maxmax then begin max:=b[i];k:=i;end; for i:=1 to x do

    if i in s[k] then b[i]:=0;

    write(max,',');

    xx:=0;

    for i:=1 to x do

    if b[i]>0 then

    begin

    inc(xx);k:=a[i];

    for j:=i+1 to x do

    if a[j]

  • 0
    @ 2008-09-20 20:52:26

    program ex;

    var

    i,j,k,n:integer;

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

    f:text;

    function max:longint;

    var

    i,j,k:integer;

    m:longint;

    begin

    m:=1;

    for i:=n-1 downto 1 do

    begin

    k:=1;

    for j:=i+1 to n do

    if (b[j]+1>k)and(a[i]>a[j]) then

    begin

    k:=b[j]+1;

    if m

  • 0
    @ 2008-09-11 20:51:54

    logics_space,你到底会不会贪心啊,真SB!!!!!

    4 5 6 7 8 14 15 16 1 2 3 9 10 11 12 13

    贪心:4 5 6 7 8 14 15 16

       1 2 3 9 10 11 12 13

    多次动态:4 5 6 7 8 9 10 11 12 13

       14 15 16

       1 2 3

    记录号 Flag 得分 记录信息 环境 评测机 程序提交时间

    R823831 Accepted 100 From PROGRAM qxz-

      P1303 FPC Vivid Puppy 2008-9-11 20:44:46

    编译通过...

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

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

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

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

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

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

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

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

    program v1303

    type

    v=array[1..20] of integer

    var

    i,j,n,max1,min1,k,jk:integer

    s:ansistring

    s1:string

    a,max,min:v

    begin

    assign(input,'daodan.in');reset(input);

    assign(output,'daodan.out');rewrite(output);

    readln(s);

    n:=1;

    for i:=1 to length(s) do

    begin

    if s[i]=',' then n:=n+1;

    if (s[i]='0') then

    begin

    s1:=s[i];

    val(s1,j);

    a[n]:=a[n]*10+j;

    end;

    end;

    {============================================================================

    max[1]:=1;max1:=1;

    for i:=2 to n do

    begin

    max[i]:=1;

    for j:=1 to i-1 do

    begin

    if (a[i]

  • 0
    @ 2008-09-04 11:49:43

    我看不懂解题报告,我的方法就是维护序列,就这样简单

信息

ID
1303
难度
6
分类
动态规划 | 单调性DP 点击显示
标签
递交数
7583
已通过
2014
通过率
27%
被复制
11
上传者