提出 #16520821
ソースコード 拡げる
Copy
#include <bits/stdc++.h> using namespace std; // ----------- define -------------- #define int long long #define vi vector<int> #define vc vector<char> #define ii pair<int,int> #define fi first #define sc second #define stoi stoll #define all(x) (x).begin(),(x).end() #define get_bit(x, k) ((x >> k) & 1) // --------------------------------- void MAIN() { string s; cin >> s; set<char> d; for (char c = 'a'; c <= 'z'; c++) d.insert(c); for (auto &i : s) d.erase(i); if (d.size()) { s += *d.begin(); cout << s << '\n'; return; } 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; } g.insert(c); } cout << -1 << '\n'; } signed main() { ios::sync_with_stdio(0); cin.tie(0); int T = 1; // cin >> T; while (T--) MAIN(); }
提出情報
提出日時 | |
---|---|
問題 | A - Diverse Word |
ユーザ | erke |
言語 | C++ (GCC 9.2.1) |
得点 | 300 |
コード長 | 951 Byte |
結果 | AC |
実行時間 | 8 ms |
メモリ | 3620 KB |
ジャッジ結果
セット名 | Sample | All | ||||
---|---|---|---|---|---|---|
得点 / 配点 | 0 / 0 | 300 / 300 | ||||
結果 |
|
|
セット名 | テストケース |
---|---|
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 |
ケース名 | 結果 | 実行時間 | メモリ |
---|---|---|---|
01.txt | AC | 8 ms | 3516 KB |
02.txt | AC | 2 ms | 3616 KB |
03.txt | AC | 3 ms | 3456 KB |
04.txt | AC | 2 ms | 3584 KB |
05.txt | AC | 2 ms | 3616 KB |
06.txt | AC | 2 ms | 3568 KB |
07.txt | AC | 4 ms | 3572 KB |
08.txt | AC | 3 ms | 3512 KB |
09.txt | AC | 2 ms | 3556 KB |
10.txt | AC | 4 ms | 3620 KB |
11.txt | AC | 2 ms | 3612 KB |
12.txt | AC | 3 ms | 3588 KB |
13.txt | AC | 2 ms | 3620 KB |
14.txt | AC | 2 ms | 3460 KB |
15.txt | AC | 3 ms | 3512 KB |
16.txt | AC | 4 ms | 3512 KB |
17.txt | AC | 3 ms | 3452 KB |
18.txt | AC | 2 ms | 3608 KB |
19.txt | AC | 2 ms | 3576 KB |
s1.txt | AC | 2 ms | 3556 KB |
s2.txt | AC | 2 ms | 3452 KB |
s3.txt | AC | 2 ms | 3496 KB |
s4.txt | AC | 3 ms | 3616 KB |