結果
| 問題 |
No.3323 岩井星式ジャンケン
|
| コンテスト | |
| ユーザー |
aketijyuuzou
|
| 提出日時 | 2025-11-01 16:43:36 |
| 言語 | C# (.NET 8.0.404) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 4,218 bytes |
| コンパイル時間 | 7,677 ms |
| コンパイル使用メモリ | 170,768 KB |
| 実行使用メモリ | 214,840 KB |
| 最終ジャッジ日時 | 2025-11-01 16:43:53 |
| 合計ジャッジ時間 | 16,803 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 WA * 3 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (99 ミリ秒)。 main -> /home/judge/data/code/bin/Release/net8.0/main.dll main -> /home/judge/data/code/bin/Release/net8.0/publish/
ソースコード
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
static string InputPattern = "InputX";
static List<string> GetInputList()
{
var WillReturn = new List<string>();
if (InputPattern == "Input1") {
WillReturn.Add("2 3");
WillReturn.Add("GGG");
WillReturn.Add("CPC");
//GPG
}
else if (InputPattern == "Input2") {
WillReturn.Add("4 3");
WillReturn.Add("PGC");
WillReturn.Add("PCP");
WillReturn.Add("PPG");
WillReturn.Add("GGP");
//-1
}
else if (InputPattern == "Input3") {
WillReturn.Add("4 5");
WillReturn.Add("PGCPC");
WillReturn.Add("PPGGP");
WillReturn.Add("CPGPC");
WillReturn.Add("CGCCP");
//CPPCP
}
else {
string wkStr;
while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
}
return WillReturn;
}
static long[] GetSplitArr(string pStr)
{
return (pStr == "" ? new string[0] : pStr.Split(' ')).Select(pX => long.Parse(pX)).ToArray();
}
static long mN;
static long mM;
static char[,] mBanArr;
static int UB_X;
static int UB_Y;
static void Main()
{
List<string> InputList = GetInputList();
long[] wkArr = GetSplitArr(InputList[0]);
mN = wkArr[0];
mM = wkArr[1];
mBanArr = CreateBanArr(InputList.Skip(1));
UB_X = mBanArr.GetUpperBound(0);
UB_Y = mBanArr.GetUpperBound(1);
var Stk = new Stack<JyoutaiDef>();
JyoutaiDef WillPush;
WillPush.Path = "";
Stk.Push(WillPush);
while (Stk.Count > 0) {
JyoutaiDef Popped = Stk.Pop();
int Result = CheckMethod(Popped.Path);
if (Result == 1) {
Console.WriteLine(Popped.Path.PadRight((int)mM, 'P'));
return;
}
if (Popped.Path.Length == 10) {
continue;
}
if (Popped.Path.Length < mM) {
WillPush.Path = Popped.Path + 'C'; Stk.Push(WillPush);
WillPush.Path = Popped.Path + 'G'; Stk.Push(WillPush);
WillPush.Path = Popped.Path + 'P'; Stk.Push(WillPush);
}
}
Console.WriteLine(-1);
}
static int CheckMethod(string pPath)
{
var WinIndSet = new HashSet<int>();
for (int X = 0; X <= pPath.Length - 1; X++) {
for (int Y = 0; Y <= UB_Y; Y++) {
if (WinIndSet.Contains(Y)) continue;
int Syouhai = GetSyouhai(pPath[X], mBanArr[X, Y]);
if (Syouhai == -1) {
return -1;
}
if (Syouhai == 1) {
WinIndSet.Add(Y);
}
}
if (WinIndSet.Count == mN) return 1;
}
return 0;
}
static int GetSyouhai(char pIwai, char pAite)
{
if (pIwai == 'C' && pAite == 'G') return -1;
if (pIwai == 'G' && pAite == 'P') return -1;
if (pIwai == 'P' && pAite == 'C') return -1;
if (pIwai == 'C' && pAite == 'P') return +1;
if (pIwai == 'G' && pAite == 'C') return +1;
if (pIwai == 'P' && pAite == 'G') return +1;
return 0;
}
struct JyoutaiDef
{
internal string Path;
}
////////////////////////////////////////////////////////////////
// IEnumerable<string>をcharの2次元配列に設定
////////////////////////////////////////////////////////////////
static char[,] CreateBanArr(IEnumerable<string> pStrEnum)
{
var StrList = pStrEnum.ToList();
if (StrList.Count == 0) {
return new char[0, 0];
}
int UB_X = StrList[0].Length - 1;
int UB_Y = StrList.Count - 1;
char[,] WillReturn = new char[UB_X + 1, UB_Y + 1];
for (int Y = 0; Y <= UB_Y; Y++) {
for (int X = 0; X <= UB_X; X++) {
WillReturn[X, Y] = StrList[Y][X];
}
}
return WillReturn;
}
}
aketijyuuzou