結果

問題 No.361 門松ゲーム2
ユーザー koyumeishikoyumeishi
提出日時 2016-03-23 16:17:03
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 967 bytes
コンパイル時間 523 ms
コンパイル使用メモリ 65,772 KB
実行使用メモリ 13,756 KB
最終ジャッジ日時 2024-04-09 21:04:42
合計ジャッジ時間 4,045 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
13,756 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 1 ms
6,944 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 1 ms
6,944 KB
testcase_07 AC 3 ms
6,940 KB
testcase_08 TLE -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int game(const std::vector<int>&)’:
main.cpp:45:1: warning: control reaches end of non-void function [-Wreturn-type]
   45 | }
      | ^

ソースコード

diff #

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

vector<int> memo;
int d;

int game(const vector<int>& v){
	int win  = 0;
	int lose = 0;

	for(int i=0; i<v.size(); i++){
		vector<int> vv;
		for(int j=0; j<v.size(); j++){
			if(i!=j) vv.push_back(v[j]);
		}
		int L = v[i];
		vv.push_back(-1);
		vv.push_back(-2);
		vv.push_back(-3);
		for(int a=1; a<L; a++){
			for(int b=a+1; b<L; b++){
				int c = L-(a+b);
				if(c<=b) break;
				if(a<b && b<c && c-a<=d){

					vv[vv.size()-3] = a;
					vv[vv.size()-2] = b;
					vv[vv.size()-1] = c;

					int tmp = game(vv);
					if(tmp == 1) win = 1;
					else lose = 1;
				}
			}
		}

	}

	if     (win == 0 && lose == 0) return 0;
	else if(win == 1 && lose == 0) return 0;
	else if(win == 0 && lose == 1) return 1;
	else if(win == 1 && lose == 1) return 1;
}

int main(){
	int L;
	cin >> L >> d;
	memo.resize(L+1, -1);

	int ans = game({L});

	cout << (ans!=0?"kado":"matsu") << endl;

	return 0;
}
0