回答編集履歴
1
修正
test
CHANGED
@@ -7,6 +7,8 @@
|
|
7
7
|
#include <iostream>
|
8
8
|
|
9
9
|
#include <algorithm>
|
10
|
+
|
11
|
+
#include <set>
|
10
12
|
|
11
13
|
#include <string>
|
12
14
|
|
@@ -18,15 +20,11 @@
|
|
18
20
|
|
19
21
|
bool contains_str(const std::string& str, const std::string& target) {
|
20
22
|
|
21
|
-
|
23
|
+
// targetに含まれる文字をそれぞれ一つ含み、sortされた文字集合tgtを作る。
|
22
24
|
|
23
|
-
|
25
|
+
std::set<char> tgt(target.begin(), target.end());
|
24
26
|
|
25
|
-
std::sort(tgt_.begin(), tgt_.end());
|
26
|
-
|
27
|
-
tgt_.erase(std::unique(tgt_.begin(),tgt_.end()), tgt_.end());
|
28
|
-
|
29
|
-
// strがtgt
|
27
|
+
// strがtgtを包含するならtrue
|
30
28
|
|
31
29
|
return std::includes(str.begin(), str.end(), tgt_.begin(), tgt_.end());
|
32
30
|
|
@@ -76,6 +74,4 @@
|
|
76
74
|
|
77
75
|
*/
|
78
76
|
|
79
|
-
|
80
|
-
|
81
77
|
```
|