QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#407759#4252. Permutationzhaohaikun#71.630769 809ms4636kbC++202.7kb2024-05-09 10:44:562024-05-09 10:44:57

Judging History

你现在查看的是最新测评结果

  • [2024-05-09 10:44:57]
  • 评测
  • 测评结果:71.630769
  • 用时:809ms
  • 内存:4636kb
  • [2024-05-09 10:44:56]
  • 提交

answer

#pragma GCC optimize(2)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline","fast-math","unroll-loops","no-stack-protector")
#pragma GCC diagnostic error "-fwhole-program"
#pragma GCC diagnostic error "-fcse-skip-blocks"
#pragma GCC diagnostic error "-funsafe-loop-optimizations"
#include "perm.h"
// MagicDark
#include <bits/stdc++.h>
#define debug cerr << "\033[32m[" << __LINE__ << "]\033[0m "
#define SZ(x) ((int) x.size() - 1)
#define all(x) x.begin(), x.end()
#define ms(x, y) memset(x, y, sizeof x)
#define F(i, x, y) for (int i = (x); i <= (y); i++)
#define DF(i, x, y) for (int i = (x); i >= (y); i--)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template <typename T> T& chkmax(T& x, T y) {return x = max(x, y);}
template <typename T> T& chkmin(T& x, T y) {return x = min(x, y);}
template <typename T> T& read(T &x) {
	x = 0; int f = 1; char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
	return x *= f;
}
mt19937 mrand(chrono::steady_clock::now().time_since_epoch().count());
inline int rnd(int l, int r) {return mrand() % (r - l + 1) + l;}
int cc(ll n) {
	int ans = 0;
	DF(i, 60, 1) {
		ll w = (1ll << i) - 1;
		while (n >= w) {
			ans += i;
			n -= w;
		}
	}
	return ans;
}
vector <int> solve(ll n) {
	vector <int> ans;
	DF(i, 60, 1) {
		ll w = (1ll << i) - 1;
		while (n >= w) {
			for (int& j: ans) j += i;
			F(j, 1, i) ans.push_back(j - 1);
			n -= w;
		}
	}
	return ans;
}
int dp[1010], t[1010], len;
void modify(int x, int y) {
	x++;
	for (; x <= len; x += x & -x) t[x] += y;
}
int query(int x) {
	int s = 0;
	for (; x; x ^= x & -x) s += t[x];
	return s;
}
int calc(vector <int> x) {
	len = x.size();
	F(i, 1, len) t[i] = 0;
	int s = 0;
	F(i, 0, SZ(x)) {
		dp[i] = 1 + query(x[i]);
		// F(j, 0, i - 1) {
		// 	if (x[j] < x[i]) {
		// 		dp[i] += dp[j];
		// 	}
		// }
		s += dp[i];
		modify(x[i], dp[i]);
	}
	return s;
}
std::vector<int> construct_permutation(long long n) {
	n--;
	vector <int> ans;
	// if (n <= 90) {
	// 	F(i, 1, n) ans.push_back(n - i);
	// 	return ans;
	// }
	ans = solve(n);
	int lim = 1;
	F(i, 1, 20) {
		vector <int> t(i);
		F(j, 1, i) t[j - 1] = j - 1;
		lim = min(2000, lim * i);
		// do {
		F(j, 1, lim) {
			shuffle(all(t), mrand);
			int v = calc(t);
			// debug << v << endl;
			if (n >= v) {
				// vector <int> w = cc(n - v);
				if (cc(n - v) + i < ans.size()) {
					vector <int> w = solve(n - v);
					ans.clear();
					for (int j: t) ans.push_back(j + w.size());
					for (int j: w) ans.push_back(j);
				}
			}
		}
		// } while (next_permutation(all(t)));
	}
	return ans;
}

详细

Subtask #1:

score: 10
Accepted

Test #1:

score: 10
Accepted
time: 507ms
memory: 4036kb

input:

a92b3f80-b312-8377-273c-3916024d7f2a
89
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90

output:

