Submission #1172612
Source Code Expand
#include <bits/stdc++.h> using namespace std; #define FOR(i,a,b) for(int i=(a);i<(b);i++) #define REP(i,n) FOR(i,0,n) #define ALL(v) (v).begin(),(v).end() template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; } template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; } typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef pair<int, pii> P; #define INF (1<<29) #define INFL (1ll<<60) #define EPS (1e-8) #define PI (acos(-1)) const ll MOD = 1000000007ll; int main() { string S; int K; cin >> S >> K; assert(S.size() <= 1000); int c = count(ALL(S), 'a'); vector<string> ans; if (S.size() - c <= K) { string tmp = ""; REP(i, S.size() - K) tmp += "a"; ans.push_back(tmp); } REP(i, 26) { string now = S; int cnt = 0, pos = -1; REP(j, now.size()) { if (now[j] == 'a' + i) { if (cnt < K) pos = j; break; } if (cnt < K && now[j] != 'a') { now[j] = 'a'; cnt++; } } string tmp = ""; while (cnt < K) tmp += "a", cnt++; ans.push_back(tmp + now); if (pos != -1) { now[pos] = 'a'; if (tmp.size() > 0) tmp.erase(tmp.end() - 1); ans.push_back(tmp + now); } } sort(ALL(ans)); cout << ans[0] << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - アメージングな文字列は、きみが作る! |
User | tkmst201 |
Language | C++14 (GCC 5.4.1) |
Score | 10 |
Code Size | 1386 Byte |
Status | RE |
Exec Time | 114 ms |
Memory | 900 KB |
Judge Result
Set Name | Sample | Subtask1 | Subtask2 | Subtask3 | All | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 10 / 10 | 0 / 10 | 0 / 20 | 0 / 60 | ||||||||||||||||||
Status |
|
|
|
|
|
Set Name | Test Cases |
---|---|
Sample | 00_example_01.txt, 00_example_02.txt, 00_example_03.txt |
Subtask1 | 00_example_01.txt, 00_example_02.txt, 00_example_03.txt, 10_rand_01.txt, 10_rand_02.txt, 10_rand_03.txt, 10_rand_04.txt, 10_rand_05.txt, 20_hand_01.txt, 20_hand_02.txt, 20_hand_03.txt, 20_hand_04.txt, 20_hand_05.txt |
Subtask2 | 00_example_01.txt, 00_example_02.txt, 00_example_03.txt, 10_rand_01.txt, 10_rand_02.txt, 10_rand_03.txt, 10_rand_04.txt, 10_rand_05.txt, 20_hand_01.txt, 20_hand_02.txt, 20_hand_03.txt, 20_hand_04.txt, 20_hand_05.txt, 40_rand_01.txt, 40_rand_02.txt, 40_rand_03.txt, 40_rand_04.txt, 40_rand_05.txt, 40_rand_06.txt, 40_rand_07.txt, 40_rand_08.txt, 40_rand_09.txt, 40_rand_10.txt, 50_hand_01.txt, 50_hand_02.txt, 50_hand_03.txt, 50_hand_04.txt, 50_hand_05.txt |
Subtask3 | 00_example_01.txt, 00_example_02.txt, 00_example_03.txt, 10_rand_01.txt, 10_rand_02.txt, 10_rand_03.txt, 10_rand_04.txt, 10_rand_05.txt, 20_hand_01.txt, 20_hand_02.txt, 20_hand_03.txt, 20_hand_04.txt, 20_hand_05.txt, 40_rand_01.txt, 40_rand_02.txt, 40_rand_03.txt, 40_rand_04.txt, 40_rand_05.txt, 40_rand_06.txt, 40_rand_07.txt, 40_rand_08.txt, 40_rand_09.txt, 40_rand_10.txt, 50_hand_01.txt, 50_hand_02.txt, 50_hand_03.txt, 50_hand_04.txt, 50_hand_05.txt, 60_rand_01.txt, 60_rand_02.txt, 60_rand_03.txt, 60_rand_04.txt, 60_rand_05.txt, 60_rand_06.txt, 60_rand_07.txt, 60_rand_08.txt, 70_hand_01.txt, 70_hand_02.txt, 70_hand_03.txt, 70_hand_04.txt, 70_hand_05.txt, 70_hand_06.txt, 70_hand_07.txt |
All | 00_example_01.txt, 00_example_02.txt, 00_example_03.txt, 10_rand_01.txt, 10_rand_02.txt, 10_rand_03.txt, 10_rand_04.txt, 10_rand_05.txt, 20_hand_01.txt, 20_hand_02.txt, 20_hand_03.txt, 20_hand_04.txt, 20_hand_05.txt, 40_rand_01.txt, 40_rand_02.txt, 40_rand_03.txt, 40_rand_04.txt, 40_rand_05.txt, 40_rand_06.txt, 40_rand_07.txt, 40_rand_08.txt, 40_rand_09.txt, 40_rand_10.txt, 50_hand_01.txt, 50_hand_02.txt, 50_hand_03.txt, 50_hand_04.txt, 50_hand_05.txt, 60_rand_01.txt, 60_rand_02.txt, 60_rand_03.txt, 60_rand_04.txt, 60_rand_05.txt, 60_rand_06.txt, 60_rand_07.txt, 60_rand_08.txt, 70_hand_01.txt, 70_hand_02.txt, 70_hand_03.txt, 70_hand_04.txt, 70_hand_05.txt, 70_hand_06.txt, 70_hand_07.txt, 80_rand_01.txt, 80_rand_02.txt, 80_rand_03.txt, 80_rand_04.txt, 80_rand_05.txt, 80_rand_06.txt, 80_rand_07.txt, 80_rand_08.txt, 80_rand_09.txt, 80_rand_10.txt, 90_hand_01.txt, 90_hand_02.txt, 90_hand_03.txt, 90_hand_04.txt, 90_hand_05.txt, 90_hand_06.txt, 90_hand_07.txt, 90_hand_08.txt, 90_hand_09.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_example_01.txt | AC | 1 ms | 256 KB |
00_example_02.txt | AC | 1 ms | 256 KB |
00_example_03.txt | AC | 1 ms | 256 KB |
10_rand_01.txt | AC | 1 ms | 256 KB |
10_rand_02.txt | AC | 1 ms | 256 KB |
10_rand_03.txt | AC | 1 ms | 256 KB |
10_rand_04.txt | AC | 1 ms | 256 KB |
10_rand_05.txt | AC | 1 ms | 256 KB |
20_hand_01.txt | AC | 1 ms | 256 KB |
20_hand_02.txt | AC | 1 ms | 256 KB |
20_hand_03.txt | AC | 1 ms | 256 KB |
20_hand_04.txt | AC | 1 ms | 256 KB |
20_hand_05.txt | AC | 1 ms | 256 KB |
40_rand_01.txt | WA | 1 ms | 256 KB |
40_rand_02.txt | WA | 1 ms | 256 KB |
40_rand_03.txt | AC | 1 ms | 256 KB |
40_rand_04.txt | WA | 1 ms | 256 KB |
40_rand_05.txt | WA | 1 ms | 256 KB |
40_rand_06.txt | AC | 1 ms | 256 KB |
40_rand_07.txt | AC | 1 ms | 256 KB |
40_rand_08.txt | AC | 1 ms | 256 KB |
40_rand_09.txt | AC | 1 ms | 256 KB |
40_rand_10.txt | AC | 1 ms | 256 KB |
50_hand_01.txt | AC | 1 ms | 256 KB |
50_hand_02.txt | AC | 1 ms | 256 KB |
50_hand_03.txt | AC | 1 ms | 256 KB |
50_hand_04.txt | AC | 1 ms | 256 KB |
50_hand_05.txt | AC | 1 ms | 256 KB |
60_rand_01.txt | WA | 1 ms | 256 KB |
60_rand_02.txt | WA | 1 ms | 256 KB |
60_rand_03.txt | WA | 1 ms | 256 KB |
60_rand_04.txt | WA | 1 ms | 256 KB |
60_rand_05.txt | WA | 1 ms | 384 KB |
60_rand_06.txt | WA | 1 ms | 256 KB |
60_rand_07.txt | WA | 1 ms | 256 KB |
60_rand_08.txt | WA | 1 ms | 256 KB |
70_hand_01.txt | AC | 1 ms | 256 KB |
70_hand_02.txt | AC | 2 ms | 384 KB |
70_hand_03.txt | AC | 1 ms | 256 KB |
70_hand_04.txt | AC | 1 ms | 256 KB |
70_hand_05.txt | WA | 2 ms | 384 KB |
70_hand_06.txt | AC | 1 ms | 256 KB |
70_hand_07.txt | AC | 1 ms | 256 KB |
80_rand_01.txt | RE | 103 ms | 640 KB |
80_rand_02.txt | RE | 101 ms | 512 KB |
80_rand_03.txt | RE | 105 ms | 644 KB |
80_rand_04.txt | RE | 105 ms | 640 KB |
80_rand_05.txt | RE | 102 ms | 640 KB |
80_rand_06.txt | RE | 104 ms | 640 KB |
80_rand_07.txt | RE | 105 ms | 644 KB |
80_rand_08.txt | RE | 103 ms | 640 KB |
80_rand_09.txt | RE | 104 ms | 644 KB |
80_rand_10.txt | RE | 103 ms | 512 KB |
90_hand_01.txt | RE | 107 ms | 900 KB |
90_hand_02.txt | RE | 106 ms | 900 KB |
90_hand_03.txt | RE | 111 ms | 900 KB |
90_hand_04.txt | RE | 114 ms | 900 KB |
90_hand_05.txt | RE | 108 ms | 900 KB |
90_hand_06.txt | RE | 112 ms | 900 KB |
90_hand_07.txt | RE | 107 ms | 900 KB |
90_hand_08.txt | RE | 108 ms | 900 KB |
90_hand_09.txt | RE | 111 ms | 900 KB |