1471: 换换换!

文件提交:无需freopen 内存限制:128 MB 时间限制:1.000 S
评测方式:普通裁判 命题人:
提交:1 解决:1

题目描述

阿源和阿粮为了打发时间,玩起了一种游戏,叫做“推杯换盏”。

游戏准备阶段,阿源在桌子上放置三个倒置的一次性纸杯,并在其中一个纸杯下面藏了一块小的鹅卵石。随后阿源会两两调换纸杯(大家一定玩过换纸杯猜小球的游戏),同时阿粮试着去猜鹅卵石的位置。

这个游戏的标准形式是玩家可以看见初始位置,然后要求玩家猜所有交换完成之后鹅卵石的位置。

然而这两个同学想要这样玩,阿粮不知道鹅卵石的初始位置,同时他可以在每一次交换之后猜一下鹅卵石的位置。阿源知道正确答案,在游戏结束后会给阿粮一个分数,等于他猜对的次数。

给定所有的交换和阿粮的猜测,但是不给出鹅卵石的初始位置,请求出阿粮最高可能获得的分数。

以下是英文原版内容:

To pass the time, Bessie the cow and her friend Elsie like to play a version of a game they saw at the county fair.

To start, Bessie puts three inverted shells on a table and places a small round pebble under one of them (at least she hopes it is a pebble -- she found it on the ground in one of the pastures). Bessie then proceeds to swap pairs of shells, while Elsie tries to guess the location of the pebble.

The standard version of the game the cows saw being played at the county fair allowed the player to see the initial location of the pebble, and then required guessing its final location after all the swaps were complete.

However, the cows like to play a version where Elsie does not know the initial location of the pebble, and where she can guess the pebble location after every swap. Bessie, knowing the right answer, gives Elsie a score at the end equal to the number of correct guesses she made.

Given the swaps and the guesses, but not the initial pebble location, please determine the highest possible score Elsie could have earned.



输入

The first line of the input file contains an integer N giving the number of swaps (1≤N≤100). Each of the next N lines describes a step of the game and contains three integers a, b, and g, indicating that shells a and b were swapped by Bessie, and then Elsie guessed shell gafter the swap was made. All three of these integers are either 1, 2, or 3, and a≠b.

输出

输出阿粮可以得到的最高分数。 
Please output the maximum number of points Elsie could have earned. 

样例输入

3
1 2 1
3 2 1
1 3 1

样例输出

2

提示

在这个例子中,阿粮最多可以获得2分。如果鹅卵石开始时位于杯子1下面,那么他猜中了一次(最后一次)。如果鹅卵石开始时位于杯子2下面,那么他猜中了两次(开始两次)。如果鹅卵石开始时位于杯子3下面,那么她没有猜对任何一次。

来源/分类