답안 #899849

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
899849 2024-01-07T07:27:43 Z pcc Palinilap (COI16_palinilap) C++14
17 / 100
1000 ms 716 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fs first
#define sc second
#define tlll tuple<ll,ll,ll>


int ans = 0;

inline bool isp(string s){
	for(int i= 0;i<s.size();i++){
		if(s[i] != s.end()[-i-1])return false;
	}
	return true;
}

inline int calc(string &s){
	int re = 0;
	for(int len = 1;len<=s.size();len++){
		for(int i = 0;i+len<=s.size();i++){
			if(isp(s.substr(i,len)))re++;
		}
	}
	return re;
}

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	string s;
	cin>>s;
	int n = s.size();
	for(int i = 0;i<n;i++){
		string t = s;
		for(char c = 'a';c<='z';c++){
			t[i] = c;
			ans = max(ans,calc(t));
		}
	}
	cout<<ans;
}

Compilation message

palinilap.cpp: In function 'bool isp(std::string)':
palinilap.cpp:15:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |  for(int i= 0;i<s.size();i++){
      |               ~^~~~~~~~~
palinilap.cpp: In function 'int calc(std::string&)':
palinilap.cpp:23:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |  for(int len = 1;len<=s.size();len++){
      |                  ~~~^~~~~~~~~~
palinilap.cpp:24:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |   for(int i = 0;i+len<=s.size();i++){
      |                 ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 132 ms 436 KB Output is correct
2 Correct 403 ms 428 KB Output is correct
3 Correct 252 ms 344 KB Output is correct
4 Correct 247 ms 428 KB Output is correct
5 Correct 226 ms 432 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1052 ms 716 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1030 ms 600 KB Time limit exceeded
2 Halted 0 ms 0 KB -