众筹网站的分析与设计,手机h5建站,德文网站建设,wordpress 后台 500传送门 文章目录题意#xff1a;思路#xff1a;题意#xff1a; 思路#xff1a;
找规律yydsyydsyyds。 一看没什么想法#xff0c;所以打了个表#xff0c;好家伙#xff0c;不打不知道#xff0c;一打不得了#xff0c;下面是n6n6n6的符合要求的情况#xff1a; …传送门
文章目录题意思路题意 思路
找规律yydsyydsyyds。 一看没什么想法所以打了个表好家伙不打不知道一打不得了下面是n6n6n6的符合要求的情况 不难发现他符合条件的个数为2n−12^{n-1}2n−1个并且很有规律以某个数开头的个数分别为1,20,21,22,...,2n−21,2^0,2^1,2^2,...,2^{n-2}1,20,21,22,...,2n−2并且加入这个数之后小于他的数也都跟在后面了之后又是上面那种情况类似于递归。 比如333开头的我们通过不断k−2xk-2^xk−2x最终确定在以333开头的块内让后把3213 \ \ 2 \ \ 13 2 1放入答案之后发现又在444的块内让后将43214\ \ 3 \ \ 2 \ \ 14 3 2 1加入答案由于3213 \ \ 2 \ \ 13 2 1之前加入了所以加入444即可一直这样递归确定块即可。 由于nnn很大我们不能算出来2n2^n2n所以让他等于一个大于kkk的数即可。
附赠打标程序。
// Problem: B. Almost Sorted
// Contest: Codeforces - Codeforces Round #715 (Div. 1)
// URL: https://codeforces.com/problemset/problem/1508/B
// Memory Limit: 256 MB
// Time Limit: 2000 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
#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].r1)
#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; LL k;
int a[N];
LL b[N],inf;
bool st[N];
vectorpairLL,intv;
vectorintans;bool check() {for(int i1;i6;i) if(a[i1]a[i]-1) return false;return true;
}LL qmi(LL a,LL b) {LL ans1;while(b) {if(b1) ansans*a;aa*a;b1;}return ans;
}void solve() {for(int i1;in;i) {if(in) b[i]1;else {int nown-i-1;if(now62) b[i]inf;else b[i]qmi(2ll,now);}}for(int i1;in;i) {if(kb[i]) {k-b[i];}else {for(int ji;j1!st[j];j--) ans.pb(j),st[j]1;}}for(auto x:ans) printf(%d ,x); puts();
}int main()
{
// ios::sync_with_stdio(false);
// cin.tie(0);/*for(int i1;i6;i) a[i]i;do {if(check()) {for(int i1;i6;i) printf(%d ,a[i]);puts();}}while(next_permutation(a1,a16));*/infqmi(2ll,62);int _; scanf(%d,_);while(_--) {scanf(%d%lld,n,k);ans.clear();for(int i1;in;i) st[i]0;if(n1) {if(k!1) puts(-1);else printf(1\n);continue;}if(n-262) solve();else {LL nowqmi(2ll,n-1);if(know) puts(-1);else solve();}}return 0;
}
/**/