Submission #743511

# Submission time Handle Problem Language Result Execution time Memory
743511 2023-05-17T12:58:42 Z drkarlicio2107 Palinilap (COI16_palinilap) C++14
17 / 100
1000 ms 564 KB
#include <bits/stdc++.h>
using namespace std;
int par [200010];
int nep [200010];
int count (string s){
	int sol=0;
	for (int i=0; i<s.size(); i++){
		int ind=0;
		for (int j=1; j<s.size(); j++){
			int l=i+j; int r=i-j;
			if (l<0 || r>s.size()-1) break;
			if (s [l]!=s [r]) break;
			ind++;
		}
		sol+=(ind+1);
	}
	for (int i=0; i<s.size()-1; i++){
		int ind=0;
		for (int j=1; j<s.size(); j++){
			int l=i+j; int r=i-j+1;
			if (l<0 || r>s.size()-1) break;
			if (s [l]!=s [r]) break;
			ind++;
		}
		sol+=ind;
	}
	return sol;
}
int main(){
	string s; cin >> s;
	int ans=count (s);
	for (int i=0; i<s.size(); i++){
		char re=s [i];
		for (int j=0; j<26; j++){
			s [i]=('a'+j);
			ans=max (ans, count (s));
		}
		s [i]=re;
	}
	cout << ans;
}

Compilation message

palinilap.cpp: In function 'int count(std::string)':
palinilap.cpp:7:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    7 |  for (int i=0; i<s.size(); i++){
      |                ~^~~~~~~~~
palinilap.cpp:9:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |   for (int j=1; j<s.size(); j++){
      |                 ~^~~~~~~~~
palinilap.cpp:11:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |    if (l<0 || r>s.size()-1) break;
      |               ~^~~~~~~~~~~
palinilap.cpp:17:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |  for (int i=0; i<s.size()-1; i++){
      |                ~^~~~~~~~~~~
palinilap.cpp:19:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |   for (int j=1; j<s.size(); j++){
      |                 ~^~~~~~~~~
palinilap.cpp:21:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |    if (l<0 || r>s.size()-1) break;
      |               ~^~~~~~~~~~~
palinilap.cpp: In function 'int main()':
palinilap.cpp:32:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |  for (int i=0; i<s.size(); i++){
      |                ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 212 KB Output is correct
2 Correct 13 ms 304 KB Output is correct
3 Correct 3 ms 304 KB Output is correct
4 Correct 2 ms 304 KB Output is correct
5 Correct 2 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1046 ms 312 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1059 ms 564 KB Time limit exceeded
2 Halted 0 ms 0 KB -