답안 #939151

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
939151 2024-03-06T06:16:59 Z vjudge1 Palindromic Partitions (CEOI17_palindromic) C++17
60 / 100
10000 ms 5744 KB
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define int long long
/*
4
bonobo
deleted
racecar
racecars
*/

int f(string s){
	
}

void solve(){
	string s; cin >> s;
	int n = s.size();
	deque<char> dq;
	for(int i = 0;i < n; i++) dq.push_back(s[i]);
	int ans = 0;
	while(true){
		int left = dq.size()-1;
		int idx = -1, suf = 1;
		int len = -1;
		for(int j = dq.size() - 1; j >= 0; j--, left--, suf++){
			if(suf > left) break;
			int ok = 1;
			for(int i = 0; i + j < dq.size(); i++){
				if(dq[i] != dq[i+j]){
					ok = 0;
					break;
				}
			}
			if(ok){
				len = suf;
				idx = j;
				break;
			}
		}
		
		if(idx == -1){
			ans++;
			break;
		}
		while(len--){
			dq.pop_back();
			dq.pop_front();
		}
		ans+= 2;
		if(dq.empty()) break;
	

	}
	cout << ans;
}


signed main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int tt; cin >> tt;
	while(tt--){
		solve();
		cout << '\n';
	}
	return 0;
}

Compilation message

palindromic.cpp: In function 'long long int f(std::string)':
palindromic.cpp:17:1: warning: no return statement in function returning non-void [-Wreturn-type]
   17 | }
      | ^
palindromic.cpp: In function 'void solve()':
palindromic.cpp:32:25: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::deque<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |    for(int i = 0; i + j < dq.size(); i++){
      |                   ~~~~~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 43 ms 596 KB Output is correct
11 Correct 9 ms 348 KB Output is correct
12 Correct 2 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 43 ms 596 KB Output is correct
11 Correct 9 ms 348 KB Output is correct
12 Correct 2 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Execution timed out 10098 ms 5744 KB Time limit exceeded
15 Halted 0 ms 0 KB -