답안 #969432

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
969432 2024-04-25T06:54:46 Z guymmk 회문 (APIO14_palindrome) C++14
23 / 100
1000 ms 131072 KB
#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();
    }
}

Compilation message

palindrome.cpp: In function 'void solve()':
palindrome.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++){
      |                 ~^~~~~~~~~
palindrome.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++){
      |                     ~^~~~~~~~~
palindrome.cpp:75:15: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   75 |     for(auto& [i,j]:m){
      |               ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 424 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 600 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 158 ms 1072 KB Output is correct
2 Correct 141 ms 812 KB Output is correct
3 Correct 181 ms 1088 KB Output is correct
4 Correct 131 ms 596 KB Output is correct
5 Correct 179 ms 860 KB Output is correct
6 Correct 179 ms 856 KB Output is correct
7 Correct 130 ms 896 KB Output is correct
8 Correct 165 ms 856 KB Output is correct
9 Correct 134 ms 576 KB Output is correct
10 Correct 128 ms 520 KB Output is correct
11 Correct 128 ms 344 KB Output is correct
12 Correct 129 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1036 ms 50384 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 309 ms 131072 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 309 ms 131072 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -