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

Slicice

스페셜 저지 — 출력을 사용자 정의 프로그램으로 검사하므로 여러 정답이 인정될 수 있습니다.
Platinum II 플래티넘 II
난이도
3s
시간 제한
32MB
메모리 제한
1
맞았습니다!!
4
제출 수
25.0%
정답률
레이팅

의견: 0

설명

After their pool burst, Mirko and Slavko started collecting cards. In their neighbourhood, card
collection is taken seriously and there are strict rules for the purchase and trading of cards.
Purchasing cards is always done by two children together. Each of them gives half the required funds
and two cards are bought. Then they race to the fountain downtown, the winner getting both cards. If
they arrive at the exact same time, each of them gets one of the cards.
At first the rules performed okay, but soon accusations started that some kids could not have acquired
their cards only through such purchases.
One day all the children met to figure out if there were irregularities. They managed to agree on the
exact number of cards each of them currently has. They also made a partial list of who went to the
store with whom, but they do not know who won any of the races and took the cards on those
occasions.
Write a program that determines who participated in all purchases that were made and who won the
subsequent races so that after all the purchases, the cards counts correspond to the given counts.
Assume that before any purchases, the children had no cards.
If there are multiple possible solutions, output any of them.

제약
입력 형식

The first line contains the integers \(N\) and \(M\) (\(1 \le N \le 100\), \(0 \le M \le 1000\)), the number of children and the number of purchases they recall. The children are labeled \(1\) through \(N\).

The second line contains \(N\) integers, the number of cards each child currently has.

The following \(M\) lines contain two integers each, the labels of the children who made the purchase.

출력 형식

On the first line, output the total number of purchases.

Each of the following lines should describe one purchase. The description of a purchase consists of three numbers: the labels of the children that made the purchase and the number \(0\), \(1\) or \(2\), how many cards the first child got after the race.

Note: A solution will always exist, although not necessarily unique. The total number of purchases will be at most \(1000\).

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

Subtask 1

130점
예제 1
입력
2 3
5 1
1 2
1 2
1 2
출력
3
1 2 1
1 2 2
1 2 2
예제 2
입력
4 3
5 3 1 1
1 3
2 3
4 1
출력
5
1 3 1
2 3 2
4 1 0
2 4 1
1 3 2
예제 3
입력
5 0
3 0 2 4 1
출력
5
1 2 2
1 3 1
4 2 2
3 4 0
3 5 1
문제 정보

riseoj 작성

출처 COCI 2008/2009 Contest 6

평가 및 의견

Slicice

개요
출제자 난이도 Platinum II 플래티넘 II 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

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

풀이 제출

Slicice

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