2010-04-22から1日間の記事一覧

PKU 1575 Easier Done Than Said?

時間制限が緩いので条件を丁寧に書けば通る static int type[256]; bool check(const string& s) { vector<int> types; for (string::const_iterator it = s.begin(), itEnd = s.end(); it != itEnd; ++it) { types.push_back(type[*it]); } if (find(types.begin</int>…

PKU 2251 Dungeon Master

三次元の幅優先探索 広げる方向は6方向 static const int dx[] = {1, -1, 0, 0, 0, 0}; static const int dy[] = {0, 0, 1, -1, 0, 0}; static const int dz[] = {0, 0, 0, 0, 1, -1}; int main() { for (int X, Y, Z; cin >> X >> Y >> Z && (X || Y || Z);…

PKU 1915 Knight Moves

300x300なので幅優先探索で十分 広げる方向は8方向 static const int dx[] = {2, 2, 1, 1, -1, -1, -2, -2}; static const int dy[] = {1, -1, 2, -2, 2, -2, 1, -1}; int main() { int numberOfTests; cin >> numberOfTests; for (int testIndex = 0; testI…

PKU 1562 Oil Deposits

幅優先探索 広げる方向は8方向 static const int dx[] = {-1, -1, -1, 0, 0, 1, 1, 1}; static const int dy[] = {-1, 0, 1, -1, 1, -1, 0, 1}; int main() { for (int height, width; cin >> height >> width && (height || width); ) { static char maze[1…