Submission #104701

#TimeUsernameProblemLanguageResultExecution timeMemory
104701ShtefDijamant (COI16_dijament)C++14
0 / 100
3 ms384 KiB
#include <iostream> using namespace std; typedef long long ll; string s; int n, cnt1[100005], cnt2[100005]; ll brojpalin(){ ll ret = 0; int l = 0, r = -1; for(int i = 0 ; i < n ; ++i){ int k = (i > r ? 1 : min(cnt1[l + r - i], r - i + 1)); while(i - k >= 0 && i + k < n && s[i - k] == s[i + k]){ k++; } cnt1[i] = k--; if(i + k > r){ l = i - k; r = i + k; } ret += k + 1; int x = i - k + 1, y = i + k + 1; } l = 0; r = -1; for(int i = 0 ; i < n ; ++i){ int k = (i > r ? 0 : min(cnt1[l + r - i + 1], r - i + 1)); while(i - k - 1 >= 0 && i + k < n && s[i - k - 1] == s[i + k]){ k++; } cnt1[i] = k--; if(i + k > r){ l = i - k - 1; r = i + k; } ret += k + 1; } return ret; } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> s; n = (int)s.size(); ll sol = brojpalin(); for(int i = 0 ; i < n ; ++i){ char poc = s[i]; for(int j = 0 ; j < 26 ; ++j){ s[i] = j + 'a'; sol = max(sol, brojpalin()); } s[i] = poc; } cout << sol << endl; return 0; }

Compilation message (stderr)

dijament.cpp: In function 'll brojpalin()':
dijament.cpp:24:7: warning: unused variable 'x' [-Wunused-variable]
   int x = i - k + 1, y = i + k + 1;
       ^
dijament.cpp:24:22: warning: unused variable 'y' [-Wunused-variable]
   int x = i - k + 1, y = i + k + 1;
                      ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...