Skip to content

Commit 051d57c

Browse files
committed
string addition
1 parent 36b13b6 commit 051d57c

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

1144.E. Median String.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#include "stdc++.h"
2+
3+
int main() {
4+
int n;
5+
string s, t;
6+
cin >> n >> s >> t;
7+
reverse(ALL(s));
8+
reverse(ALL(t));
9+
for (int i=0; i<s.size(); ++i) {
10+
s[i] = s[i]-'a' + t[i]-'a';
11+
if (s[i] > 25) {
12+
s[i] -= 26;
13+
if (i+1==s.size())
14+
s.PB(1);
15+
else
16+
++s[i+1];
17+
}
18+
}
19+
reverse(ALL(s));
20+
int c = 0;
21+
FOR(i, SZ(s)) {
22+
if (c) {
23+
s[i] += 26;
24+
c = 0;
25+
}
26+
c = s[i] & 1;
27+
s[i] = (s[i]>>1) + 'a';
28+
}
29+
cout << s.substr(SZ(s)-n) << endl;
30+
return 0;
31+
}

0 commit comments

Comments
 (0)