6cad0f33-b1bd-3a3e-1a8d-c4af23adfcbf
OK
1
0
2
1 0
2
0 1
3
1 2 0
3
0 2 1
4
2 3 0 1
3
0 1 2
4
1 2 3 0
4
2 0 1 3
5
2 3 4 0 1
4
0 1 3 2
5
1 3 2 4 0
5
2 1 3 0 4
5
1 2 0 4 3
4
0 1 2 3
5
1 2 3 4 0
5
0 2 3 4 1
6
2 3 4 5 0 1
5
1 2 0 3 4
6
1 2 4 5 3 0
6
0 2 5 1 4 3
6
3 0 1 5 2 4
5
0 1 2 4 3
6
1 2 3 5 4 0
6
0 ...

result:

ok 

Subtask #2:

score: 61.6308
Acceptable Answer

Test #2:

score: 90
Accepted
time: 785ms
memory: 4064kb

input:

a92b3f80-b312-8377-273c-3916024d7f2a
100
39993
85709
48645
25391
15360
54084
28947
18808
86735
316
14357
82845
96210
16242
58466
43439
77462
70742
76176
20397
30314
22634
29622
81835
31904
81283
37072
36527
26764
55878
72762
5262
34915
63468
20595
66579
77373
36670
89340
83384
73268
31960
67318
3908...

output:

6cad0f33-b1bd-3a3e-1a8d-c4af23adfcbf
OK
51
43 32 35 36 37 41 40 34 42 33 45 50 38 46 44 48 49 47 39 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 5 6 7 8 9 10 11 12 13 14 15 16 2 3 4 0 1
61
44 43 48 49 45 58 51 46 59 50 54 55 57 42 56 47 53 60 52 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 12 13 ...

result:

ok 

Test #3:

score: 75.8615
Acceptable Answer
time: 680ms
memory: 4084kb

input:

a92b3f80-b312-8377-273c-3916024d7f2a
100
2147483647
1073741823
536870911
268435455
134217727
67108863
33554431
16777215
8388607
4194303
2097151
1582
24319
38
463
7
1073741503
3
18
3
3780
2
24934
124910
65535
154
1069539071
209452285
1662
3
3
93
4070
131071
502986749
3164
268430159
247
21746
124927
1...

output:

6cad0f33-b1bd-3a3e-1a8d-c4af23adfcbf
OK
60
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
58
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 ...

result:

points 0.84290598290

Test #4:

score: 61.6308
Acceptable Answer
time: 729ms
memory: 4252kb

input:

a92b3f80-b312-8377-273c-3916024d7f2a
100
576460752303423487
288230376151711743
144115188075855871
72057594037927935
36028797018963967
18014398509481983
9007199254740991
4503599627370495
2251799813685247
1125899906842623
562949953421311
8166608599550
16508780543
33554427
43000192155799
62353919
71773...

output:

6cad0f33-b1bd-3a3e-1a8d-c4af23adfcbf
OK
116
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 2...

result:

points 0.68478632480

Test #5:

score: 73.5385
Acceptable Answer
time: 759ms
memory: 4152kb

input:

a92b3f80-b312-8377-273c-3916024d7f2a
100
336455856505
197522918480
260689715591
857530435844
89809708292
207893569808
702779448503
917149928374
643600357316
927175148543
51879726697
974331197849
721971572596
902469653832
936157710917
714588060426
276939435899
393954173900
692525720126
762289367234
1...

output:

6cad0f33-b1bd-3a3e-1a8d-c4af23adfcbf
OK
374
363 364 368 370 365 367 369 371 372 373 366 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 ...

result:

points 0.81709401710

Test #6:

score: 69.4923
Acceptable Answer
time: 788ms
memory: 4092kb

input:

a92b3f80-b312-8377-273c-3916024d7f2a
100
330061280882697
570108406837011
246465711199350
844437948491708
542197441405836
481743322695013
913237337833838
634038564781156
969749245791701
445335878892049
722391184659757
25600568975288
304176471716316
934030664268458
770565383569314
38589802113902
56387...

output:

