求求你们了40分找不出问题
查看原帖
求求你们了40分找不出问题
1121011
lifeiyang1楼主2025/1/7 19:33
#include <bits/stdc++.h>
using namespace std;
#define int long long
int n;
const int mod = 1e8 + 7;
struct jg {
    int x, y, id;
} a[25];
int dp[1118580][22];
int cnt[25][25];
bool b[26];
signed main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%d %d", &a[i].x, &a[i].y);
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            for (int p = 1; p <= n; p++) {
                if (p != i && p != j && i != j &&
                    ((a[i].x <= a[p].x && a[p].x <= a[j].x) || (a[j].x <= a[p].x && a[p].x <= a[i].x)) &&
                    ((a[i].y <= a[p].y && a[p].y <= a[j].y) || (a[j].y <= a[p].y && a[p].y <= a[i].y))) {
                    if (abs(a[i].x - a[p].x) * abs((a[j].y - a[i].y)) ==
                        abs(a[i].y - a[p].y) * abs((a[i].x - a[j].x))) {
                        cnt[i][j] = (cnt[i][j] | (1 << (p - 1)));
                        cnt[j][i] = cnt[i][j];
                    }
                }
            }
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) dp[1 << (i - 1)][i] = 1;
    for (int s = 1; s <= (1 << n); s++) {
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n; j++) {
                if (i == j)
                    continue;
                if (!((cnt[i][j] & s) != cnt[i][j])) {
                    if (((1 << (i - 1)) & s) == 0)
                        continue;
                    if (((1 << (j - 1)) & s) != 0)
                        continue;
                    // cout<<s<<' '<<i<<' '<<j<<'\n';
                    dp[s | (1 << (j - 1))][j] += dp[s][i] ;
                    dp[s | (1 << (j - 1))][j] = dp[s | (1 << (j - 1))][j]%mod;
                    if (__popcount(s) >=3) {
                        ans += dp[s][i];
                        ans = ans%mod;
						//if(ans>14411692216694830)cout<<"no";
                    }
                }
            }
        }
    }
    // cout<<dp[1][1]<<"ererer"<<dp[1][2]<<"hyvghgv";
    cout << ans%mod;
    return 0;
}
2025/1/7 19:33
加载中...