답안 #1013387

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1013387 2024-07-03T13:45:20 Z ByeWorld Palindromic Partitions (CEOI17_palindromic) C++14
60 / 100
10000 ms 14844 KB
#include <bits/stdc++.h>
// #pragma GCC optimize("O3", "unroll-loops")
#define ll long long
// #define int long long
#define pb push_back
#define fi first
#define se second
#define lf (id<<1)
#define rg ((id<<1)|1)
#define md ((l+r)>>1)
#define ld long double
using namespace std;
typedef pair<int,int> pii;
typedef pair<pii, int> ipii;
const int MAXN = 3e5+20;
const int MAXA = 9e3+20;
const ll INF = 1e18+10;
const int LOG = 19;
const int MOD = 998244353;
const int SQRT = 450;
const vector<int> NOL = {};
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const vector<int> dx = {1, -1, 0, 0};
const vector<int> dy = {0, 0, 1, -1};
int sum(int a, int b){ return ((ll)a+(ll)b)%MOD; }
int mul(int a, int b){ return (1ll*a*b)%MOD; }
int expo(int a, int b){
	if(b==0) return 1;
	int te = expo(a, b/2); te = mul(te, te);
	return (b%2 ? mul(te, a) : te);
}
void chsum(int &a, int b){ a = ((ll)a+(ll)b)%MOD; }
void chmul(int &a, int b){ a = (1ll*a*b)%MOD; }

int n, dp[MAXN];
vector <int> adj[MAXN];

void dfs(int nw, int par){
	dp[nw] = 1;
	for(auto nx : adj[nw]){
		if(nx==par) continue;
		dfs(nx, nw);
	}
	for(auto nx : adj[nw]){
		if(nx ==par) continue;
		chmul(dp[nw], sum(dp[nx], 1));
	}
	// cout << nw << ' ' << dp[nw] << " p\n";
}
signed main(){
	// ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int T; cin >> T;
	while(T--){
		string s; cin >> s; s = '.'+s;
		int n = s.size()-1;
		int l=1, r=n, ANS = 0;
		string le = ""; le += s[1];
		string ri = ""; ri += s[n];
		int lasl = -1, lasr = -1;
		while(l<r){
			if(le != ri){
				l++; le += s[l];
				r--; ri = s[r]+ri;
			} else {
				// cout << le << ' ' << ri << " pp\n";
				ANS+=2;
				lasl = l; lasr = r;
				l++; r--;
				le = ""; le += s[l]; 
				ri = ""; ri += s[r];
			}
		}
		if(lasl != n/2 || lasr != n/2+1) ANS++;
 		cout << ANS << '\n';
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 7256 KB Output is correct
2 Correct 5 ms 7260 KB Output is correct
3 Correct 3 ms 7260 KB Output is correct
4 Correct 3 ms 7260 KB Output is correct
5 Correct 4 ms 7260 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 7256 KB Output is correct
2 Correct 5 ms 7260 KB Output is correct
3 Correct 3 ms 7260 KB Output is correct
4 Correct 3 ms 7260 KB Output is correct
5 Correct 4 ms 7260 KB Output is correct
6 Correct 3 ms 7428 KB Output is correct
7 Correct 3 ms 7260 KB Output is correct
8 Correct 3 ms 7260 KB Output is correct
9 Correct 5 ms 7488 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 7256 KB Output is correct
2 Correct 5 ms 7260 KB Output is correct
3 Correct 3 ms 7260 KB Output is correct
4 Correct 3 ms 7260 KB Output is correct
5 Correct 4 ms 7260 KB Output is correct
6 Correct 3 ms 7428 KB Output is correct
7 Correct 3 ms 7260 KB Output is correct
8 Correct 3 ms 7260 KB Output is correct
9 Correct 5 ms 7488 KB Output is correct
10 Correct 7 ms 7516 KB Output is correct
11 Correct 5 ms 7516 KB Output is correct
12 Correct 6 ms 7516 KB Output is correct
13 Correct 9 ms 7496 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 7256 KB Output is correct
2 Correct 5 ms 7260 KB Output is correct
3 Correct 3 ms 7260 KB Output is correct
4 Correct 3 ms 7260 KB Output is correct
5 Correct 4 ms 7260 KB Output is correct
6 Correct 3 ms 7428 KB Output is correct
7 Correct 3 ms 7260 KB Output is correct
8 Correct 3 ms 7260 KB Output is correct
9 Correct 5 ms 7488 KB Output is correct
10 Correct 7 ms 7516 KB Output is correct
11 Correct 5 ms 7516 KB Output is correct
12 Correct 6 ms 7516 KB Output is correct
13 Correct 9 ms 7496 KB Output is correct
14 Execution timed out 10066 ms 14844 KB Time limit exceeded
15 Halted 0 ms 0 KB -