提出 #71148714


ソースコード 拡げる

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,sse4,popcnt,abm,mmx,avx,avx2")
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
#define ll long long
#define ull unsigned long long
//#define int long long
#define SZ(x) ((int)((x).size()))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
inline int read()
{
	char c=getchar();int x=0;bool f=0;
	for(;!isdigit(c);c=getchar())f^=!(c^45);
	for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
	return f?-x:x;
}

#define fi first
#define se second
#define pb push_back
#define mkp make_pair
typedef pair<int,int>pii;
typedef vector<int>vi;

#define maxn 500005
#define inf 0x3f3f3f3f

char s[maxn];
int ch[maxn][26],len[maxn],sz[maxn],fa[maxn],tot=1,lst=1;
void append(int c){
	int u=++tot,p=lst;
	sz[u]=1; len[u]=len[p]+1;
	for(;p&&!ch[p][c];p=fa[p])ch[p][c]=u;
	if(!p)fa[u]=1;
	else{
		int q=ch[p][c];
		if(len[q]==len[p]+1)fa[u]=q;
		else{
			int nq=++tot;
			len[nq]=len[p]+1; fa[nq]=fa[q];
			memcpy(ch[nq],ch[q],sizeof ch[q]);
			for(;p&&ch[p][c]==q;p=fa[p])ch[p][c]=nq;
			fa[q]=fa[u]=nq;
		}
	}lst=u;
}

int n;
int sg[maxn];
char t[maxn];
bool vs[maxn];

void dfs(int i){
	if(sg[i]!=-1) return;
	For(j,0,25) if(ch[i][j]) dfs(ch[i][j]);
	For(j,0,25) if(ch[i][j]) vs[sg[ch[i][j]]]=1;
	sg[i]=0;
	while(vs[sg[i]])++sg[i];
	For(j,0,25) if(ch[i][j]) vs[sg[ch[i][j]]]=0;
}

int b[30];
void work()
{
	if(~scanf("%s",s+1));
	else exit(0);
	n=strlen(s+1);
    For(i,1,n) b[s[i]-'a']=1;
	For(i,1,n)append(s[i]-'a');
	For(i,1,tot) sg[i]=-1;
	int res=0;

		int m=0;
		int u=1;
		dfs(u),res^=sg[u];

	if(res)puts("Alice");
	else puts("Bob");
	For(i,0,tot)memset(ch[i],0,sizeof ch[i]),len[i]=sz[i]=fa[i]=sg[i]=0; tot=lst=1;
}

signed main()
{
	int tt; cin>>tt;
	while(1)work();
	return 0;
}

提出情報

提出日時
問題 G - Substring Game
ユーザ AceTaffy_
言語 C++23 (GCC 15.2.0)
得点 600
コード長 1945 Byte
結果 AC
実行時間 96 ms
メモリ 58652 KiB

コンパイルエラー

./Main.cpp: In function 'void work()':
./Main.cpp:5:20: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
    5 | #define For(i,a,b) for(int i=(a);i<=(b);++i)
      |                    ^~~
./Main.cpp:82:9: note: in expansion of macro 'For'
   82 |         For(i,0,tot)memset(ch[i],0,sizeof ch[i]),len[i]=sz[i]=fa[i]=sg[i]=0; tot=lst=1;
      |         ^~~
./Main.cpp:82:78: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   82 |         For(i,0,tot)memset(ch[i],0,sizeof ch[i]),len[i]=sz[i]=fa[i]=sg[i]=0; tot=lst=1;
      |                                                                              ^~~
./Main.cpp:76:21: warning: unused variable 'm' [-Wunused-variable]
   76 |                 int m=0;
      |                     ^

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 600 / 600
結果
AC × 1
AC × 32
セット名 テストケース
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
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 1 ms 3720 KiB
01_small_00.txt AC 14 ms 3644 KiB
01_small_01.txt AC 19 ms 3664 KiB
01_small_02.txt AC 38 ms 3740 KiB
02_random_00.txt AC 96 ms 54204 KiB
02_random_01.txt AC 92 ms 57408 KiB
02_random_02.txt AC 91 ms 54668 KiB
02_random_03.txt AC 92 ms 57464 KiB
02_random_04.txt AC 93 ms 58652 KiB
02_random_05.txt AC 86 ms 52376 KiB
02_random_06.txt AC 84 ms 50288 KiB
02_random_07.txt AC 84 ms 48284 KiB
02_random_08.txt AC 69 ms 37444 KiB
02_random_09.txt AC 69 ms 38224 KiB
02_random_10.txt AC 71 ms 41628 KiB
02_random_11.txt AC 70 ms 38068 KiB
02_random_12.txt AC 42 ms 4048 KiB
02_random_13.txt AC 42 ms 3924 KiB
02_random_14.txt AC 42 ms 3928 KiB
02_random_15.txt AC 42 ms 3792 KiB
02_random_16.txt AC 49 ms 7432 KiB
02_random_17.txt AC 49 ms 7576 KiB
02_random_18.txt AC 48 ms 7448 KiB
02_random_19.txt AC 49 ms 7452 KiB
03_handmade_00.txt AC 33 ms 35920 KiB
03_handmade_01.txt AC 29 ms 35992 KiB
03_handmade_02.txt AC 63 ms 40912 KiB
03_handmade_03.txt AC 63 ms 38280 KiB
03_handmade_04.txt AC 1 ms 4020 KiB
03_handmade_05.txt AC 45 ms 50768 KiB
03_handmade_06.txt AC 30 ms 36032 KiB
03_handmade_07.txt AC 30 ms 36148 KiB