# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
94140 |
2019-01-16T11:38:49 Z |
MrTEK |
Tavan (COCI16_tavan) |
C++14 |
|
2 ms |
504 KB |
#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;
// cerr << i << ' ' << t[i] << ' ' << suff[i] << "\n";
}
int lst = 0;
for (int i = 0 ; i < n ; i++) {
if (s[i] == '#') {
lst++;
int p = 0;
while(!ok[i + 1] && p < t[lst].size() && suff[lst + 1] < x) {
x -= suff[lst + 1];
p++;
}
// cerr << "anan " << x << ' ' << p << "\n";
ans.push_back(t[lst][p]);
}
else
ans.push_back(s[i]);
}
cout << ans << endl;
}
Compilation message
tavan.cpp: In function 'int main()':
tavan.cpp:36:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
while(!ok[i + 1] && p < t[lst].size() && suff[lst + 1] < x) {
~~^~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
504 KB |
Output is correct |
2 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
3 |
Correct |
2 ms |
504 KB |
Output is correct |
4 |
Correct |
2 ms |
504 KB |
Output is correct |
5 |
Correct |
2 ms |
504 KB |
Output is correct |
6 |
Correct |
2 ms |
504 KB |
Output is correct |
7 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
8 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
9 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
10 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |