답안 #243214

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
243214 2020-06-30T14:46:03 Z kimbj0709 Palindromic Partitions (CEOI17_palindromic) C++14
100 / 100
84 ms 20708 KB
#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

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++){
               ~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 8192 KB Output is correct
2 Correct 18 ms 8192 KB Output is correct
3 Correct 18 ms 8192 KB Output is correct
4 Correct 19 ms 8192 KB Output is correct
5 Correct 17 ms 8192 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 8192 KB Output is correct
2 Correct 18 ms 8192 KB Output is correct
3 Correct 18 ms 8192 KB Output is correct
4 Correct 19 ms 8192 KB Output is correct
5 Correct 17 ms 8192 KB Output is correct
6 Correct 18 ms 8192 KB Output is correct
7 Correct 17 ms 8192 KB Output is correct
8 Correct 17 ms 8192 KB Output is correct
9 Correct 20 ms 8192 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 8192 KB Output is correct
2 Correct 18 ms 8192 KB Output is correct
3 Correct 18 ms 8192 KB Output is correct
4 Correct 19 ms 8192 KB Output is correct
5 Correct 17 ms 8192 KB Output is correct
6 Correct 18 ms 8192 KB Output is correct
7 Correct 17 ms 8192 KB Output is correct
8 Correct 17 ms 8192 KB Output is correct
9 Correct 20 ms 8192 KB Output is correct
10 Correct 18 ms 8320 KB Output is correct
11 Correct 19 ms 8240 KB Output is correct
12 Correct 19 ms 8320 KB Output is correct
13 Correct 17 ms 8352 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 8192 KB Output is correct
2 Correct 18 ms 8192 KB Output is correct
3 Correct 18 ms 8192 KB Output is correct
4 Correct 19 ms 8192 KB Output is correct
5 Correct 17 ms 8192 KB Output is correct
6 Correct 18 ms 8192 KB Output is correct
7 Correct 17 ms 8192 KB Output is correct
8 Correct 17 ms 8192 KB Output is correct
9 Correct 20 ms 8192 KB Output is correct
10 Correct 18 ms 8320 KB Output is correct
11 Correct 19 ms 8240 KB Output is correct
12 Correct 19 ms 8320 KB Output is correct
13 Correct 17 ms 8352 KB Output is correct
14 Correct 81 ms 20708 KB Output is correct
15 Correct 56 ms 15668 KB Output is correct
16 Correct 84 ms 19736 KB Output is correct
17 Correct 53 ms 14812 KB Output is correct