結果
| 問題 |
No.334 門松ゲーム
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-10-13 23:02:42 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 932 bytes |
| コンパイル時間 | 1,583 ms |
| コンパイル使用メモリ | 166,096 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-13 23:02:45 |
| 合計ジャッジ時間 | 2,371 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 13 |
ソースコード
# include <bits/stdc++.h>
using namespace std;
typedef long long ll;
# define int long long
# define lc u << 1
# define rc u << 1 | 1
# define fi first
# define se second
const int N = 25;
int n;
int a[N];
int x, y, z;
bool dfs (int S)
{
for (int i = 0; i < n; i ++ )
{
for (int j = i + 1; j < n; j ++ )
{
for (int k = j + 1; k < n; k ++ )
{
if (~S & (1 << i) && ~S & (1 << j) && ~S & (1 << k))
{
if ((a[i] > a[j] && a[j] < a[k] && a[i] != a[k]) || (a[i] < a[j] && a[j] > a[k] && a[i] != a[k]))
{
if (!dfs (S ^ (1 << i) ^ (1 << j) ^ (1 << k)))
{
x = i, y = j, z = k;
return 1;
}
}
}
}
}
}
return 0;
}
signed main ()
{
// freopen ("game.in", "r", stdin); freopen ("game.out", "w", stdout);
scanf ("%lld", &n);
for (int i = 0; i < n; i ++ ) scanf ("%lld", &a[i]);
if (dfs (0)) printf ("%lld %lld %lld\n", x, y, z);
else printf ("-1\n");
return 0;
}