Submission #969250

# Submission time Handle Problem Language Result Execution time Memory
969250 2024-04-24T19:38:33 Z guymmk Palindromes (APIO14_palindrome) C++14
0 / 100
3 ms 1764 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));
    }
};
void solve() {
    string s;
    cin>>s;
    map<string,int>m;
    for(int i=0;i<s.size();i++){
        for(int j=i;j<s.size();i++){
            m[s.substr(i,j)]++;
        }
    }int ans=0;
    for(auto& [i,j]:m){
        ans+=(i.size()*j);
    }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:64: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]
   64 |     for(int i=0;i<s.size();i++){
      |                 ~^~~~~~~~~
palindrome.cpp:65: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]
   65 |         for(int j=i;j<s.size();i++){
      |                     ~^~~~~~~~~
palindrome.cpp:69:15: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   69 |     for(auto& [i,j]:m){
      |               ^
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 604 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 604 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 604 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 1116 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 1764 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -