답안 #545678

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
545678 2022-04-05T07:27:15 Z Ai7081 Palindromic Partitions (CEOI17_palindromic) C++17
15 / 100
1 ms 320 KB
#include <bits/stdc++.h>
using namespace std;

int t, out;
string s;
stack<char> st;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> t;
    while (t--) {
        out = 0;
        while (!st.empty()) st.pop();
        cin >> s;
        for (int i=0; i<s.size()/2; i++) {
            if (st.empty()) st.push(s[i]);
            else {
                if (st.top() == s[i]) st.pop();
                else st.push(s[i]);
            }
            if (st.top() == s[s.size()-1-i]) st.pop();
            else st.push(s[s.size()-1-i]);
            out += 2*st.empty();
        }
        if (s.size()%2 || !st.empty()) out++;
        cout << out << endl;
    }
    return 0;
}

Compilation message

palindromic.cpp: In function 'int main()':
palindromic.cpp:15:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |         for (int i=0; i<s.size()/2; i++) {
      |                       ~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Incorrect 1 ms 212 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Incorrect 1 ms 212 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Incorrect 1 ms 212 KB Output isn't correct
8 Halted 0 ms 0 KB -