結果

問題 No.361 門松ゲーム2
ユーザー koyumeishi
提出日時 2016-03-23 16:17:03
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
TLE  
実行時間 -
コード長 967 bytes
コンパイル時間 629 ms
コンパイル使用メモリ 67,232 KB
実行使用メモリ 10,496 KB
最終ジャッジ日時 2024-10-01 21:30:53
合計ジャッジ時間 4,109 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 8 TLE * 1 -- * 19
権限があれば一括ダウンロードができます
コンパイルメッセージ
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