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

Restoran

스페셜 저지 — 출력을 사용자 정의 프로그램으로 검사하므로 여러 정답이 인정될 수 있습니다.
Diamond IV 다이아몬드 IV
난이도
1s
시간 제한
128MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

In Croatia there are \(N\) cities connected by \(E\) two-way roads. Two large food chains have recently reached an agreement on market sharing. In the middle of each road, exactly one chain will be given rights to build a restaurant.

To ensure the market is shared fairly, each city must have at least one restaurant from each chain on the roads connected to that city. However, there are cities with only one road, or no roads at all, and for them it is impossible to have both chains. Such cities are doomed to visit one chain, or travel a bit further.

Write a program that will determine for each road the chain that should build there so that these requirements are met.

제약

This taks has test cases grouped into test runs. Each test run consists of one
or more test cases. In order to score points for the test run, all test cases in
the run must be solved correctly.
You do not need to worry about test runs during input and output. The
system does that for you. Follow the format described in INP\(UT/OU\)TPUT to
the letter!
Test runs worth 60% have \(N \le 1000\), \(E \le 5000\).
SAMPLE TEST CASES
Input:
5 6
1 2
2 3
3 1
3 4
1 4
4 5
Input:
7 7
1 2
2 3
3 1
4 5
5 6
6 7
7 4
Input:
77777 4
1 2
1 3
1 4
1 5
Output:
1
2
1
2
2
1
Output:
0
Output:
1
2
2
2

입력 형식

The first line of input contains two integers \(N\) and \(E\) (\(1 \le N, E \le 100\,000\)), the number of cities and the number of roads.

The next \(E\) lines contain two integers each. Each line describes one road. Integers \(A_i\) and \(B_i\) (\(1 \le A_i, B_i \le N\); \(A_i \ne B_i\)) denote a road connecting cities \(A_i\) and \(B_i\).

There will never be two or more roads connecting the same cities.

출력 형식

If there is no way to fairly assign the roads, the first and only line of output should contain 0.

Otherwise output exactly \(E\) lines, one for each road, in the same order as they were given in the input. The \(i\)-th line should contain 1 if the first chain has the right to build on this road, or 2 if the second one does.

Note: if the solution is not unique, you may output any valid one.

Scoring: This task has test cases grouped into test runs. In order to score points for a test run, all test cases in the run must be solved correctly. Test runs worth \(60\%\) of points have \(N \le 1000\), \(E \le 5000\).

서브태스크
서브태스크점수설명

Test 1

5점

None

Test 2

5점

None

Test 3

5점

None

Test 4

5점

None

Test 5

5점

None

Test 6

5점

None

Test 7

5점

None

Test 8

5점

None

Test 9

5점

None

Test 10

5점

None

Test 11

5점

None

Test 12

5점

None

Test 13

5점

None

Test 14

5점

None

Test 15

5점

None

Test 16

5점

None

Test 17

5점

None

Test 18

5점

None

Test 19

5점

None

Test 20

5점

None

예제 1
입력
5 6
1 2
2 3
3 1
3 4
1 4
4 5
출력
1
2
1
2
2
1
예제 2
입력
7 7
1 2
2 3
3 1
4 5
5 6
6 7
7 4
출력
0
예제 3
입력
77777 4
1 2
1 3
1 4
1 5
출력
1
2
2
2
문제 정보

riseoj 작성

출처 COCI 2009/2010 Contest 7

평가 및 의견

Restoran

개요
출제자 난이도 Diamond IV 다이아몬드 IV 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

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

풀이 제출

Restoran

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