結果
| 問題 |
No.334 門松ゲーム
|
| コンテスト | |
| ユーザー |
h_noson
|
| 提出日時 | 2016-03-14 11:49:46 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,158 bytes |
| コンパイル時間 | 543 ms |
| コンパイル使用メモリ | 65,048 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-09-25 12:02:43 |
| 合計ジャッジ時間 | 1,332 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 9 WA * 4 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define RREP(i,s,e) for (i = e-1; i >= s; i--)
#define rrep(i,n) RREP(i,0,n)
#define REP(i,s,e) for (i = s; i < e; i++)
#define rep(i,n) REP(i,0,n)
#define INF 1e8
typedef long long ll;
int ans1, ans2, ans3;
bool dfs(vector<int> a, bool me) {
int i, j, k, n;
bool ret, ans;
if (a.size() < 3)
return false;
n = a.size();
ans = false;
rrep (i,n-2) RREP (j,i+1,n-1) RREP (k,j+1,n) {
if (a[i] != a[k] && (a[j] < min(a[i],a[k]) || a[j] > max(a[i],a[k]))) {
vector<int> b = a;
auto p = b.begin();
b.erase(p+k); b.erase(p+j); b.erase(p+i);
if (!dfs(b,!me)) {
if (me) {
ans1 = i; ans2 = j; ans3 = k;
}
ans = true;
}
}
}
return ans;
}
int main() {
int i, j, k, n;
vector<int> a;
cin >> n;
rep (i,n) {
cin >> k;
a.push_back(k);
}
if (dfs(a,true))
cout << ans1 << " " << ans2 << " " << ans3 << endl;
else
cout << -1 << endl;
return 0;
}
h_noson