-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1606a.cpp
More file actions
43 lines (33 loc) · 794 Bytes
/
1606a.cpp
File metadata and controls
43 lines (33 loc) · 794 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <bits/stdc++.h>
using namespace std;
#define fastio ios::sync_with_stdio(false); cin.tie(NULL)
int main() {
fastio;
int t;
cin >> t;
while (t--) {
string s;
cin >> s;
int n = s.length();
// int ab = 0,ba = 0;
// for(int i = 0;i<n-1;i++){
// if(s[i] == 'a' && s[i+1] == 'b') ab++;
// if(s[i] == 'b' && s[i+1] == 'a') ba++;
// }
// if(ab == ba){
// cout << s << "\n";
// }else{
// s[0] = s[n-1];
// cout << s << "\n";
// }
if(s[0] != s[n-1]){
if(s[0] == 'a'){
s[0] = 'b';
}else {
s[0] = 'a';
}
}
cout << s << "\n";
}
return 0;
}