QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#34680#4252. Permutationdutinmeow#100 ✓1ms3912kbC++201.2kb2022-06-12 04:39:122024-05-26 00:51:56

Judging History

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

  • [2024-05-26 00:51:56]
  • 评测
  • 测评结果:100
  • 用时:1ms
  • 内存:3912kb
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-06-12 04:39:12]
  • 提交

answer

#include "perm.h"

#include <bits/stdc++.h>
using namespace std;

namespace permutation {
	vector<int> construct_permutation_slow(long long k) {
		vector<int> ret(k - 1);
		for (int i = 0; i < k - 1; i++)
			ret[i] = k - 2 - i;
		return ret;
	}

	vector<int> construct_permutation_mid(long long k) {
		int n = __lg(k);
		vector<int> ret(n);
		iota(ret.begin(), ret.end(), 0);
		for (int b = n - 1; b >= 0; b--)
			if (k >> b & 1)
				ret.insert(ret.begin() + b, n++);
		return ret;
	}

	const array<int, 5> primes = {2, 3, 5, 7, 11};

	vector<int> construct_permutation_dumb(long long k) {
		if (k <= 3)
			return construct_permutation_slow(k);
		for (int p : primes) {
			if (k % p != 0 || k == p)
				continue;
			auto ret = construct_permutation_dumb(k / p);
			auto tem = construct_permutation_dumb(p);
			int r = ret.size();
			for (int t : tem)
				ret.push_back(t + r);
			return ret;
		}
		auto ret = construct_permutation_dumb(k / 2);
		ret.push_back(ret.size());
		ret.insert(ret.begin(), ret.size());
		return ret;
	}
}

vector<int> construct_permutation(long long k) { 
	if (k <= 90)
		return permutation::construct_permutation_slow(k);
	else 
		return permutation::construct_permutation_dumb(k);
}

详细

Subtask #1:

score: 10
Accepted

Test #1:

score: 10
Accepted
time: 1ms
memory: 3712kb

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
3
2 1 0
4
3 2 1 0
5
4 3 2 1 0
6
5 4 3 2 1 0
7
6 5 4 3 2 1 0
8
7 6 5 4 3 2 1 0
9
8 7 6 5 4 3 2 1 0
10
9 8 7 6 5 4 3 2 1 0
11
10 9 8 7 6 5 4 3 2 1 0
12
11 10 9 8 7 6 5 4 3 2 1 0
13
12 11 10 9 8 7 6 5 4 3 2 1 0
14
13 12 11 10 9 8 7 6 5 4 3 2 1 0
15
14 1...

result:

ok 

Subtask #2:

score: 90
Accepted

Test #2:

score: 90
Accepted
time: 0ms
memory: 3716kb

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
21
18 13 6 1 0 3 2 4 5 8 7 10 9 11 12 16 14 15 17 20 19
22
21 14 4 0 1 2 3 7 5 6 9 8 11 10 12 13 18 16 15 17 19 20
20
12 2 0 1 4 3 6 5 8 7 9 10 11 15 13 14 17 16 19 18
22
21 16 8 6 4 2 0 1 3 5 7 10 9 12 11 14 13 15 19 17 18 20
15
2 0 1 4 3 5 6 7 8 9 10 11 12 1...

result:

ok 

Test #3:

score: 90
Accepted
time: 1ms
memory: 3772kb

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
46
45 30 23 13 11 9 4 1 0 2 3 7 5 6 8 10 12 17 15 14 16 21 19 18 20 22 26 24 25 28 27 29 35 33 31 32 34 39 37 36 38 41 40 43 42 44
44
30 23 13 11 9 4 1 0 2 3 7 5 6 8 10 12 17 15 14 16 21 19 18 20 22 26 24 25 28 27 29 35 33 31 32 34 39 37 36 38 41 40 43 42
41
4...

result:

ok 

Test #4:

score: 90
Accepted
time: 1ms
memory: 3736kb

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
79
78 74 68 63 52 47 36 32 29 23 16 4 0 1 2 3 9 7 5 6 8 12 10 11 14 13 15 19 17 18 21 20 22 25 24 27 26 28 30 31 34 33 35 37 38 39 40 41 42 43 44 45 46 49 48 50 51 56 54 53 55 58 57 59 60 61 62 64 65 66 67 71 69 70 72 73 76 75 77
77
74 68 63 52 47 36 32 29 23 ...

