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 |
Re:TNN的不是读写文件没注释掉就是选了G++~贡献脑残代码,几十MS~比较菜的代码~#include<iostream> #include<algorithm> #include<fstream> using namespace std; struct Node{ int value, x, y; }node[10010]; int cmp(const void *a, const void *b) { Node *c = (Node *)a; Node *d = (Node *)b; return c->value - d->value; } int main() { //fstream cin("a.txt"); int r, c, num[110][110], goal[110][110], k = 0; memset(num, 0, sizeof(num)); memset(goal, 0, sizeof(goal)); cin>>r>>c; for (int i = 1; i <= r; i++) for (int j = 1; j <= c; j++) { cin>>num[i][j]; node[k].value = num[i][j]; node[k].x = i; node[k].y = j; k++; } qsort(node, k, sizeof(node[0]), cmp); int total = -100; for (int i = 0; i < k; i++) { int max = 0; if (num[node[i].x][node[i].y] > num[node[i].x][node[i].y - 1] && max < goal[node[i].x][node[i].y - 1]) max = goal[node[i].x][node[i].y - 1]; if (num[node[i].x][node[i].y] > num[node[i].x - 1][node[i].y] && max < goal[node[i].x - 1][node[i].y]) max = goal[node[i].x - 1][node[i].y]; if (num[node[i].x][node[i].y] > num[node[i].x][node[i].y + 1] && max < goal[node[i].x][node[i].y + 1]) max = goal[node[i].x][node[i].y + 1]; if (num[node[i].x][node[i].y] > num[node[i].x + 1][node[i].y] && max < goal[node[i].x + 1][node[i].y]) max = goal[node[i].x + 1][node[i].y]; if (max > 0)goal[node[i].x][node[i].y] = max + 1; else goal[node[i].x][node[i].y] = 1; if (total < goal[node[i].x][node[i].y]) total = goal[node[i].x][node[i].y]; } cout<<total<<endl; return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator