結果
| 問題 | No.334 門松ゲーム |
| コンテスト | |
| ユーザー |
hogeover30
|
| 提出日時 | 2016-01-25 15:57:51 |
| 言語 | C++11(old_compat) (gcc 12.4.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 876 bytes |
| 記録 | |
| コンパイル時間 | 1,098 ms |
| コンパイル使用メモリ | 168,920 KB |
| 実行使用メモリ | 7,848 KB |
| 最終ジャッジ日時 | 2026-03-08 16:05:15 |
| 合計ジャッジ時間 | 1,534 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 13 |
ソースコード
#include <iostream>
#include <algorithm>
using namespace std;
bool isKadomatsu(int a, int b, int c)
{
return b>a and b>c or b<a and b<c;
}
bool win(const vector<int>& a, int mask)
{
int n=a.size();
bool res=true;
#define REP(i, a, b) for(int i=a;i<b;++i)
REP(i, 0, n) REP(j, i+1, n) REP(k, j+1, n) {
int m=mask&~((1<<i)|(1<<j)|(1<<k));
if ((mask&(1<<i)) and (mask&(1<<j)) and (mask&(1<<k)) and isKadomatsu(a[i], a[j], a[k]))
res=res and !win(a, m);
}
return res;
}
int main()
{
int n; cin>>n;
vector<int> a(n); for(int& v: a) cin>>v;
REP(i, 0, n) REP(j, i+1, n) REP(k, j+1, n) {
if (isKadomatsu(a[i], a[j], a[k])) {
if (win(a, ((1<<n)-1)^(1<<i)^(1<<j)^(1<<k))) {
cout<<i<<' '<<j<<' '<<k<<endl;
return 0;
}
}
}
cout<<-1<<endl;
}
hogeover30