USACO 2017 February Contest Bronze Division - Why Did the Cow Cross the Road#
Problem link: here
Solution Author: Stefan Dascalescu
Problem Solution#
Process crossings left to right and see what changes occured.
Source codes#
The source codes in C++ and Python can be seen below.
#include <bits/stdc++.h>
using namespace std;
int main()
{
ifstream cin("crossroad.in");
ofstream cout("crossroad.out");
int n, cnt = 0;
cin >> n;
vector<int> signs(11, -1);
for(int i = 0; i < n; i++)
{
int a, b;
cin >> a >> b;
if(signs[a] != b && signs[a] != -1)
cnt++;
signs[a] = b;
}
cout << cnt;
return 0;
}