結果

問題 No.334 門松ゲーム
ユーザー 小指が強い人小指が強い人
提出日時 2016-02-07 19:16:08
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 2,663 bytes
コンパイル時間 1,343 ms
コンパイル使用メモリ 161,028 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-21 20:08:24
合計ジャッジ時間 1,945 ms
ジャッジサーバーID
(参考情報)
judge10 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 3 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0