結果

問題 No.334 門松ゲーム
ユーザー 小指が強い人小指が強い人
提出日時 2016-02-07 18:45:03
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,765 bytes
コンパイル時間 481 ms
コンパイル使用メモリ 57,116 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-21 20:08:21
合計ジャッジ時間 1,280 ms
ジャッジサーバーID
(参考情報)
judge13 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
using namespace std;
#define REP(i, c, n) for(int i = c; i < n; i++)

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;
        int c1=0,c2=0;
        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;
            c1++;
            bool win2=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;
				}
				win2=true;
                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((v[0] < v[1] && v[2] < v[1]) || (v[0] > v[1] && v[2] > v[1])) {
                    win2=false;
                }
                p[b[k][0]] = p[b[k][1]] = p[b[k][2]] = false;
            }
            if(win2) c2++;
            p[b[j][0]] = p[b[j][1]] = p[b[j][2]] = false;
        }
		if(win || c1==c2) {
			res = i;
			break;
		}
    }
    if(res != -1)
        cout << b[res][0] << " " << b[res][1] << " " << b[res][2] << endl;
    else
        cout << -1 << endl;
    return 0;
}
0