| ||||||||||
| 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 | |||||||||
为什么回WA?!#include<iostream.h>
#include<string.h>
using namespace std;
//ifstream fin("1088.in");
//ofstream fout("1088.out");
int n, m, num;
int high[10001];
int x[10001], y[10001];
int dist[102][102];
int ans;
int max(int a, int b, int c, int d) {
if (a >= b && a >= c && a >= d) return a;
if (b >= a && b >= c && b >= d) return b;
if (c >= a && c >= b && c >= d) return c;
if (d >= a && d >= b && d >= c) return d;
};
void sort() {
int f, g, swap;
for (f = 1; f < num; f ++)
for (g = f + 1; g <= num; g ++)
if (high[f] < high[g]) {
swap = high[f]; high[f] = high[g]; high[g] = swap;
swap = x[f]; x[f] = x[g]; x[g] = swap;
swap = y[f]; y[f] = y[g]; y[g] = swap;
};
};
void init() {
num = n * m;
int f, g, h = 0;
for (f = 1; f <= n; f ++)
for (g = 1; g <= m; g ++) {
h ++;
x[h] = f; y[h] = g;
cin >> high[h];
};
memset(dist, sizeof(dist), 0);
ans = 0;
};
void work() {
sort();
int i, j, k;
for (i = 1; i <= num; i ++) {
dist[x[i]][y[i]] = max(dist[x[i] - 1][y[i]] + 1, dist[x[i] + 1][y[i]] + 1, dist[x[i]][y[i] - 1] + 1, dist[x[i]][y[i] + 1] + 1);
if (dist[x[i]][y[i]] > ans) ans = dist[x[i]][y[i]];
};
};
void print() {
cout << ans << endl;
};
int main() {
while (cin >> n >> m) {
init();
work();
print();
};
return 0;
};
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator