-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCompleteTheWorld.cpp
More file actions
61 lines (52 loc) · 1.35 KB
/
CompleteTheWorld.cpp
File metadata and controls
61 lines (52 loc) · 1.35 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <iostream>
#include <cstdio>
#include <string>
using namespace std;
int main() {
bool alphabets[26] = {false,};
string str;
cin >> str;
int len = str.length();
bool check = true;
int start = 0, end = start + 26;
for(int i = 0; i <= len - 26; i++) {
start = i;
end = start + 26;
check = true;
for(int j = 0; j < 26; j++) {
alphabets[j] = false;
}
for(int j = i; j < i + 26; j++) {
if(str[j] == '?') continue;
if(!alphabets[str[j] - 'A']) {
alphabets[str[j] - 'A'] = true;
}else {
check = false;
}
}
if(check) break;
}
if(!check || len < 26) {
cout << -1 << '\n';
}else {
for(int i = 0; i < len; i++) {
if(start <= i && i < end) {
if(str[i] == '?') {
for(int j = 0; j < 26; j++) {
if(!alphabets[j]) {
str[i] = j + 'A';
alphabets[j] = true;
break;
}
}
}
}else {
if(str[i] == '?') {
str[i] = 'A';
}
}
}
cout << str << '\n';
}
return 0;
}