답안 #319750

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
319750 2020-11-06T11:10:46 Z armanmohammadi Palindromic Partitions (CEOI17_palindromic) C++14
60 / 100
19 ms 4360 KB
//in the name of god
//if you read this code please search about imam hussain
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

#define pb push_back
#define endl "\n"
#define X first
#define Y second
#define pii pair<int,int>
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define read freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout)

const int maxn=1e5+5;
const int mod=1e9+7;
const int inf=1e9;
const int del=728729;
const int pr =  637;
ll poww(ll a, ll b, ll md) {return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));}
string s  ; 
ll tav[maxn] ;
ll h[maxn]  ;
ll L ;
ll R ;
ll sz ;
ll n  ;
ll l ;
ll r ;
ll mid ;
ll b ;
ll ans ;
ll lh ;
ll rh ;
ll cnt  ;
ll t;
int main()
{
	int t ; 
	migmig; 
	tav[0] = 1 ; 
	for(int i = 1; i < maxn ; i ++ )
	{
		tav[i] = tav[i-1] * pr % mod ; 
	}
	cin>> t ; 
	for(int i = 0 ; i < t  ;i++){
	ans = 0 ; 
	cin>>s ; 
	L= 0 ;
	R = s.size() - 1 ;
	lh = rh = 0 ;
	cnt = 0 ; 
	for(; L < R ; L++ , R-- , cnt++){
		lh = (lh * pr % mod + s[L]) % mod ;
		rh = (rh + tav[cnt] * s[R] % mod ) % mod ; 
		if(lh == rh)
		{
			ans += 2 ; 
			lh = rh = cnt = 0 ; cnt = -1 ; 
		}
	}
	if(s.size() % 2 == 1 || lh != rh)
	ans ++ ; 
	cout<<ans << endl ; 
	}
}
 
 
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1132 KB Output is correct
2 Correct 1 ms 1132 KB Output is correct
3 Correct 1 ms 1132 KB Output is correct
4 Correct 1 ms 1132 KB Output is correct
5 Correct 1 ms 1132 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1132 KB Output is correct
2 Correct 1 ms 1132 KB Output is correct
3 Correct 1 ms 1132 KB Output is correct
4 Correct 1 ms 1132 KB Output is correct
5 Correct 1 ms 1132 KB Output is correct
6 Correct 1 ms 1132 KB Output is correct
7 Correct 2 ms 1164 KB Output is correct
8 Correct 2 ms 1132 KB Output is correct
9 Correct 1 ms 1132 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1132 KB Output is correct
2 Correct 1 ms 1132 KB Output is correct
3 Correct 1 ms 1132 KB Output is correct
4 Correct 1 ms 1132 KB Output is correct
5 Correct 1 ms 1132 KB Output is correct
6 Correct 1 ms 1132 KB Output is correct
7 Correct 2 ms 1164 KB Output is correct
8 Correct 2 ms 1132 KB Output is correct
9 Correct 1 ms 1132 KB Output is correct
10 Correct 2 ms 1132 KB Output is correct
11 Correct 2 ms 1132 KB Output is correct
12 Correct 2 ms 1132 KB Output is correct
13 Correct 2 ms 1280 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1132 KB Output is correct
2 Correct 1 ms 1132 KB Output is correct
3 Correct 1 ms 1132 KB Output is correct
4 Correct 1 ms 1132 KB Output is correct
5 Correct 1 ms 1132 KB Output is correct
6 Correct 1 ms 1132 KB Output is correct
7 Correct 2 ms 1164 KB Output is correct
8 Correct 2 ms 1132 KB Output is correct
9 Correct 1 ms 1132 KB Output is correct
10 Correct 2 ms 1132 KB Output is correct
11 Correct 2 ms 1132 KB Output is correct
12 Correct 2 ms 1132 KB Output is correct
13 Correct 2 ms 1280 KB Output is correct
14 Runtime error 19 ms 4360 KB Execution killed with signal 11 (could be triggered by violating memory limits)
15 Halted 0 ms 0 KB -