| 比赛 |
26暑假集训模拟赛2 |
评测结果 |
AATTTTTTTT |
| 题目名称 |
and I am home |
最终得分 |
20 |
| 用户昵称 |
杨蕙宇 |
运行时间 |
16.832 s |
| 代码语言 |
C++ |
内存使用 |
3.50 MiB |
| 提交时间 |
2026-07-02 12:01:57 |
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=998244353;
const int N=5e3+10;
typedef pair<ll,ll>PII;
set<PII>st;
ll n,mk[N][N],xy[4][2]={{-1,0},{1,0},{0,-1},{0,1}},ans;
void dfs(ll x,ll y,ll s){
if(s==n){
ans=(ans+st.size())%mod;
return;
}
for(int i=0;i<4;i++){
int xx=x+xy[i][0];
int yy=y+xy[i][1];
bool f=st.insert({xx,yy}).second;
dfs(xx,yy,s+1);
if(f)st.erase({xx,yy});
}
}
int main(){
freopen("home.in","r",stdin);
freopen("home.out","w",stdout);
cin>>n;
st.insert({0,0});
dfs(0,0,0);
cout<<ans;
return 0;
}