結果
| 問題 |
No.8 N言っちゃダメゲーム
|
| ユーザー |
14番
|
| 提出日時 | 2016-03-30 14:10:38 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 2,347 bytes |
| コンパイル時間 | 1,834 ms |
| コンパイル使用メモリ | 105,344 KB |
| 実行使用メモリ | 29,184 KB |
| 最終ジャッジ日時 | 2024-10-02 08:09:23 |
| 合計ジャッジ時間 | 7,587 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 3 TLE * 1 -- * 7 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
using System.Collections.Generic;
public class Program
{
public void Proc() {
Reader.IsDebug = false;
int cnt = int.Parse(Reader.ReadLine());
for(int i=0; i<cnt;i++) {
int[] inpt = Reader.GetInt();
if(this.IsWin(inpt[0], inpt[1])) {
Console.WriteLine("Win");
} else
{
Console.WriteLine("Lose");
}
}
}
private bool IsWin(int max, int len) {
this.Goal = max;
this.MoveLen = len;
this.CanWinDic = new Nullable<bool>[Goal + 1];
this.CanWinDic[Goal - 1] = false;
for(int i=1; i<=len; i++) {
int idx = Math.Max(0, Goal - 1 - i);
this.CanWinDic[idx] = true;
}
return CanWin(0);
}
private int Goal = 0;
private int MoveLen = 0;
private Nullable<bool>[] CanWinDic;
private bool CanWin(int num) {
if(this.CanWinDic[num] != null) {
return this.CanWinDic[num].Value;
}
bool isOnlyWin = true;
for(int i=1; i<=MoveLen; i++) {
if(num + i < Goal) {
if(!this.CanWin(num + i)) {
isOnlyWin = false;
}
}
}
this.CanWinDic[num] = !isOnlyWin;
return this.CanWinDic[num].Value;
}
public class Reader {
private static String InitText = @"
3
5 10
40 6
100 8
";
private static System.IO.StringReader sr = null;
public static bool IsDebug = true;
public static string ReadLine() {
if(IsDebug) {
if(sr == null) {
sr = new System.IO.StringReader(InitText.Trim());
}
return sr.ReadLine();
} else {
return Console.ReadLine();
}
}
public static int[] GetInt(char delimiter = ' ') {
string[] inpt = ReadLine().Split(delimiter);
int[] ret = new int[inpt.Length];
for(int i=0; i<inpt.Length; i++) {
ret[i] = int.Parse(inpt[i]);
}
return ret;
}
}
public static void Main(string[] args)
{
Program prg = new Program();
prg.Proc();
}
}
14番