結果
問題 | No.334 門松ゲーム |
ユーザー |
|
提出日時 | 2020-04-13 22:32:16 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 1,175 bytes |
コンパイル時間 | 1,125 ms |
コンパイル使用メモリ | 75,636 KB |
最終ジャッジ日時 | 2025-01-09 18:15:29 |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 13 |
ソースコード
#include <iostream> #include <vector> bool judge(int a, int b, int c) { return !(a == b || b == c || c == a || (a < b && b < c) || (a > b && b > c)); } std::vector<int> sim(std::vector<int> v) { int n = v.size(); for (int i = 0; i < n; ++i) { for (int j = i + 1; j < n; ++j) { for (int k = j + 1; k < n; ++k) { if (!judge(v[i], v[j], v[k])) continue; std::vector<int> nv; for (int l = 0; l < n; ++l) { if (l == i || l == j || l == k) continue; nv.push_back(v[l]); } if (sim(nv).empty()) { return {i, j, k}; } } } } return {}; } void solve() { int n; std::cin >> n; std::vector<int> xs(n); for (auto& x : xs) std::cin >> x; auto ans = sim(xs); if (ans.empty()) { std::cout << -1 << std::endl; } else { for (auto a : ans) std::cout << a << " "; std::cout << std::endl; } } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); solve(); return 0; }