无锡网站seo外包,制作企业网站的版式,大鱼号自媒体平台,怎么样百度能搜到自己的网站传送门 文章目录题意#xff1a;思路#xff1a;题意#xff1a; 思路#xff1a;
一个显然的思路就是2302^{30}230枚举所有的xxx#xff0c;让后再检查#xff0c;这个复杂度显然不能接受。 又发现对于每个位置它取多少不受其他位置限制#xff0c;满足可拼接性#…传送门
文章目录题意思路题意 思路
一个显然的思路就是2302^{30}230枚举所有的xxx让后再检查这个复杂度显然不能接受。 又发现对于每个位置它取多少不受其他位置限制满足可拼接性所以我们考虑用折半搜索来搜出来前151515位的所有情况让后再枚举后151515位的所有情况让后从另一半取出来需要的信息即可。 实现还是比较有技巧的前151515位搜出来的情况可以用mapmapmap存一下让后后151515位搜出来之后我们可以枚举它的总长度让后就可以算出来还需要多少查询是否在mapmapmap中有即可。 当然我们也可以省去枚举长度的一部分只需要将我们的前151515位的数组都减去一个公共长度后151515位的数组用最长长度减去原本长度就是我们需要的长度了说的可能不清楚具体细节看代码吧跑的倒是蛮快的。
// Problem: F. Make Them Similar
// Contest: Codeforces - Educational Codeforces Round 76 (Rated for Div. 2)
// URL: https://codeforces.com/contest/1257/problem/F
// Memory Limit: 1024 MB
// Time Limit: 4000 ms
//
// Powered by CP Editor (https://cpeditor.org)//#pragma GCC optimize(Ofast,no-stack-protector,unroll-loops,fast-math)
//#pragma GCC target(sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tunenative)
//#pragma GCC optimize(2)
#includecstdio
#includeiostream
#includestring
#includecstring
#includemap
#includecmath
#includecctype
#includevector
#includeset
#includequeue
#includealgorithm
#includesstream
#includectime
#includecstdlib
#includerandom
#includecassert
#define X first
#define Y second
#define L (u1)
#define R (u1|1)
#define pb push_back
#define mk make_pair
#define Mid ((tr[u].ltr[u].r)1)
#define Len(u) (tr[u].r-tr[u].l1)
#define random(a,b) ((a)rand()%((b)-(a)1))
#define db puts(---)
using namespace std;//void rd_cre() { freopen(d://dp//data.txt,w,stdout); srand(time(NULL)); }
//void rd_ac() { freopen(d://dp//data.txt,r,stdin); freopen(d://dp//AC.txt,w,stdout); }
//void rd_wa() { freopen(d://dp//data.txt,r,stdin); freopen(d://dp//WA.txt,w,stdout); }typedef long long LL;
typedef unsigned long long ULL;
typedef pairint,int PII;const int N1000010,mod1e97,INF0x3f3f3f3f;
const double eps1e-6;int n;
int a[N];
mapvectorint,intmp;
vectorintv;
int ans-1;void dfs1(int u,int sum) {if(u15) {v.clear();int miINF;for(int i1;in;i) {int nowa[i]((115)-1);now^sum;v.pb(__builtin_popcount(now));mimin(mi,__builtin_popcount(now));}for(auto x:v) x-mi;mp[v]sum;return;}dfs1(u1,sum(1u));dfs1(u1,sum);
}void dfs2(int u,int sum) {//coutsumendl;if(ans!-1) return;if(u30) {v.clear();int mx0;for(int i1;in;i) {int nowa[i]1515;now^sum;v.pb(__builtin_popcount(now));mxmax(mx,__builtin_popcount(now));}for(auto x:v) xmx-x;if(mp.count(v)) {ansmp[v]sum;}return;}dfs2(u1,sum(1u));dfs2(u1,sum);
}int main()
{
// ios::sync_with_stdio(false);
// cin.tie(0);scanf(%d,n);for(int i1;in;i) scanf(%d,a[i]);dfs1(0,0); dfs2(15,0);coutansendl;return 0;
}
/**/