Submission #71158197


Source Code Expand

#include<bits/stdc++.h>
//bool Mst;
using namespace std;
namespace wyzfastio
{
#ifndef LOCAL
	namespace __getchar{const int bufsize=1<<22;char buf[bufsize],*p1=buf,*p2=buf;inline char getchar(){return (p1==p2&&(p2=(p1=buf)+fread(buf,1,bufsize,stdin),p1==p2))?EOF:(*p1++);}}using __getchar::getchar;namespace __putchar{const int bufsize=1<<22;char buf[bufsize],*p=buf;inline void putchar(const char ch){if(p-buf==bufsize) fwrite(buf,1,bufsize,stdout),p=buf;*p++=ch;}inline void flush(){fwrite(buf,1,p-buf,stdout),p=buf;}}using __putchar::putchar;using __putchar::flush;namespace __flusher{struct Flusher{Flusher(){}~Flusher(){flush();}}flusher;}
#define endl "\n"
#else
	void flush(){}
#define endl wyzfastio::oshelper::_endl
#endif
	std::string bool_str[2]={"false","true"};int double_mx=12;struct istream{void tie([[maybe_unused]]int x){}};struct ostream{void tie([[maybe_unused]]int x){}};istream in;ostream out;
	istream &operator>>(istream &in,char &s){s=getchar();while(s==' '||s=='\n'||s=='\r')s=getchar();return in;}istream &operator>>(istream &in,std::string &s){char ch=getchar();s.clear();while(ch==' '||ch=='\n'||ch=='\r')ch=getchar();while(!(ch==' '||ch=='\n'||ch=='\r'||ch==EOF))s+=ch,ch=getchar();return in;}istream &operator>>(istream &in,__int128 &x){char ch=getchar();int o=0;__int128 r=0;while(ch<'0'||ch>'9'){if(ch=='-')o^=1;ch=getchar();}while(ch>='0'&&ch<='9')r=(r<<3)+(r<<1)+ch-'0',ch=getchar();x=o?-r:r;return in;}istream &operator>>(istream &in,unsigned __int128 &x){char ch=getchar();__int128 r=0;while(ch>='0'&&ch<='9')r=(r<<3)+(r<<1)+ch-'0',ch=getchar();x=r;return in;}
	ostream &operator<<(ostream &out,const char x){putchar(x);return out;}ostream &operator<<(ostream &out,const char *s){while(*s!='\0'&&*s!=EOF)putchar(*s),s++;return out;}ostream &operator<<(ostream &out,std::string s){for(char ch:s)putchar(ch);return out;}ostream &operator<<(ostream &out,__int128 x){static int __stk[66];int top=0,op=1-((x<0)<<1);if(x==0)__stk[top++]=0;else while(x)__stk[top++]=(x%10)*op,x/=10;if(op==-1)putchar('-');while(top)putchar(__stk[--top]+'0');return out;}ostream &operator<<(ostream &out,unsigned __int128 x){static int __stk[66];int top=0;if(x==0)__stk[top++]=0;else while(x)__stk[top++]=(x%10),x/=10;while(top)putchar(__stk[--top]+'0');return out;}
	template<typename _Tp>inline typename std::enable_if<std::is_integral<_Tp>::value&&!std::is_same<_Tp,bool>::value,istream &>::type operator>>(istream &in,_Tp &x){char ch=getchar();int o=0;_Tp r=0;while(ch<'0'||ch>'9'){if(ch=='-')o^=1;ch=getchar();}while(ch>='0'&&ch<='9')r=(r<<3)+(r<<1)+ch-'0',ch=getchar();x=o?-r:r;return in;}template<typename _Tp>inline typename std::enable_if<std::is_same<_Tp,bool>::value,istream &>::type operator>>(istream &in,_Tp &x){int r;in>>r;x=r;return in;}template<typename _Tp>inline typename std::enable_if<std::is_floating_point<_Tp>::value,istream &>::type operator>>(istream &in,_Tp &x){_Tp r=0,p=1;int op=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')op=-op;ch=getchar();}while(ch>='0'&&ch<='9'){r=r*10+ch-'0';ch=getchar();}if(ch=='.'){ch=getchar();while(ch>='0'&&ch<='9')r+=(p*=0.1)*(ch-'0'),ch=getchar();}x=r*op;return in;}
	template<typename _Tp>inline typename std::enable_if<std::is_integral<_Tp>::value&&!std::is_same<_Tp,bool>::value,ostream &>::type operator<<(ostream &out,_Tp x){static int __stk[33];int top=0,op=1-((x<0)<<1);if(x==0)__stk[top++]=0;else while(x)__stk[top++]=(x%10)*op,x/=10;if(op==-1)putchar('-');while(top)putchar(__stk[--top]+'0');return out;}template<typename _Tp>inline typename std::enable_if<std::is_same<_Tp,bool>::value,ostream &>::type operator<<(ostream &out,_Tp x){out<<bool_str[x];return out;}template<typename _Tp>inline typename std::enable_if<std::is_floating_point<_Tp>::value,ostream &>::type operator<<(ostream &out,_Tp x){if(x<0)putchar('-'),x=-x;static int __stk[233];int top=0;for(int i=0;i<double_mx;i++)x*=10;x=std::floor(x+0.5);for(_Tp y;x>=1;)y=std::floor(x/10),__stk[top++]=x-y*10,x=y;while(top<=double_mx)__stk[top++]=0;while(top>double_mx)putchar(__stk[--top]+'0');putchar('.');while(top)putchar(__stk[--top]+'0');return out;}
	namespace oshelper{struct ostreamhelper{};struct endler{};endler _endl;ostreamhelper set_bool_str(const std::string str_false,const std::string str_true){bool_str[0]=str_false,bool_str[1]=str_true;return ostreamhelper();}ostreamhelper set_precision(int precision){double_mx=precision;return ostreamhelper();}ostream &operator<<(ostream &out,[[maybe_unused]]ostreamhelper outhelper){return out;}ostream &operator<<(ostream &out,[[maybe_unused]]endler _endl){out<<"\n",flush();return out;}}
#define cin wyzfastio::in
#define cout wyzfastio::out
}
using ll=long long;
using ld=long double;
//#define int ll
using pii=pair<int,int>;
const int N=2e5+5;
struct SAM
{
	struct __SAM_nd
	{
		map<int,int> ch;
		int link,len;
		__SAM_nd(){ch.clear(),len=link=0;}
	}node[N<<1];
	map<int,int> mp;
	int dp(int u)
	{
		if(mp.count(u)) return mp[u];
		mp[u]=0;
		for(auto [c,v]:node[u].ch) mp[u]|=!dp(v);
		return mp[u];
	}
	int sz,lst;
	void init(){node[0].ch.clear(),node[0].len=0,node[0].link=-1,sz=1,lst=0;mp.clear();}
	SAM(){init();}
	inline int nd()
	{
		return node[sz]=__SAM_nd(),sz++;
	}
	void insert(char c)
	{
		int cur=nd();
		node[cur].len=node[lst].len+1;
		int p=lst;
		while(p!=-1&&!node[p].ch.count(c)) node[p].ch[c]=cur,p=node[p].link;
		if(p==-1) node[cur].link=0;
		else
		{
			int q=node[p].ch[c];
			if(node[p].len+1==node[q].len) node[cur].link=q;
			else
			{
				int cl=nd();
				node[cl].len=node[p].len+1,node[cl].ch=node[q].ch,node[cl].link=node[q].link;
				while(p!=-1&&node[p].ch[c]==q) node[p].ch[c]=cl,p=node[p].link;
				node[q].link=node[cur].link=cl;
			}
		}
		lst=cur;
	}
}sam;
//bool Med;
signed main()
{
//	cerr<<"Memory Size: "<<abs((&Med)-(&Mst))/1024.0/1024<<" MB\n";
//	freopen("in.in","r",stdin);
//	freopen("out.out","w",stdout);
	int tc;cin>>tc;
	while(tc--) [&]()
	{
		sam.init();
		string s;cin>>s;
		for(char c:s) sam.insert(c);
		if(sam.dp(0)) cout<<"Alice\n";
		else cout<<"Bob\n";
	}();
	return 0;
}

Submission Info

Submission Time
Task G - Substring Game
User wangyizhi
Language C++23 (GCC 15.2.0)
Score 600
Code Size 6128 Byte
Status AC
Exec Time 744 ms
Memory 86076 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 600 / 600
Status
AC × 1
AC × 32
Set Name Test Cases
Sample 00_sample_00.txt
All 00_sample_00.txt, 01_small_00.txt, 01_small_01.txt, 01_small_02.txt, 02_random_00.txt, 02_random_01.txt, 02_random_02.txt, 02_random_03.txt, 02_random_04.txt, 02_random_05.txt, 02_random_06.txt, 02_random_07.txt, 02_random_08.txt, 02_random_09.txt, 02_random_10.txt, 02_random_11.txt, 02_random_12.txt, 02_random_13.txt, 02_random_14.txt, 02_random_15.txt, 02_random_16.txt, 02_random_17.txt, 02_random_18.txt, 02_random_19.txt, 03_handmade_00.txt, 03_handmade_01.txt, 03_handmade_02.txt, 03_handmade_03.txt, 03_handmade_04.txt, 03_handmade_05.txt, 03_handmade_06.txt, 03_handmade_07.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 10 ms 25392 KiB
01_small_00.txt AC 50 ms 25744 KiB
01_small_01.txt AC 55 ms 25828 KiB
01_small_02.txt AC 78 ms 26116 KiB
02_random_00.txt AC 653 ms 78912 KiB
02_random_01.txt AC 744 ms 84116 KiB
02_random_02.txt AC 675 ms 79584 KiB
02_random_03.txt AC 659 ms 84332 KiB
02_random_04.txt AC 672 ms 86076 KiB
02_random_05.txt AC 739 ms 82116 KiB
02_random_06.txt AC 696 ms 78196 KiB
02_random_07.txt AC 602 ms 74896 KiB
02_random_08.txt AC 572 ms 67296 KiB
02_random_09.txt AC 595 ms 68604 KiB
02_random_10.txt AC 624 ms 73980 KiB
02_random_11.txt AC 612 ms 68148 KiB
02_random_12.txt AC 203 ms 26028 KiB
02_random_13.txt AC 202 ms 26000 KiB
02_random_14.txt AC 202 ms 25904 KiB
02_random_15.txt AC 203 ms 25876 KiB
02_random_16.txt AC 323 ms 30668 KiB
02_random_17.txt AC 328 ms 30440 KiB
02_random_18.txt AC 322 ms 30532 KiB
02_random_19.txt AC 326 ms 30380 KiB
03_handmade_00.txt AC 163 ms 60496 KiB
03_handmade_01.txt AC 160 ms 60460 KiB
03_handmade_02.txt AC 421 ms 67676 KiB
03_handmade_03.txt AC 410 ms 64044 KiB
03_handmade_04.txt AC 11 ms 25488 KiB
03_handmade_05.txt AC 243 ms 74300 KiB
03_handmade_06.txt AC 204 ms 66636 KiB
03_handmade_07.txt AC 164 ms 60388 KiB