結果
| 問題 |
No.3262 水色コーダーさん、その問題d問題ですよ?(1<=d<=N)
|
| コンテスト | |
| ユーザー |
aketijyuuzou
|
| 提出日時 | 2025-09-06 13:57:54 |
| 言語 | C# (.NET 8.0.404) |
| 結果 |
AC
|
| 実行時間 | 132 ms / 2,000 ms |
| コード長 | 4,261 bytes |
| コンパイル時間 | 11,402 ms |
| コンパイル使用メモリ | 171,056 KB |
| 実行使用メモリ | 212,560 KB |
| 最終ジャッジ日時 | 2025-09-06 13:58:42 |
| 合計ジャッジ時間 | 13,703 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 24 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (111 ミリ秒)。 /home/judge/data/code/Main.cs(89,21): warning CS1717: 同じ変数に代入られました。他の変数に代入しますか? [/home/judge/data/code/main.csproj] 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("8");
WillReturn.Add("5 15");
WillReturn.Add("40 110");
WillReturn.Add("700 1400");
WillReturn.Add("600 800");
WillReturn.Add("900 1500");
WillReturn.Add("1800 2300");
WillReturn.Add("2100 2500");
WillReturn.Add("2400 3000");
//9
}
else if (InputPattern == "Input2") {
WillReturn.Add("7");
WillReturn.Add("12 12");
WillReturn.Add("54 54");
WillReturn.Add("128 128");
WillReturn.Add("1310 1310");
WillReturn.Add("1193 1193");
WillReturn.Add("1806 1806");
WillReturn.Add("2876 2876");
//1
}
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();
}
struct RangeInfoDef
{
internal long RangeMin;
internal long RangeMax;
}
static List<RangeInfoDef> mRangeInfoList = new List<RangeInfoDef>();
static void Main()
{
List<string> InputList = GetInputList();
long[] wkArr = { };
Action<string> SplitAct = (pStr) => wkArr = GetSplitArr(pStr);
foreach (string EachStr in InputList.Skip(1)) {
SplitAct(EachStr);
RangeInfoDef WillAdd;
WillAdd.RangeMin = wkArr[0];
WillAdd.RangeMax = wkArr[1];
mRangeInfoList.Add(WillAdd);
}
var IndList = new List<int>();
for (int I = 0; I <= mRangeInfoList.Count - 1; I++) {
IndList.Add(I);
}
long Answer = 0;
foreach (int[] EachArr in RubyPatternClass<int>.Permutation(IndList, IndList.Count)) {
bool IsOK=true;
long RunMax = long.MinValue;
foreach (int EachInd in EachArr) {
long RangeMin = mRangeInfoList[EachInd].RangeMin;
long RangeMax = mRangeInfoList[EachInd].RangeMax;
if (RunMax <= RangeMin) {
RunMax = RangeMin;
continue;
}
if (RangeMin <= RunMax && RunMax <= RangeMax) {
RunMax = RunMax;
continue;
}
IsOK = false;
break;
}
if (IsOK) Answer++;
}
Console.WriteLine(Answer);
}
}
#region RubyPatternClass
// Rubyの場合の数
internal static class RubyPatternClass<Type>
{
// 順列を返す
private struct JyoutaiDef_Permutation
{
internal List<int> SelectedIndList;
}
internal static IEnumerable<Type[]> Permutation(IEnumerable<Type> pEnum, int pR)
{
if (pR == 0) yield break;
Type[] pArr = pEnum.ToArray();
if (pArr.Length < pR) yield break;
var Stk = new Stack<JyoutaiDef_Permutation>();
JyoutaiDef_Permutation WillPush;
for (int I = pArr.GetUpperBound(0); 0 <= I; I--) {
WillPush.SelectedIndList = new List<int>() { I };
Stk.Push(WillPush);
}
while (Stk.Count > 0) {
JyoutaiDef_Permutation Popped = Stk.Pop();
// クリア判定
if (Popped.SelectedIndList.Count == pR) {
var WillReturn = new List<Type>();
Popped.SelectedIndList.ForEach(X => WillReturn.Add(pArr[X]));
yield return WillReturn.ToArray();
continue;
}
for (int I = pArr.GetUpperBound(0); 0 <= I; I--) {
if (Popped.SelectedIndList.Contains(I)) continue;
WillPush.SelectedIndList = new List<int>(Popped.SelectedIndList) { I };
Stk.Push(WillPush);
}
}
}
}
#endregion
aketijyuuzou