結果
問題 |
No.3262 水色コーダーさん、その問題d問題ですよ?(1<=d<=N)
|
ユーザー |
![]() |
提出日時 | 2025-09-06 16:28:44 |
言語 | C# (.NET 8.0.404) |
結果 |
AC
|
実行時間 | 107 ms / 2,000 ms |
コード長 | 4,703 bytes |
コンパイル時間 | 9,435 ms |
コンパイル使用メモリ | 172,272 KB |
実行使用メモリ | 196,596 KB |
最終ジャッジ日時 | 2025-09-06 16:28:58 |
合計ジャッジ時間 | 13,790 ms |
ジャッジサーバーID (参考情報) |
judge / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 24 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (169 ミリ秒)。 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; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Runtime.CompilerServices; class Program { static string ReadLine() => Console.ReadLine().Trim(); static int ReadInt() => int.Parse(ReadLine()); static long ReadLong() => long.Parse(ReadLine()); static int[] ReadIntArray() { string str = ReadLine(); return str != "" ? str.Split().Select(_ => int.Parse(_)).ToArray() : new int[0]; } static long[] ReadLongArray() { string str = ReadLine(); return str != "" ? str.Split().Select(_ => long.Parse(_)).ToArray() : new long[0]; } static (int a, int b) ReadInt2() { int[] vs = ReadIntArray(); return (a: vs[0], b: vs[1]); } static (int a, int b, int c) ReadInt3() { int[] vs = ReadIntArray(); return (a: vs[0], b: vs[1], c: vs[2]); } static (int a, int b, int c, int d) ReadInt4() { int[] vs = ReadIntArray(); return (a: vs[0], b: vs[1], c: vs[2], d: vs[3]); } static (long a, long b) ReadLong2() { long[] vs = ReadLongArray(); return (a: vs[0], b: vs[1]); } static (long a, long b, long c) ReadLong3() { long[] vs = ReadLongArray(); return (a: vs[0], b: vs[1], c: vs[2]); } static (long a, long b, long c, long d) ReadLong4() { long[] vs = ReadLongArray(); return (a: vs[0], b: vs[1], c: vs[2], d: vs[3]); } class LR { public LR(int l, int r) { L = l; R = r; } public int L = 0; public int R = 0; } static void Main() { SourceExpander.Expander.Expand(); int N = ReadInt(); List<LR> lrs = new List<LR>(); int[] arr = new int[N]; for (int i = 0; i < N; i++) { (int L, int R) = ReadInt2(); lrs.Add(new LR(L, R)); arr[i] = i; } int ans = 0; do { if (Check()) ans++; } while (AtCoder.StlFunction.NextPermutation(arr)); Console.WriteLine(ans); bool Check() { List<LR> lrs2 = new List<LR>(); for (int i = 0; i < N; i++) { int idx = arr[i]; lrs2.Add(lrs[idx]); } int min = lrs2[0].L; for (int i = 1; i < N; i++) { LR cur = lrs2[i]; if (cur.R < min) return false; min = Math.Max(min, cur.L); } return true; } } } #region Expanded by https://github.com/kzrnm/SourceExpander namespace AtCoder{public static class StlFunction{public struct NextPermutationEnumerator<T>:IEnumerator<T[]>,IEnumerable<T[]>where T:IComparable<T>{internal readonly IEnumerable<T>_orig;internal NextPermutationEnumerator(IEnumerable<T>orig){_orig=orig;Current=null;}public T[]Current{get;private set;}[MethodImpl(256)]public bool MoveNext(){if(Current==null){Current=_orig.ToArray();return true;}return NextPermutation(Current);}public void Reset()=>Current=null;object IEnumerator.Current=>Current;void IDisposable.Dispose(){}[MethodImpl(256)]public NextPermutationEnumerator<T>GetEnumerator()=>this;IEnumerator<T[]>IEnumerable<T[]>.GetEnumerator()=>this;IEnumerator IEnumerable.GetEnumerator()=>this;}[MethodImpl(256)]public static bool NextPermutation<T>(T[]array)where T:IComparable<T> =>NextPermutation(array.AsSpan());[MethodImpl(256)]public static bool NextPermutation<T>(Span<T>span)where T:IComparable<T>{int i;for(i=span.Length-2;i>=0;i--)if(span[i].CompareTo(span[i+1])<0)break;if(i<0)return false;int j;for(j=span.Length-1;j>=0;j--)if(span[i].CompareTo(span[j])<0)break;(span[i],span[j])=(span[j],span[i]);span.Slice(i+1,span.Length-i-1).Reverse();return true;}[MethodImpl(256)]public static NextPermutationEnumerator<T>Permutations<T>(IEnumerable<T>orig)where T:IComparable<T> =>new NextPermutationEnumerator<T>(orig);private struct DefaultComparer<T>:IComparer<T>where T:IComparable<T>{[MethodImpl(256)]public int Compare(T x,T y)=>x.CompareTo(y);}[MethodImpl(256)]public static int BinarySearch(int ok,int ng,Predicate<int>Ok){while(Math.Abs(ok-ng)>1){var m=(ok+ng)>>1;if(Ok(m))ok=m;else ng=m;}return ok;}[MethodImpl(256)]public static long BinarySearch(long ok,long ng,Predicate<long>Ok){while(Math.Abs(ok-ng)>1){var m=(ok+ng)>>1;if(Ok(m))ok=m;else ng=m;}return ok;}}} namespace SourceExpander{public class Expander{[Conditional("EXP")]public static void Expand(string inputFilePath=null,string outputFilePath=null,bool ignoreAnyError=true){}public static string ExpandString(string inputFilePath=null,bool ignoreAnyError=true){return "";}}} #endregion Expanded by https://github.com/kzrnm/SourceExpander