Submission #1603255
Source Code Expand
// #include {{{ #include <array> #include <vector> #include <deque> #include <queue> #include <set> #include <unordered_set> #include <map> #include <unordered_map> #include <string> #include <algorithm> #include <numeric> #include <functional> #include <iterator> #include <tuple> #include <utility> #include <random> #include <limits> #include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <cstdint> #include <cassert> // }}} using namespace std; // macros {{{ template<typename T, size_t N> constexpr size_t NELEMS(T (&)[N]) { return N; } template<typename InputIt> void PRINT_RANGE(InputIt first, InputIt last) { for(; first != last; ++first) cout << *first << (first==last ? "" : " "); cout << "\n"; } template<typename T> void PRINT_MATRIX(T mat, size_t nr, size_t nc) { for(size_t r = 0; r < nr; ++r) { for(size_t c = 0; c < nc; ++c) { cout << mat[r][c] << (c==nc-1 ? "" : " "); } cout << "\n"; } } #define FOR(i, start, end) for(int i = (start); i < (end); ++i) #define REP(i, n) FOR(i, 0, n) // }}} // types {{{ using ll = long long; using ull = unsigned long long; // }}} string S; string change(const string& s, char c) { string result(begin(s), end(s)-1); for(size_t i = 0; i < result.size(); ++i) { if(s[i] == c || s[i+1] == c) { result[i] = c; } } return result; } void solve() { int cnt_min = 99999; for(char c = 'a'; c <= 'z'; ++c) { string s = S; for(size_t i = 0; i < S.size(); ++i) { if(all_of(begin(s), end(s), [c](char e) { return e == c; })) { int cnt = i; if(cnt < cnt_min) { cnt_min = cnt; break; } } s = change(s, c); } } cout << cnt_min << "\n"; } int main() { cin >> S; solve(); return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - Shrinking |
User | yumsiim |
Language | C++14 (GCC 5.4.1) |
Score | 300 |
Code Size | 1962 Byte |
Status | AC |
Exec Time | 2 ms |
Memory | 256 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 300 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt |
All | 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_00.txt | AC | 1 ms | 256 KB |
0_01.txt | AC | 1 ms | 256 KB |
0_02.txt | AC | 1 ms | 256 KB |
0_03.txt | AC | 1 ms | 256 KB |
1_00.txt | AC | 1 ms | 256 KB |
1_01.txt | AC | 2 ms | 256 KB |
1_02.txt | AC | 1 ms | 256 KB |
1_03.txt | AC | 1 ms | 256 KB |
1_04.txt | AC | 1 ms | 256 KB |
1_05.txt | AC | 1 ms | 256 KB |
1_06.txt | AC | 1 ms | 256 KB |
1_07.txt | AC | 1 ms | 256 KB |
1_08.txt | AC | 2 ms | 256 KB |
1_09.txt | AC | 2 ms | 256 KB |