| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 574170 | Lawliet | 순열 (APIO22_perm) | C++17 | 3 ms | 340 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "perm.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> buildBaseTwo(long long k)
{
int mn = 0;
vector<int> ans;
while( k > 1 )
{
if( k & 1 )
ans.push_back( mn++ ), k ^= 1;
else
ans.push_back( -1 ), k >>= 1;
}
int mx = (int)ans.size() - 1;
for(int i = 0 ; i < ans.size() ; i++)
if( ans[i] == -1 ) ans[i] = mx--;
reverse( ans.begin() , ans.end() );
return ans;
}
vector<int> buildBaseThree(long long k)
{
int mn = 0;
vector<int> ans;
while( k > 2 )
{
if( k%3 == 1 )
ans.push_back( mn++ ), k--;
else if( k%3 == 2 )
ans.insert( ans.end() , { mn , mn + 1 } ), k -= 2, mn += 2;
else
ans.insert( ans.end() , { -1 , -1 } ), k /= 3;
}
if( k == 2 )
ans.push_back( mn++ );
int mx = (int)ans.size() - 1;
for(int i = 0 ; i < ans.size() ; i++)
if( ans[i] == -1 ) ans[i + 1] = mx--, ans[i] = mx--;
reverse( ans.begin() , ans.end() );
return ans;
}
vector<int> construct_permutation(long long k)
{
vector<int> bTwo = buildBaseTwo(k);
vector<int> bThree = buildBaseThree(k);
if( bTwo.size() <= bThree.size() )
return bTwo;
return bThree;
}컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
