fork download
  1. #include <iostream>
  2. #include <string>
  3. #define endl '\n'
  4. using namespace std;
  5.  
  6. int main() {
  7. ios_base::sync_with_stdio(false);
  8. cin.tie(NULL);
  9. int n , cnt = 1;
  10. cin >> n;
  11. string c , p;
  12. cin >> p;
  13. for(int i = 1; i < n - 1; ++i)
  14. {
  15. cin >> c;
  16. if(c != p)
  17. {
  18. ++cnt;
  19. }
  20. p = c;
  21. }
  22. cout << cnt << endl;
  23. return 0;
  24. }
Success #stdin #stdout 0.01s 5284KB
stdin
4
01
01
10
10
stdout
2