Submission #243214

#TimeUsernameProblemLanguageResultExecution timeMemory
243214kimbj0709Palindromic Partitions (CEOI17_palindromic)C++14
100 / 100
84 ms20708 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define mod 1000000009 #define maxn 1000050 #define po 179 vector<int> powers(maxn,1); void find(){ string input; cin >> input; int sum1 = 0; int sum2 = 0; int ans = 0; int cnt = -1; int currcnt = 0; for(int i=0;i<input.length()/2;i++){ sum1 += powers[currcnt]*(input.at(i)-'a'); sum2 *= po; sum1 %= mod; sum2 %= mod; sum2 += (input.at(input.length()-1-i)-'a'); currcnt++; sum2 %= mod; if(sum1==sum2){ ans += 2; sum1 = 0; sum2 = 0; cnt = i; currcnt = 0; } } if((cnt+1)*2==input.length()){ } else{ ans++; } cout << ans << "\n"; } int32_t main() { ios::sync_with_stdio(0); cin.tie(0);cout.tie(0); int no_of_input; cin >> no_of_input; for(int i=1;i<powers.size();i++){ powers[i] = powers[i-1]*po; powers[i] %= mod; } for(int i=0;i<no_of_input;i++){ find(); } }

Compilation message (stderr)

palindromic.cpp: In function 'void find()':
palindromic.cpp:16:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=0;i<input.length()/2;i++){
               ~^~~~~~~~~~~~~~~~~
palindromic.cpp:32:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if((cnt+1)*2==input.length()){
      ~~~~~~~~~^~~~~~~~~~~~~~~~
palindromic.cpp: In function 'int32_t main()':
palindromic.cpp:45:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=1;i<powers.size();i++){
               ~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...