結果

問題 No.497 入れ子の箱
ユーザー kuuso1
提出日時 2017-07-01 16:29:35
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,787 bytes
コンパイル時間 1,166 ms
コンパイル使用メモリ 110,736 KB
実行使用メモリ 32,608 KB
最終ジャッジ日時 2024-10-05 05:34:21
合計ジャッジ時間 3,059 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 29
権限があれば一括ダウンロードができます
コンパイルメッセージ
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