제출 #208916

#제출 시각아이디문제언어결과실행 시간메모리
208916MertD014Tavan (COCI16_tavan)C++17
48 / 80
5 ms380 KiB
#include <bits/stdc++.h> #define ll long long #define int ll #define pb push_back #define pob pop_back using namespace std; int n,m,k,x; string s; queue<int> q; int32_t main(){ //freopen("all.in","r",stdin); //freopen("all.out","w",stdout); cin>>n>>m>>k>>x; cin>>s; int cl=0; while(pow(k,cl)<x) cl++; for(int i=0;i<m-cl;i++) q.push(1); int clc=cl; cl=pow(k,cl-1); for(int i=0;i<clc;i++){ for(int i=1;i<=k+1;i++){ if(i*cl>=x){ q.push(i); x-=i*cl; cl/=k; break; } } } string ss; for(int i=0;i<n;i++){ if(s[i]!='#') cout<<s[i]; else{ cin>>ss; sort(ss.begin(),ss.end()); cout<<ss[q.front()-1]; q.pop(); } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...