| 比赛 |
2025.12.6 |
评测结果 |
AEAAEEEEEEEEETTTEEEE |
| 题目名称 |
填数游戏 |
最终得分 |
15 |
| 用户昵称 |
梦那边的没好TM |
运行时间 |
5.298 s |
| 代码语言 |
C++ |
内存使用 |
3.51 MiB |
| 提交时间 |
2025-12-06 11:32:20 |
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define cpy(a,b) copy(begin(a),end(a),begin(b))
#define ld long double
#define dot(x) fixed<<setprecision(x)
#define foru(a,b,c) for(ll a=b;a<=c;a++)
ll n,m,a[15][15],ans;
struct p{
string w,s;
};
vector<p>path;
void pa(ll r,ll c,string w,string s){
s+=to_string(a[r][c]);
if(r==n-1&&c==m-1){
path.push_back({w,s});
return;
}
if(c+1<m)pa(r,c+1,w+"R",s);
if(r+1<n)pa(r+1,c,w+"D",s);
}
bool cmp(p a,p b){
return a.w<b.w;
}
bool check(){
path.clear();
pa(0,0,"","");
sort(path.begin(),path.end(),cmp);
foru(i,0,path.size()-2){
if(path[i].s<path[i+1].s)return 0;
}
return 1;
}
void dfs(ll r,ll c){
if(r==n) {
if(check())ans++;
return;
}
ll nr=r,nc=c+1;
if(nc==m){
nr=r+1;
nc=0;
}
a[r][c]=0;
dfs(nr,nc);
a[r][c]=1;
dfs(nr, nc);
}
int main(){
freopen("game.in" ,"r",stdin );
freopen("game.out","w",stdout);
ios::sync_with_stdio(false);
cin.tie(NULL);cout.tie(NULL);
cin>>n>>m;
dfs(0,0);
cout<<ans;
return 0;
}