답안 #134906

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
134906 2019-07-23T12:00:02 Z wmrmr 회문 (APIO14_palindrome) C++17
23 / 100
1000 ms 3608 KB
#include <bits/stdc++.h>
using namespace std;

long long int ans;
map<string,int> m;
map<string,int>::iterator mit;
string s;

void ImpInsert()
{
	int tam = s.size();
	for(int i=0;i<tam;i++)
	{
		string aux;
		int maxt = min( i+1, tam-i );
		for(int j=0;j<maxt;j++)
		{
			if( s[i+j] != s[i-j] ) break;
			aux.push_back(s[i+j]);
			if(m.find(aux) == m.end()) m.insert({aux,1});
			else m[aux]++;
		}
	}
	return;
}
void PairInsert()
{
	int tam = s.size();
	for(int i=1;i<tam;i++)
	{
		string aux;
		int maxt = min(i,tam-i);
		for(int j=0;j<maxt;j++)
		{
				if(s[i-1-j] != s[i+j]) break;
			aux.push_back(s[i+j]);
			if(m.find(aux) == m.end()) m.insert({aux,1});
			else m[aux]++;
		}
	}	
	return;
}

int main()
{
	cin >> s;
	ImpInsert();
	for(mit = m.begin();mit!=m.end();mit++)
	{
		int tam = (mit->first).size(), qtd = mit->second;
		ans = max( ans , (long long int) qtd*(2*tam-1) );
	}
	m.clear();
	PairInsert();
	for(mit = m.begin();mit!=m.end();mit++)
	{
		int tam = (mit->first).size(), qtd = mit->second;
		ans = max( ans , (long long int) qtd*(2*tam) );
	}
	printf("%lld",ans);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 256 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 256 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 256 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 3 ms 376 KB Output is correct
24 Correct 2 ms 436 KB Output is correct
25 Correct 3 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 2 ms 256 KB Output is correct
28 Correct 2 ms 256 KB Output is correct
29 Correct 2 ms 256 KB Output is correct
30 Correct 2 ms 256 KB Output is correct
31 Correct 2 ms 256 KB Output is correct
32 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 129 ms 604 KB Output is correct
2 Correct 47 ms 504 KB Output is correct
3 Correct 238 ms 760 KB Output is correct
4 Correct 11 ms 376 KB Output is correct
5 Correct 245 ms 504 KB Output is correct
6 Correct 235 ms 504 KB Output is correct
7 Correct 4 ms 616 KB Output is correct
8 Correct 129 ms 768 KB Output is correct
9 Correct 6 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 396 KB Output is correct
12 Correct 4 ms 548 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1069 ms 3200 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1069 ms 3156 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1078 ms 3608 KB Time limit exceeded
2 Halted 0 ms 0 KB -