Submission #15106396
Source Code Expand
N = gets.to_i
E = Array.new(N){ [] }
(N-1).times{
u,v = gets.split.map(&:to_i)
E[u-1] << v-1
E[v-1] << u-1
}
P = [nil]*N
P[0] = 0
Q = [0]
while p = Q.shift
E[p].each{|c|
next if P[c]
P[c] = p
Q << c
}
end
p N+(1...N).sum{|c|
p = P[c]
[(c+1)*(p-c),(p-c)*(c-N),].max
}
Submission Info
| Submission Time | |
|---|---|
| Task | F - Intervals on Tree |
| User | ds14050 |
| Language | Ruby (2.7.1) |
| Score | 600 |
| Code Size | 307 Byte |
| Status | AC |
| Exec Time | 351 ms |
| Memory | 35716 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 600 / 600 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | s1.txt, s2.txt, s3.txt |
| All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, s1.txt, s2.txt, s3.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 01.txt | AC | 60 ms | 14180 KiB |
| 02.txt | AC | 62 ms | 14136 KiB |
| 03.txt | AC | 65 ms | 14244 KiB |
| 04.txt | AC | 59 ms | 14224 KiB |
| 05.txt | AC | 68 ms | 14112 KiB |
| 06.txt | AC | 68 ms | 14208 KiB |
| 07.txt | AC | 67 ms | 14180 KiB |
| 08.txt | AC | 63 ms | 14156 KiB |
| 09.txt | AC | 60 ms | 14080 KiB |
| 10.txt | AC | 62 ms | 14328 KiB |
| 11.txt | AC | 330 ms | 35596 KiB |
| 12.txt | AC | 333 ms | 35716 KiB |
| 13.txt | AC | 339 ms | 35072 KiB |
| 14.txt | AC | 326 ms | 35200 KiB |
| 15.txt | AC | 325 ms | 35424 KiB |
| 16.txt | AC | 330 ms | 35080 KiB |
| 17.txt | AC | 273 ms | 28976 KiB |
| 18.txt | AC | 144 ms | 21428 KiB |
| 19.txt | AC | 348 ms | 35376 KiB |
| 20.txt | AC | 351 ms | 35164 KiB |
| 21.txt | AC | 347 ms | 31684 KiB |
| 22.txt | AC | 349 ms | 31436 KiB |
| 23.txt | AC | 304 ms | 31476 KiB |
| s1.txt | AC | 55 ms | 14240 KiB |
| s2.txt | AC | 64 ms | 14180 KiB |
| s3.txt | AC | 62 ms | 14104 KiB |