Submission #201177

#TimeUsernameProblemLanguageResultExecution timeMemory
201177SamAndTavan (COCI16_tavan)C++17
80 / 80
6 ms504 KiB
#include <bits/stdc++.h> using namespace std; const int N = 505; int n, m, k, x; char a[N]; char b[N][33]; char ans[N]; int main() { scanf("%d%d%d%d", &n, &m, &k, &x); scanf(" %s", a); for (int i = 0; i < m; ++i) scanf(" %s", b[i]); for (int i = 0; i < m; ++i) { sort(b[i], b[i] + k); long long xx = 1; for (int j = i + 1; j < m; ++j) { xx *= k; if (xx > x) break; } long long y = xx; for (int j = 0; j < k; ++j) { if (x <= y) { ans[i] = b[i][j]; x -= (y - xx); break; } y += xx; } } int j = 0; for (int i = 0; i < n; ++i) { if (a[i] == '#') a[i] = ans[j++]; } printf("%s\n", a); return 0; }

Compilation message (stderr)

tavan.cpp: In function 'int main()':
tavan.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d%d", &n, &m, &k, &x);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
tavan.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf(" %s", a);
     ~~~~~^~~~~~~~~~
tavan.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf(" %s", b[i]);
         ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...