제출 #309820

#제출 시각아이디문제언어결과실행 시간메모리
309820peuchPalindromic Partitions (CEOI17_palindromic)C++17
0 / 100
10067 ms256 KiB
#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()){
		if(st2.size() != 0) part.push_back(st2);
		int tam = part.size();
		int cnt = 0;
		bool flag = 1;
		for(int i = 0; i < tam / 2; i++){
			if(part[i] == part[tam - i - 1]) cnt += 2;
			else flag = 0;
		}
		cnt++;
		if(flag) {
			ans = max(ans, cnt);
		}
		if(st2.size() != 0) part.pop_back();
		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;
}

컴파일 시 표준 에러 (stderr) 메시지

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()){
      |     ~~~~^~~~~~~~~~~~~
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);
      |  ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...