Contest Duration: ~ (local time) (150 minutes) Back to Home

Submission #2285038

Source Code Expand

Copy
```#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, -1, 0, 1 };

template<class T> void inputVector(vector<T>& v, int n) {
v.resize(n);
for (int i = 0; i < v.size(); i++) cin >> v[i];
}

bool cnt[30];

signed main() {
string S;
cin >> S;

if (S == "zyxwvutsrqponmlkjihgfedcba") {
cout << -1 << endl;
return 0;
}

rep(i, S.size()) {
cnt[S[i] - 'a']++;
}

if (S.size() < 26) {
char ch;
rep(i, 26) {
if (cnt[i] == 0) {
ch = i + 'a';
break;
}
}
cout << S << ch << endl;
} else {
for (int pt = 25; pt >= 0; pt--) {
for (char ch = S[pt] + 1; ch <= 'z'; ch++) {
if (cnt[ch - 'a']) continue;
cout << S.substr(0, pt) << ch << endl;
return 0;
}
cnt[S[pt] - 'a'] = false;
S = S.substr(0, pt);
}
}

return 0;
}
```

#### Submission Info

Submission Time 2018-04-01 00:16:40+0900 A - Diverse Word iwashi31 C++14 (GCC 5.4.1) 300 1496 Byte AC 1 ms 256 KB

#### Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 s1.txt, s2.txt, s3.txt, s4.txt
All 300 / 300 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, s1.txt, s2.txt, s3.txt, s4.txt
Case Name Status Exec Time Memory
01.txt 1 ms 256 KB
02.txt 1 ms 256 KB
03.txt 1 ms 256 KB
04.txt 1 ms 256 KB
05.txt 1 ms 256 KB
06.txt 1 ms 256 KB
07.txt 1 ms 256 KB
08.txt 1 ms 256 KB
09.txt 1 ms 256 KB
10.txt 1 ms 256 KB
11.txt 1 ms 256 KB
12.txt 1 ms 256 KB
13.txt 1 ms 256 KB
14.txt 1 ms 256 KB
15.txt 1 ms 256 KB
16.txt 1 ms 256 KB
17.txt 1 ms 256 KB
18.txt 1 ms 256 KB
19.txt 1 ms 256 KB
s1.txt 1 ms 256 KB
s2.txt 1 ms 256 KB
s3.txt 1 ms 256 KB
s4.txt 1 ms 256 KB