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

Praktični

Unrated 레이팅 미적용
난이도
1s
시간 제한
64MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

1 \(s / 64\) \(MB / 130\) points

While writing an exam, Ivan had problems with the following task:
"In the input there is an integer number N. Find the N {th}{ } digit of the number 0.135791113151719 ..."

In order to succeed in the next attempt to pass the exam and so saving himself from repeating the

academic year, he decided to practice by being the main character in tasks such as the following:

An undirected graph of \(N\) nodes and \(M\) edges is given. Each edge has a value, an integer number

less than 10 {9}{ }.
A simple cycle (a cycle without repeating nodes) is good if the bitwise XOR of all the values of the

cycle’s edges is equal to zero.
Ivan can make a number of operations on the graph. An operation consists of the following steps:

Ivan selects an integer number \(x\) ;

then he selects a n\(on-em\)pty subset of edges of the given graph;

and then he applies bitwise XOR by number \(x\) on all the the selected edges (If one of the

selected edges has a value \(p\) , after the described operation, the new value of that edge will be

equal to \(p\) XOR \(x\) )

Ivan wants to obtain a graph in which every simple cycle is good. Also, he wants to do so in as few

operations as possible. Determine the minimum possible number of operations after which each

simple cycle is good and print them. It can be proved that it is always possible to meet Ivan's

requirements with a certain sequence of operations.

제약

In the test samples worth 20% of the total points, the minimum number of required operations will be

equal to 1.
In the test samples worth additional 40% of the total points all the numbers from input will be less

than or equal to 10 {6}{ }.

1 \(s / 64\) \(MB / 130\) points

입력 형식

The first line contains two positive integers \(N\) and \(M\) (1 ≤ N, \(M\) ≤100 000), the number of nodes and

the number of edges.
In the i {th}{ } of the following \(M\) lines there is a description of the \(i\) {th}{ } edge: three integer numbers \(a\) {i}{ }, \(b\) {i}{ }i \(p\) {i}
(1 ≤ \(a\)
{ }, \(b\) { }≤ N, a { } ≠ \(b\) { }, { }0 ≤ \(p\) {i}{ }≤ 10 {9}{ }), the nodes connected with the \(i\) {th}{ } edge and the value of the edge.
The graph is connected and all the edges are different.

출력 형식

In the first line of output, print \(K\) , minimum number of task operations.
In each of the following \(K\) lines, print a sequence numbers separated by space:

the first number in the row is the number \(x\) from the operation;

the second number is \(B\) , the number of selected bridges;

then follows \(B\) numbers, \(E\) {i} (1 ≤ \(E\) \(M\) ) which indicate labels of the selected edges in the

ascending order.
All numbers in the output should be less than or equal to \(2 \cdot 10\) {9}{ }.

예제 1
입력
4 4
1 2 10
2 3 9
3 4 8
4 1 7


2 1
1 2 3


6 8
1 2 6
2 3 1
3 5 6
3 1 5
4 5 0
3 6 0
4 2 8
4 1 1
출력
output
output
1
12 3 1 2 3


0

2
2 2 4 6
15 1 7
설명

Explanation of test samples:

In the first test sample, the initial graph is given in the image left below, and the final graph (after applying XOR
on the first three edges with 12) is given in the image right below. The only cycle in the graph is good because
XOR of its edges is 0.

In the second test sample, there is no cycle, so the claim "every simple cycle is good" is trivially fulfilled. That is
why the number of required operations is 0.

문제 정보

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

출처 COCI 2018/2019 Contest 3

평가 및 의견

Praktični

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

Log in to rate problems.

개별 의견

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

풀이 제출

Praktični

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