Submission #1012438

# Submission time Handle Problem Language Result Execution time Memory
1012438 2024-07-02T07:25:19 Z Almonther Difference (POI11_roz) C++
0 / 100
256 ms 14072 KB
#include<bits/stdc++.h>

#define ll long long
#define co cout<<
#define suiii ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
// stuff
ll n;
string s;
ll mx=1;
vector<ll>v[28];
void solve(){
    cin>>n>>s;
    for(int i=0;i<s.size();i++) v[s[i]-'a'].push_back(i);
    for(int i=0;i<26;i++){
        if(v[i].size()==0) continue;
        for(int j=0;j<26;j++){
            ll l,r;
            l=r=0;
            bool can=0;
            ll curr=0;
            while(l!=v[i].size()||r!=v[j].size()){
                if(l==v[i].size()){
                    curr--;
                    can=1;
                    r++;
                }
                else if(r==v[j].size()){
                    curr++;
                    l++;
                }
                else{
                    if(v[i][l]<v[j][r]){
                        curr++;
                        l++;
                    }
                    else{
                        can=1;
                        curr--;
                        r++;
                    }
                }
                if(can) mx=max(mx,curr);
            }
        }
    }
    
    co mx;
}

int main(){
    suiii
    int tt=1;
    // cin>>tt;
    while(tt--){
        solve();
    }
}

Compilation message

roz.cpp: In function 'void solve()':
roz.cpp:14:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |     for(int i=0;i<s.size();i++) v[s[i]-'a'].push_back(i);
      |                 ~^~~~~~~~~
roz.cpp:22:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |             while(l!=v[i].size()||r!=v[j].size()){
      |                   ~^~~~~~~~~~~~~
roz.cpp:22:36: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |             while(l!=v[i].size()||r!=v[j].size()){
      |                                   ~^~~~~~~~~~~~~
roz.cpp:23:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |                 if(l==v[i].size()){
      |                    ~^~~~~~~~~~~~~
roz.cpp:28:26: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |                 else if(r==v[j].size()){
      |                         ~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 448 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 28 ms 1372 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 243 ms 14068 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 231 ms 14072 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 256 ms 13616 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 241 ms 14068 KB Output isn't correct
2 Halted 0 ms 0 KB -