feat(cf): update with 957.f
This commit is contained in:
parent
d1b961e1c4
commit
68422f90e1
13 changed files with 282 additions and 33 deletions
|
|
@ -68,22 +68,12 @@ using vec = std::vector<T>;
|
|||
void solve() {
|
||||
string s;
|
||||
cin >> s;
|
||||
vec<char> S;
|
||||
for (auto e : s) {
|
||||
if (!S.empty() && S.back() == e) {
|
||||
S.pop_back();
|
||||
S.push_back('*');
|
||||
} else
|
||||
S.push_back(e);
|
||||
bool can = false;
|
||||
for (int i = 1; i < sz<int>(s); ++i) {
|
||||
if (s[i] == s[i - 1])
|
||||
can = true;
|
||||
}
|
||||
|
||||
while (sz<int>(S) >= 2) {
|
||||
if (S.back() == '*' || S[sz<int>(S) - 1] == '*')
|
||||
S.pop_back();
|
||||
else
|
||||
break;
|
||||
}
|
||||
prln("{}", sz<int>(S));
|
||||
prln("{}", can ? 1 : sz<int>(s));
|
||||
}
|
||||
|
||||
// {{{
|
||||
|
|
|
|||
|
|
@ -4,4 +4,4 @@
|
|||
4
|
||||
|
||||
[code]: 0
|
||||
[time]: 11.9956 ms
|
||||
[time]: 12.0482 ms
|
||||
|
|
@ -4,4 +4,4 @@
|
|||
1001001000100
|
||||
|
||||
[code]: 0
|
||||
[time]: 3.66259 ms
|
||||
[time]: 4.07124 ms
|
||||
Loading…
Add table
Add a link
Reference in a new issue