RT,一直段错误,在NOI linux系统下一直编译不了
#include <iostream>
#include <cstdio>
#include <cctype>
#include <cstring>
#define il inline
#define ll long long
#define gc getchar
#define int long long
#define R register
using namespace std;
//---------------------初始函数-------------------------------
il int read(){
R int x=0;R bool f=0;R char ch=gc();
while(!isdigit(ch)) {f|=ch=='-';ch=gc();}
while(isdigit(ch)) {x=(x<<1)+(x<<3)+(ch^48);ch=gc();}
return f?-x:x;
}
il int max(int a,int b) {return a>b?a:b;}
il int min(int a,int b) {return a<b?a:b;}
//---------------------初始函数-------------------------------
const int MAXN=1e6+10;
char s[MAXN],t[MAXN],ans[MAXN];
//---------------------------KMP算法---------------------------
int kmp[MAXN],top;
void getkmp(){
int lent=strlen(t+1);
kmp[0]=kmp[1]=0;
for(R int j=1;j<lent;++j){
int k=kmp[k];
while(k&&t[j+1]!=t[k+1]) k=kmp[k];
if(t[j+1]==t[k+1]) ++k;
kmp[j+1]=k;
}
}
void KMP(){
int lens=strlen(s+1),lent=strlen(t+1);
getkmp();
for(R int j=0;j<lens;++j){
if(j) ans[++top]=s[j];
int k=kmp[k];
while(k&&s[j+1]!=t[k+1]) k=kmp[k];
if(s[j+1]==t[k+1]) ++k;
if(k==lent) {top-=lent;k=kmp[top];}
}
}
//---------------------------KMP算法---------------------------
signed main(){
scanf("%s%s",s+1,t+1);
KMP();
for(R int i=1;i<=top;++i) printf("%c ",ans[i]);
return 0;
}