从小事看国人和外国人的素质差异
2010-03-29 09:03
176 查看
/* THE PROGRAM IS MADE BY PYY */ /*----------------------------------------------------------------------------// Copyright (c) 2012 panyanyany All rights reserved. URL : http://acm.hdu.edu.cn/showproblem.php?pid=1548 Name : 1548 A strange lift Date : Sunday,April 1, 2012 Time Stage : many hours Result: 5685230 2012-04-01 18:17:43 Accepted 1548 0MS 244K 1689 B C++ pyy Test Data : Review : 一开始一直MLE,真是莫名奇妙啊,完全不知道原因,在原代码的基础上改来改去不得其法。 后来直接重新写一遍,酸酸地AC了…… //----------------------------------------------------------------------------*/ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> #include <vector> #include <algorithm> #include <iostream> #include <queue> using namespace std ; #define MEM(a, v) memset (a, v, sizeof (a)) // a for address, v for value #define max(x, y) ((x) > (y) ? (x) : (y)) #define min(x, y) ((x) < (y) ? (x) : (y)) #define INF (0x3f3f3f3f) #define MAXN (202) #define MAXM (100) #define DB /##/ #define LL __int64 #define _IN(a) (0 < (a) && (a) <= n) #define CHECK(a) (_IN(a) && -1 == step[(a)]) #define LOAD(a) do { q.push(a); step[(a)] = step[t] + 1; } while(0) int n, a, b; int step[MAXN], next[MAXN]; void bfs() { int t, na, nb; queue<int> q; q.push(a); while (!q.empty()) { t = q.front(); q.pop(); if (t == b) break; na = t + next[t]; nb = t - next[t]; if (CHECK(na)) { LOAD(na); /* q.push(na); step[na] = step[t] + 1; */ } if (CHECK(nb)) { LOAD(nb); /* q.push(nb); step[nb] = step[t] + 1; */ } } } int main() { int i; while (scanf("%d", &n), n) { scanf("%d %d", &a, &b); MEM(step, -1); step[a] = 0; for (i = 1; i <= n; ++i) scanf("%d", &next[i]); bfs(); printf ("%d\n", step[b]); } return 0; }
相关文章推荐
- 这是所谓的国人的素质!!!
- 外国人推荐本国人到google-china 下载破解软件
- 细节决定成败,小事反应素质
- 外国人义卖助残丢了X国人的脸?
- 论国人的素质和一个公司的商业道德
- 少年之文明与国之文明——---从奥运会看国人素质之飞跃
- 猪八戒让网赚国人再也不用看外国人…
- 别老让外国人拿咱国人说事。。。
- 高级程序员的基本素质
- 进程、会话、连接之间的差异 .+数据库资料
- 心怀大爱做小事---德雷莎修女
- Silverlight与WPF中BeginInvoke的差异
- CVT户外素质拓展
- Server系列20:浅谈KMS与MAK在域环境中的应用差异
- Hyper-v之利用差异磁盘快速创建多个虚拟机
- 成为项目经理的一些基本素质
- 外国人在中国永久居留享有相关待遇的办法
- Dom sax pull解析xml的差异
- 外国人如何看“剩女”
- Unity3D与cocos2d-x之间的区别和差异