結果

問題 No.497 入れ子の箱
ユーザー kuuso1kuuso1
提出日時 2017-07-01 16:29:35
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,787 bytes
コンパイル時間 1,163 ms
コンパイル使用メモリ 114,896 KB
実行使用メモリ 32,608 KB
最終ジャッジ日時 2024-04-15 10:51:22
合計ジャッジ時間 3,775 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
25,064 KB
testcase_01 AC 31 ms
27,080 KB
testcase_02 WA -
testcase_03 AC 58 ms
32,608 KB
testcase_04 AC 59 ms
30,692 KB
testcase_05 AC 58 ms
30,560 KB
testcase_06 AC 57 ms
30,556 KB
testcase_07 AC 59 ms
32,608 KB
testcase_08 AC 58 ms
30,692 KB
testcase_09 AC 57 ms
28,640 KB
testcase_10 AC 57 ms
30,440 KB
testcase_11 AC 58 ms
24,576 KB
testcase_12 AC 54 ms
22,784 KB
testcase_13 AC 54 ms
22,400 KB
testcase_14 AC 54 ms
22,400 KB
testcase_15 AC 54 ms
22,528 KB
testcase_16 AC 54 ms
22,656 KB
testcase_17 AC 54 ms
22,656 KB
testcase_18 AC 56 ms
24,960 KB
testcase_19 AC 57 ms
24,576 KB
testcase_20 AC 57 ms
24,832 KB
testcase_21 AC 58 ms
24,704 KB
testcase_22 AC 57 ms
24,704 KB
testcase_23 AC 57 ms
28,160 KB
testcase_24 AC 57 ms
28,160 KB
testcase_25 AC 31 ms
18,816 KB
testcase_26 AC 32 ms
18,944 KB
testcase_27 AC 59 ms
24,448 KB
testcase_28 AC 60 ms
24,576 KB
testcase_29 AC 59 ms
24,704 KB
testcase_30 AC 46 ms
19,456 KB
testcase_31 AC 47 ms
19,840 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