版本比较
2tu1かわいい
正文
增加 18 行删除 18 行
24 行未改动252627282930313233347 行未改动42434445464748495051525354555657585960616263646566676869707172737415 行未改动90919293949596979816 行未改动1151161171181191201211221231241251261271281291301311321331341351361371381391408 行未改动1491501511521531541551561571581591601611621631641651661671681691708 行未改动17918018118218318418518624 行未改动```cpp/*考虑一个问题的归约。由于 n >= 3,我们先来看一下 n >= 3 的答案。搞了 30min。。。等一下,也就是说我还要把 n <= 4 的情况全部打出来表。。。*/#include "bits/stdc++.h"using namespace std;#define ll long long7 行未改动};vector<Node> Psy[15];inline void pt(int x,int y){printf("%d to %d\n",x,y);}void work(int N,int ad){int L = ad + 1 , R = ad + 2 * N;//[1,2n]if(N <= 7){if(N <= 4) for(int i = 0 ; i < Psy[N].size() ; i ++) printf("%d to %d\n",Psy[N][i].x + ad,Psy[N][i].y + ad);else{if(N == 5){pt(R - 2 , L - 2);pt(L + 2 , R - 2);pt(R - 4 , L + 2);pt(L - 1 , R - 4);pt(R - 1 , L - 1);}if(N == 6){pt(R - 2 , L - 2);pt(R - 5 , R - 2);pt(L + 1 , R - 5);pt(R - 6 , L + 1);pt(L - 1 , R - 6);pt(R - 1 , L - 1);}if(N == 7){pt(R - 6 , L - 2);pt(L + 4 , R - 6);pt(R - 2 , L + 4);15 行未改动map<ll,ll> dp,pre[3];//B:1,A:2int now[Len];bool check(){for(int i = 1 ; i <= 4 * n ; i ++){if(now[i] == 0) continue;if(now[i]){16 行未改动ll Now = ds();bk(Now);if(as > dp[Now]) return;dp[Now] = as;//if(as == 3){printf("%d %lld\n",as,Now);Out();}if(check()){if(as == 5) flaw = 1;return;}for(int i = 1 ; i < (4 * n) ; i ++){if(now[i] && now[i + 1]){for(int j = 1 ; j < (4 * n) ; j ++){if(!now[j] && !now[j + 1]){int a = now[i] , b = now[i + 1];now[i] = now[i + 1] = 0;now[j] = a , now[j + 1] = b;ll to = ds();bk(to);if(dp[to] > as + 1){pre[0][to] = Now , pre[1][to] = i - 2 * n , pre[2][to] = j - 2 * n;dfs(as + 1);}8 行未改动void Output(ll rec){if(rec == bg) return;Output(pre[0][rec]);printf("Psy[5].push_back(Node(%lld, %lld));\n",pre[1][rec],pre[2][rec]);}int main(){/*n = 5;int op = 1;for(int i = 2 * n + 1 ; i <= 4 * n ; i ++) now[i] = op , op = 3 - op;bg = ds();dfs(0);const int LEN = 2 * n;ll as = 114,ass = 0;for(int i = 2 * n ; i <= 4 * n ; i ++){ll rs = 0;int l = i - LEN + 1;ll ml = 1;for(int j = 1 ; j < l ; j ++) ml *= 3;for(int j = l ; j <= l + n - 1 ; j ++){rs += 2 * ml;ml *= 3;}8 行未改动Psy[4].push_back(Node(3, 6));Psy[4].push_back(Node(0, 3));Psy[4].push_back(Node(7, 0));scanf("%d",&n);work(n , 0);return 0;}```24 行未改动252627282930313233347 行未改动42434445464748495051525354555657585960616263646566676869707172737415 行未改动90919293949596979816 行未改动1151161171181191201211221231241251261271281291301311321331341351361371381391408 行未改动1491501511521531541551561571581591601611621631641651661671681691708 行未改动17918018118218318418518624 行未改动```cpp/*考虑一个问题的归约。由于 n >= 3,我们先来看一下 n >= 3 的答案。搞了 30min。。。等一下,也就是说我还要把 n <= 4 的情况全部打出来表。。。*/#include "bits/stdc++.h"using namespace std;#define ll long long7 行未改动};vector<Node> Psy[15];inline void pt(int x,int y){printf("%d to %d\n",x,y);}void work(int N,int ad){int L = ad + 1 , R = ad + 2 * N;//[1,2n]if(N <= 7){if(N <= 4) for(int i = 0 ; i < Psy[N].size() ; i ++) printf("%d to %d\n",Psy[N][i].x + ad,Psy[N][i].y + ad);else{if(N == 5){pt(R - 2 , L - 2);pt(L + 2 , R - 2);pt(R - 4 , L + 2);pt(L - 1 , R - 4);pt(R - 1 , L - 1);}if(N == 6){pt(R - 2 , L - 2);pt(R - 5 , R - 2);pt(L + 1 , R - 5);pt(R - 6 , L + 1);pt(L - 1 , R - 6);pt(R - 1 , L - 1);}if(N == 7){pt(R - 6 , L - 2);pt(L + 4 , R - 6);pt(R - 2 , L + 4);15 行未改动map<ll,ll> dp,pre[3];//B:1,A:2int now[Len];bool check(){for(int i = 1 ; i <= 4 * n ; i ++){if(now[i] == 0) continue;if(now[i]){16 行未改动ll Now = ds();bk(Now);if(as > dp[Now]) return;dp[Now] = as;//if(as == 3){printf("%d %lld\n",as,Now);Out();}if(check()){if(as == 5) flaw = 1;return;}for(int i = 1 ; i < (4 * n) ; i ++){if(now[i] && now[i + 1]){for(int j = 1 ; j < (4 * n) ; j ++){if(!now[j] && !now[j + 1]){int a = now[i] , b = now[i + 1];now[i] = now[i + 1] = 0;now[j] = a , now[j + 1] = b;ll to = ds();bk(to);if(dp[to] > as + 1){pre[0][to] = Now , pre[1][to] = i - 2 * n , pre[2][to] = j - 2 * n;dfs(as + 1);}8 行未改动void Output(ll rec){if(rec == bg) return;Output(pre[0][rec]);printf("Psy[5].push_back(Node(%lld, %lld));\n",pre[1][rec],pre[2][rec]);}int main(){/*n = 5;int op = 1;for(int i = 2 * n + 1 ; i <= 4 * n ; i ++) now[i] = op , op = 3 - op;bg = ds();dfs(0);const int LEN = 2 * n;ll as = 114,ass = 0;for(int i = 2 * n ; i <= 4 * n ; i ++){ll rs = 0;int l = i - LEN + 1;ll ml = 1;for(int j = 1 ; j < l ; j ++) ml *= 3;for(int j = l ; j <= l + n - 1 ; j ++){rs += 2 * ml;ml *= 3;}8 行未改动Psy[4].push_back(Node(3, 6));Psy[4].push_back(Node(0, 3));Psy[4].push_back(Node(7, 0));scanf("%d",&n);work(n , 0);return 0;}```