結果
| 問題 |
No.3323 岩井星式ジャンケン
|
| コンテスト | |
| ユーザー |
aketijyuuzou
|
| 提出日時 | 2025-11-08 09:08:39 |
| 言語 | C# (.NET 8.0.404) |
| 結果 |
AC
|
| 実行時間 | 226 ms / 2,000 ms |
| コード長 | 3,317 bytes |
| コンパイル時間 | 8,041 ms |
| コンパイル使用メモリ | 170,568 KB |
| 実行使用メモリ | 190,968 KB |
| 最終ジャッジ日時 | 2025-11-08 09:08:52 |
| 合計ジャッジ時間 | 12,351 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 26 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (109 ミリ秒)。 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;
// No.3323 岩井星式ジャンケン
// https://yukicoder.me/problems/no/3323
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 void Main()
{
List<string> InputList = GetInputList();
List<string> TeList = new List<string>();
TeList.AddRange(InputList.Skip(1));
var ValidYSet = new HashSet<int>();
for (int Y = 0; Y <= TeList.Count - 1; Y++) {
ValidYSet.Add(Y);
}
var AnswerList = new List<char>();
for (int X = 0; X <= TeList[0].Length - 1; X++) {
var TeSet = new HashSet<char>();
foreach (int EachY in ValidYSet) {
TeSet.Add(TeList[EachY][X]);
}
if (TeSet.Count == 3) {
Console.WriteLine(-1);
return;
}
char WinTe = '\0';
if (TeSet.Count == 2) {
if (TeSet.Contains('C') && TeSet.Contains('G')) {
WinTe = 'G';
}
if (TeSet.Contains('C') && TeSet.Contains('P')) {
WinTe = 'C';
}
if (TeSet.Contains('G') && TeSet.Contains('P')) {
WinTe = 'P';
}
}
if (TeSet.Count == 1) {
if (TeSet.Contains('C')) WinTe = 'G';
if (TeSet.Contains('G')) WinTe = 'P';
if (TeSet.Contains('P')) WinTe = 'C';
}
if (TeSet.Count == 0) {
WinTe = 'C';
}
AnswerList.Add(WinTe);
var ExceptSet = new HashSet<int>();
foreach (int EachY in ValidYSet) {
if (WinTe == 'C' && TeList[EachY][X] == 'P') {
ExceptSet.Add(EachY);
}
if (WinTe == 'G' && TeList[EachY][X] == 'C') {
ExceptSet.Add(EachY);
}
if (WinTe == 'P' && TeList[EachY][X] == 'G') {
ExceptSet.Add(EachY);
}
}
ValidYSet.ExceptWith(ExceptSet);
}
if (ValidYSet.Count == 0) {
AnswerList.ForEach(pX => Console.Write(pX));
Console.WriteLine();
}
else {
Console.WriteLine(-1);
}
}
}
aketijyuuzou