제출 #658305

#제출 시각아이디문제언어결과실행 시간메모리
658305Zena_Hossam순열 (APIO22_perm)C++17
10 / 100
1091 ms852 KiB
#include<bits/stdc++.h> #include "perm.h" //#include "grader.cpp" #define ll long long using namespace std; std::vector<int> construct_permutation(long long k) { ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); vector<pair<ll,ll>>v; vector<int>s,x; long long l=1; for(ll i=0;i<1e18;i++) { v.push_back({l-1,i}); l*=2; if(l-1>1e18)break; } ll p=k-2;k--; while(1) { pair<ll,ll>h={k,0}; ll o=upper_bound(v.begin(),v.end(),h)-v.begin(); while(v[o].first>k)o--; for(ll i=p-v[o].second+1;i<=p;i++){ s.push_back(i); } // cout<<v[o].first<<" "<<v[o].second<<" "<<k<<"\n"; p-=v[o].second; k-=v[o].first; if(k<=0)break; }x=s; sort(x.begin(),x.end()); map<ll,ll>m; for(ll i=0;i<x.size();i++) { m[x[i]]=i; } for(ll i=0;i<x.size();i++) { s[i]=m[s[i]]; } return s; }

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

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