Submission #94142

#TimeUsernameProblemLanguageResultExecution timeMemory
94142MrTEKTavan (COCI16_tavan)C++14
80 / 80
2 ms508 KiB
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<int,int> ii; const int N = 5e3 + 5; string s,ans,t[N]; int n,m,k,x; bool ok[N]; ll suff[N]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> n >> m >> k >> x >> s; for (int i = 1 ; i <= m ; i++) { cin >> t[i]; sort(t[i].begin(),t[i].end()); t[i].resize(unique(t[i].begin(),t[i].end()) - t[i].begin()); } suff[m + 1] = 1; for (int i = m ; i >= 1 ; i--) { suff[i] = suff[i + 1] * t[i].size(); if (ok[i + 1] || suff[i] > x) ok[i] = true; } int lst = 0; for (int i = 0 ; i < n ; i++) { if (s[i] == '#') { lst++; int p = 0; while(!ok[lst + 1] && p < t[lst].size() && suff[lst + 1] < x) { x -= suff[lst + 1]; p++; } ans.push_back(t[lst][p]); } else ans.push_back(s[i]); } cout << ans << endl; }

Compilation message (stderr)

tavan.cpp: In function 'int main()':
tavan.cpp:35:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
       while(!ok[lst + 1] && p < t[lst].size() && suff[lst + 1] < x) {
                             ~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...