| ||||||||||
| 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 | |||||||||
哈哈,我爱暴力594ms#include <iostream>
using namespace std;
int main()
{
int hang,lie,hight[101][101],max=1,Continue=1;
long path[101][101];
cin >> hang >> lie;
for (int i=0;i<hang;i++)
{
for(int j=0;j<lie;j++)
{
path[i][j]=1;
}
}
for (int i=0;i<hang;i++)
{
for(int j=0;j<lie;j++)
{
cin >> hight[i][j];
}
}
while (Continue)
{
Continue=0;
for (int i=0;i<hang;i++)
for(int j=0;j<lie;j++)
{
// to one point,but the directions??
if (j>0) if (hight[i][j]>hight[i][j-1]) if (path[i][j-1]>path[i][j]-1)
{
Continue=1;
path[i][j]=path[i][j-1]+1;
if (max<path[i][j]) max=path[i][j];
}
if (j<lie-1) if (hight[i][j]>hight[i][j+1]) if (path[i][j+1]>path[i][j]-1)
{
Continue=1;
path[i][j]=path[i][j+1]+1;
if (max<path[i][j]) max=path[i][j];
}
if (i>0) if (hight[i][j]>hight[i-1][j]) if (path[i-1][j]>path[i][j]-1)
{
Continue=1;
path[i][j]=path[i-1][j]+1;
if (max<path[i][j]) max=path[i][j];
}
if (i<hang-1) if (hight[i][j]>hight[i+1][j]) if (path[i+1][j]>path[i][j]-1)
{
Continue=1;
path[i][j]=path[i+1][j]+1;
if (max<path[i][j]) max=path[i][j];
}
}
}
cout <<max;
system("pause");
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator