#include <bits/stdc++.h> using namespace std; int main(){ ios_base::sync_with_stdio(0); cin.tie(NULL); int a; cin >> a; string n; cin >> n; int A = 0; int B = 0; for(int i =0; i < n.size(); i++){ if(n[i] == 'a'){ A = A + 1; } if(n[i] == 'b'){ B = B + 1; } } cout << A << " " << B << " "; cout << n.size() / 2 - min(A,B); return 0; }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter