-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbyte.h
More file actions
43 lines (32 loc) · 849 Bytes
/
byte.h
File metadata and controls
43 lines (32 loc) · 849 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#pragma once
#include <map>
#include <vector>
#include <iostream>
bool IsDependy(std::vector<std::pair<char, char> >& listVal, std::map<char, int> mapPath, char chTmp) {
for (auto i = 1; i < listVal.size(); ++i)
{
auto stInfo = listVal[i];
if (stInfo.first != chTmp)
continue;
auto it = mapPath.find(stInfo.second);
if (it != mapPath.end())
return true;
mapPath[stInfo.second] = 0;
if (IsDependy(listVal, mapPath, stInfo.second))
return true;
auto it_ = mapPath.find(stInfo.second);
mapPath.erase(it_);
}
return false;
}
bool IsSearch(std::vector<std::pair<char, char> >&listval)
{
if (listval.size() == 0)
return false;
std::map<char, int> mapPath;
char chTmp = 0;
auto stinfo = listval[0];
mapPath[stinfo.first] = 0;
mapPath[stinfo.second] = 0;
return IsDependy(listval, mapPath, stinfo.second);
}