結果

問題 No.334 門松ゲーム
ユーザー h_nosonh_noson
提出日時 2016-03-14 11:49:46
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,158 bytes
コンパイル時間 739 ms
コンパイル使用メモリ 65,872 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-26 04:14:50
合計ジャッジ時間 1,431 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

#define RREP(i,s,e) for (i = e-1; i >= s; i--)
#define rrep(i,n) RREP(i,0,n)
#define REP(i,s,e) for (i = s; i < e; i++)
#define rep(i,n) REP(i,0,n)
#define INF 1e8

typedef long long ll;

int ans1, ans2, ans3;

bool dfs(vector<int> a, bool me) {
    int i, j, k, n;
    bool ret, ans;
    if (a.size() < 3)
        return false;
    n = a.size();
    ans = false;
    rrep (i,n-2) RREP (j,i+1,n-1) RREP (k,j+1,n) {
        if (a[i] != a[k] && (a[j] < min(a[i],a[k]) || a[j] > max(a[i],a[k]))) {
            vector<int> b = a;
            auto p = b.begin();
            b.erase(p+k); b.erase(p+j); b.erase(p+i);
            if (!dfs(b,!me)) {
                if (me) {
                    ans1 = i; ans2 = j; ans3 = k;
                }
                ans = true;
            }
        }
    }
    return ans;
}

int main() {
    int i, j, k, n;
    vector<int> a;
    cin >> n;
    rep (i,n) {
        cin >> k;
        a.push_back(k);
    }
    if (dfs(a,true))
        cout << ans1 << " " << ans2 << " " << ans3 << endl;
    else
        cout << -1 << endl;
    return 0;
}
0