24 hour archive: Problem
2756  Gifts for Jerry 2756  Gifts for Jerry 2756  Gifts for Jerry
Statistics  Sub: 62  AC: 20  AC%: 32,26  Score: 4,00 
Created by  José Carlos González Fernández 
Added by  jcfernandez (20140313) 
Limits 
Total Time: 60000 MS

Test Time:
6000 MS
Memory: 62 MB  Output: 64 MB  Size:
14 KB

Enabled languages  
Available in 
Description
GusGus wants to give Jerry a new coat
able to withstand a temperature of at most t (0 <= t <= 10^9)
degrees, so he can go through the tunnels that have been built under the
house of Tom. The tunnels always connect two ladders, which allow to go
up to ground level. The tunnels may be traversed in either direction
and each has a set temperature Ti(1 <= Ti <= 10^9) due to the
depth to which it is, ensures that all the tunnels will have different
temperatures. Travelling through a tunnel with a temperature higher than
supported by the protective coat can cause death.
GusGus wants to give Jerry a new coat
able to withstand a temperature of at most t (0 <= t <= 10^9)
degrees, so he can go through the tunnels that have been built under the
house of Tom. The tunnels always connect two ladders, which allow to go
up to ground level. The tunnels may be traversed in either direction
and each has a set temperature Ti(1 <= Ti <= 10^9) due to the
depth to which it is, ensures that all the tunnels will have different
temperatures. Travelling through a tunnel with a temperature higher than
supported by the protective coat can cause death.
GusGus wants to give Jerry a new coat
able to withstand a temperature of at most t (0 <= t <= 10^9)
degrees, so he can go through the tunnels that have been built under the
house of Tom. The tunnels always connect two ladders, which allow to go
up to ground level. The tunnels may be traversed in either direction
and each has a set temperature Ti(1 <= Ti <= 10^9) due to the
depth to which it is, ensures that all the tunnels will have different
temperatures. Travelling through a tunnel with a temperature higher than
supported by the protective coat can cause death.
Input specification
Output specification
For each coat S answer how many pairs <A,B> (A < B) of ladders Jerry can select such that there is a path from the ladder A to the ladder B that Jerry can take if GusGus gives him the layer S.
;jsessionid=726C9DD7C3D738A032A2F05526D863A7For each coat S answer how many pairs <A,B> (A < B) of ladders Jerry can select such that there is a path from the ladder A to the ladder B that Jerry can take if GusGus gives him the layer S.
;jsessionid=726C9DD7C3D738A032A2F05526D863A7Sample input
5
1 2 1
1 3 5
1 4 4
2 3 2
3 4 3
3
10
2
1
Sample output
6
3
1