# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
208867 | 2020-03-12T11:15:05 Z | Sensei | Tavan (COCI16_tavan) | C++14 | 5 ms | 504 KB |
/* 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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 376 KB | Output is correct |
2 | Correct | 5 ms | 376 KB | Output is correct |
3 | Correct | 5 ms | 376 KB | Output is correct |
4 | Correct | 5 ms | 376 KB | Output is correct |
5 | Correct | 5 ms | 376 KB | Output is correct |
6 | Correct | 5 ms | 376 KB | Output is correct |
7 | Correct | 5 ms | 376 KB | Output is correct |
8 | Correct | 5 ms | 504 KB | Output is correct |
9 | Correct | 5 ms | 504 KB | Output is correct |
10 | Correct | 5 ms | 504 KB | Output is correct |