結果

問題 No.334 門松ゲーム
ユーザー kotatsugamekotatsugame
提出日時 2017-10-04 03:43:54
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 615 bytes
コンパイル時間 432 ms
コンパイル使用メモリ 64,116 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-28 01:00:28
合計ジャッジ時間 1,048 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 1 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 1 ms
6,940 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 2 ms
6,944 KB
testcase_13 AC 1 ms
6,944 KB
testcase_14 AC 1 ms
6,940 KB
testcase_15 AC 1 ms
6,940 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:32:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   32 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
using namespace std;
bool a[12];
int n,K[12],A,B,C;
bool f()
{
	bool win=false;
	for(int i=0;i<n;i++)
	{
		if(a[i])continue;
		for(int j=i+1;j<n;j++)
		{
			if(a[j])continue;
			for(int k=j+1;k<n;k++)
			{
				if(a[k])continue;
				if(K[i]==K[j]||K[j]==K[k])continue;
				if(K[i]<K[j]&&K[j]<K[k]||K[i]>K[j]&&K[j]>K[k])continue;
				a[i]=a[j]=a[k]=true;
				win|=!f();
				a[i]=a[j]=a[k]=false;
				if(win)
				{
					A=i,B=j,C=k;
					return true;
				}
			}
		}
	}
	return false;
}
main()
{
	cin>>n;
	for(int i=0;i<n;i++)cin>>K[i];
	if(!f())cout<<-1<<endl;
	else cout<<A<<" "<<B<<" "<<C<<endl;
}
0