結果
問題 | No.197 手品 |
ユーザー |
|
提出日時 | 2015-07-20 22:08:51 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 960 bytes |
コンパイル時間 | 1,012 ms |
コンパイル使用メモリ | 100,588 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-20 03:41:51 |
合計ジャッジ時間 | 2,337 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 43 |
ソースコード
#include <cstdio> #include <iostream> #include <sstream> #include <fstream> #include <iomanip> #include <algorithm> #include <cmath> #include <string> #include <vector> #include <list> #include <queue> #include <stack> #include <set> #include <map> #include <bitset> #include <numeric> #include <limits> #include <climits> #include <cfloat> #include <functional> using namespace std; int main() { string init, goal; int n; cin >> init >> n >> goal; set<string> curr; curr.insert(init); while(--n >= 0){ set<string> next; for(const string& s : curr){ for(int i=0; i<2; ++i){ string t = s; swap(t[i], t[i+1]); next.insert(t); } } if(curr == next) break; curr.swap(next); } if(curr.find(goal) == curr.end()) cout << "SUCCESS" << endl; else cout << "FAILURE" << endl; return 0; }