Submission #362640

# Submission time Handle Problem Language Result Execution time Memory
362640 2021-02-03T19:25:23 Z shahriarkhan Palindromic Partitions (CEOI17_palindromic) C++14
60 / 100
10000 ms 6436 KB
#include<bits/stdc++.h>
using namespace std ;

int main()
{
    int t ;
    scanf("%d",&t) ;
    while(t--)
    {
        string s ;
        cin>>s ;
        int siz = s.size() , l = 0 , r = siz - 1 , len = 1 , ans = 0 ;
        while((l+len-1)<r)
        {
            int cur_l = l , cur_r = r , bad = 0 ;
            while(cur_l<(l+len))
            {
                if(s[cur_l]==s[cur_r])
                {
                    ++cur_l , ++cur_r ;
                }
                else
                {
                    bad = 1 ;
                    break ;
                }
            }
            if(!bad)
            {
                l += len , len = 1 ;
                --r , ans += 2 ;
            }
            else
            {
                ++len , --r ;
            }
        }
        if(l<=r) ++ans ;
        printf("%d\n",max(1,ans)) ;
    }
    return 0 ;
}

Compilation message

palindromic.cpp: In function 'int main()':
palindromic.cpp:7:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    7 |     scanf("%d",&t) ;
      |     ~~~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 15 ms 492 KB Output is correct
11 Correct 5 ms 364 KB Output is correct
12 Correct 4 ms 492 KB Output is correct
13 Correct 3 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 15 ms 492 KB Output is correct
11 Correct 5 ms 364 KB Output is correct
12 Correct 4 ms 492 KB Output is correct
13 Correct 3 ms 364 KB Output is correct
14 Execution timed out 10006 ms 6436 KB Time limit exceeded
15 Halted 0 ms 0 KB -