제출 #953674

#제출 시각아이디문제언어결과실행 시간메모리
953674De3b0o순열 (APIO22_perm)C++17
91.33 / 100
103 ms716 KiB
#include "perm.h" #include<bits/stdc++.h> #define ll long long #define F first #define S second #define in insert #define pb push_back #define ppb pop_back() #define d3 ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define cans cout << ans << "\n"; #define yes cout << "Yes" << "\n"; #define no cout << "No" << "\n"; #define pll pair<ll,ll> #define lin cout << "\n"; #define sqr 340 #define mod 1000000007 #define mid ((l+r)/2) //#define lc (2*n) //#define rc (2*n+1) using namespace std; ll fp(ll x , ll y) { if(y==0) return 1; ll z = fp(x,y/2); if(y&1) return z*z*x; else return z*z; } std::vector<int> construct_permutation(long long k) { vector<ll> v; k--; ll p = 0; while(k>0) { ll y = 0; ll x = k; while(x) { x/=2; y++; } ll e = fp(2,min(y,p)); if(e>k) { e=fp(2,min(y,p)-1); k-=e; v.pb(min(y,p)-1); } else { k-=e; v.pb(min(y,p)); } p++; } ll n = v.size(); vector<int> ans(n,0); map<ll,ll> mp; for(int i = n-1 ; i>=0 ; i--) { ll y; for(int j = 0 ; n>j ; j++) { if(mp[j]==1) continue; ll x = j; for(auto it : mp) { if(it.S==1) { if(it.F<j) x--; } } if(x==v[i]) { y=j; break; } } ans[i]=y; mp[y]=1; } return ans; }

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

perm.cpp: In function 'std::vector<int> construct_permutation(long long int)':
perm.cpp:88:15: warning: 'y' may be used uninitialized in this function [-Wmaybe-uninitialized]
   88 |         ans[i]=y;
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...