IOI2006 D0-3:HIGHWAYS

来源:互联网 发布:云豹手机直播系统源码 编辑:程序博客网 时间:2024/05/16 06:35

 IOI2006 D0-3

Highways Country: Official Version

IOI’06 English

Practice – Task 3 Version 1.0

 

HIGHWAYS

There are c cities in the Yucatan Peninsula. These cities are interconnected via h highways.

Because of its flat surface, the highways of the peninsula have very few curves and drivers tend to

over speed. The government wants to implement a new traffic system that will set radars to

measure the speed of cars in the highways.

The government can afford to put radars in at most c highways. The governor wants to set the

radars so that for every city in the peninsula there is an odd number of highways that leave from

that city that have the radar system.

Help the governor achieve his goal.

The figure shows a map of the cities and the highways.

Circles represent the cities and lines represent the highways.

 

Thick lines represent the highways which have the radar

system. You can see that for every city there is an odd

number of highways that have the system. Also the number

of highways with the radar system is less than c.

The cities will be arbitrarily numbered from 1 to c.

 

 

TASK

Write a program that given the map of the cities and the highways decides on which highways to

set the radar system so that the goal of the governor is achieved and the budget is not exceeded.

 

CONSTRAINTS

0 < c _ 10 000

0 < h _ 100 000

 

INPUT

Your program must read from the file highways.in the following data

highways.in DESCRIPTION

6 7

1 2

2 4

4 6

3 5

4 5

2 3

5 6

LINE 1: Contains 2 space-separated integers that represent c and h

respectively

NEXT h LINES: Each line contains 2 space-separated integers that

represent a highway. The integers represent the cities in each

end of the highway.

 

OUTPUT

Your program must write to the file highways.out the following data

highway.out DESCRIPTION

4

1 2

2 3

2 4

5 6

LINE 1: Must contain one integer that represents the number of

highways in which the radar system will be implemented or –1

if it is impossible to achieve the desired goal.

NEXT LINES: Must contain 2 space-separated integers that represent

the highway in which the system will be implemented.

 

GRADING INFO

In one test case every test run will satisfy the following constraints:

0 < c _ 50

0 < h _ 1 000

 

原创粉丝点击