結果
| 問題 |
No.497 入れ子の箱
|
| コンテスト | |
| ユーザー |
kuuso1
|
| 提出日時 | 2017-03-24 23:09:38 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 45 ms / 5,000 ms |
| コード長 | 1,662 bytes |
| コンパイル時間 | 867 ms |
| コンパイル使用メモリ | 108,544 KB |
| 実行使用メモリ | 24,832 KB |
| 最終ジャッジ日時 | 2024-07-05 23:30:59 |
| 合計ジャッジ時間 | 3,212 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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));}
}
kuuso1