0% found this document useful (0 votes)
135 views1 page

Problem C Cable Car: 3 147.3 N 1 N K I MS ME I VS VE

The document describes a cable car problem from a programming contest in Vietnam. The problem involves two cable car companies, Mobi and Vina, operating on a mountain with n stations numbered 1 to n. Each company operates k cable cars connecting stations. The conditions require that each company's cable cars uniquely connect lower numbered stations to higher numbered stations, and that no pair of stations is connected by both companies. The task is to check if it is possible for each company to operate k cable cars satisfying these conditions, given inputs n and k.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
135 views1 page

Problem C Cable Car: 3 147.3 N 1 N K I MS ME I VS VE

The document describes a cable car problem from a programming contest in Vietnam. The problem involves two cable car companies, Mobi and Vina, operating on a mountain with n stations numbered 1 to n. Each company operates k cable cars connecting stations. The conditions require that each company's cable cars uniquely connect lower numbered stations to higher numbered stations, and that no pair of stations is connected by both companies. The task is to check if it is possible for each company to operate k cable cars satisfying these conditions, given inputs n and k.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

15/11/2020 Cable Car – Kattis, ICPC Vietnam National Programming Contest 2020

Problem ID: vietnam-

Problem C
national20.cablecar
CPU Time limit: 1 second

Cable Car Memory limit: 1024 MB

At 3 147.3 meters high, Fansipan is the tallest mountain in the Indochina peninsula. To promote tourism, n stations were built
on the mountain, numbered from 1 to n.

Two companies, Mobi and Vina are in charge of operating cable cars connecting the stations. Each of the two companies have k

cable cars. The i-th cable car of Mobi connects two stations M Si and M Ei . The i-th cable car of Vina connects two stations
V Si and V Ei .

Two stations are called connected by a company, i we can go from one station to the other by using cable cars only of that
company. To achieve peaceful cooperation, the two companies agreed with the following conditions:

For every valid i, M Si < M Ei and V Si < V Ei .

All M Si are unique, all M Ei are unique.

All V Si are unique, all V Ei are unique.

For any i ≠ j, if M Si < M Sj , then M Ei < M Ej .

For any i ≠ j, if V Si < V Sj , then V Ei < V Ej .

No pair of stations is connected by both companies. In other words, for every pair of stations i and j, if i and j are
connected by Mobi, they should not be connected by Vina, and vice versa.

Given n and k, your task is to check whether it is possible for Mobi and Vina to each operates k cable cars, satisfying all the
above conditions.

Input
The input contains two integers n and k, separated by a single space (1 ≤ k < n ≤ 100) .

Output
For each test case, if it is not possible to satisfy all the conditions, print ‘NO’. Otherwise, print ‘YES’, followed by 2 ⋅ k lines. In
the rst k lines, the i-th line contains two integers M Si and M Ei . In the last k lines, the i-th line contains two integers V Si

and V Ei .

Sample Input 1 Sample Output 1


3 1 YES
1 2
1 3

Sample Input 2 Sample Output 2


3 2 NO

https://vietnam-national20.kattis.com/problems/vietnam-national20.cablecar 1/1

You might also like