RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
문제 ICPC00155

K. Train Splitting

스페셜 저지 — 출력을 사용자 정의 프로그램으로 검사하므로 여러 정답이 인정될 수 있습니다.
설명

There are \(n\) big cities in Italy, and there are \(m\) train routes between pairs of cities. Each route connects two different cities bidirectionally. Moreover, using the trains one can reach every city starting from any other city. Right now, all the routes are operated by the governme\(nt-ow\)ned Italian Carriage Passenger C\(om- pa\)ny, but the government wants to privatize the routes. The government does not want to give too much power to a single company, but it also does not want to make people buy a lot of different subscriptions. Also, it would like to give a fair chance to all companies. In order to formalize all these wishes, the following model was proposed. There will be \(k \ge 2\) private companies indexed by 1, 2, . . . , \(k\). Each train route will be operated by exactly one of the \(k\) companies. Then: • For any company, there should exist two cities such that it is impossible to reach one from the other using only routes operated by that company. • On the other hand, for any two companies, it should be possible to reach every city from any other city using only routes operated by these two companies. Find a plan satisfying all these criteria. It can be shown that a viable plan always exists. Please note that you can choose the number \(k\) and you do not have to minimize or maximize it.

제약
입력 형식

Each test contains multiple test cases. The first line contains an integer \(t\) (\(1 \le t \le 1000\)) — the number of test cases. The descriptions of the \(t\) test cases follow. The first line of each test case contains two integers \(n\) and \(m\) (\(3 \le n \le 50\), \(n - 1 \le m \le n\)(\(n - 1\))/2) — the number of cities and the number of train routes. The next \(m\) lines contain two integers \(u_{i}\) and \(v_{i}\) each (\(1 \le u_{i}\), \(v_{i} \le n\), \(u_{i}\)̸ = \(v_{i}\)) — the \(i-th\) train route connects cities \(u_{i}\) and \(v_{i}\). It is guaranteed that the routes connect \(m\) distinct pairs of cities. It is guaranteed that using the trains one can reach every city starting from any other city. The sum of the values of \(n\) over all test cases does not exceed 5000.

출력 형식

For each test case, on the first line print an integer \(k\) (\(2 \le k \le m\)) — the number of companies in your plan; on the second line print \(m\) integers \(c_{1}\), \(c_{2}\), . . . , \(c_{m}\) (\(1 \le c_{i} \le k\)) — in your plan company \(c_{i}\) operates the \(i-th\) route. If there are multiple valid plans, you may print any of them. Problem K: Train Splitting SWERC \(2022-2023\)

예제 1
입력
2
5 9
1 2
1 3
1 4
1 5
2 3
2 4
2 5
3 4
3 5
3 3
1 2
3 1
2 3
출력
4
1 2 3 1 4 2 2 4 3
3
2 3 1
문제 정보

생성자가 기록되지 않았습니다.

출처 ICPC SWERC 2022

평가 및 의견

K. Train Splitting

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

K. Train Splitting

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8