比赛 期末考试0 评测结果 WWWAWWWWWW
题目名称 Sayaku,移动 最终得分 10
用户昵称 2_16鸡扒拌面 运行时间 0.028 s
代码语言 C++ 内存使用 3.66 MiB
提交时间 2026-02-07 10:39:45
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;

int n,a[2005],cnt=0;
string s;
bool b=1;
struct tree {
	int p,lc,rc;
	bool ilc,irc;
} t[2005];
int rear=-1;

void DFS(int x) {
	rear++;
	if(x!=rear) b=0;
	//cout<<a[x]<<" "<<x<<" "<<rear<<endl;
	if(a[x]==0)
	{
	    t[x].lc=-1;
	    t[x].rc=-1;
	    return;
	}
	if(a[x]==1)
	{
	    t[x].lc=x+1;
	    t[x].rc=-1;
	    t[x+1].p=x;
	    DFS(x+1);
	}
	if(a[x]==2)
	{
	    t[x].rc=x+1;
	    t[x].lc=-1;
	    t[x+1].p=x;
	    DFS(x+1);
	}
	if(a[x]==3)
	{
	    t[x].lc=x+1;
	    t[x+1].p=x;
	    DFS(x+1);
	    t[x].rc=rear+1;
	    t[rear+1].p=x;
	    DFS(rear+1);
	}
}

int main() {
    freopen("movement.in","r",stdin);
    freopen("movement.out","w",stdout);
	cin>>s;
	n=s.size();
	for(int i=0; i<n; ++i) a[i]=s[i]-'0';
	DFS(0);
	/*if(b) {
		cout<<n;
		return 0;
	}*/
	cout<<n;
	return 0;
}