QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#237619#7512. Almost Prefix ConcatenationkonyakestCompile Error//C++232.5kb2023-11-04 14:34:142023-11-04 14:34:15

Judging History

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

  • [2023-11-04 14:34:15]
  • 评测
  • [2023-11-04 14:34:14]
  • 提交

answer

#include<bits/stdc++.h>
#define F(i,j,k) for(auto i=j;i<=(decltype(j))(k);i++)
#define exec(...) [&](){__VA_ARGS__}()
#define view(x) begin(x),end(x)
#define pb push_back
#define lambda [&]
#define x first
#define y second
#define endl '\n'
#define os ostream
using namespace std;
using ll=long long;
template<typename T>void ckmin(T& a,T b){(a>b)&&(a=b);}
template<typename T>void ckmax(T& a,T b){(a<b)&&(a=b);}

#ifdef DEBUG
template<typename ...T>os& operator<<(os& out,tuple<T...> x);

template<typename T1,typename T2>os& operator<<(os& out,pair<T1,T2> x){return out<<tuple(x);}
template<typename T,typename=decltype(T().begin()),typename=enable_if_t<!is_same_v<decay_t<T>,string>>>os& operator<<(os& out,T x){return out<<"{",exec(auto n=0u;for(auto i:x) out<<i<<(++n==x.size()?"":",");),out<<"}";}
template<typename ...T>os& operator<<(os& out,tuple<T...> x){return apply(lambda(T... xx){auto n=0u;out<<"{";((out<<xx<<(++n==sizeof...(T)?"":",")),...),out<<"}";},x),out;}
#define debug(...) cerr<<"#"<<__LINE__<<": "<<#__VA_ARGS__<<" = "<<tuple(__VA_ARGS__)<<endl
#else
#define debug(...) (void)0
#endif

const int maxn=1e6+5,MOD=998244353;
const ll mod=1e16+61,base=137;

ll pw[maxn],hsh1[maxn],hsh2[maxn];
int n,m,len[maxn];
char s[maxn],t[maxn];

ll gethsh(ll* hsh,int x,int y){
	return (mod+hsh[y]-__int128(hsh[x-1])*pw[y-x+1]%mod)%mod;
}

int getlen(int x,int y){
	int l=0,r=m-y+3;
	while(l<r){
		int mid=(l+r+1)/2;
		if(gethsh(hsh1,x,x+mid-1)==gethsh(hsh2,y,y+mid-1)) l=mid;
		else r=mid-1;
	}
	return l;
}

struct Array:array<int,3>{
	template<typename ...T>Array(T... x):array({x...}){}
	void operator+=(const Array& a){F(i,0,2) ((*this)[i]+=a[i])%=MOD;}
	friend Array operator-(Array a,const Array& b){
		F(i,0,2) (a[i]+=MOD-b[i])%=MOD;
		return a;
	}
	friend Array add_one(Array a){debug(a);return {(a[0]+a[1]+a[2])%MOD,(2*a[2]+a[1])%MOD,a[2]};}
}dp[maxn],qzh[maxn];



signed main(){
    cin.tie(0)->sync_with_stdio(0);
	cin>>(s+1)>>(t+1);
	n=strlen(s+1),m=strlen(t+1);
	pw[0]=1;
	F(i,1,n) pw[i]=pw[i-1]*base%mod;
	F(i,1,n) hsh1[i]=(hsh1[i-1]*base+s[i])%mod;
	F(i,1,m) hsh2[i]=(hsh2[i-1]*base+t[i])%mod;
	F(i,1,n){
		int ln=getlen(i,1);
		len[i]=min({m,n-i+1,ln+1+getlen(i+ln+1,ln+2)});
		debug(i,len[i]);
	}
	dp[n+1]=qzh[n+1]={0,0,1};
	for(int i=n;i>=1;i--){
		dp[i]=add_one(qzh[i+1]-qzh[i+len[i]+1]);
		qzh[i]+=qzh[i+1],qzh[i]+=dp[i];
		debug(i,dp[i],qzh[i]);
	}
	cout<<dp[1][0]<<endl;
	debug(dp[1],qzh[1]);
    return not "FST";
}
/*
 *
 *
 *
 *
 *
 *
 *
 */




詳細信息

answer.code: In function ‘int main()’:
answer.code:62:12: error: no match for ‘operator>>’ (operand types are ‘std::istream’ {aka ‘std::basic_istream<char>’} and ‘char*’)
   62 |         cin>>(s+1)>>(t+1);
      |         ~~~^~~~~~~
      |         |      |
      |         |      char*
      |         std::istream {aka std::basic_istream<char>}
In file included from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from answer.code:1:
/usr/include/c++/11/istream:168:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]’ (near match)
  168 |       operator>>(bool& __n)
      |       ^~~~~~~~
/usr/include/c++/11/istream:168:7: note:   conversion of argument 1 would be ill-formed:
answer.code:62:16: error: cannot bind non-const lvalue reference of type ‘bool&’ to a value of type ‘char*’
   62 |         cin>>(s+1)>>(t+1);
      |              ~~^~~
In file included from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from answer.code:1:
/usr/include/c++/11/istream:172:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]’ (near match)
  172 |       operator>>(short& __n);
      |       ^~~~~~~~
/usr/include/c++/11/istream:172:7: note:   conversion of argument 1 would be ill-formed:
answer.code:62:16: error: invalid conversion from ‘char*’ to ‘short int’ [-fpermissive]
   62 |         cin>>(s+1)>>(t+1);
      |              ~~^~~
      |                |
      |                char*
answer.code:62:16: error: cannot bind rvalue ‘(short int)(((char*)(& s)) + 1)’ to ‘short int&’
In file included from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from answer.code:1:
/usr/include/c++/11/istream:175:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]’ (near match)
  175 |       operator>>(unsigned short& __n)
      |       ^~~~~~~~
/usr/include/c++/11/istream:175:7: note:   conversion of argument 1 would be ill-formed:
answer.code:62:16: error: invalid conversion from ‘char*’ to ‘short unsigned int’ [-fpermissive]
   62 |         cin>>(s+1)>>(t+1);
      |              ~~^~~
      |                |
      |                char*
answer.code:62:16: error: cannot bind rvalue ‘(short unsigned int)(((char*)(& s)) + 1)’ to ‘short unsigned int&’
In file included from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from answer.code:1:
/usr/include/c++/11/istream:179:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]’ (near match)
  179 |       operator>>(int& __n);
      |       ^~~~~~~~
/usr/include/c++/11/istream:179:7: note:   conversion of argument 1 would be ill-formed:
answer.code:62:16: error: invalid conversion from ‘char*’ to ‘int’ [-fpermissive]
   62 |         cin>>(s+1)>>(t+1);
      |              ~~^~~
      |                |
      |                char*
answer.code:62:16: error: cannot bind rvalue ‘(int)(((char*)(& s)) + 1)’ to ‘int&’
In file included from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from answer.code:1:
/usr/include/c++/11/istream:182: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>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]’ (near match)
  182 |       operator>>(unsigned int& __n)
      |       ^~~~~~~~
/usr/include/c++/11/istream:182:7: note:   conversion of argument 1 would be ill-formed:
answer.code:62:16: error: invalid conversion fro...