teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

3

追記

2020/04/29 12:16

投稿

episteme
episteme

スコア16612

answer CHANGED
@@ -40,4 +40,20 @@
40
40
  [&](char ch) { return hist.count(ch) % 2 == 0;});
41
41
  std::cout << (beautiful ? "Yes" : "No") << std::endl;
42
42
  }
43
+ ```
44
+ [追追記] さらに、multisetすら要らない。
45
+ ```C++
46
+ #include <iostream>
47
+ #include <string>
48
+ #include <algorithm>
49
+
50
+ int main() {
51
+ std::string s;
52
+ std::cin >> s;
53
+
54
+ bool beautiful =
55
+ std::all_of(s.begin(), s.end(),
56
+ [&](char ch) { return std::count(s.begin(), s.end(), ch) % 2 == 0;});
57
+ std::cout << (beautiful ? "Yes" : "No") << std::endl;
58
+ }
43
59
  ```

2

微修正

2020/04/29 12:16

投稿

episteme
episteme

スコア16612

answer CHANGED
@@ -21,8 +21,8 @@
21
21
  }
22
22
  ```
23
23
 
24
- if (check.count(i)) continue;の文がどういう意味なのかわからなくていい。
25
24
  実際checkは何もつかわれていない。
25
+ まったくの無駄なので、if (check.count(i)) continue;の文がどういう意味なのかわからなくていい。
26
26
 
27
27
  [追記] ここまで短くなる。multiset::count を使った例
28
28
  ```C++

1

追記

2020/04/29 12:10

投稿

episteme
episteme

スコア16612

answer CHANGED
@@ -22,4 +22,22 @@
22
22
  ```
23
23
 
24
24
  if (check.count(i)) continue;の文がどういう意味なのかわからなくていい。
25
- 実際checkは何もつかわれていない。
25
+ 実際checkは何もつかわれていない。
26
+
27
+ [追記] ここまで短くなる。multiset::count を使った例
28
+ ```C++
29
+ #include <iostream>
30
+ #include <string>
31
+ #include <algorithm>
32
+ #include <set>
33
+
34
+ int main() {
35
+ std::string s;
36
+ std::cin >> s;
37
+
38
+ std::multiset<char> hist(s.begin(), s.end());
39
+ bool beautiful = std::all_of(s.begin(), s.end(),
40
+ [&](char ch) { return hist.count(ch) % 2 == 0;});
41
+ std::cout << (beautiful ? "Yes" : "No") << std::endl;
42
+ }
43
+ ```