| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
请高手指点一下,哪个地方错了.#include <stdio.h>
#include <string.h>
#define R_MAX 101
#define C_MAX 101
#define H_MAX 11000
typedef struct{
int high;
int row;
int col;
long value;
}node_t;
node_t node[H_MAX];
node_t two[R_MAX][C_MAX];
int R,C;
void h_sort(void)
{
int i,j;
long temp,pos;
node_t t_node;
for(i=0;i<R*C-1;i++)
{
temp=node[i].value;
pos=i;
for(j=i+1;j<R*C;j++){
if(temp>node[j].value){
temp=node[j].value;
pos=j;
}
}
t_node=node[pos];
node[pos]=node[i];
node[i]=t_node;
}
}
void deal_with(void)
{
int i;
int max;
node_t u,l,r,d;
long r1,c1,v1,h1;
max=1;
for(i=0;i<R*C;i++)
{
r1=node[i].row;
c1=node[i].col;
v1=node[i].value;
h1=1;
if(r1>0){/*有up节点*/
u=two[r1-1][c1];
if(u.value<v1){
if(h1<u.high+1){
h1=u.high+1;
}
}
}
if(r1<R-1){/*有down节点*/
d=two[r1+1][c1];
if(d.value<v1){
if(h1<d.high+1){
h1=d.high+1;
}
}
}
if(c1>0){/*有left节点*/
l=two[r1][c1-1];
if(l.value<v1){
if(h1<l.high+1){
h1=l.high+1;
}
}
}
if(c1<C-1){/*有right节点*/
r=two[r1][c1+1];
if(r.value<v1){
if(h1<r.high+1){
h1=r.high+1;
}
}
}
two[r1][c1].high=h1;
if(max<h1)max=h1;
}
printf("%d\n",max);
}
int main(int argc, char* argv[])
{
int i,j;
scanf("%d %d",&R,&C);
for(i=0;i<R;i++){
for(j=0;j<C;j++){
scanf("%d",&node[i*R+j].value);
node[i*R+j].row=i;
node[i*R+j].col=j;
two[i][j].value=node[i*R+j].value;
two[i][j].high=1;
}
}
h_sort();
deal_with();
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator