QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#480291#464. 前缀函数 / KMPClonoth#Compile Error//C++20832b2024-07-16 12:54:112024-07-16 12:54:11

Judging History

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

  • [2024-07-16 12:54:11]
  • 评测
  • [2024-07-16 12:54:11]
  • 提交

answer

#include<bits/stdc++.h>
#define fir first
#define sec second
#define all(x) begin(x),end(x)
using namespace std;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int,int> pii;
template<typename type>
inline void chmin(type &x,const type &y)
{
	if(y<x)
		x=y;
}
template<typename type>
inline void chmax(type &x,const type &y)
{
	if(x<y)
		x=y;
}
constexpr int Max=1e5+10;
int n;
char str[Max];
int nxt[Max];
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr),cout.tie(nullptr);
	cin>>(str+1),n=strlen(str+1);
	for(int i=2,j=0;i<=n;++i)
	{
		while(j&&str[j+1]!=str[i])
			j=nxt[j];
		if(str[j+1]==str[i])
			++j;
		nxt[i]=j;
	}
	for(int i=1;i<=n;++i)
		cout<<nxt[i]<<" \n"[i==n];
	return 0;
}

Details

answer.code: In function ‘int main()’:
answer.code:32:12: error: no match for ‘operator>>’ (operand types are ‘std::istream’ {aka ‘std::basic_istream<char>’} and ‘char*’)
   32 |         cin>>(str+1),n=strlen(str+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:32:18: error: cannot bind non-const lvalue reference of type ‘void*&’ to an rvalue of type ‘void*’
   32 |         cin>>(str+1),n=strlen(str+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:32:18: error: invalid conversion from ‘char*’ to ‘long long unsigned int’ [-fpermissive]
   32 |         cin>>(str+1),n=strlen(str+1);
      |              ~~~~^~~
      |                  |
      |                  char*
answer.code:32:18: error: cannot bind rvalue ‘(long long unsigned int)(((char*)(& str)) + 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:32:18: error: invalid conversion from ‘char*’ to ‘long long int’ [-fpermissive]
   32 |         cin>>(str+1),n=strlen(str+1);
      |              ~~~~^~~
      |                  |
      |                  char*
answer.code:32:18: error: cannot bind rvalue ‘(long long int)(((char*)(& str)) + 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:32:18: error: invalid conversion from ‘char*’ to ‘long unsigned int’ [-fpermissive]
   32 |         cin>>(str+1),n=strlen(str+1);
      |              ~~~~^~~
      |                  |
      |                  char*
answer.code:32:18: error: cannot bind rvalue ‘(long unsigned int)(((char*)(& str)) + 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:32:18: error: invalid conversion from ‘char*’ to ‘long int’ [-fpermissive]
   32 |         cin>>(str+1),n=strlen(str+1);
      |              ~~~~^~~
      |                  |
      |                  char*
answer.code:32:18: error: cannot bind rvalue ‘(long int)(((char*)(& str)) + 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:32:18: error: invalid conversion from ‘char*’ to ‘unsigned int’ [-fpermissive]
   32 |         cin>>(str+1),n=strlen(str+1);
      |              ~~~~^~~
      |                  |
      |            ...