F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

oasis in desert

Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 272    Accepted Submission(s): 72


Problem Description
There are N oases connected by M roads in the desert,and each road is L km long.Now a traveler who can at most walk K km with his supplies.

We define two concept now:

1.The Biggest Dangerous Oasis List: For every pair of oases in the list,their minimum distance should be longer than K km.And the size of The Biggest Dangerous Oasis List is biggest among lists which meet the condition.

2.The Smallest Safe Oasis List:for every pair of oases in the desert,if their minimum distance is shorter than K km,the list should contain at least one of them .And the size of The Smallest Safe Oasis List is smallest among lists which meet the condition.

Now the traveler wants to get a list which is both The Biggest Dangerous Oasis List and The Smallest Safe Oasis List.
 

Input
There is a t in the first line,means k cases.In each case,there is firstly n (0<= n <= 500 ),m(0<=m<=n*(n-1)/2) and k(0<=k<=100000).Then m lines, each line input a,b(1<=a,b<=n),and l(0<=l<=100000),means there is a road which is l km long between a and b.
 

Output
for each case,firstly the size of the list,then print the oases in the list in increasing order,separated by spaces.
If there are multiple answers, print the lexicographically smallest one.
If there is no list, output "Impossible"
 

Sample Input
1 6 7 30 1 2 40 1 3 20 1 4 30 2 3 15 5 3 20 5 6 20 3 6 50
 

Sample Output
3 1 2 5
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 21:15:54, Gzip enabled