Task: | ABC-poisto |
Sender: | jubidubi |
Submission time: | 2020-10-17 17:10:28 +0300 |
Language: | C++ (C++11) |
Status: | READY |
Result: | 42 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 42 |
#2 | TIME LIMIT EXCEEDED | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.01 s | 1, 2 | details |
#2 | TIME LIMIT EXCEEDED | -- | 2 | details |
Code
#include <bits/stdc++.h> using namespace std; using ll = long long; int solve(string s) { int mx = 0; int n = s.length(); for (int i = 0; i < n-1; ++i) { if (s[i] != s[i+1]) { string temp = ""; for (int j = 0; j < n; ++j) { if (j != i && j != i+1) temp += s[j]; } mx = max(mx, solve(temp) + 2); } } return mx ; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; cin >> n; for (int i = 0; i < n; ++i) { string s; cin >> s; cout << solve(s) << endl; } }