답안 #309827

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
309827 2020-10-04T15:35:20 Z peuch Palindromic Partitions (CEOI17_palindromic) C++17
0 / 100
86 ms 256 KB
#include<bits/stdc++.h>
using namespace std;

const int MAXN = 1e6 + 10;

int t;
string st1, st2;
vector<string> part;
int ans;

void bt(int cur);

int main(){
	scanf("%d", &t);
	while(t--){
		ans = 0;
		cin >> st1;
		bt(0);
		printf("%d\n", ans);
	}
}

void bt(int cur){
	if(cur == st1.size() / 2){
		string rst2;
		for(int i = 0; i < part.size(); i++){
			reverse(part[i].begin(), part[i].end());
			rst2 += part[i];
			reverse(part[i].begin(), part[i].end());
		}
		int tam = rst2.size();
		string rst1 = "";
		for(int i = 0; i < tam; i++){
			rst1 += st1[st1.size() - i - 1];
		}
		if(rst1 == rst2) {
			ans = max(ans, (int)part.size() * 2 + 1);
		}
		return;
	}
	string aux = st2;
	st2 += st1[cur];
	part.push_back(st2);
	st2 = "";
	bt(cur + 1);
	st2 = part[part.size() - 1];
	part.pop_back();
	bt(cur + 1);
	st2 = aux;
}

Compilation message

palindromic.cpp: In function 'void bt(int)':
palindromic.cpp:24:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |  if(cur == st1.size() / 2){
      |     ~~~~^~~~~~~~~~~~~~~~~
palindromic.cpp:26:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |   for(int i = 0; i < part.size(); i++){
      |                  ~~^~~~~~~~~~~~~
palindromic.cpp: In function 'int main()':
palindromic.cpp:14:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   14 |  scanf("%d", &t);
      |  ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 86 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 86 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 86 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 86 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -