题解

203 条题解

  • 0
    @ 2009-10-22 20:22:45

    WA掉了很多次发现是输出没有逗号。。。

    还有要注意只有一枚导弹的情况

  • 0
    @ 2009-10-21 20:12:18

    居然有4个点的最长不上升子序列结果都是dp[n]。。。。。。。。

    我脑残了。。。

  • 0
    @ 2009-10-18 20:12:14

    总算过了...2个小时...

    似乎有人能证明第二问等价于求最长下降子序列,可惜那个人不是我。

    注意时间,这么水的题,这么弱的我...

  • 0
    @ 2009-10-12 22:10:20

    program daodan;

    var

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

    ch:char;

    s:string;

    a,f,g:array[0..200] of longint;

    begin

    readln(s);

    s[length(s)+1]:=',';

    i:=0;j:=0;

    while length(s)>0 do begin

    inc(i);

    if s[i]=','

    then begin

    inc(j);

    val(copy(s,1,i-1),a[j]);

    delete(s,1,i);

    i:=0;

    end;

    end;

    n:=j;

    for i:=1 to n do

    f[i]:=1;

    for i:=2 to n do

    for j:=1 to i-1 do

    if (a[i]a[j]) and (f[i]max

    then max:=f[i];

    writeln(max-1);

    end.

    别信底下的,害人的

  • 0
    @ 2009-10-12 22:11:46

    var

    s:string;

    f,a:array[0..1000] of longint;

    k,x,max,i,j,min,l:longint;

    begin

    readln(s);

    s[length(s)+1]:=',';

    k:=0;j:=0;

    while length(s)>0 do begin

    inc(k);

    if s[k]=','

    then begin

    inc(j);

    val(copy(s,1,k-1),a[j]);

    delete(s,1,k);

    k:=0;

    end;

    end;

    for i:=1 to k do f[i]:=1;

    for i:=k-1 downto 1 do

    for j:=i+1 to k do

    if (a[i]>=a[j]) and (f[j]+1>f[i]) then f[i]:=f[j]+1;

    max:=0;

    for i:=1 to k do

    if f[i]>max then max:=f[i];

    writeln(max);

    for i:=1 to k do f[i]:=1;

    for i:=k-1 downto 1 do

    for j:=i+1 to k do

    if (a[i]f[i]) then f[i]:=f[j]+1;

    max:=0;

    千万别信底下的

    for i:=1 to k do

    if f[i]>min then min:=f[i];

    write(min);

    end.

  • 0
    @ 2009-10-11 09:15:28

    var i,j,k,l,n,o,max,m:longint;

    a,f:array [0..2000] of longint;

    s:string;

    begin

    i:=1;

    read(s);

    while pos(',',s)0 do begin

    val(copy(s,1,pos(',',s)-1),a[i]);

    delete(s,1,pos(',',s));

    inc(i);

    end;

    val(s,a[i]);

    n:=i;

    max:=0;

    fillchar(f,sizeof(f),0);

    for i:=1 to n do

    f[i]:=1;

    for i:= n-1 downto 1 do begin

    m:=0;

    for j:=i to n do begin

    if a[j]m then m:=f[j];

    end;

    inc(f[i],m);

    end;

    for i:=1 to n do

    if f[i]>f[0] then f[0]:=f[i];

    write(f[0],',');

    fillchar(f,sizeof(f),0);

    for i:= 1 to n do f[i]:=1;

    for i:= n-1 downto 1 do begin

    m:=0;

    for j:=i to n do begin

    if a[j]>a[i] then

    if f[j]>m then m:=f[j];

    end;

    inc(f[i],m);

    end;

    for i:=1 to n do

    if f[i]>f[0] then f[0]:=f[i];

    writeln(f[0]-1);

    end.

  • 0
    @ 2009-10-09 18:18:28

    写得很辛苦啊!

    #include

    #include

    using namespace std;

    const int Max_n = -1000000000;

    int f[1000], h[1000], w[1000],dmax = 0, one,i,j,k,n,yy[256],xb , xb1 ;

    string str;

    int work()

    {

    h[one] = Max_n;

    while(one != w[one])

    {

    h[w[one]] = Max_n;

    one = w[one];

    }

    }

    int kk()

    {

    dmax = 1;

    for(i = xb1; i >= 1; i -- )

    f[i] = 1;

    for(i = xb1; i >= 1; i --)

    {

    w[i] = i;

    for(j = i + 1; j dmax)

    {

    dmax = f[i];

    one = i;

    }

    }

    }

    }

    int main()

    {

    int total = 0, ans = 0, l;

    xb = 1, xb1 = 1;

    cin >> str;

    l = str.length();

    for(i = 0; i < l; i++)

    {

    if(str[i] != ',')

    {

    yy[xb] = str[i] - '0';

    xb ++;

    }

    else

    {

    int qq = 1;

    for(int g = xb - 1; g >= 1; g--)

    {

    h[xb1] += yy[g] * qq;

    qq *= 10;

    }

    ++xb1;

    xb = 1;

    }

    }

    int qq = 1;

    for(int g = xb - 1; g >= 1; g-- )

    {

    h[xb1] += yy[g] * qq;

    qq *= 10;

    }

    kk();

    cout

  • 0
    @ 2009-10-06 17:36:25

    program p1303(input,output);

    var

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

    i,ans,max,l,j,k,m,n:integer;

    s:string;

    begin

    ans:=0;

    max:=0;

    readln(s);

    i:=1;

    while true do

    begin

    l:=pos(',',s);

    if l=0

    then begin val(s,a[i]);break;end;

    val(copy(s,1,l-1),a[i]);

    inc(i);

    delete(s,1,l);

    end;

    for j:=1 to 20 do

    f[j]:=1;

    for l:=2 to i do

    for j:=1 to l-1 do

    if (a[j]>=a[l])and(f[j]>=f[l])

    then f[l]:=f[j]+1;

    for j:=1 to i do

    if f[j]>max

    then max:=f[j];

    write(max,',');

    for j:=1 to i do

    begin

    k:=a[j];

    if k=0

    then continue;

    for l:=j+1 to i do

    begin

    if (a[l]

  • 0
    @ 2009-10-06 10:23:42

    Flag    Accepted

    题号   P1303

    类型(?)   动态规划

    通过   3109人

    提交   10001次

    通过率   31%

    难度   2

    这道题让我刷高一点AC 不错

  • 0
    @ 2009-10-05 22:50:37

    编译通过...

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

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

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

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

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

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

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

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

    狂怒中!!! 水题一道浪费我13次!!!!!

    var n,t,i,j,max,sum,min,p,code:integer;

    s,s1:string;

    a,f,mo:array[0..20]of integer;

    o:boolean;

    begin

    read(s); n:=0; p:=1;

    while p>0 do

    begin

    inc(n);

    p:=pos(',',s);

    if p>0 then s1:=copy(s,1,p-1) else s1:=s;

    delete(s,1,p);

    val(s1,a[n],code);

    end;

    for i:=1 to n do

    write(a[i],' ');

    for i:=1 to n do

    f[i]:=1;

    for i:=2 to n do

    for j:=1 to i-1 do

    if (a[i]f[i]) then

    f[i]:=f[j]+1;

    max:=0;

    for i:=1 to n do

    if f[i]>max then max:=f[i];

    write(max,',');

    sum:=1;

    mo[1]:=a[1]; mo[0]:=maxint;

    for i:=2 to n do

    begin

    o:=false; min:=0;

    for j:=1 to sum do

    if mo[j]>=a[i] then

    if mo[j]

  • 0
    @ 2009-10-05 16:20:36

    奇水无比.......

  • 0
    @ 2009-09-02 01:56:56

    编译通过...

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

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

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

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

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

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

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

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

    大家注意边界条件,当真好可以拦截所有导弹时,就不需要求最长上升数列了,直接输出0!

  • 0
    @ 2009-08-29 00:28:59

    一遍秒

  • 0
    @ 2009-08-26 10:56:25

    6,5,1,7,3,2没有问题啊。

    2套装置可以搞定啊。

    6,5,1

    7,3,2

    只要两套就行了。

    问的是增加多少套,注意一下。

  • 0
    @ 2009-08-24 11:33:03

    #include

    using namespace std;

    #define maxn 1000

    typedef int dp[maxn+1];

    void DP1(int n,dp a,int &max1)

    {

    int i,j = 0;int p;

    int b[maxn+1];

    for(i=0;i=1 ;i--)

    {

    max1 = 0;

    for(j = i+1; j max2))

    b[i] = b[j] + 1, max2 = b[j];

    }

    }

    max2 = 0;

    for(i = 1;i max2) max2 = b[i], p = i;

    }

    void input(dp &a,int &n)

    {

    char ch;

    int i =0;

    for(i = 1; cin>>a[i]; i++)

    {

    cin.get(ch);

    }

    n = i - 1;

    }

    void output(int max1,int max2)

    {

    cout

  • 0
    @ 2009-08-23 21:38:26

    太水了,不要技巧。还2J体!

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

    program p1303;

    var

    i,j,n,m,x,l,xi:integer;

    fire,num,ok:array[1..20]of integer;

    v:char;

    s,t:string;

    begin

    read(s);

    i:=1; n:=0;

    while ilength(s));

    val(t,fire[n+1]);

    inc(i); inc(n);

    end;

    x:=n;

    num[1]:=1;

    for i:=2 to x do

    begin

    m:=0;n:=0;

    for j:=1 to i-1 do

    if (fire[j]>fire[i])and(num[j]>m) then

    m:=num[j];n:=j;

    num[i]:=m+1;

    end;

    m:=0;

    for i:=1 to x do

    if num[i]>m then m:=num[i];

    write(m,',');

    l:=x;m:=0;

    for i:=1 to x do ok[i]:=maxint;

    repeat

    m:=m+1;

    for i:=1 to x do

    if (ok[m]>=fire[i])and(fire[i]0) then begin ok[m]:=fire[i];fire[i]:=0;l:=l-1; end;

    until l=0;

    write(m-1);

    end.

  • 0
    @ 2009-08-18 18:32:17

    var

    st :string;

    b :array[1..255]of boolean;

    i,k,j,lab,star,max,ans,step :longint;

    a,c,longest :array[1..20]of longint;

    procedure init;

    begin

    fillchar(b,sizeof(b),true);

    for i:=1 to length(st) do

    if st[i]=',' then b[i]:=false; k:=1;

    for i:=1 to length(st) do

    begin

    if b[i]=true then begin

    a[k]:=a[k]*10+ord(st[i])-ord('0'); end

    else inc(k)end;

    end;

    begin

    readln(st);init;

    longest[1]:=1;

    for i:=2 to k do begin

    longest[i]:=1;

    for j:=i-1 downto 1 do

    begin

    if (a[j]>=a[i])and(longest[j]+1>longest[i]) then

    longest[i]:=longest[j]+1;

    end;

    end; max:=-1;

    for i:=1 to k do if longest[i]>max then max:=longest[i];

    write(max);

    c[1]:=a[1];step:=2;ans:=1;

    while stepstar then star:=c[i];

    for i:=1 to ans do

    if (c[i]>=a[step])and(c[i]

  • 0
    @ 2009-08-18 13:57:56

    水题,鉴定完毕。

  • 0
    @ 2009-08-17 14:57:56

    为什么测试2过不了……

    到现在还没有过

    就不能告诉我为什么84吗?我快疯掉了;

信息

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