题目链接
https://www.acwing.com/problem/content/description/844/
思路回溯搜索即可
代码#include
using namespace std;
//----------------自定义部分----------------
#define ll long long
#define mod 1000000007
#define endl "\n"
#define PII pair
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
ll ksm(ll a,ll b) {
ll ans = 1;
for(;b;b>>=1LL) {
if(b & 1) ans = ans * a % mod;
a = a * a % mod;
}
return ans;
}
ll lowbit(ll x){return -x & x;}
const int N = 2e6+10;
//----------------自定义部分----------------
int n,m,q,a[N];
bool vis[N];
void dfs(vector v){
if(v.size() == n){
for(int i = 0;i
关注
打赏