fork(1) download
  1. #include <iostream>
  2. #include <stdio.h>
  3. using namespace std;
  4.  
  5. int main() {
  6. int n, cnt=1;
  7. string s, tmp;
  8. scanf("%d", &n);
  9. for(int i=0; i<n; i++) {
  10. cin>>s;
  11. if(i==0) {tmp=s; continue;}
  12. else {if(s!=tmp) cnt++;}
  13. tmp=s;
  14. }
  15. printf("%d", cnt);
  16. return 0;
  17. }
Success #stdin #stdout 0s 3476KB
stdin
4
01
01
10
10
stdout
2