結果

問題 No.334 門松ゲーム
ユーザー mayoko_mayoko_
提出日時 2016-01-15 23:19:02
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,982 bytes
コンパイル時間 634 ms
コンパイル使用メモリ 86,784 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-19 23:35:04
合計ジャッジ時間 1,305 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 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 1 ms
4,348 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 1 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<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
//#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
//#include<list>
#include<queue>
#include<deque>
#include<algorithm>
//#include<numeric>
#include<utility>
#include<complex>
//#include<memory>
#include<functional>
#include<cassert>
#include<set>
#include<stack>

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

const int MAXN = 13;
bool used[MAXN];
int K[MAXN];
int N;

vector<int> solve() {
    for (int i = 0; i < N; i++) {
        if (used[i]) continue;
        for (int j = i+1; j < N; j++) {
            if (used[j]) continue;
            for (int k = j+1; k < N; k++) {
                if (used[k]) continue;
                if (K[i] == K[j]) continue;
                if (K[j] == K[k]) continue;
                if (K[k] == K[i]) continue;
                if (K[i] < K[j] && K[j] < K[k]) continue;
                if (K[i] > K[j] && K[j] > K[k]) continue;
                used[i] = true;
                used[j] = true;
                used[k] = true;
                auto v = solve();
                used[i] = false;
                used[j] = false;
                used[k] = false;
                if (v[0] < 0) {
                    vector<int> ret(3);
                    ret[0] = i;
                    ret[1] = j;
                    ret[2] = k;
                    return ret;
                }
            }
        }
    }
    vector<int> ret(3);
    ret[0] = -1;
    ret[1] = -1;
    ret[2] = -1;
    return ret;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    for (int i = 0; i < N; i++) cin >> K[i];
    auto v = solve();
    if (v[0] != -1) {
        cout << v[0] << " " << v[1] << " " << v[2] << endl;
    } else {
        cout << -1 << endl;
    }
    return 0;
}
0