Submission #246760

#TimeUsernameProblemLanguageResultExecution timeMemory
246760Vladikus004Tavan (COCI16_tavan)C++14
48 / 80
6 ms384 KiB
#include <bits/stdc++.h> #define int long long #define inf 2e9 #define all(v) v.begin(), v.end() using namespace std; typedef long long ll; typedef long double ld; typedef pair <int, int> pii; const int N = 501; int n, m, k, x; string s, t[N]; ll pr; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(0); #ifdef LOCAL freopen("input.txt", "r", stdin); #endif // LOCAL cin >> n >> m >> k >> x >> s; --x; for (int i = 0; i < m; i++) { cin >> t[i]; sort(all(t[i])); } vector <int> ans; for (int i = 0; i < m; i++){ ll pr = 1; for (int i = m - 1; i > i; i--) { if (inf / t[i].size() < pr){ pr = inf; break; } pr *= (int)t[i].size(); } if (pr == inf){ ans.push_back(0); continue; } for (int j = 0; j < t[i].size(); j++){ if (x - pr * j < 0){ ans.push_back(j - 1); x -= pr * j; break; } } if (ans.size() == i) { ans.push_back(t[i].size() - 1); x -= pr * (int)(t[i].size() - 1); } } reverse(all(ans)); // for (auto u: ans) cout << u << " "; int ind = 0; for (int i = 0; i < n; i++){ if (s[i] != '#') { cout << s[i]; continue; } cout << t[ind++][ans.back()]; ans.pop_back(); } }

Compilation message (stderr)

tavan.cpp: In function 'int32_t main()':
tavan.cpp:31:31: warning: self-comparison always evaluates to false [-Wtautological-compare]
         for (int i = m - 1; i > i; i--) {
                             ~~^~~
tavan.cpp:42:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int j = 0; j < t[i].size(); j++){
                         ~~^~~~~~~~~~~~~
tavan.cpp:49:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if (ans.size() == i) {
             ~~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...