Website Summary Files Commits Branches @commit @diff @stats
path: root / Seminar13 / task02.cpp
diff options
context:
space:
mode:
1 files changed, 0 insertions, 41 deletions
-rw-r--r--Seminar13/task02.cpp41
diff --git a/Seminar13/task02.cpp b/Seminar13/task02.cpp
deleted file mode 100644
index 8d47b45..0000000
--- a/Seminar13/task02.cpp
+++ /dev/null
@@ -1,41 +0,0 @@
-#include<iostream>
-#include<string>
-#include<map>
-#include<vector>
-
-bool canRead(const std::multimap<char, char>& graph, const std::string& word, size_t at) {
- if(at == word.length() - 1)
- return true;
-
- auto successors = graph.find(word[at]); // Може ли да си спестим това търсене?
-
- if(successors == graph.end())
- return false;
-
- while(successors != graph.end() && (*successors).first == word[at]) {
- if((*successors).second == word[at + 1]) {
- return canRead(graph, word, at + 1);
- }
-
- ++successors;
- }
-
- return false;
-}
-
-int main() {
- std::multimap<char, char> graph;
-
- graph.insert({'a', 'c'});
- graph.insert({'a', 'd'});
- graph.insert({'c', 'b'});
- graph.insert({'b', 'd'});
- graph.insert({'d', 'k'});
- graph.insert({'d', 'c'});
- graph.insert({'d', 'a'});
-
- std::map<char, bool> visited;
- std::string word = "adaz";
-
- std::cout << canRead(graph, word, 0);
-} \ No newline at end of file