2010-05-18から1日間の記事一覧

PKU 1826 The Best Farm

深さ優先探索 タイルを二次元配列で持たせることができないのでハッシュマップを使って持たせている 時間がギリギリのためscanf()を使用した #ifdef _MSC_VER #include <hash_set> #include <hash_map> using namespace stdext; #else #include <ext/hash_set> #include <ext/hash_map> using namespace __gnu</ext/hash_map></ext/hash_set></hash_map></hash_set>…

PKU 1146 ID Codes

C++ならnext_permutation()で終り int main() { string line; while (getline(cin, line) && line != "#") { if (next_permutation(line.begin(), line.end())) { cout << line << endl; } else { cout << "No Successor" << endl; } } }