result:

ok 

Test #5:

score: 90
Accepted
time: 1ms
memory: 3732kb

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
51
47 38 17 11 8 1 0 3 2 5 4 6 7 9 10 13 12 15 14 16 22 20 18 19 21 24 23 26 25 28 27 30 29 32 31 33 34 35 36 37 41 39 40 44 42 43 45 46 50 48 49
47
39 27 3 1 0 2 7 5 4 6 9 8 11 10 13 12 15 14 17 16 19 18 21 20 23 22 24 25 26 30 28 29 32 31 33 34 35 36 37 38 4...

result:

ok 

Test #6:

score: 90
Accepted
time: 1ms
memory: 3880kb

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
67
58 54 43 37 33 27 24 16 9 2 0 1 5 3 4 7 6 8 14 12 10 11 13 15 18 17 20 19 21 22 23 25 26 29 28 30 31 32 35 34 36 39 38 40 41 42 48 46 44 45 47 50 49 51 52 53 56 55 57 62 60 59 61 64 63 66 65
70
63 58 52 40 35 25 16 8 6 4 2 0 1 3 5 7 11 9 10 14 12 13 15 21 1...

result:

ok 

Test #7:

score: 90
Accepted
time: 1ms
memory: 3784kb

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
74
73 66 55 53 38 34 28 26 24 19 9 2 0 1 4 3 6 5 7 8 13 11 10 12 15 14 16 17 18 22 20 21 23 25 27 31 29 30 32 33 36 35 37 41 39 40 44 42 43 47 45 46 48 49 50 51 52 54 59 57 56 58 62 60 61 64 63 65 69 67 68 70 71 72
82
79 75 60 57 44 25 22 9 7 4 1 0 2 3 5 6 8 1...

result:

ok 

Test #8:

score: 90
Accepted
time: 1ms
memory: 3820kb

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
79
76 74 68 63 52 47 36 32 29 23 16 4 0 1 2 3 9 7 5 6 8 12 10 11 14 13 15 19 17 18 21 20 2...

result:

ok 

Test #9:

score: 90
Accepted
time: 1ms
memory: 3852kb

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

result:

ok 

Test #10:

score: 90
Accepted
time: 1ms
memory: 3912kb

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
79
78 75 67 57 49 35 33 23 15 12 6 1 0 3 2 4 5 8 7 10 9 11 13 14 18 16 17 21 19 20 22 24 25 26 27 28 29 30 31 32 34 40 38 36 37 39 45 43 41 42 44 47 46 48 51 50 53 52 54 55 56 59 58 61 60 63 62 64 65 66 69 68 71 70 73 72 74 76 77
84
83 81 72 66 64 61 51 49 47 ...

result:

ok 

Test #11:

score: 90
Accepted
time: 1ms
memory: 3772kb

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
69
50 36 32 23 16 11 2 0 1 4 3 6 5 8 7 9 10 13 12 14 15 19 17 18 21 20 22 28 26 24 25 27 29 30 31 33 34 35 38 37 40 39 42 41 43 44 45 46 47 48 49 55 53 51 52 54 58 56 57 60 59 62 61 64 63 65 66 67 68
55
49 45 36 34 31 26 17 10 6 2 0 1 3 4 5 8 7 9 13 11 12 14 1...

result:

ok 

Test #12:

score: 90
Accepted
time: 0ms
memory: 3756kb

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
80
78 65 61 55 50 41 37 31 29 19 17 10 1 0 3 2 4 5 6 7 8 9 13 11 12 14 15 16 18 23 21 20 22 26 24 25 27 28 30 34 32 33 35 36 39 38 40 43 42 45 44 46 47 48 49 53 51 52 54 58 56 57 59 60 63 62 64 69 67 66 68 72 70 71 74 73 75 76 77 79
77
74 68 63 52 47 36 32 29 ...

result:

ok 

Extra Test:

score: 0
Extra Test Passed