Skip to content

Commit 67d6a51

Browse files
committed
Solve problem 709C from codeforces
1 parent 892c4c0 commit 67d6a51

File tree

3 files changed

+43
-6
lines changed

3 files changed

+43
-6
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
5+
typedef long long ll;
6+
7+
int const N = 1e5 + 1;
8+
char s[N];
9+
10+
int main() {
11+
scanf("%s", s);
12+
13+
int len = strlen(s), idx = -1;
14+
for(int i = 0; i < len; ++i)
15+
if(s[i] != 'a') {
16+
idx = i;
17+
break;
18+
}
19+
20+
if(idx == -1) {
21+
s[len - 1] = 'z';
22+
puts(s);
23+
return 0;
24+
}
25+
26+
while(idx < len && s[idx] != 'a') {
27+
s[idx] = char(int(s[idx]) - 1);
28+
++idx;
29+
}
30+
puts(s);
31+
32+
return 0;
33+
}
34+

CodeForces/863C. 1-2-3.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ using namespace std;
55
typedef long long ll;
66

77
int const N = 4;
8-
long long k, a, b, aa[N][N], bb[N][N], ra, rb, tmpa, tmpb, loops, c1, c2;
9-
bool vis1[N][N], vis2[N][N];
8+
ll k, a, b, aa[N][N], bb[N][N], ra, rb, tmpa, tmpb, loops, c1, c2;
9+
bool vis[N][N];
1010
vector<int> all;
1111

1212
int main() {
@@ -18,15 +18,15 @@ int main() {
1818
for(int j = 1; j < N; ++j)
1919
scanf("%lld", &bb[i][j]);
2020

21-
while(k > 0 && !vis1[a][b]) {
21+
while(k > 0 && !vis[a][b]) {
2222
if(a != b) {
2323
if((a == 3 && b == 2) || (a == 2 && b == 1) || (a == 1 && b == 3))
2424
++ra;
2525
else
2626
++rb;
2727
}
2828

29-
vis1[a][b] = true;
29+
vis[a][b] = true;
3030

3131
tmpa = aa[a][b];
3232
tmpb = bb[a][b];
@@ -38,15 +38,17 @@ int main() {
3838
}
3939

4040
if(k > 0) {
41-
while(!vis2[a][b]) {
41+
memset(vis, false, sizeof vis);
42+
43+
while(!vis[a][b]) {
4244
if(a == b)
4345
all.push_back(0);
4446
else if((a == 3 && b == 2) || (a == 2 && b == 1) || (a == 1 && b == 3))
4547
all.push_back(1);
4648
else
4749
all.push_back(2);
4850

49-
vis2[a][b] = true;
51+
vis[a][b] = true;
5052

5153
tmpa = aa[a][b];
5254
tmpb = bb[a][b];

CodeForces/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@
186186
- [706D. Vasiliy's Multiset](http://codeforces.com/contest/706/problem/D)
187187
- [707A. Brain's Photos](http://codeforces.com/problemset/problem/707/A)
188188
- [709B. Checkpoints](http://codeforces.com/problemset/problem/709/C)
189+
- [709C. Letters Cyclic Shift](http://codeforces.com/contest/709/problem/C)
189190
- [719A. Vitya in the Countryside](http://codeforces.com/problemset/problem/719/A)
190191
- [722A. Broken Clock](http://codeforces.com/problemset/problem/722/A)
191192
- [721A. One-dimensional Japanese Crossword](http://codeforces.com/problemset/problem/721/A)

0 commit comments

Comments
 (0)