이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int m_INF = -1e9+7;
bool palindrom(string s){
reverse(s.begin(),s.end());
string z = s ;
reverse(s.begin(),s.end());
if(z == s){
return true;
}
else{
return false;
}
}
ll find_say_string(string s , string q)
{
ll say = 0 ;
for(ll i = 0;i <= s.size()-q.size();i++){
string z = "";
for(ll j = i;j < i + q.size();j++)
{
z += s[j];
}
if(z == q)
{
say++;
}
}
return say ;
}
void find_max_palindrom_on_string(string s)
{
ll l = 0 , r = s.size()-1 ;
vector < string > palindroms ;
vector < char > q ;
if(palindrom(s)){
palindroms.push_back(s);
}
for(ll i = 0;i < s.size();i++){
q.push_back(s[i]);
}
while(r > 0)
{
string z = s.substr(l,r);
if(palindrom(z) && z.size() != 1)
{
palindroms.push_back(z);
}
l++;
if(l == r)
{
l = 0 ;
r--;
}
}
sort(palindroms.begin(),palindroms.end());
for(ll i = 0;i < palindroms.size();i++){
if(palindroms[i] == palindroms[i+1]){
palindroms.erase(palindroms.begin() + i);
}
}
sort(q.begin(),q.end());
///////////////////////////////////////////////////////////////////////////////
int maks = m_INF ;
for(ll i = 0;i < palindroms.size();i++)
{
string t = palindroms[i];
maks = max(maks,int(t.size())*(int((find_say_string(s,t)))));
}
for(ll i = 0;i < q.size();i++)
{
int say = 0 ;
char c = q[i] ;
for(ll j = 0;j < s.size();j++)
{
if(s[j] == c){
say++;
}
}
maks = max(maks,say);
}
cout << maks << endl ;
}
signed main()
{
string s ;
cin >> s ;
find_max_palindrom_on_string(s);
}
컴파일 시 표준 에러 (stderr) 메시지
palindrome.cpp: In function 'long long int find_say_string(std::string, std::string)':
palindrome.cpp:26:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
26 | for(ll i = 0;i <= s.size()-q.size();i++){
| ~~^~~~~~~~~~~~~~~~~~~~
palindrome.cpp:29:24: warning: comparison of integer expressions of different signedness: 'long long int' and 'long long unsigned int' [-Wsign-compare]
29 | for(ll j = i;j < i + q.size();j++)
| ~~^~~~~~~~~~~~~~
palindrome.cpp: In function 'void find_max_palindrom_on_string(std::string)':
palindrome.cpp:55:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
55 | for(ll i = 0;i < s.size();i++){
| ~~^~~~~~~~~~
palindrome.cpp:80:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
80 | for(ll i = 0;i < palindroms.size();i++){
| ~~^~~~~~~~~~~~~~~~~~~
palindrome.cpp:92:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
92 | for(ll i = 0;i < palindroms.size();i++)
| ~~^~~~~~~~~~~~~~~~~~~
palindrome.cpp:99:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
99 | for(ll i = 0;i < q.size();i++)
| ~~^~~~~~~~~~
palindrome.cpp:105:24: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
105 | for(ll j = 0;j < s.size();j++)
| ~~^~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |