跳到正文

闲话

白总请看

destroying约 2 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2026年4月3日
篇幅
约 2 分钟

版本

  1. v1当前
C++
#include<bits/stdc++.h>
using namespace std;
int n,t,k,tx[2]={0,1},ty[2]={1,0},a;
char c[52][52]={};
void dfs(int x,int y,int t,int f){
	if(x==n&&y==n){
		a++;
		return ;
	}
	if(c[x+tx[f]][y+ty[f]]=='.') dfs(x+tx[f],y+ty[f],t,f);
	if(c[x+tx[(f+1)&1]][y+ty[(f+1)&1]]=='.'&&t!=k&&!(x==1&&y==1)) dfs(x+tx[(f+1)&1],y+ty[(f+1)&1],t+1,(f+1)&1);
	return ;
}
signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
	cin>>t;
	while(t--){
        cin>>n>>k;
		for(register long long i=1;i<=n+1;i++){
			for(register long long j=1;j<=n+1;j++){
				c[i][j]=' ';
			}
		}
		for(register long long i=1;i<=n;i++){
			for(register long long j=1;j<=n;j++){
				cin>>c[i][j];
			}
		}
		a=0;
		dfs(1,1,0,0);
		dfs(1,1,0,1);
        cout<<a<<"\n";
	}
    return 0;
}
原文