正文
增加 6 行删除 6 行
52 行未改动53545556575859606145 行未改动10710810911011111211311411530 行未改动1461471481491501511521531544 行未改动15916016116216316416516616716816917017117217317417517617717852 行未改动时间复杂度 $O(n)$。很强的题。放签到还是太前卫了。::::info[code]```cpp#include <bits/stdc++.h>using namespace std;45 行未改动pos1 = unique (numx + 1, numx + n + 1) - numx - 1;pos2 = unique (numy + 1, numy + n + 1) - numy - 1;for (int i = 1; i <= n; i++) {x[i] = lower_bound (numx + 1, numx + pos1 + 1, x[i]) - numx;y[i] = lower_bound (numy + 1, numy + pos2 + 1, y[i]) - numy;addEdge (x[i], y[i] + pos1);addEdge (y[i] + pos1, x[i]);}for (int i = 1; i <= pos1 + pos2; i++) {30 行未改动struct Node {int a, b;bool operator < (const Node &x) const {return a < x.a;}}arr[25];int main () {freopen ("inv.in", "r", stdin);4 行未改动for (int i = 1; i <= n; i++)scanf ("%d", &arr[i].b);sort (arr + 1, arr + n + 1);for (int i = 1; i <= n; i++) b[i] = arr[i].b;for (int i = 1; i <= n; i++)for (int j = 1; j < i; j++)if (b[j] < b[i])L[i] |= (1 << (j - 1));dp[0] = 1;for (int s = 0; s < (1 << n); s++) {for (int t = 1; t <= n; t++) {if ((s >> (t - 1)) & 1) continue ;if ((L[t] | s) == s) dp[s ^ (1 << (t - 1))] += dp[s];}}printf ("%lld", dp[(1 << n) - 1]);}```::::52 行未改动53545556575859606145 行未改动10710810911011111211311411530 行未改动1461471481491501511521531544 行未改动15916016116216316416516616716816917017117217317417517617717852 行未改动时间复杂度 $O(n)$。很强的题。放签到还是太前卫了。::::info[code]```cpp#include <bits/stdc++.h>using namespace std;45 行未改动pos1 = unique (numx + 1, numx + n + 1) - numx - 1;pos2 = unique (numy + 1, numy + n + 1) - numy - 1;for (int i = 1; i <= n; i++) {x[i] = lower_bound (numx + 1, numx + pos1 + 1, x[i]) - numx;y[i] = lower_bound (numy + 1, numy + pos2 + 1, y[i]) - numy;addEdge (x[i], y[i] + pos1);addEdge (y[i] + pos1, x[i]);}for (int i = 1; i <= pos1 + pos2; i++) {30 行未改动struct Node {int a, b;bool operator < (const Node &x) const {return a < x.a;}}arr[25];int main () {freopen ("inv.in", "r", stdin);4 行未改动for (int i = 1; i <= n; i++)scanf ("%d", &arr[i].b);sort (arr + 1, arr + n + 1);for (int i = 1; i <= n; i++) b[i] = arr[i].b;for (int i = 1; i <= n; i++)for (int j = 1; j < i; j++)if (b[j] < b[i])L[i] |= (1 << (j - 1));dp[0] = 1;for (int s = 0; s < (1 << n); s++) {for (int t = 1; t <= n; t++) {if ((s >> (t - 1)) & 1) continue ;if ((L[t] | s) == s) dp[s ^ (1 << (t - 1))] += dp[s];}}printf ("%lld", dp[(1 << n) - 1]);}```::::