結果
| 問題 |
No.2427 Tree Distance Two
|
| コンテスト | |
| ユーザー |
bluemegane
|
| 提出日時 | 2023-08-19 06:59:07 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 972 bytes |
| コンパイル時間 | 2,223 ms |
| コンパイル使用メモリ | 105,216 KB |
| 実行使用メモリ | 111,948 KB |
| 最終ジャッジ日時 | 2024-11-28 21:23:05 |
| 合計ジャッジ時間 | 29,891 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 29 TLE * 6 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System.Collections.Generic;
using System;
public class Hello
{
static void Main()
{
var n = int.Parse(Console.ReadLine().Trim());
getAns(n);
}
static void getAns(int n)
{
var aa = new List<int>[n];
for (int i = 0; i < n; i++) aa[i] = new List<int>();
for (int i = 0; i < n - 1; i++)
{
string[] line = Console.ReadLine().Trim().Split(' ');
var a = int.Parse(line[0]) - 1;
var b = int.Parse(line[1]) - 1;
aa[a].Add(b);
aa[b].Add(a);
}
var ans = new int[n];
foreach (var x in aa)
{
var m = x.Count;
if (m <= 1) continue;
for (int i = 0; i < m - 1; i++)
for (int j = i + 1; j < m; j++)
{
ans[x[i]]++;
ans[x[j]]++;
}
}
Console.WriteLine(string.Join("\n", ans));
}
}
bluemegane