E - Red Polyomino
暴力,对于状态的记录考虑下面用set<vector<string>> mp
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template <class T=int> T rd()
{T res=0;T fg=1;char ch=getchar();while(!isdigit(ch)) {if(ch=='-') fg=-1;ch=getchar();}while( isdigit(ch)) res=(res<<1)+(res<<3)+(ch^48),ch=getchar();return res*fg;
}
const int N=200010,mod=1e9+7;vector<string> s;
int n;ll m;
ll ans;
int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
set<vector<string>> mp;
void dfs(int num)
{if(mp.count(s)) return;mp.insert(s);if(!num) return ans++,void();for(int i=0;i<n;i++)for(int j=0;j<n;j++){if(s[i][j]!='.') continue;for(int k=0;k<4;k++){int x=i+dx[k],y=j+dy[k];if(x<0||y<0||x>=n||y>=n||s[x][y]!='@') continue;s[i][j]='@';dfs(num-1);s[i][j]='.';}}
}
int main()
{cin>>n>>m;s.resize(n);for(int i=0;i<n;i++) cin>>s[i];for(int i=0;i<n;i++)for(int j=0;j<n;j++)if(s[i][j]=='.') {s[i][j]='@';dfs(m-1);s[i][j]='.';}cout<<ans<<'\n';return 0;
}