QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#412059 | #4252. Permutation | Rafi22 | 10 | 75ms | 4152kb | C++14 | 2.0kb | 2024-05-16 01:52:15 | 2024-05-16 01:52:16 |
Judging History
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<=45) return W[m];
vector<int>t1=calc(m/2),T1;
for(auto x:W[m%2+1]) T1.pb(x+sz(t1)+sz(W[2]));
for(auto x:W[2]) T1.pb(x);
for(auto x:t1) T1.pb(x+sz(W[2]));
/* vector<int>t2=calc(m/5),T2;
for(auto x:W[m%5+1]) T2.pb(x+sz(t2)+sz(W[5]));
for(auto x:W[5]) T2.pb(x);
for(auto x:t2) T2.pb(x+sz(W[5]));*/
vector<int>t3=calc(m/11),T3;
for(auto x:W[m%11+1]) T3.pb(x+sz(t3)+sz(W[11]));
for(auto x:W[11]) T3.pb(x);
for(auto x:t3) T3.pb(x+sz(W[11]));
vector<int> res=T1;
// if(sz(T2)<sz(res)) res=T2;
if(sz(T3)<sz(res)) res=T3;
return res;
}
vector<int>construct_permutation(ll m)
{
for(int n=1;n<=7;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);
}
int cnt(vector<int>p)
{
int n=sz(p);
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];
}
return act;
}
/*
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
vector<int>w=construct_permutation(123456);
for(auto x:w) cout<<x<<" ";
cout<<endl<<cnt(w);
return 0;
}*/
详细
Subtask #1:
score: 10
Accepted
Test #1:
score: 10
Accepted
time: 40ms
memory: 3816kb
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: 0
Time Limit Exceeded
Test #2:
score: 90
Accepted
time: 47ms
memory: 3860kb
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 20 0 1 2 19 3 18 4 17 5 6 7 8 9 11 10 13 14 16 15 12 25 24 0 1 23 2 22 3 4 5 21 6 20 7 8 19 9 18 10 12 13 14 16 17 15 11 21 20 0 1 19 2 3 4 5 6 7 8 18 9 17 10 12 13 15 11 16 14 20 19 0 18 1 3 5 6 4 2 17 7 8 9 10 11 12 14 13 16 15 15 0 1 2 3 4 5 6 7 8 9 11 1...
result:
ok
Test #3:
score: 90
Accepted
time: 75ms
memory: 4152kb
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 0 2 4 5 3 1 44 6 7 43 8 42 9 41 10 11 40 12 13 14 15 39 16 17 38 18 37 19 36 20 21 35 22 23 24 25 34 26 27 29 30 32 28 33 31 44 1 3 4 2 0 43 5 6 42 7 41 8 40 9 10 39 11 12 13 14 38 15 16 37 17 36 18 35 19 20 34 21 22 23 24 33 25 26 28 29 31 27 32 30 45 4...
result:
ok
Test #4:
score: 0
Time Limit Exceeded
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:
Unauthorized output