6cad0f33-b1bd-3a3e-1a8d-c4af23adfcbf
OK
458
453 454 456 455 457 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 360 361 362 363 364 365 366 367 368 369 370 ...

result:

points 0.77213675210

Test #7:

score: 64.1231
Acceptable Answer
time: 793ms
memory: 4216kb

input:

a92b3f80-b312-8377-273c-3916024d7f2a
100
9808783958425241
800256975993528789
891794666437715812
154809014071580277
262143300778136084
508038278751820218
855062810898478629
196129157832150290
519747744582635554
544132224659269080
335568667826635843
978219202156109836
887928188166976766
57068450616591...

output:

6cad0f33-b1bd-3a3e-1a8d-c4af23adfcbf
OK
660
643 647 644 648 649 657 640 651 654 645 641 646 642 653 650 652 658 655 656 659 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 ...

result:

points 0.71247863250

Test #8:

score: 90
Accepted
time: 753ms
memory: 3848kb

input:

a92b3f80-b312-8377-273c-3916024d7f2a
100
576460752303423488
576460752303423489
576460752303423490
576460752303423491
576460752303423492
576460752303423493
576460752303423494
576460752303423495
576460752303423496
576460752303423497
576460752303423498
576460752303423499
576460752303423500
576460752303...

output:

6cad0f33-b1bd-3a3e-1a8d-c4af23adfcbf
OK
59
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
60
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 ...

result:

ok 

Test #9:

score: 65.9846
Acceptable Answer
time: 786ms
memory: 4636kb

input:

a92b3f80-b312-8377-273c-3916024d7f2a
100
999999999999999901
999999999999999902
999999999999999903
999999999999999904
999999999999999905
999999999999999906
999999999999999907
999999999999999908
999999999999999909
999999999999999910
999999999999999911
999999999999999912
999999999999999913
999999999999...

output:

6cad0f33-b1bd-3a3e-1a8d-c4af23adfcbf
OK
1021
1004 1019 1018 1003 1005 1007 1011 1006 1010 1008 1012 1013 1009 1014 1016 1017 1015 1020 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 9...

result:

points 0.73316239320

Test #10:

score: 64.1385
Acceptable Answer
time: 809ms
memory: 4160kb

input:

a92b3f80-b312-8377-273c-3916024d7f2a
100
333271685633113373
303681151173201623
185954994672690293
695000491456721509
680039555562404861
711731044985538439
725639770789026979
653124604194000671
716161846351295353
727816570890872159
566821251164212697
620956504691616073
845196440395453799
654653854021...

output:

6cad0f33-b1bd-3a3e-1a8d-c4af23adfcbf
OK
644
627 625 624 636 626 630 637 639 629 634 635 640 638 641 632 631 642 628 643 633 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 ...

result:

points 0.71264957260

Test #11:

score: 65.2769
Acceptable Answer
time: 734ms
memory: 4144kb

input:

a92b3f80-b312-8377-273c-3916024d7f2a
100
11260605527954640
3776579230632
1586488757700
753903936556020250
10601397297904140
810787108223734551
544021594614225000
609804018090927660
212587386929622705
334981274861463750
759012209987031
879302565815602500
156896254323644472
501935537823034315
23356411...

output:

6cad0f33-b1bd-3a3e-1a8d-c4af23adfcbf
OK
475
459 460 463 474 470 465 466 461 471 462 464 469 467 458 472 468 473 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 ...

result:

points 0.72529914530

Test #12:

score: 63.1231
Acceptable Answer
time: 768ms
memory: 4200kb

input:

a92b3f80-b312-8377-273c-3916024d7f2a
100
450283905890997362
288230376151711743
298023223876953124
789730223053602815
558545864083284006
144115188075855871
150094635296999120
999999999999999999
505447028499293770
184884258895036415
665416609183179840
155568095557812223
437893890380859374
720575940379...

output:

6cad0f33-b1bd-3a3e-1a8d-c4af23adfcbf
OK
1043
1027 1041 1033 1029 1031 1028 1036 1030 1038 1032 1034 1037 1040 1026 1035 1042 1025 1039 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 100...

result:

points 0.70136752140