为什么会RE!!!
查看原帖
为什么会RE!!!
1368093
J_y_AC_t_k楼主2024/6/19 21:02

rt,代码莫名RE了qql。

只RE了#4一个点

题目:P8658

Code:

#include<bits/stdc++.h>
using namespace std;
inline int read(){
	int rt=0;	char g=getchar();
	while(g<'0'||g>'9')	g=getchar();
	while(g>='0'&&g<='9')	rt=(rt<<3)+(rt<<1)+g-'0',g=getchar();
	return rt;
}
int T,len;
char c[25];
string s;
map<string,int>mp[21];

bool win(string c)
{
	bool kk=0;
	for(int i=1;i<len-1&&!kk;i++)
		kk|=(c[i-1]=='L'&&c[i]=='O'&&c[i+1]=='L');
	return kk;
}
inline int dg(string now)
{
	if(mp[len][now])	return mp[len][now];
	if(win(now))	return mp[len][now]=1;
	
	int kk=1,ls;
	bool kkk=0;
	for(int i=0;i<len;i++)
	{
		if(now[i]=='*')
		{
			kkk=1;
			
			now[i]='L';	ls=dg(now);
			if(ls==1){kk=3;now[i]='*';break;}
			else if(ls==2)	kk=2;
			
			now[i]='O';	ls=dg(now);
			if(ls==1){kk=3;now[i]='*';break;}
			else if(ls==2)	kk=2;
			
			now[i]='*';
		}
	}
	
	if(kkk)	return mp[len][now]=kk;
	else	return mp[len][now]=2;
}
int main()
{
	T=read();
	while(T--)
	{
		scanf("%s",&c);s=c;len=s.length();
		if(len<=2){puts("0");continue;}
		dg(s);
		printf("%d\n",mp[len][s]-2);
	}
	return 0;
}
2024/6/19 21:02
加载中...