답안 #131840

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
131840 2019-07-17T19:40:21 Z Vardanyan Palindromic Partitions (CEOI17_palindromic) C++14
60 / 100
665 ms 131076 KB
#include <bits/stdc++.h>
using namespace std;
string st;
int solve(int s,int e,int l, int r){
    if(l>r) return 0;
    if(s == l && e == r && l == r) return 1;

    string s1,s2;
    for(int i = s;i<=l;i++) s1+=st[i];
    for(int i = r;i<=e;i++) s2+=st[i];
    if(s1 == s2){

       return 2+solve(l+1,r-1,l+1,r-1);
    }
    else{
        if(r-l == 1) return 1;
        if(r-l == 2) return 1;
        return solve(s,e,l+1,r-1);
    }
}
int main(){
    ios_base::sync_with_stdio(false);
    int t;
    cin>>t;
    while(t--){
        cin>>st;
        cout<<solve(0,st.length()-1,0,st.length()-1)<<endl;
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 3 ms 376 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 3 ms 376 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 665 ms 38292 KB Output is correct
11 Correct 657 ms 38192 KB Output is correct
12 Correct 44 ms 2096 KB Output is correct
13 Correct 4 ms 1144 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 3 ms 376 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 665 ms 38292 KB Output is correct
11 Correct 657 ms 38192 KB Output is correct
12 Correct 44 ms 2096 KB Output is correct
13 Correct 4 ms 1144 KB Output is correct
14 Runtime error 376 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
15 Halted 0 ms 0 KB -