QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#558409#9244. Counting StringsLarunatrecyCompile Error//C++141012b2024-09-11 15:59:122024-09-11 15:59:13

Judging History

This is the latest submission verdict.

  • [2024-09-11 15:59:13]
  • Judged
  • [2024-09-11 15:59:12]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
template <typename T>inline void read(T &x)
{
    x=0;char c=getchar();bool f=0;
    for(;c<'0'||c>'9';c=getchar())f|=(c=='-');
    for(;c>='0'&&c<='9';c=getchar())x=(x<<1)+(x<<3)+(c-'0');
    x=(f?-x:x);
}
const int N = 2e5+7;
int n;
char s[N];
int tot=1,last=1;
int tr[N][26],len[N],fa[N],pos[N];
void extend(int x,int c)
{
    int p=last,np=last=++tot;
    pos[x]=np;
    while(p&&!tr[p][c])
    {
        tr[p][c]=np;
        p=fa[p];
    }
    if(!p)fa[np]=1;
    else
    {
        int q=tr[p][c];
        if(len[p]==len[p]+1)fa[np]=q;
        else
        {
            int nq=++tot;
            copy(nq,q);
            fa[np]=fa[q]=p;
            len[nq]=len[p]+1;
            while(p&&tr[p][c]==q)
            {
                tr[p][c]=nq;
                p=fa[p];
            }
        }
    }
}
int main()
{
    read(n);
    scanf("%s",s+1);
    for(int i=1;i<=n;i++)extend(i,s[i]-'a');

    return 0;
}

Details

answer.code: In function ‘void extend(int, int)’:
answer.code:32:17: error: no matching function for call to ‘copy(int&, int&)’
   32 |             copy(nq,q);
      |             ~~~~^~~~~~
In file included from /usr/include/c++/13/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from answer.code:1:
/usr/include/c++/13/bits/stl_algobase.h:624:5: note: candidate: ‘template<class _II, class _OI> _OI std::copy(_II, _II, _OI)’
  624 |     copy(_II __first, _II __last, _OI __result)
      |     ^~~~
/usr/include/c++/13/bits/stl_algobase.h:624:5: note:   template argument deduction/substitution failed:
answer.code:32:17: note:   candidate expects 3 arguments, 2 provided
   32 |             copy(nq,q);
      |             ~~~~^~~~~~
In file included from /usr/include/c++/13/iterator:66,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:54:
/usr/include/c++/13/bits/streambuf_iterator.h:339:5: note: candidate: ‘template<class _CharT> typename __gnu_cxx::__enable_if<std::__is_char<_Tp>::__value, std::ostreambuf_iterator<_CharT> >::__type std::copy(istreambuf_iterator<_CharT, char_traits<_CharT> >, istreambuf_iterator<_CharT, char_traits<_CharT> >, ostreambuf_iterator<_CharT>)’
  339 |     copy(istreambuf_iterator<_CharT> __first,
      |     ^~~~
/usr/include/c++/13/bits/streambuf_iterator.h:339:5: note:   template argument deduction/substitution failed:
answer.code:32:17: note:   mismatched types ‘std::istreambuf_iterator<_CharT, std::char_traits<_CharT> >’ and ‘int’
   32 |             copy(nq,q);
      |             ~~~~^~~~~~
answer.code: In function ‘int main()’:
answer.code:46:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   46 |     scanf("%s",s+1);
      |     ~~~~~^~~~~~~~~~