結果
| 問題 |
No.334 門松ゲーム
|
| コンテスト | |
| ユーザー |
小指が強い人
|
| 提出日時 | 2016-02-07 19:16:08 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 2,663 bytes |
| コンパイル時間 | 1,209 ms |
| コンパイル使用メモリ | 159,600 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-21 21:33:48 |
| 合計ジャッジ時間 | 1,818 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 13 |
ソースコード
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> veci;
typedef vector<string> vecs;
template<class T,class U> using Hash=unordered_map<T,U>;
#define REP(i, a, n) for(ll i = a; i < n; i++)
#define RREP(i, a, n) for(ll i = n-1; i >= 0; i--)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) RREP(i, 0, n)
template<class T> T read(){T a;cin >> a;return a;}
template<class T> T read(T& a){cin >> a;}
template<class T> void rarr(T a, int n){for(int i = 0; i < n; i++) {cin >> a[i];}}
template<class T> void write(T a){cout << a << endl;}
template<class T> void writes(vector<T> a, char* c = " "){cout << a[0];for(int i = 1; i < a.size(); i++)cout << c << a[i];cout << endl;;}
void write(double a){cout << fixed << setprecision(12) << a << endl;}
template<class T> void warr(T a, int n, char* c = " "){cout << a[0];for(int i = 1; i < n; i++)cout << c << a[i];cout << endl;}
ll gcd(ll a, ll b){while(true){ll k = a % b;if(k == 0)return b;a = b;b = k;}}
int main(void)
{
int n;
int blen = 0;
int a[12];
int b[1000][3];
cin >> n;
for(int i = 0; i < n; i++)
cin >> a[i];
REP(i, 0, n)
REP(j, i + 1, n)
REP(k, j + 1, n)
if((a[i] < a[j] && a[k] < a[j]) || (a[i] > a[j] && a[k] > a[j])) {
b[blen][0] = i; b[blen][1] = j; b[blen++][2] = k;
}
int res = -1;
for(int i = 0; i < blen; i++) {
bool p[12] = {0};
bool win = true;
p[b[i][0]] = p[b[i][1]] = p[b[i][2]] = true;
for(int j = 0; j < blen; j++) {
if(p[b[j][0]] || p[b[j][1]] || p[b[j][2]])
continue;
win = false;
p[b[j][0]] = p[b[j][1]] = p[b[j][2]] = true;
for(int k = 0; k < blen; k++) {
if(p[b[k][0]] || p[b[k][1]] || p[b[k][2]]) {
continue;
}
p[b[k][0]] = p[b[k][1]] = p[b[k][2]] = true;
int v[3];
int vlen = 0;
for(int l = 0; l < n; l++)
if(!p[l]) v[vlen++] = a[l];
if(n<12||!((v[0] < v[1] && v[2] < v[1]) || (v[0] > v[1] && v[2] > v[1]))) {
win=true;
}
p[b[k][0]] = p[b[k][1]] = p[b[k][2]] = false;
}
if(!win) break;
p[b[j][0]] = p[b[j][1]] = p[b[j][2]] = false;
}
if(win) {
res = i;
break;
}
}
if(res != -1)
cout << b[res][0] << " " << b[res][1] << " " << b[res][2] << endl;
else
cout << -1 << endl;
return 0;
}
小指が強い人