結果
| 問題 |
No.1594 Three Classes
|
| コンテスト | |
| ユーザー |
aketijyuuzou
|
| 提出日時 | 2025-02-20 22:00:57 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,578 bytes |
| コンパイル時間 | 3,550 ms |
| コンパイル使用メモリ | 116,288 KB |
| 実行使用メモリ | 34,248 KB |
| 最終ジャッジ日時 | 2025-02-20 22:01:07 |
| 合計ジャッジ時間 | 6,881 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 2 |
| other | AC * 14 WA * 4 |
コンパイルメッセージ
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;
using System.Linq;
// https://yukicoder.me/problems/no/1594
class Program
{
static string InputPattern = "InputX";
static List<string> GetInputList()
{
var WillReturn = new List<string>();
if (InputPattern == "Input1") {
WillReturn.Add("5");
WillReturn.Add("1 2 3 4 5");
}
else if (InputPattern == "Input2") {
WillReturn.Add("7");
WillReturn.Add("3 1 4 1 5 9 2");
}
else if (InputPattern == "Input3") {
WillReturn.Add("9");
WillReturn.Add("729 756 767 778 792 804 816 831 855");
}
else {
string wkStr;
while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
}
return WillReturn;
}
static void Main()
{
List<string> InputList = GetInputList();
long[] EArr = InputList[1].Split(' ').Select(pX => long.Parse(pX)).ToArray();
long UB = EArr.GetUpperBound(0);
var Stk = new Stack<JyoutaiDef>();
JyoutaiDef WillPush;
WillPush.ValList = new List<long>();
WillPush.CurrInd = 0;
Stk.Push(WillPush);
while (Stk.Count > 0) {
JyoutaiDef Popped = Stk.Pop();
int CurrInd = Popped.CurrInd;
if (CurrInd > UB) {
if (Popped.ValList.Count == 3) {
if (Popped.ValList.Distinct().Count() == 1) {
Console.WriteLine("Yes");
return;
}
}
continue;
}
// 枝切り
if (Popped.ValList.Count >= 2) {
if (Popped.ValList[0] < Popped.ValList[1]) {
continue;
}
}
// Listの要素に足し算する場合
for (int I = 0; I <= Popped.ValList.Count - 1; I++) {
WillPush.ValList = new List<long>(Popped.ValList);
WillPush.ValList[I] = Popped.ValList[I] + EArr[CurrInd];
WillPush.CurrInd = CurrInd + 1;
Stk.Push(WillPush);
}
// ListにAddする場合
WillPush.ValList = new List<long>(Popped.ValList);
WillPush.ValList.Add(EArr[CurrInd]);
WillPush.CurrInd = CurrInd + 1;
Stk.Push(WillPush);
}
Console.WriteLine("No");
}
struct JyoutaiDef
{
internal List<long> ValList;
internal int CurrInd;
}
}
aketijyuuzou