Codeforces A. Magnets
#include<bits/stdc++.h>
//#include<cstdio>
//#include<iostream>
//#include<algorithm>
//#include<vector>
//#include<cstring>
//#include<cmath>
//#include<map>
using namespace std;
#define fast ios_base::sync_with_stdio(false)
#define bfast cin.tie(0)
#define outs(x) cout << x << " "
#define outn(x) cout << x << "\n"
#define sf scanf
#define pf printf
typedef long long LL;
typedef vector<int>vii;
typedef vector<LL>vll;
int main()
{
fast;
int n , i , cnt=0;
string s, tmp="";
while(cin >> n)
{
tmp="";
cnt=0;
cin >> s;
tmp = s;
for(i=1; i<n; i++)
{
cin >> s;
if(s != tmp)
{
cnt++;
}
tmp = s;
}
cnt++;
outn(cnt);
}
return 0;
}
//#include<cstdio>
//#include<iostream>
//#include<algorithm>
//#include<vector>
//#include<cstring>
//#include<cmath>
//#include<map>
using namespace std;
#define fast ios_base::sync_with_stdio(false)
#define bfast cin.tie(0)
#define outs(x) cout << x << " "
#define outn(x) cout << x << "\n"
#define sf scanf
#define pf printf
typedef long long LL;
typedef vector<int>vii;
typedef vector<LL>vll;
int main()
{
fast;
int n , i , cnt=0;
string s, tmp="";
while(cin >> n)
{
tmp="";
cnt=0;
cin >> s;
tmp = s;
for(i=1; i<n; i++)
{
cin >> s;
if(s != tmp)
{
cnt++;
}
tmp = s;
}
cnt++;
outn(cnt);
}
return 0;
}
Comments
Post a Comment