답안 #939100

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
939100 2024-03-06T05:40:50 Z vjudge1 Palindromic Partitions (CEOI17_palindromic) C++17
60 / 100
10000 ms 3800 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pii pair<int,int>
using namespace __gnu_pbds;
using namespace std;
#define pb push_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define f first
#define int long long
#define s second
#define pii pair<int,int>
template<class T>bool umax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<class T>bool umin(T &a,T b){if(b<a){a=b;return true;}return false;}
typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
	tree_order_statistics_node_update> ordered_set;
const int N = 3e5 + 5	;
const int inf = 1e17 + 7;
const int mod = 998244353;

int n,m,k;

void solve(){
	
	
	string str;
	cin>>str;
	
	string l,r;
	
	int i = 0,j = str.size() - 1;
	int ans = 0;
	while(i < j){
		
		l += str[i];
		r = str[j] + r;
		i += 1;
		j -= 1;
		//~ cout<<l<<" "<<r<<"\n";
		if(l == r){
			ans += 2;
			l = "";
			r = "";
		}
		
	}
	
	if(l != "" && r != "" || i == j)ans += 1;
	
	cout<<ans<<"\n";
	
	
	
	
	
	
}

signed main()
{
//	freopen("seq.in", "r", stdin);
//  freopen("seq.out", "w", stdout);
	ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
	int tt=1;cin>>tt;
	while(tt--)solve();

}

Compilation message

palindromic.cpp: In function 'void solve()':
palindromic.cpp:49:13: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   49 |  if(l != "" && r != "" || i == j)ans += 1;
      |     ~~~~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 436 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 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 436 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 3 ms 348 KB Output is correct
11 Correct 2 ms 348 KB Output is correct
12 Correct 2 ms 488 KB Output is correct
13 Correct 2 ms 480 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 436 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 3 ms 348 KB Output is correct
11 Correct 2 ms 348 KB Output is correct
12 Correct 2 ms 488 KB Output is correct
13 Correct 2 ms 480 KB Output is correct
14 Execution timed out 10100 ms 3800 KB Time limit exceeded
15 Halted 0 ms 0 KB -