Submission #654957

#TimeUsernameProblemLanguageResultExecution timeMemory
654957BliznetcAron (COCI17_aron)C++17
50 / 50
1 ms212 KiB
#include <bits/stdc++.h> #pragma GCC optimize("unroll-loops") #pragma GCC optimize("-O3") #pragma GCC target("avx2") using namespace std; #define pb push_back #define sz size() #define all(x) x.begin(), x.end() #define F first #define S second typedef pair < int, int > pii; typedef vector < int > vi; typedef vector < vi > vvi; void solve(){ int n; cin >> n; char a[n + 7]; for (int i = 1; i <= n; i++) { cin >> a[i]; } int ans = 0; for (int i = 1; i <= n; i++) { int pos = n; for (int j = i + 1; j <= n; j++) { if (a[i] != a[j]) { pos = j - 1; break; } } ans++; i = pos; } cout << ans + 1; } signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t = 1; //cin >> t; while (t--) { solve(); cout << "\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...