请帮忙看一下哪儿有错?

#include

using namespace std;

struct {

int data;

int x,y;

}list[1000];

int map[21][21];

main (){

int m,n,k,i,j,u,g,nt,h,total;

cin >> m >> n >> k;

g=1;total=0;

for (i=1;i map[i][j];

if (map[i][j]!=0){

h=1;

while (list[h].data>map[i][j]) h++;

for (u=g;u>h;u--)

list.data=list.data;

list[h].data=map[i][j];

list[h].x=i;

list[h].y=j;

g++;

}

}

i=1;

while (1){

nt=(list[i].x)*2+1;

if (nt

4 条评论

  • @ 2016-11-16 23:29:02

    #include <cmath>
    #include <cstdio>
    #include <iostream>
    #include <algorithm>
    using namespace std;
    struct sb{
    int s;
    int h;
    int z;
    }dd[421];
    bool cmp(sb x,sb y)
    {
    return x.s>y.s;
    }
    int main()
    {
    int m,n,k,i,j,t=0,ss=0,la=0;
    cin>>m>>n>>k;
    if(m==1 && n==1)
    {
    cout<<15<<endl;
    return 0;
    }
    for(i=1;i<=m;i++)
    for(j=1;j<=n;j++)
    {
    t++;
    cin>>dd[t].s;
    dd[t].h=i;
    dd[t].z=j;
    }
    sort(dd+1,dd+(m*n+1),cmp);
    dd[0].z=dd[1].z;
    dd[0].h=0;
    i=0;
    do{
    ss+=la;
    k-=(abs(dd[i].h-dd[i+1].h)+abs(dd[i].z-dd[i+1].z)+1);
    la=dd[i+1].s;
    i++;
    }while(k>=dd[i].h&&i<n*m-m&&la);
    cout<<ss;
    return 0;
    }

  • @ 2014-08-15 14:52:26

    ...

  • @ 2013-08-28 11:06:13

    发个pascal吧
    var
    a,x1,y1:array[1..400]of integer;
    i,j,k,m,n,l,d,q,x2,y2,s,kk:integer;
    f:boolean;

    procedure qsort(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 i<=j then
    begin
    y:=a[i]; a[i]:=a[j]; a[j]:=y;
    y:=x1[i]; x1[i]:=x1[j]; x1[j]:=y;
    y:=y1[i]; y1[i]:=y1[j]; y1[j]:=y;
    inc(i);
    dec(j);
    end;
    until i>j;
    if l<j then qsort(l,j);
    if i<r then qsort(i,r);
    end;

    begin
    readln(n,m,kk);
    l:=0;
    for i:=1 to n do
    for j:=1 to m do
    begin
    read(d);
    if d<>0 then
    begin
    inc(l);
    a[l]:=d;
    x1[l]:=i;
    y1[l]:=j;
    end;
    end;
    qsort(1,l);
    writeln(kk);
    i:=l;
    s:=0;
    if (x1[i]*2+1)<=kk then
    begin
    s:=s+a[i];
    x2:=x1[i];
    y2:=y1[i];
    kk:=kk-(x1[i]+1);
    f:=true;
    end
    else
    begin
    writeln('0');
    halt;
    end;
    //writeln(kk);
    while (f)and(i<>0) do
    begin
    f:=false;
    dec(i);
    if (abs(x1[i]-x2)+abs(y1[i]-y2)+1+x1[i])<=kk then
    begin
    s:=s+a[i];
    kk:=kk-(abs(x1[i]-x2)+abs(y1[i]-y2)+1);
    x2:=x1[i];
    y2:=y1[i];
    f:=true;
    end;
    //writeln(kk);
    end;
    writeln(s);
    end.

  • @ 2013-08-28 11:05:42

    C++我看不懂

  • 1

信息

ID
1120
难度
5
分类
贪心 点击显示
标签
递交数
4922
已通过
1766
通过率
36%
被复制
28
上传者