232972026-01-18 16:14:18abcdDNScpp17Forditási hiba
#include <bits/stdc++.h>
using namespace std;

int n;

void update(int i, int x, vector<int>& xl, vector<int>& xr){
    if(xl[x]==-1)xl[x]=i;
    xr[x]=i;
}

int solve(vector<int>& xl, vector<int>& xr){
    int ans=0;
    for(int i=0;i<=2*n;i++){
        if(xl[i]!=-1){
            ans=max(ans,xr[i]-xl[i]);
        }
    }
    return ans;
}

int main(){
    string s;cin>>s;
    if(s==' '){
        cout<<"0\n";
        return 0;
    }
    n=s.size();
    int a=0,c=0,g=0,t=0;
    vector<int> al(2*n+2,-1),ar(2*n+2,-1),cl(2*n+2,-1),cr(2*n+2,-1);
    vector<int> gl(2*n+2,-1),gr(2*n+2,-1),tl(2*n+2,-1),tr(2*n+2,-1);
    for(int i=0;i<n;i++){
        char ch=s[i];
        if(ch=='A'){
            a++;c--;g--;t--;
        }else if(ch=='C'){
            c++;a--;g--;t--;
        }else if(ch=='G'){
            g++;a--;c--;t--;
        }else{
            t++;a--;g--;c--;
        }
        update(i,a+n,al,ar);
        update(i,c+n,cl,cr);
        update(i,g+n,gl,gr);
        update(i,t+n,tl,tr);
    }
    int ans=0;
    ans=max(ans,solve(al,ar));
    ans=max(ans,solve(cl,cr));
    ans=max(ans,solve(tl,tr));
    ans=max(ans,solve(gl,gr));
    cout<<ans<<'\n';
}
Forditási hiba
open /var/local/lib/isolate/427/box/a.out: no such file or directory
main.cpp: In function 'int main()':
main.cpp:23:9: error: no match for 'operator==' (operand types are 'std::string' {aka 'std::__cxx11::basic_string<char>'} and 'char')
   23 |     if(s==' '){
      |        ~^~~~~
      |        |  |
      |        |  char
      |        std::string {aka std::__cxx11::basic_string<char>}
In file included from /usr/include/c++/12/regex:66,
                 from /usr/include/x86_64-linux-gnu/c++/12/bits/stdc++.h:110,
                 from main.cpp:1:
/usr/include/c++/12/bits/regex.h:1063:5: note: candidate: 'template<class _BiIter> bool std::__cxx11::operator==(const sub_match<_BiIter>&, const sub_match<_BiIter>&)'
 1063 |     operator==(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs)
      |     ^~~~~~~~
/usr/include/c++/12/bits/regex.h:1063:5: note:   template argument deduction/substitution failed:
main.cpp:23:11: note:   'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
   23 |     if(s==' '){
      |           ^~~
/usr/include/c++/12/bits/regex.h:1159:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator==(__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const sub_match<_BiIter>&)'
 1159 |     operator==(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/12/bits/regex.h:1159:5: note:   template argument deduction/substitution failed:
main.cpp:23:11: note:   mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'char'
   23 |     if(s==' '){
      |           ^~~
/usr/include/c++/12/bits/regex.h:1234:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator==(const sub_match<_BiIter>&, __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)'
 1234 |     operator==(const sub_match<_Bi_iter>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/12/bits/regex.h:1234:5:...