Download 2022/quals/second_second_meaning.cpp from hackercupai/hackercup: direct link, hf CLI and curl.
- Browser
- Download file 746 Bytes
-
https://huggingface.co/datasets/hackercupai/hackercup/resolve/main/2022/quals/second_second_meaning.cpp
- Command line
-
hf download hf://datasets/hackercupai/hackercup/2022/quals/second_second_meaning.cpp
-
curl -L -o second_second_meaning.cpp https://huggingface.co/datasets/hackercupai/hackercup/resolve/main/2022/quals/second_second_meaning.cpp
746 Bytes
| using namespace std; | |
| set<string> solve(int N, string C1) { | |
| set<string> leaves; | |
| queue<string> q; | |
| for (q.push(""); !q.empty(); q.pop()) { | |
| string curr = q.front(); | |
| leaves.erase(curr); | |
| for (string s : {curr + ".", curr + "-"}) { | |
| q.push(s); | |
| if (C1.rfind(s, 0) != 0 && s.rfind(C1, 0) != 0) { | |
| leaves.insert(s); | |
| if (leaves.size() == N - 1) { | |
| return leaves; | |
| } | |
| } | |
| } | |
| } | |
| return {}; | |
| } | |
| int main() { | |
| int T, N; | |
| string C1; | |
| cin >> T; | |
| for (int t = 1; t <= T; t++) { | |
| cin >> N >> C1; | |
| cout << "Case #" << t << ":" << endl; | |
| auto S = solve(N, C1); | |
| for (auto s : S) { | |
| cout << s << endl; | |
| } | |
| } | |
| return 0; | |
| } | |