제출 #657786

#제출 시각아이디문제언어결과실행 시간메모리
657786iomoon191순열 (APIO22_perm)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "perm.h" using namespace std; typedef long long ll; typedef pair<ll,ll> pl; #define endl "\n" #define ff first #define ss second #define pb push_back #define all(a) (a).begin(),(a).end() const int N=1e6+5; //const ll mod=1e9+7; mt19937 rng(std::chrono::system_clock::now().time_since_epoch().count()); vector<ll> sub_1(ll k) { vector<ll> vt(k-1); iota(all(vt),0ll); reverse(all(vt)); return vt; } vector<ll> construct_permutation(ll k) { // if (k<=90) // return sub_1(k); if (k==1ll) return {}; if (k==2ll) return {0ll}; if (k==3ll) return {1ll,0ll}; vector<ll> vt=construct_permutation(k/4ll); ll sz=(ll)vt.size(); if (k%4==0) { vt.pb(sz); vt.pb(sz+1); return vt; } if (k%4==1) { vt.pb(sz); vt.pb(sz+1); vt.pb(-1ll); for (auto &to:vt) ++to; return vt; } if (k%4==2) { vt.pb(sz); vt.pb(-1ll); vt.pb(sz+1); for (auto &to:vt) ++to; //for (auto &o:vt) cout<<o<<' '; return vt; } vector<ll> vT=vt; vt.pb(sz); vt.pb(sz+1); for (auto &to:vt) { if (to>1) to++; } vt.pb(2); vector<ll> f((ll)vt.size()); ll sum=1; for (ll i=0; i<(ll)vt.size(); i++) { f[i]=1; for (ll j=0; j<i; j++) { if (vt[j]<vt[i]) { f[i]+=f[j]; f[i]=min(f[i],LLONG_MAX); } } sum+=f[i]; sum=min(sum,LLONG_MAX); //cout<<sum<<endl; } if (sum==k) return vt; for (auto &to:vT) { //cout<<to<<' '; //cout<<endl; to+=2; } vT.pb(sz+2); vT.pb(1ll); vT.pb(sz+3); vT.pb(0ll); return vT; } /* int main() { ios::sync_with_stdio(false); cin.tie(0); if (fopen("t.inp","r")) { freopen("teddy.inp","r",stdin); freopen("teddy.out","w",stdout); } int tt; cin>>tt; while (tt--) { ll k; cin>>k; for (auto &to:construct_permutation(k)) cout<<to<<' '; cout<<endl; } } */

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

perm.cpp:28:12: error: ambiguating new declaration of 'std::vector<long long int> construct_permutation(ll)'
   28 | vector<ll> construct_permutation(ll k)
      |            ^~~~~~~~~~~~~~~~~~~~~
In file included from perm.cpp:2:
perm.h:3:18: note: old declaration 'std::vector<int> construct_permutation(long long int)'
    3 | std::vector<int> construct_permutation(long long k);
      |                  ^~~~~~~~~~~~~~~~~~~~~
perm.cpp: In function 'std::vector<long long int> construct_permutation(ll)':
perm.cpp:38:40: error: conversion from 'vector<int>' to non-scalar type 'vector<long long int>' requested
   38 |     vector<ll> vt=construct_permutation(k/4ll);
      |                   ~~~~~~~~~~~~~~~~~~~~~^~~~~~~