結果

問題 No.497 入れ子の箱
ユーザー kuuso1kuuso1
提出日時 2017-03-24 23:09:38
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 91 ms / 5,000 ms
コード長 1,662 bytes
コンパイル時間 2,532 ms
コンパイル使用メモリ 106,600 KB
実行使用メモリ 31,568 KB
最終ジャッジ日時 2023-09-20 03:10:31
合計ジャッジ時間 6,523 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 66 ms
19,500 KB
testcase_01 AC 66 ms
23,436 KB
testcase_02 AC 65 ms
21,508 KB
testcase_03 AC 88 ms
27,596 KB
testcase_04 AC 90 ms
29,656 KB
testcase_05 AC 91 ms
29,568 KB
testcase_06 AC 90 ms
29,600 KB
testcase_07 AC 89 ms
27,456 KB
testcase_08 AC 90 ms
27,504 KB
testcase_09 AC 91 ms
31,560 KB
testcase_10 AC 89 ms
29,512 KB
testcase_11 AC 88 ms
27,448 KB
testcase_12 AC 86 ms
23,664 KB
testcase_13 AC 86 ms
23,532 KB
testcase_14 AC 85 ms
25,800 KB
testcase_15 AC 84 ms
23,692 KB
testcase_16 AC 85 ms
21,680 KB
testcase_17 AC 86 ms
25,724 KB
testcase_18 AC 85 ms
29,620 KB
testcase_19 AC 85 ms
29,608 KB
testcase_20 AC 85 ms
25,532 KB
testcase_21 AC 84 ms
29,656 KB
testcase_22 AC 84 ms
29,656 KB
testcase_23 AC 70 ms
23,480 KB
testcase_24 AC 71 ms
21,560 KB
testcase_25 AC 65 ms
23,400 KB
testcase_26 AC 62 ms
19,356 KB
testcase_27 AC 87 ms
29,512 KB
testcase_28 AC 87 ms
31,568 KB
testcase_29 AC 89 ms
27,584 KB
testcase_30 AC 75 ms
21,544 KB
testcase_31 AC 76 ms
23,568 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int[] InDeg= new int[N];
		List<int>[] E = new List<int>[N];
		for(int i=0;i<N;i++){
			E[i] = new List<int>();
		}
		
		for(int i=0;i<N;i++){
			for(int j=0;j<N;j++){
				if(B[i][0] < B[j][0] && B[i][1] < B[j][1] && B[i][2] < B[j][2]){
					E[i].Add(j);
					InDeg[j]++;
				}
			}
		}
		
		int[] dp = new int[N];
		for(int i=0;i<N;i++) dp[i] = 1;
		
		Queue<int> Q = new Queue<int>();
		for(int i=0;i<N;i++) if(InDeg[i] == 0) Q.Enqueue(i);
		
		while(Q.Count > 0){
			var now = Q.Dequeue();
			foreach(var nxt in E[now]){
				dp[nxt] = Math.Max(dp[nxt],dp[now]+1);
				InDeg[nxt]--;
				if(InDeg[nxt] == 0) Q.Enqueue(nxt);
			}
		}
		Console.WriteLine(dp.Max());
		
	}
	int N;
	int[][] B;
	public Sol(){
		N = ri();
		B = new int[N][];
		for(int i=0;i<N;i++){
			B[i] = ria();
			Array.Sort(B[i]);
		}
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}
0