Submission #622671

#TimeUsernameProblemLanguageResultExecution timeMemory
622671enter_hedgehog_polyPalindromic Partitions (CEOI17_palindromic)C++11
100 / 100
57 ms11008 KiB
//Palindromiczny podział #include <bits/stdc++.h> using namespace std; char buff[1000010]; typedef uint64_t ll; const ll P = 31; const ll MOD_N = 31; const ll MOD = ((ll) 1 << MOD_N) - 1; inline ll FMOD(ll x) { return ((x) >> MOD_N) + ((x) & MOD); } int main() { int t; scanf("%d", &t); while(t--) { scanf("%s", buff + 1); int n = strlen(buff + 1); ll left = 0, right = 0, exp = 1; int lp = 1, res = 0; for(int i = 1; i <= n / 2; i++) { left = FMOD(left + (buff[i] - 'a' + 1) * exp); exp = FMOD(exp * P); right = FMOD(right * P + (buff[n + 1 - i] - 'a' + 1)); if(left == right) { exp = 1; left = right = 0; res += 2; lp = i + 1; } } if(lp != (n / 2) + 1 || (n & 1)) res++; printf("%d\n", res); } return 0; }

Compilation message (stderr)

palindromic.cpp: In function 'int main()':
palindromic.cpp:17:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |  scanf("%d", &t);
      |  ~~~~~^~~~~~~~~~
palindromic.cpp:19:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |   scanf("%s", buff + 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...