結果
問題 | No.233 めぐるはめぐる (3) |
ユーザー |
![]() |
提出日時 | 2015-06-26 23:27:34 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 382 ms / 1,000 ms |
コード長 | 1,568 bytes |
コンパイル時間 | 871 ms |
コンパイル使用メモリ | 76,492 KB |
実行使用メモリ | 13,568 KB |
最終ジャッジ日時 | 2024-07-07 18:31:44 |
合計ジャッジ時間 | 7,693 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 11 |
ソースコード
#include <iostream> #include <vector> #include <set> #include <string> using namespace std; void make_cand(set<string>& cand, vector<string>& shiin, vector<string>& boin, int pos, vector<string> cur){ if(pos >= 6){ string res; for(int i = 0; i < cur.size(); i++){ res += cur[i]; } cand.insert(res); return; } for(int i = 0; i < shiin.size(); i++){ for(int j = 0; j < boin.size(); j++){ cur.push_back(shiin[i]); cur.push_back(boin[j]); shiin.erase(shiin.begin() + i); boin.erase(boin.begin() + j); make_cand(cand, shiin, boin, pos+1, cur); boin.insert(boin.begin() + j, cur.back()); cur.pop_back(); shiin.insert(shiin.begin() + i, cur.back()); cur.pop_back(); } } } int main(){ vector<string> shiin; shiin.push_back(""); shiin.push_back("n"); shiin.push_back("b"); shiin.push_back("m"); shiin.push_back("g"); shiin.push_back("r"); vector<string> boin; boin.push_back("i"); boin.push_back("a"); boin.push_back("a"); boin.push_back("e"); boin.push_back("u"); boin.push_back("u"); set<string> cand; vector<string> cur; make_cand(cand, shiin, boin, 0, cur); int N; cin >> N; for(int i = 0; i < N; i++){ string s; cin >> s; cand.erase(s); } if(cand.empty()){ cout << "NO" << endl; }else{ cout << *cand.begin() << endl; } return 0; }