아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Broken Swords

시간 제한1초메모리 제한1024 MB

요약
각 칼의 T, B, L, R 슬랫이 부서졌는지 주어질 때, 남은 슬랫을 짝지어 만들 수 있는 완성된 칼의 최대 개수와 남는 슬랫 수를 구한다.
난이도

보통10점 중 5점

유형
그리디, 구현, 수학
정답자
아직 제출이 없습니다

문제

Ken is a fencer with a big problem: he swings too hard!

Whenever Ken gets a new sword, he's sure to break it sooner rather than later. It's occurred to him that this habit is costing him quite a bit of money, since he normally buys a new sword whenever his current sword breaks. However, he's heard from a fellow club member that he could instead make new swords out of his old swords!

Each bamboo sword Ken uses has four bamboo 'slats' which help to cushion each blow for the receiving partner. Whenever Ken breaks his sword, he breaks either one, two, three, or all four slats.

When Ken first tried to put a sword together with the remains of two broken swords, he realized that not all slats are equivalent. When the slats are bundled together, they conform to the shape of the slat which sits opposite!

Ken doesn't want an uncomfortable grip, so he will put only an old slat in a new position if it is of the same or opposite type.  There are four possible slats "top" (T), "bottom" (B), "left" (L), and "right" (R). When looking at a sword head on, these slats form the following configuration:

As an example, Ken will only replace a top slat with a top or bottom slat.

After collecting broken swords for quite a while, Ken has decided to build as many swords as possible.  Write a program to compute how many swords he will be able to build and how many slats he'll have left over!

입력

The input consists of a single test case. On the first line, you are given NN, the number of swords Ken has broken.  On each of the next NN lines, you are given four characters. The characters correspond to the following slat ordering: TBLR. If the character in a position is 0, then the slat is not broken, and if it is a 1, Ken is out of luck!

출력

Output three numbers: the total number of swords Ken can make, the sum of the numbers of the remaining T and B slats, and the sum of the numbers of the remaining L and R slats, respectively.

예제1

  1. 예제 1

    입력
    4
    0100
    0010
    0110
    1010
    
    예상 출력
    2 1 1