結果

問題 No.497 入れ子の箱
ユーザー kuuso1kuuso1
提出日時 2017-07-01 16:30:25
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 69 ms / 5,000 ms
コード長 1,788 bytes
コンパイル時間 1,274 ms
コンパイル使用メモリ 109,440 KB
実行使用メモリ 24,832 KB
最終ジャッジ日時 2024-04-15 10:51:31
合計ジャッジ時間 3,978 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
19,328 KB
testcase_01 AC 36 ms
19,072 KB
testcase_02 AC 36 ms
19,072 KB
testcase_03 AC 67 ms
24,704 KB
testcase_04 AC 64 ms
24,576 KB
testcase_05 AC 64 ms
24,704 KB
testcase_06 AC 66 ms
24,704 KB
testcase_07 AC 64 ms
24,576 KB
testcase_08 AC 63 ms
24,576 KB
testcase_09 AC 64 ms
24,576 KB
testcase_10 AC 64 ms
24,576 KB
testcase_11 AC 65 ms
24,320 KB
testcase_12 AC 59 ms
22,528 KB
testcase_13 AC 58 ms
22,528 KB
testcase_14 AC 60 ms
22,528 KB
testcase_15 AC 60 ms
22,784 KB
testcase_16 AC 59 ms
22,656 KB
testcase_17 AC 59 ms
22,528 KB
testcase_18 AC 64 ms
24,832 KB
testcase_19 AC 64 ms
24,448 KB
testcase_20 AC 65 ms
24,704 KB
testcase_21 AC 64 ms
24,704 KB
testcase_22 AC 64 ms
24,576 KB
testcase_23 AC 43 ms
19,712 KB
testcase_24 AC 45 ms
19,584 KB
testcase_25 AC 33 ms
19,072 KB
testcase_26 AC 33 ms
18,816 KB
testcase_27 AC 63 ms
24,704 KB
testcase_28 AC 69 ms
24,576 KB
testcase_29 AC 64 ms
24,704 KB
testcase_30 AC 49 ms
19,456 KB
testcase_31 AC 51 ms
19,584 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(){
		
		List<int>[] E = new List<int>[N];
		for(int i=0;i<N;i++) E[i] = new List<int>();
		
		Func<int[],int[],bool> canGo = (a,b) =>{
			for(int i=0;i<3;i++) if(a[i] >= b[i]) return false;
			return true;
		};
		
		int[] Indeg = new int[N];
		for(int i=0;i<N;i++){
			for(int j=i+1;j<N;j++){
				if(canGo(B[i],B[j])){ E[i].Add(j); Indeg[j]++;}
				if(canGo(B[j],B[i])){ E[j].Add(i); Indeg[i]++;}
			}
		}
		
		int[] max = new int[N];
		for(int i=0;i<N;i++) max[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]){
				Indeg[nxt]--;
				max[nxt] = Math.Max(max[nxt],max[now]+1);
				if(Indeg[nxt] == 0){
					Q.Enqueue(nxt);
				}
			}
		}
		
		Console.WriteLine(max.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