Skip to content

Commit 4cf29cd

Browse files
committed
Adding submissions
1 parent 93edc50 commit 4cf29cd

File tree

2 files changed

+54
-1
lines changed

2 files changed

+54
-1
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// http://codeforces.com/contest/424/problem/A
2+
3+
#include<bits/stdc++.h>
4+
using namespace std;
5+
#define __ ios_base::sync_with_stdio(0); cin.tie(0);
6+
#define endl '\n'
7+
#define foreach(it, x) for (__typeof (x).begin() it = (x).begin(); it != (x).end(); ++it)
8+
#define all(x) x.begin(),x.end()
9+
#define D(x) cout << #x " = " << (x) << endl;
10+
11+
template <class T> string toStr(const T &x)
12+
{ stringstream s; s << x; return s.str(); }
13+
14+
template <class T> int toInt(const T &x)
15+
{ stringstream s; s << x; int r; s >> r; return r; }
16+
17+
int dx[8] = {-1,-1,-1,0,1,1, 1, 0};
18+
int dy[8] = {-1, 0, 1,1,1,0,-1,-1};
19+
20+
int main() {
21+
int n;
22+
cin >> n;
23+
24+
string s;
25+
cin >> s;
26+
27+
int up = 0;
28+
for (int i = 0; i < n; ++i) if (s[i] == 'X') up ++;
29+
30+
int ans;
31+
32+
if (up >= n / 2) {
33+
int cnt = up - (n / 2);
34+
ans = cnt;
35+
for (int i = 0; cnt > 0 ; i++) if (s[i] == 'X') {
36+
s[i] = 'x';
37+
cnt --;
38+
}
39+
}
40+
else {
41+
int cnt = (n / 2) - up;
42+
ans = cnt;
43+
for (int i = 0; cnt > 0 ; i++) if (s[i] == 'x') {
44+
s[i] = 'X';
45+
cnt --;
46+
}
47+
}
48+
49+
cout << ans << endl << s;
50+
51+
return 0;
52+
}

codeforces/data.db

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,4 +646,5 @@
646646
12997400
647647
12998226
648648
13001578
649-
13002330
649+
13002330
650+
13002434

0 commit comments

Comments
 (0)