# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
312053 | 2020-10-12T08:27:46 Z | FatihSolak | Palinilap (COI16_palinilap) | C++14 | 1000 ms | 512 KB |
#include <bits/stdc++.h> using namespace std; string s; long long solve(){ long long tot = 0; for (int i = 0; i < s.length(); i++) { int odd = 1; while (i - odd >= 0 && odd + i < s.length() && s[i - odd] == s[i + odd]) { odd++; } int even = 0; int l = i - 1; int r = i; while (l >= 0 && r < s.length() && s[l] == s[r]) { even++; l--; r++; } tot += odd + even; } return tot; } int main(){ cin >> s; long long maxi=0; int l=s.length(); for(int i=0;i<l;i++){ char now=s[i]; for(int j=0;j<26;j++){ s[i] = j+'a'; maxi = max(maxi, solve()); } s[i] = now; } cout << maxi; /* long long arr[l][26]; long long brr[l]; for(int i=0;i<l;i++){ for(int j=0;j<26;j++){ arr[i][j]=1; } brr[i]=0; } for(int i=0;i<l;i++){ for(int j=i;j<l;j++){ string a=""; for(int c=i;c<=j;c++){ a +=s[c]; } string b=a; reverse(a.begin(),a.end()); if(j-i%2 == 0){ for(int c=0;c<26;c++){ if(c!=s[(i+j)/2]-'a'){ arr[(i+j)/2][c]++; } } } if(b == a){ ans++; for(int c=i;c<=j;c++){ brr[c]++; } } else{ for(int h=0;h<(j-i+1)/2;h++){ if(b[h] != a[h]){ string d =""; for(int c=i;c<=j;c++){ if(c == i+h || c == j-h){ continue; } d+=s[c]; } string e=d; reverse(d.begin(),d.end()); if(d==e){ arr[i+h][a[h]-'a']++; arr[j-h][b[h]-'a']++; //cout << i<< " " << j << " "<< i+h <<" " << a[h] << " " << j-h << " " << b[h]<< endl; } } } } } } //cout <<endl; long long maxi=0; for(int i=0;i<l;i++){ for(int j=0;j<26;j++){ if(brr[i] <=arr[i][j]){ maxi = max(maxi,arr[i][j]-brr[i]); } cout << arr[i][j] <<" "; } cout <<endl; } cout << maxi +ans;*/ }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 256 KB | Output is correct |
2 | Correct | 12 ms | 256 KB | Output is correct |
3 | Correct | 3 ms | 256 KB | Output is correct |
4 | Correct | 2 ms | 256 KB | Output is correct |
5 | Correct | 2 ms | 256 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1081 ms | 256 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1087 ms | 512 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |