#PU711. USACO 2017 February Contest, Bronze — Problem 1. Why Did the Cow Cross the Road

    ID: 1362 传统题 文件IO:crossroad 2000ms 256MiB 尝试: 0 已通过: 0 难度: 普及 上传者: 标签>USACO赛事:feb17来源:usaco.orgscoring:equal_test_cases模拟枚举

USACO 2017 February Contest, Bronze — Problem 1. Why Did the Cow Cross the Road

USACO 2017 February Contest, Bronze — Problem 1. Why Did the Cow Cross the Road

题目描述

While the age-old question of why chickens cross roads has been addressed in great depth by the scientific community, surprisingly little has been published in the research literature on the related subject of cow crossings. Farmer John, well-aware of the importance of this issue, is thrilled when he is contacted by a local university asking for his assistance in conducting a scientific study of why cows cross roads. He eagerly volunteers to help. As part of the study, Farmer John has been asked to document the number of times each of his cows crosses the road. He carefully logs data about his cows' locations, making a series of NN observations over the course of a single day. Each observation records the ID number of a cow (an integer in the range 1…101 \ldots 10, since Farmer John has 10 cows), as well as which side of the road the cow is on. Based on the data recorded by Farmer John, please help him count the total number of confirmed crossings. A confirmed crossing occurs when a consecutive sightings of a cow place it on different sides of the road.

输入格式

The first line of input contains the number of observations, NN, a positive integer at most 100. Each of the next NN lines contains one observation, and consists of a cow ID number followed by its position indicated by either zero or one (zero for one side of the road, one for the other side).

输出格式

Please compute the total number of confirmed crossings.

数据范围

(见题面原文)

样例

样例 1

8
3 1
3 0
6 0
2 1
4 1
3 0
4 0
3 1
3
In this example, cow 3 crosses twice -- she first appears on side 1, then later appears
on side 0, and then later still appears back on side 1. Cow 4 definitely crosses
once.  Cows 2 and 6 do not appear to cross.
Problem credits: Brian Dean