Submission #16563738
Source Code Expand
Copy
#include <algorithm> #include <cmath> #include <cstring> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <regex> #include <set> #include <sstream> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> typedef long long ll; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) constexpr double PI = 3.141592653589793; constexpr int INF = 1e9 + 10; constexpr ll INFL = 1e18 + 10; template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; } using namespace std; // cout << setprecision(20) << ans << "\n"; int main() { ios::sync_with_stdio(false); std::cin.tie(nullptr); string s; cin >> s; if (s.size() != 26) { vector<int> seen(26, 0); for (char c : s) { seen[c - 'a'] = 1; } for (int i = 0; i < 26; i++) { if (!seen[i]) { s.push_back('a' + i); cout << s << "\n"; return 0; } } } set<char> g; while (s.size()) { char c = s.back(); s.pop_back(); auto it = g.upper_bound(c); if (it != g.end()) { s += *it; cout << s << '\n'; return 0; } g.insert(c); } cout << -1 << "\n"; return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - Diverse Word |
User | mmatthew_43 |
Language | C++ (GCC 9.2.1) |
Score | 300 |
Code Size | 1465 Byte |
Status | AC |
Exec Time | 7 ms |
Memory | 3628 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 300 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | s1.txt, s2.txt, s3.txt, s4.txt |
All | 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 | AC | 7 ms | 3468 KB |
02.txt | AC | 2 ms | 3480 KB |
03.txt | AC | 2 ms | 3536 KB |
04.txt | AC | 2 ms | 3584 KB |
05.txt | AC | 1 ms | 3548 KB |
06.txt | AC | 2 ms | 3584 KB |
07.txt | AC | 3 ms | 3432 KB |
08.txt | AC | 2 ms | 3492 KB |
09.txt | AC | 2 ms | 3492 KB |
10.txt | AC | 1 ms | 3600 KB |
11.txt | AC | 2 ms | 3544 KB |
12.txt | AC | 2 ms | 3596 KB |
13.txt | AC | 2 ms | 3596 KB |
14.txt | AC | 2 ms | 3492 KB |
15.txt | AC | 2 ms | 3476 KB |
16.txt | AC | 2 ms | 3596 KB |
17.txt | AC | 1 ms | 3548 KB |
18.txt | AC | 1 ms | 3532 KB |
19.txt | AC | 2 ms | 3588 KB |
s1.txt | AC | 3 ms | 3628 KB |
s2.txt | AC | 2 ms | 3544 KB |
s3.txt | AC | 1 ms | 3544 KB |
s4.txt | AC | 2 ms | 3596 KB |