题解

273 条题解

  • 0
    @ 2012-07-21 15:09:58

    以为这题我没用动规 肯定挂了 结果:。。。。。。

    编译通过...

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

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

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

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

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

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

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

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

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

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

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

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

    弱弱的数据 n,m

  • 0
    @ 2012-07-20 23:26:02

    说实话。。我是通过自己模拟了一遍5*4的图才找出的方程。。

    大家试着人工找出这个数据的DP表就会知道方程了:

    1 0 1 1 0

    1 1 1 1 0

    1 1 1 1 1

    1 1 1 1 1

    方程:f[i][j]=min(f[j-1], min(f[i][j-1], f[j]))

  • 0
    @ 2010-04-13 18:20:47

    var b:array[0..1000,0..1000] of longint;

    a:array[1..1000,1..1000] of integer;

    n,m,i,j,s:longint;

    function min(x,y,z:longint):integer;

    var ss:longint;

    begin

    ss:=x;

    if ss>y then ss:=y;

    if ss>z then ss:=z;

    min:=ss;

    end;

    begin

    readln(n,m);

    for i:=1 to n do

    for j:=1 to m do

    read(a);

    for i:=1 to n do

    for j:=1 to m do

    if a=1 then

    begin

    b:=min(b,b,b)+1;

    if b>s then s:=b;

    end;

    writeln(s);

    end.

  • 0
    @ 2010-04-04 19:47:36

    f(i,j)=min(f(i-1,j-1),f(i,j-1),f(i-1,j))+1

    then cout

  • 0
    @ 2010-03-28 18:52:20

    program Project1;

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

    a,b:array[0..1000,0..1000] of integer;

    f:array[0..1000] of integer;

    procedure init;

    begin

    readln(n,m);

    for i:=1 to n do

    for j:=1 to m do read(a);

    for i:=1 to n do

    for j:=1 to m do

    if a=0 then b:=0

       else b:=b+1;

    end;

    procedure work;

    begin

    f[0]:=0;

    for i:=1 to n do begin

    x:=f+1;f[i]:=f;t:=0;

    for j:=1 to m do begin

    if b>=x then begin

    inc(t);

    if t=x then f[i]:=x;end

    else t:=0;

    end;

    end;

    writeln(f[n]);

    end;

    begin

    init;

    work;

    end.

  • 0
    @ 2010-03-17 22:31:57

    program p1057;

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

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

    function check(x,y,len:longint):boolean;

    var i,j:longint;

    begin

    for i:=x to x+len-1 do

    for j:=y to y+len-1 do

    if a=0 then exit(false);

    exit(true);

    end;

    begin

    readln(n,m);

    for i:=1 to n do

    for j:=1 to m do read(a);

    for i:=1 to n do

    for j:=1 to m do

    begin

    if n-imax) and check(i,j,k) then max:=k;

    end;

    writeln(max);

    end.

    可以秒杀...

  • 0
    @ 2010-03-16 23:04:15

    const

    xx:array[1..3]of integer=(-1,-1,0);

    yy:array[1..3]of integer=(0,-1,-1);

    var

    i,j,m,n:longint;

    a:array[0..1001,0..1001]of boolean;

    b:array[0..1001,0..1001]of longint;

    s:integer;

    max:longint;

    function f(x,y:longint):longint;

    var k:longint;

    begin

    if a[x,y] then exit(0);

    if b[x,y]>=0 then exit(b[x,y]);

    b[x,y]:=maxlongint;

    for k:=1 to 3 do

    if f(x+xx[k],y+yy[k])+1max then max:=f(i,j);

    writeln(max);

    end.

  • 0
    @ 2010-03-14 12:50:10

    program p1057;

    var a,f:array[1..500,1..500]of longint;

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

    function min(a,b,c:longint):longint;

    var l:longint;

    begin

    l:=a;

    if l>b then l:=b;

    if l>c then l:=c;

    min:=l;

    end;

    begin

    read(n,m);

    for i:=1 to n do

    for j:=1 to m do read(a);

    for i:=1 to n do begin

    if a[1,i]=1 then f[1,i]:=1;

    if a[1,i]=0 then f[1,i]:=0;

    end;

    for i:=1 to m do begin

    if a=1 then f:=1;

    if a=0 then f:=0;

    end;

    for i:=2 to n do

    for j:=2 to m do begin

    if a=1 then f:=min(f,f,f)+1;

    if a=0 then f:=0;

    end;

    k:=0;

    for i:=1 to n do

    for j:=1 to m do if f>k then k:=f;

    writeln(k);

    end.

  • 0
    @ 2009-11-11 16:50:26

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

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

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

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

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

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

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

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

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

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

  • 0
    @ 2009-11-10 18:14:56

    我同学想出来的方法,很妙喔~嘿嘿~0ms AC

    program Project1;

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

    a,b:array[0..1000,0..1000] of integer;

    f:array[0..1000] of integer;

    procedure init;

    begin

    readln(n,m);

    for i:=1 to n do

    for j:=1 to m do read(a);

    for i:=1 to n do

    for j:=1 to m do

    if a=0 then b:=0

    else b:=b+1;

    end;

    procedure work;

    begin

    f[0]:=0;

    for i:=1 to n do begin

    x:=f+1;f[i]:=f;t:=0;

    for j:=1 to m do begin

    if b>=x then begin

    inc(t);

    if t=x then f[i]:=x;end

    else t:=0;

    end;

    end;

    writeln(f[n]);

    end;

    begin

    init;

    work;

    end.

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

    神奇的DP!

    f:=min(f,f,f)+1;

    用min是为了求符合条件的最大正方形,画个图就懂了^_^

    编译通过...

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

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

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

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

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

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

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

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

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

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

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

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

    var

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

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

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

    function min(x,y,z:longint):longint;

    begin

    min:=x;

    if y

  • 0
    @ 2009-11-09 21:43:30

    哇!!泽钦!!!~~~~

  • 0
    @ 2009-11-09 20:48:14

    就是找 左 左上 上 找最小的+1就行了 最后搜一下

    要定义一个b数组。。全部清零!

    如:

    1 1 1 0

    0 1 1 1

    0 1 1 0

    1 1 0 1

    for i:=1 to n do

    for j:=1 to m do

    如果 a=1;那就 b:=f(b(左),b(左上),b(上))+1;

    最后搜一遍。看b数组哪个最大就是那个了额。。。

    大家应该看得懂额。。。。

  • 0
    @ 2009-11-05 23:01:03

    编译通过...

    ├ 测试数据 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-11-05 13:49:28

    编译通过...

    ├ 测试数据 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-11-03 15:41:06

    4646个,呵呵

    找左,上,左上

    三个中最小的一个

    画画图看看

  • 0
    @ 2009-11-03 01:32:01

    什么啊,这都过了,晕死!

    Program P1057(Input,Output);

    Var

    i,j : longint;

    m,n : longint;

    k,c : longint;

    g : array[1..1000,1..1000] of 0..1;

    Procedure Init;

    var

    i,j : longint;

    cc : longint;

    begin

    k := 0;

    readln(n,m);

    for i := 1 to n do

    begin

    for j := 1 to m do read(g);

    readln;

    end;

    end;

    Function Avai(i,j,k : longint) : boolean;

    var

    p,q : longint;

    begin

    for p := i to i+k-1 do

    for q := j to j+k-1 do

    if g[p,q]=0 then exit(False);

    exit(True);

    end;

    Procedure Try;

    var

    i,j : longint;

    begin

    for i := 1 to n do

    for j := 1 to m do

    begin

    if i+k>n then exit;

    if j+k>n then break;

    while Avai(i,j,k+1) do inc(k);

    end;

    end;

    BEGIN

    Init;

    Try;

    writeln(k);

    readln;

    END.

  • 0
    @ 2009-11-02 21:31:14

    #include

    #include

    #include

    #include

    int n,m;

    int a[1010][1010];

    int judge(int i,int j,int l);

    main()

    {

      

      

       int i,j,l=1,flag;

       scanf("%d%d",&n,&m);

       for(i=0;i

  • 0
    @ 2009-11-02 17:19:21

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

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

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

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

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

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

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

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

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

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

    DP万岁!!!!!

    f:=min(f,f,f)+1;

    就解决了!!!!!!

  • 0
    @ 2009-11-02 15:29:44

    #include

    #include

    #include

    #include

    int n,m;

    int a[1010][1010];

    int judge(int i,int j,int l);

    main()

    {

    int i,j,l=1,flag;

    scanf("%d%d",&n,&m);

    for(i=0;i

信息

ID
1057
难度
4
分类
动态规划 点击显示
标签
(无)
递交数
6650
已通过
3067
通过率
46%
被复制
8
上传者