제출 #208905

#제출 시각아이디문제언어결과실행 시간메모리
208905MertD014Tavan (COCI16_tavan)C++17
48 / 80
6 ms376 KiB
#include <bits/stdc++.h> #define ll long long #define pb push_back #define pob pop_back using namespace std; int n,m,k,x; string s; queue<int> q; int main(){ 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...