File tree Expand file tree Collapse file tree 1 file changed +55
-0
lines changed
Expand file tree Collapse file tree 1 file changed +55
-0
lines changed Original file line number Diff line number Diff line change 1+ /* *
2+ * @file 9565.cpp
3+ * @author Macesuted ([email protected] ) 4+ * @date 2024-11-06
5+ *
6+ * @copyright Copyright (c) 2024
7+ *
8+ */
9+
10+ #include < bits/stdc++.h>
11+ using namespace std ;
12+
13+ #ifndef LOCAL
14+ #define endl ' \n '
15+ #endif
16+
17+ bool mem1;
18+
19+ void solve (void ) {
20+ string s;
21+ cin >> s;
22+ for (int i = 1 ; i < (int )s.size (); i += 2 )
23+ if (s[i] == ' 0' )
24+ s[i] = ' 1' ;
25+ else if (s[i] == ' 1' )
26+ s[i] = ' 0' ;
27+
28+ int cnt[3 ] = {0 , 0 , 0 };
29+ for (auto i : s) cnt[i - ' 0' ]++;
30+
31+ int ans = abs (cnt[0 ] - cnt[1 ]) - cnt[2 ];
32+ if (ans < 0 ) ans = abs (ans % 2 );
33+
34+ cout << ans << endl;
35+
36+ return ;
37+ }
38+
39+ bool mem2;
40+
41+ int main () {
42+ ios::sync_with_stdio (false ), cin.tie (nullptr );
43+ #ifdef LOCAL
44+ cerr << " Memory Cost: " << abs (&mem1 - &mem2) / 1024 . / 1024 . << " MB" << endl;
45+ #endif
46+
47+ int _ = 1 ;
48+ cin >> _;
49+ while (_--) solve ();
50+
51+ #ifdef LOCAL
52+ cerr << " Time Cost: " << clock () * 1000 . / CLOCKS_PER_SEC << " MS" << endl;
53+ #endif
54+ return 0 ;
55+ }
You can’t perform that action at this time.
0 commit comments