エージェントをゲートウェイに行かせない、
または、スミスをネオの所に行かせない、
もしくは、三蔵法師を天竺に行かせない、そんなふうにするゲーム
だいたい動いてるのはこんな感じ
http://www.codingame.com/replay/solo/25830233
using System; using System.Linq; using System.IO; using System.Text; using System.Collections; using System.Collections.Generic; /** * Auto-generated code below aims at helping you parse * the standard input according to the problem statement. **/ class Player { static void Main(string[] args) { string[] inputs = Console.ReadLine().Split(' '); int N = int.Parse(inputs[0]); // the total number of nodes in the level, including the gateways int L = int.Parse(inputs[1]); // the number of links int E = int.Parse(inputs[2]); // the number of exit gateways Console.Error.WriteLine("N,L,E:{0},{1},{2}", N, L, E); List<CLine> lines = new List<CLine>(); //道情報のリスト for (int i = 0; i < L; i++) { inputs = Console.ReadLine().Split(' '); int N1 = int.Parse(inputs[0]); // N1 and N2 defines a link between these nodes int N2 = int.Parse(inputs[1]); Console.Error.WriteLine("Line{0}:{1} {2}", i, N1, N2); lines.Add(new CLine(N1,N2)); //道情報追加 } int[] EI = new int[E]; //ゲートウェイ for (int i = 0; i < E; i++) { EI[i] = int.Parse(Console.ReadLine()); // the index of a gateway node Console.Error.WriteLine("EI{0}:{1}", i, EI[i]); } // game loop while (true) { int SI = int.Parse(Console.ReadLine()); // The index of the node on which the Skynet agent is positioned this turn Console.Error.WriteLine("SI:"+SI); CLine stopline = lines[0]; //封鎖道の情報 // Write an action using Console.WriteLine() // To debug: Console.Error.WriteLine("Debug messages..."); //エージェントとゲートウェイが隣り合ってる場所を検索 for(int i = lines.Count-1; i >= 0; i--) { if(lines[i].close == false) { //未封鎖の場合 for(int j = 0; j < E; j++) { if(lines[i].con(EI[j]) && lines[i].con(SI)) { //エージェントとゲートウェイが隣り合ってるか stopline = lines[i]; //封鎖情報に入れる lines[i].close = true; //封鎖状態を封鎖にする } } } } Console.WriteLine(stopline.str()); // Example: 0 1 are the indices of the nodes you wish to sever the link between } } } //道情報クラス class CLine { public int N1 {get;set;} //ノード1 public int N2 {get;set;} //ノード2 public bool close = false; //通行状態 public CLine(int n1, int n2) { this.N1 = n1; this.N2 = n2; } public string str() { return string.Format("{0} {1}", N1, N2); } //ノードにnが含まれるかどうか public bool con(int n) { if(this.N1 == n) return true; if(this.N2 == n) return true; return false; } }
ゲートウェイ・エクスペリエンス第1?6巻セット : The Gateway Experience Wave I-VI (日本語版) [ヘミシンク]
- アーティスト: MonroeProducts
- 出版社/メーカー: MonroeProducts
- 発売日: 2006/01/12
- メディア: CD
- 購入: 2人 クリック: 4回
- この商品を含むブログ (4件) を見る