QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#834681 | #8701. Border | Ishar-zdl | Compile Error | / | / | C++20 | 3.0kb | 2024-12-27 21:30:12 | 2024-12-27 21:30:13 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define pii std::pair<int,int>
#define eb emplace_back
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;
std::mt19937_64 myrand(std::chrono::high_resolution_clock::now().time_since_epoch().count());
inline int R(int n){return myrand()%n+1;}
inline int read(){char ch=getchar();int x=0,f=1;for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')f=-1;for(;ch>='0'&&ch<='9';ch=getchar())x=(x<<3)+(x<<1)+(ch^48);return x*f;}
template<typename T> inline void Min(T&x,T y){if(x>y)x=y;}
template<typename T> inline void Max(T&x,T y){if(x<y)x=y;}
const int N=2e6+10,mod=1000000241,P=1333331;
int n,hs[N],p[N],border,ans[N];
char s[N],t[N];
std::vector<int> v1[N],v2[N];
inline int gethash(int l,int r){
if(l>n||r>n){std::cout<<l<<' '<<r<<'\n';exit(0);}
if(l>r)exit(0);
// if(s[1]=='a'&&s[2]=='k')return 0;
return ((hs[r]-hs[l-1]*p[r-l+1]%mod)+mod)%mod;
}
inline int LCP(int x,int y){
int l=1,r=n-y+1,res=0;while(l<=r){
int mid=l+r>>1;
if(gethash(x,x+mid-1)==gethash(y,y+mid-1))res=mid,l=mid+1;
else r=mid-1;
}return res;
}
inline int LCS(int x,int y){
// if(s[1]=='a'&&s[2]=='k')return 0;
int l=1,r=x,res=0;while(l<=r){
int mid=l+r>>1;if(gethash(x-mid+1,x)==gethash(y-mid+1,y))res=mid,l=mid+1;
else r=mid-1;
}return res;
}
signed main(){
// freopen("in.in","r",stdin);freopen("out.out","w",stdout);
std::ios::sync_with_stdio(false);std::cin.tie(0);std::cout.tie(0);
std::cin>>s+1>>t+1;n=strlen(s+1);
p[0]=1;for(int i=1;i<=n;++i)p[i]=p[i-1]*P%mod,hs[i]=(hs[i-1]*P+s[i])%mod;
// for(int i=1;i<=n;++i)std::cout<<hs[i]<<' ';std::cout<<'\n';
// for(int i=1;i<=n;++i)std::
// std::cout<<gethash(1,4)<<' '<<'\n';z
for(int i=1;i<n;++i){
if(gethash(1,i)==gethash(n-i+1,n)){
Max(border,i);
if(i+1<=n-i)v1[i+1].eb(i),v2[n-i].eb(i);
continue;
}
int lcp=LCP(1,n-i+1),lcs=LCS(i,n);
if(lcp+lcs==i-1){
if(s[lcp+1]==t[n-lcs])Max(ans[n-lcs],i);
if(t[lcp+1]==s[n-lcs])Max(ans[lcp+1],i);
}
else if(i*2>n){
// std::cout<<i<<"i\n";
int p1=0,p2=0,l1=1,l2=n-i+1;
int lcp=LCP(l1,l2);
p1=l1+lcp;
l1+=lcp+1,l2+=lcp+1;
lcp=LCP(l1,l2);
p2=l1+lcp;
l1+=lcp+1,l2+=lcp+1;
lcp=LCP(l1,l2);
if(l2+lcp-1<n)continue;
// std::cout<<i<<"i\n";
// std::cout<<p1<<' '<<p2<<' '<<t[p2]<<' '<<s[n-i+p2]<<' '<<s[p1]<<' '<<s[n-i+p1]<<'\n';
char zc=s[p1];s[p1]=t[p1];
if(s[p1]==s[n-i+p1]&&s[p2]==s[n-i+p2])Max(ans[p1],i);
s[p1]=zc;zc=s[p2];s[p2]=t[p2];
if(s[p2]==s[n-i+p2]&&s[p1]==s[n-i+p1])Max(ans[p2],i);
s[p2]=zc;
}
}
// if(s[1]=='a'&&s[2]=='k')exit(0);
std::multiset<int> set;
for(int i=1;i<=n;++i){
if(t[i]==s[i])Max(ans[i],border);
for(int x:v1[i])set.insert(x);
if(set.size())Max(ans[i],*set.rbegin());
for(int x:v2[i])set.erase(set.lower_bound(x));
std::cout<<ans[i]<<'\n';
}
}
Details
answer.code: In function ‘int main()’: answer.code:42:13: error: no match for ‘operator>>’ (operand types are ‘std::istream’ {aka ‘std::basic_istream<char>’} and ‘char*’) 42 | std::cin>>s+1>>t+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:42:16: error: cannot bind non-const lvalue reference of type ‘void*&’ to an rvalue of type ‘void*’ 42 | std::cin>>s+1>>t+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:42:16: error: invalid conversion from ‘char*’ to ‘long long unsigned int’ [-fpermissive] 42 | std::cin>>s+1>>t+1;n=strlen(s+1); | ~^~ | | | char* answer.code:42:16: 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:42:16: error: invalid conversion from ‘char*’ to ‘long long int’ [-fpermissive] 42 | std::cin>>s+1>>t+1;n=strlen(s+1); | ~^~ | | | char* answer.code:42:16: 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:42:16: error: invalid conversion from ‘char*’ to ‘long unsigned int’ [-fpermissive] 42 | std::cin>>s+1>>t+1;n=strlen(s+1); | ~^~ | | | char* answer.code:42:16: 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:42:16: error: invalid conversion from ‘char*’ to ‘long int’ [-fpermissive] 42 | std::cin>>s+1>>t+1;n=strlen(s+1); | ~^~ | | | char* answer.code:42:16: 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:42:16: error: invalid conversion from ‘char*’ to ‘unsigned int’ [-fpermissive] 42 | std::cin>>s+1>>t+1;n=strlen(s+1); | ~^~ | | | char* answer.code:42:16: error: cannot bind rv...