QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#408139#8280. Game of Stringslight_ink_dots#Compile Error//C++201.9kb2024-05-09 19:01:092024-05-09 19:01:09

Judging History

你现在查看的是最新测评结果

  • [2024-05-09 19:01:09]
  • 评测
  • [2024-05-09 19:01:09]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int n,q;
const int N=2e6+100;
char s[N];
const int M=N;
int ch[M][27],f[M],l[M],cnt,now,pos[N];
inline int clone(int q){
    int z=++cnt;memcpy(ch[z],ch[q],sizeof(ch[q]));
    f[z]=f[q];return z;
}
inline void ins(int c,int i){
    int p=now,np=++cnt;now=cnt;pos[i]=cnt;
    l[np]=l[p]+1;
    while(p&&ch[p][c]==0) ch[p][c]=np,p=f[p];
    if(!p){f[np]=1;return ;}
    int q=ch[p][c];
    if(l[q]==l[p]+1){f[np]=q;return ;}
    int nq=clone(q);f[np]=f[q]=nq;l[nq]=l[p]+1;
    while(p&&ch[p][c]==q) ch[p][c]=nq,p=f[p]; 
}
struct BIT{
    int t[N];
    void ins(int x,int w){
        for(int i=x;i<=cnt;i+=(i&(-i))) t[i]+=w;
    }
    int ask(int x){
        int ans=0;
        for(int i=x;i>0;i-=(i&(-i))) ans+=t[i];
        return ans;
    }
    int ask(int x,int y){
        return ask(y)-ask(x-1);
    }
}T;
vector<int>v[N];
int dfn[N],siz[N],step;
void dfs(int x){
    dfn[x]=++step;siz[x]=1;
    for(auto y:v[x]){
        dfs(y);siz[x]+=siz[y];
    }
}
int dp[N],arg[N];
int occ(int l,int r){
    int u=1;
    for(int i=l;i<=r;i++)
        u=ch[u][s[i]-'a'];
    return T.ask(dfn[u],dfn[u]+siz[u]-1);
}

int main(){
    ios::sync_with_stdio(false);
    memset(dp,-63,sizeof(dp));
    cin>>(s+1);n=strlen(s+1);
    cnt=now=1;
    for(int i=n;i>=1;i--){
        ins(s[i]-'a',i);
    }
    for(int i=2;i<=cnt;i++) v[f[i]].push_back(i);
    dfs(1);
    // BF
    arg[n]=n,dp[n]=1;dp[n+1]=0;
    T.ins(dfn[pos[n]],1);
    for(int i=n-1;i>=1;i--){
        T.ins(dfn[pos[i]],1);

        for(int j=i+1;j<=i+1;j++){
            int tmp=occ(i,j-1)-dp[j];
            if(tmp>dp[i]) dp[i]=tmp,arg[i]=j;
        }
        for(int j=arg[i+1];j<=arg[i+1]+10&&j<=n;j++){
            int tmp=occ(i,j-1)-dp[j];
            if(tmp>dp[i]) dp[i]=tmp,arg[i]=j;
        }
        // if(arg[i]!=i+1) cerr<<">>";
        // cerr<<i<<" "<<arg[i]<<" "<<dp[i]<<endl;
    }
    cout<<dp[1];
}

Details

answer.code: In function ‘int main()’:
answer.code:55:8: error: no match for ‘operator>>’ (operand types are ‘std::istream’ {aka ‘std::basic_istream<char>’} and ‘char*’)
   55 |     cin>>(s+1);n=strlen(s+1);
      |     ~~~^~~~~~~
      |     |      |
      |     |      char*
      |     std::istream {aka std::basic_istream<char>}
In file included from /usr/include/c++/13/sstream:40,
                 from /usr/include/c++/13/complex:45,
                 from /usr/include/c++/13/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:127,
                 from answer.code:1:
/usr/include/c++/13/istream:325:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match)
  325 |       operator>>(void*& __p)
      |       ^~~~~~~~
/usr/include/c++/13/istream:325:7: note:   conversion of argument 1 would be ill-formed:
answer.code:55:12: error: cannot bind non-const lvalue reference of type ‘void*&’ to an rvalue of type ‘void*’
   55 |     cin>>(s+1);n=strlen(s+1);
      |          ~~^~~
/usr/include/c++/13/istream:201:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match)
  201 |       operator>>(unsigned long long& __n)
      |       ^~~~~~~~
/usr/include/c++/13/istream:201:7: note:   conversion of argument 1 would be ill-formed:
answer.code:55:12: error: invalid conversion from ‘char*’ to ‘long long unsigned int’ [-fpermissive]
   55 |     cin>>(s+1);n=strlen(s+1);
      |          ~~^~~
      |            |
      |            char*
answer.code:55:12: error: cannot bind rvalue ‘(long long unsigned int)(((char*)(& s)) + 1)’ to ‘long long unsigned int&’
/usr/include/c++/13/istream:197:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match)
  197 |       operator>>(long long& __n)
      |       ^~~~~~~~
/usr/include/c++/13/istream:197:7: note:   conversion of argument 1 would be ill-formed:
answer.code:55:12: error: invalid conversion from ‘char*’ to ‘long long int’ [-fpermissive]
   55 |     cin>>(s+1);n=strlen(s+1);
      |          ~~^~~
      |            |
      |            char*
answer.code:55:12: error: cannot bind rvalue ‘(long long int)(((char*)(& s)) + 1)’ to ‘long long int&’
/usr/include/c++/13/istream:192:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match)
  192 |       operator>>(unsigned long& __n)
      |       ^~~~~~~~
/usr/include/c++/13/istream:192:7: note:   conversion of argument 1 would be ill-formed:
answer.code:55:12: error: invalid conversion from ‘char*’ to ‘long unsigned int’ [-fpermissive]
   55 |     cin>>(s+1);n=strlen(s+1);
      |          ~~^~~
      |            |
      |            char*
answer.code:55:12: error: cannot bind rvalue ‘(long unsigned int)(((char*)(& s)) + 1)’ to ‘long unsigned int&’
/usr/include/c++/13/istream:188:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match)
  188 |       operator>>(long& __n)
      |       ^~~~~~~~
/usr/include/c++/13/istream:188:7: note:   conversion of argument 1 would be ill-formed:
answer.code:55:12: error: invalid conversion from ‘char*’ to ‘long int’ [-fpermissive]
   55 |     cin>>(s+1);n=strlen(s+1);
      |          ~~^~~
      |            |
      |            char*
answer.code:55:12: error: cannot bind rvalue ‘(long int)(((char*)(& s)) + 1)’ to ‘long int&’
/usr/include/c++/13/istream:184:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match)
  184 |       operator>>(unsigned int& __n)
      |       ^~~~~~~~
/usr/include/c++/13/istream:184:7: note:   conversion of argument 1 would be ill-formed:
answer.code:55:12: error: invalid conversion from ‘char*’ to ‘unsigned int’ [-fpermissive]
   55 |     cin>>(s+1);n=strlen(s+1);
      |          ~~^~~
      |            |
      |            char*
answer.code:55:12: error: cannot bind rvalue ‘(unsigned int)(((char*)(& s)) + 1)’ to ‘unsigned int&’
/usr/include/c++/13/istream:181:7: note: candidate: ‘std::basic_istrea...