QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#412083#4252. PermutationRafi22100 ✓415ms4080kbC++141.8kb2024-05-16 03:47:582024-05-16 03:47:58

Judging History

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

  • [2024-05-16 03:47:58]
  • 评测
  • 测评结果:100
  • 用时:415ms
  • 内存:4080kb
  • [2024-05-16 03:47:58]
  • 提交

answer

#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define endl '\n'
#define st first
#define nd second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;
int inf=1000000007;
ll infl=1000000000000000007;
int mod=998244353;

bool is[1007];
vector<int>W[1007];

vector<int>calc(ll m)
{
    if(m<=78) return W[m];
    int mn=20000,k;
    for(int i=2;i<=78;i++)
    {
        int t=sz(W[i])+sz(W[m%i+1])+3*log2(m/i)/2;
        if(t<mn)
        {
            mn=t;
            k=i;
        }
    }
    vector<int>res,Q=calc(m/k);
    for(auto x:W[m%k+1]) res.pb(x+sz(Q)+sz(W[k]));
    for(auto x:W[k]) res.pb(x);
    for(auto x:Q) res.pb(x+sz(W[k]));
    return res;
}

vector<int>construct_permutation(ll m)
{
    for(int n=1;n<=8;n++)
    {
        vector<int>p(n);
        for(int i=0;i<n;i++) p[i]=i;
        while(true)
        {
            vector<int>DP(n);
            int act=1;
            for(int i=0;i<n;i++)
            {
                DP[i]=1;
                for(int j=0; j<i; j++) if(p[j]<p[i]) DP[i]+=DP[j];
                act+=DP[i];
            }
            if(!is[act])
            {
                is[act]=1;
                W[act]=p;
            }
            if(!next_permutation(all(p))) break;
        }
    }
    return calc(m);
}

ll cnt(vector<int>p)
{
    int n=sz(p);
    vector<ll>DP(n);
    ll act=1;
    for(int i=0;i<n;i++)
    {
        DP[i]=1;
        for(int j=0; j<i; j++) if(p[j]<p[i]) DP[i]+=DP[j];
        act+=DP[i];
    }
    return act;
}

/*
signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    vector<int>w=construct_permutation(123456789101111);
    cout<<sz(w)<<endl;

    return 0;
}*/

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 10
Accepted

Test #1:

score: 10
Accepted
time: 360ms
memory: 3856kb

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
1 3 2 0
3
0 1 2
4
1 0 3 2
4
0 2 3 1
5
1 3 4 2 0
4
0 1 3 2
5
1 2 4 3 0
5
0 2 4 3 1
5
1 0 3 4 2
4
0 1 2 3
5
1 2 3 4 0
5
0 2 1 4 3
6
1 2 5 0 4 3
5
0 1 3 4 2
6
1 0 3 5 4 2
6
0 2 4 5 3 1
6
1 2 4 0 5 3
5
0 1 2 4 3
6
1 2 0 4 5 3
6
0 ...

result:

ok 

Subtask #2:

score: 90
Accepted

Test #2:

score: 90
Accepted
time: 406ms
memory: 3904kb

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

result:

ok 

Test #3:

score: 90
Accepted
time: 409ms
memory: 4004kb

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

result:

ok 

Test #4:

score: 90
Accepted
time: 415ms
memory: 3884kb

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

result:

ok 

Test #5:

score: 90
Accepted
time: 407ms
memory: 3864kb

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

result:

ok 

Test #6:

score: 90
Accepted
time: 409ms
memory: 3964kb

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

result:

ok 

Test #7:

score: 90
Accepted
time: 405ms
memory: 4036kb

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

result:

ok 

Test #8:

score: 90
Accepted
time: 407ms
memory: 3892kb

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
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 3...

result:

ok 

Test #9:

score: 90
Accepted
time: 405ms
memory: 3872kb

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

result:

ok 

Test #10:

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

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

result:

ok 

Test #11:

score: 90
Accepted
time: 403ms
memory: 4032kb

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

result:

ok 

Test #12:

score: 90
Accepted
time: 411ms
memory: 4080kb

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

result:

ok 

Extra Test:

score: 0
Extra Test Passed