RT
40分TLE,```cpp
#include<bits/stdc++.h>
using namespace std;
int ans=0,n,m,a[100001];
struct node
{
int x,step;
node(int xx,int dep)
{
x=xx;
step=dep;
}
node()
{
}
};
queue q;
void bfs(int s)
{
q.push(node(s,0));
while(!q.empty())
{
node now=q.front();
q.pop();
if(now.step==m)
{
if(now.x==1)
{
ans++;
}
continue;
}
if(now.x+1<=n&&now.x-1>=1)
{
q.push(node(now.x+1,now.step+1));
q.push(node(now.x-1,now.step+1));
}
else if(now.x+1<=n&&now.x-1<1)
{
q.push(node(now.x+1,now.step+1));
q.push(node(n,now.step+1));
}
else if(now.x+1>n&&now.x-1>=1)
{
q.push(node(1,now.step+1));
q.push(node(now.x-1,now.step+1));
}
else
{
q.push(node(1,now.step+1));
q.push(node(n,now.step+1));
}
}
}
int main()
{
scanf("%d %d",&n,&m);
bfs(1);
printf("%d\n",ans);
}