QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#408140 | #8280. Game of Strings | light_ink_dots# | Compile Error | / | / | C++14 | 1.9kb | 2024-05-09 19:01:30 | 2024-05-09 19:01:31 |
Judging History
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:63:5: error: reference to ‘arg’ is ambiguous 63 | arg[n]=n,dp[n]=1;dp[n+1]=0; | ^~~ In file included 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/complex:2417:5: note: candidates are: ‘template<class _Tp> typename __gnu_cxx::__promote<_Tp>::__type std::arg(_Tp)’ 2417 | arg(_Tp __x) | ^~~ /usr/include/c++/13/complex:914:5: note: ‘template<class _Tp> _Tp std::arg(const complex<_Tp>&)’ 914 | arg(const complex<_Tp>& __z) { return __complex_arg(__z.__rep()); } | ^~~ answer.code:44:11: note: ‘int arg [2000100]’ 44 | int dp[N],arg[N]; | ^~~ answer.code:70:37: error: reference to ‘arg’ is ambiguous 70 | if(tmp>dp[i]) dp[i]=tmp,arg[i]=j; | ^~~ /usr/include/c++/13/complex:2417:5: note: candidates are: ‘template<class _Tp> typename __gnu_cxx::__promote<_Tp>::__type std::arg(_Tp)’ 2417 | arg(_Tp __x) | ^~~ /usr/include/c++/13/complex:914:5: note: ‘template<class _Tp> _Tp std::arg(const complex<_Tp>&)’ 914 | arg(const complex<_Tp>& __z) { return __complex_arg(__z.__rep()); } | ^~~ answer.code:44:11: note: ‘int arg [2000100]’ 44 | int dp[N],arg[N]; | ^~~ answer.code:72:19: error: reference to ‘arg’ is ambiguous 72 | for(int j=arg[i+1];j<=arg[i+1]+10&&j<=n;j++){ | ^~~ /usr/include/c++/13/complex:2417:5: note: candidates are: ‘template<class _Tp> typename __gnu_cxx::__promote<_Tp>::__type std::arg(_Tp)’ 2417 | arg(_Tp __x) | ^~~ /usr/include/c++/13/complex:914:5: note: ‘template<class _Tp> _Tp std::arg(const complex<_Tp>&)’ 914 | arg(const complex<_Tp>& __z) { return __complex_arg(__z.__rep()); } | ^~~ answer.code:44:11: note: ‘int arg [2000100]’ 44 | int dp[N],arg[N]; | ^~~ answer.code:72:31: error: reference to ‘arg’ is ambiguous 72 | for(int j=arg[i+1];j<=arg[i+1]+10&&j<=n;j++){ | ^~~ /usr/include/c++/13/complex:2417:5: note: candidates are: ‘template<class _Tp> typename __gnu_cxx::__promote<_Tp>::__type std::arg(_Tp)’ 2417 | arg(_Tp __x) | ^~~ /usr/include/c++/13/complex:914:5: note: ‘template<class _Tp> _Tp std::arg(const complex<_Tp>&)’ 914 | arg(const complex<_Tp>& __z) { return __complex_arg(__z.__rep()); } | ^~~ answer.code:44:11: note: ‘int arg [2000100]’ 44 | int dp[N],arg[N]; | ^~~ answer.code:74:37: error: reference to ‘arg’ is ambiguous 74 | if(tmp>dp[i]) dp[i]=tmp,arg[i]=j; | ^~~ /usr/include/c++/13/complex:2417:5: note: candidates are: ‘template<class _Tp> typename __gnu_cxx::__promote<_Tp>::__type std::arg(_Tp)’ 2417 | arg(_Tp __x) | ^~~ /usr/include/c++/13/complex:914:5: note: ‘template<class _Tp> _Tp std::arg(const complex<_Tp>&)’ 914 | arg(const complex<_Tp>& __z) { return __complex_arg(__z.__rep()); } | ^~~ answer.code:44:11: note: ‘int arg [2000100]’ 44 | int dp[N],arg[N]; | ^~~