이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3,unroll-loops,Ofast")
#define int long long
#define ll long long
#define endl '\n'
#define vi vector<int>
#define vpii vector<pair<int,int> >
#define umap unordered_map
#define uset unordered_set
#define mk make_pair
#define pb push_back
#define pob pop_back
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define read(x) for (auto& zu: (x)) cin >> zu;
#define F first
#define S second
#define mustawa ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
#define pii pair<int,int>
#define mishari main
const int inf=1e9+7;
void fa(bool ok){ cout << (ok ? "YES": "NO") << "\n";}
int pw(ll a,ll b,ll mod=1e9+7){
ll result = 1;
while(b) {
if(b&1) {
result = (result*a)%mod;
}
a = (a * a) % mod;
b>>=1;
}
return result;
}inline void usaco(string s) {
freopen((s + ".in").c_str(), "r", stdin);
freopen((s + ".out").c_str(), "w", stdout);
}struct Segtree{
pii oper(pii a,pii b){
int ret=1;
if(a.F==b.F)ret=a.S+b.S;
else ret=(a.F>b.F?b.S:a.S);
return {min(a.F, b.F),ret};
}
int off=1;
vpii tree;
Segtree(int n){
off<<=(int) ceil(log2(n));
tree.resize(2*off, {1e18,1});
}void update(int x,int i){
i+=off;
tree[i]={x,1};
while(i/=2)tree[i]=oper(tree[i*2],tree[i*2+1]);
}pii query(int l,int r,int lo,int hi,int i){
if(l>=lo&&r<=hi)return tree[i];
if(l>=hi||r<=lo)return {inf,0};
int md=(l+r)/2;
return oper(query(l,md,lo,hi,i*2), query(md+1,r,lo,hi,i*2+1));
}
};bool ispal(string s){
string r=s;
reverse(all(r));
return r==s;
}
void solve() {
string s;
cin>>s;
map<string,int>m;
for(int i=0;i<s.size();i++){
string f;
for(int j=i;j<s.size();j++){
f+=s[j];
if(ispal(f))m[f]++;
}
}int ans=0;
for(auto& [i,j]:m){
ans=max((int)(i.size()*j),ans);
}cout<<ans<<endl;
}
signed mishari(){
mustawa;
//usaco("a");
int t = 1;
//cin>>t;
for(int i=1;i<=t;i++){
//cout<<"Case "<<i<<":\n";
solve();
}
}
컴파일 시 표준 에러 (stderr) 메시지
sequence.cpp: In function 'void solve()':
sequence.cpp:68:18: 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]
68 | for(int i=0;i<s.size();i++){
| ~^~~~~~~~~
sequence.cpp:70:22: 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]
70 | for(int j=i;j<s.size();j++){
| ~^~~~~~~~~
sequence.cpp:75:15: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
75 | for(auto& [i,j]:m){
| ^
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |