Source Code
# include <bits/stdc++.h>
# define ll long long
# define all(x) x.begin(),x.end()

using namespace std ;

void solve() {
    int n , ans = 0 ; cin >> n ;
    vector<int> v(n) ;
    for (int i = 0; i < n; ++i) {
        cin >> v[i] ;
    }
    for (int i = 1; i < n; ++i) {
        ans += ( v[i-1] != v[i] ) ;
    }
    cout << ans << '\n' ;
}

int main () {
    cin.tie(0), cout.tie(0), cin.sync_with_stdio(0), cout.sync_with_stdio(0) ;
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
    int t = 1 ; // cin >> t ;
    while ( t-- )
        solve() ;
    // Bakii
    return 0 ;
}
Copy
Tha Bits Bakii
GNU G++17
1 ms
256 KB
Wrong Answer