# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1106345 | 2024-10-30T03:18:29 Z | _callmelucian | Palinilap (COI16_palinilap) | C++14 | 1000 ms | 592 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<ll,ll> pl; typedef pair<int,int> pii; typedef tuple<int,int,int> tt; #define all(a) a.begin(), a.end() #define filter(a) a.erase(unique(all(a)), a.end()) bool palin (const string &s) { return equal(all(s), s.rbegin()); } int cost (const string &s) { int ans = 0; for (int i = 0; i < s.size(); i++) for (int j = 1; j <= (int)s.size() - i; j++) ans += palin(s.substr(i, j)); return ans; } int main() { ios::sync_with_stdio(0); cin.tie(0); string s; cin >> s; int n = s.length(); int ans = 0; for (int i = 0; i < n; i++) { char c = s[i]; for (int j = 0; j < 26; j++) { s[i] = char('a' + j); ans = max(ans, cost(s)); //cout << "change " << i + 1 << " to " << char('a' + j) << " " << cost(s) << "\n"; } s[i] = c; } cout << ans << "\n"; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 106 ms | 336 KB | Output is correct |
2 | Correct | 359 ms | 336 KB | Output is correct |
3 | Correct | 210 ms | 336 KB | Output is correct |
4 | Correct | 206 ms | 336 KB | Output is correct |
5 | Correct | 192 ms | 336 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1056 ms | 336 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1046 ms | 592 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |