回答編集履歴
1
修正
answer
CHANGED
|
@@ -3,16 +3,15 @@
|
|
|
3
3
|
```C++
|
|
4
4
|
#include <iostream>
|
|
5
5
|
#include <algorithm>
|
|
6
|
+
#include <set>
|
|
6
7
|
#include <string>
|
|
7
8
|
|
|
8
9
|
/* target中にあるすべての文字がstr中にあるなら true さもなくば false を返す
|
|
9
10
|
ただし str は文字重複してはならず、sortされていること。*/
|
|
10
11
|
bool contains_str(const std::string& str, const std::string& target) {
|
|
11
|
-
std::string tgt_ = target;
|
|
12
|
-
// targetに含まれる文字をそれぞれ一つ含み、sortされた文字集合
|
|
12
|
+
// targetに含まれる文字をそれぞれ一つ含み、sortされた文字集合tgtを作る。
|
|
13
|
-
std::
|
|
13
|
+
std::set<char> tgt(target.begin(), target.end());
|
|
14
|
-
tgt_.erase(std::unique(tgt_.begin(),tgt_.end()), tgt_.end());
|
|
15
|
-
// strが
|
|
14
|
+
// strがtgtを包含するならtrue
|
|
16
15
|
return std::includes(str.begin(), str.end(), tgt_.begin(), tgt_.end());
|
|
17
16
|
}
|
|
18
17
|
|
|
@@ -37,5 +36,4 @@
|
|
|
37
36
|
[aiue0] : NG
|
|
38
37
|
[abcABC .] : OK
|
|
39
38
|
*/
|
|
40
|
-
|
|
41
39
|
```
|