제출 #579806

#제출 시각UTC-0아이디문제언어결과실행 시간메모리
5798062022-06-19 22:40:25peuch순열 (APIO22_perm)C++17
10 / 100
1092 ms692 KiB
#include "perm.h"
#include<bits/stdc++.h>
using namespace std;
unordered_map<long long, vector<int> > dp;
std::vector<int> construct_permutation(long long k)
{
if(k == 1) return vector<int> (0);
if(k == 2) return vector<int> (1);
if(!dp[k].empty()) return dp[k];
// printf("%lld %lld\n", k, (long long)sqrt(k) + 1);
// printf("%lld\n", k);
for(long long i = 2; i * i <= k; i++){
// printf("%lld\n", i);
if(!dp[k].empty()) break;
if(k % i != 0) continue;
// printf("Testing dividing %lld by %d\n", k, i);
vector<int> aux1 = construct_permutation(i);
vector<int> aux2 = construct_permutation(k / i);
for(int i = 0; i < aux1.size(); i++)
dp[k].push_back(aux1[i]);
for(int i = 0; i < aux2.size(); i++)
dp[k].push_back(aux2[i] + aux1.size());
}
// printf("Ok\n");
if(dp[k].empty()){
dp[k] = construct_permutation(k - 1);
dp[k].insert(dp[k].begin(), dp[k].size());
}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

컴파일 시 표준 에러 (stderr) 메시지

perm.cpp: In function 'std::vector<int> construct_permutation(long long int)':
perm.cpp:21:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |   for(int i = 0; i < aux1.size(); i++)
      |                  ~~^~~~~~~~~~~~~
perm.cpp:23:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |   for(int i = 0; i < aux2.size(); i++)
      |                  ~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...