Submission #208867

#TimeUsernameProblemLanguageResultExecution timeMemory
208867SenseiTavan (COCI16_tavan)C++14
80 / 80
5 ms504 KiB
/* DATE: 2020-03-12 14:04:45 NAME: PROBLEM: COCI16_TAVAN */ #include <bits/stdc++.h> using namespace std; const int MAXN = 500; string st; set<char> s[MAXN + 7]; long long suffe[MAXN + 7]; string dfs(int i, int mi, int x) { if (i >= st.size()) { return ""; } if (st[i] != '#') { return st[i] + dfs(i + 1, mi, x); } for (set<char>::iterator it = s[mi].begin(); it != s[mi].end(); it++) { if (suffe[mi - 1] < x) { x -= suffe[mi - 1]; continue; } else { return *it + dfs(i + 1, mi - 1, x); } } } int main() { int n, m, k, x; cin >> n >> m >> k >> x; cin >> st; st.insert(st.begin(), '#'); for (int i = m; i >= 1; i--) { string temp; cin >> temp; for (int j = 0; j < temp.size(); j++) { s[i].insert(temp[j]); } } suffe[0] = 1; for (int i = 1; i <= m; i++) { suffe[i] = suffe[i - 1] * s[i].size(); if (suffe[i] > x) { suffe[i] = x + 1; } } cout << dfs(1, m, x) << "\n"; return 0; }

Compilation message (stderr)

tavan.cpp: In function 'std::__cxx11::string dfs(int, int, int)':
tavan.cpp:19:9: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if (i >= st.size()) {
       ~~^~~~~~~~~~~~
tavan.cpp: In function 'int main()':
tavan.cpp:46:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int j = 0; j < temp.size(); j++) {
                     ~~^~~~~~~~~~~~~
tavan.cpp: In function 'std::__cxx11::string dfs(int, int, int)':
tavan.cpp:34:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
#Verdict Execution timeMemoryGrader output
Fetching results...