/* -*- coding: utf-8 -*- * * 334.cc: No.334 門松ゲーム - yukicoder */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; /* constant */ const int MAX_N = 12; const int NBITS = 1 << MAX_N; typedef long long ll; const int INF = 1 << 30; const ll LINF = 1LL << 60; /* typedef */ typedef vector vi; typedef queue qi; typedef pair pii; /* global variables */ int ks[MAX_N], dp[NBITS]; /* subroutines */ /* main */ int main() { int n; cin >> n; for (int i = 0; i < n; i++) cin >> ks[i]; int nbits = 1 << n; //for (int bits = 0; bits < nbits; bits++) dp[bits] = -1; for (int bits = 0; bits < nbits; bits++) { bool win = false; for (int i = 0; ! win && i < n; i++) { int bi = 1 << i; if (! (bits & bi)) continue; for (int j = i + 1; ! win && j < n; j++) { int bj = 1 << j; if (! (bits & bj)) continue; for (int k = j + 1; ! win && k < n; k++) { int bk = 1 << k; if (! (bits & bk)) continue; if (ks[i] != ks[k] && ((ks[i] < ks[j] && ks[j] > ks[k]) || (ks[i] > ks[j] && ks[j] < ks[k])) && dp[bits ^ bi ^ bj ^ bk] == 1) win = true; } } } dp[bits] = win ? 0 : 1; //printf("dp[%x]=%d\n", bits, dp[bits]); } if (dp[nbits - 1] == 1) puts("-1"); else { bool win = false; for (int i = 0; ! win && i < n; i++) for (int j = i + 1; ! win && j < n; j++) for (int k = j + 1; ! win && k < n; k++) { int bi = 1 << i, bj = 1 << j, bk = 1 << k; if (ks[i] != ks[k] && ((ks[i] < ks[j] && ks[j] > ks[k]) || (ks[i] > ks[j] && ks[j] < ks[k])) && dp[(nbits - 1) ^ bi ^ bj ^ bk] == 1) { printf("%d %d %d\n", i, j, k); win = true; } } } return 0; }