回答編集履歴

3

追記

2020/04/29 12:16

投稿

episteme
episteme

スコア16614

test CHANGED
@@ -83,3 +83,35 @@
83
83
  }
84
84
 
85
85
  ```
86
+
87
+ [追追記] さらに、multisetすら要らない。
88
+
89
+ ```C++
90
+
91
+ #include <iostream>
92
+
93
+ #include <string>
94
+
95
+ #include <algorithm>
96
+
97
+
98
+
99
+ int main() {
100
+
101
+ std::string s;
102
+
103
+ std::cin >> s;
104
+
105
+
106
+
107
+ bool beautiful =
108
+
109
+ std::all_of(s.begin(), s.end(),
110
+
111
+ [&](char ch) { return std::count(s.begin(), s.end(), ch) % 2 == 0;});
112
+
113
+ std::cout << (beautiful ? "Yes" : "No") << std::endl;
114
+
115
+ }
116
+
117
+ ```

2

微修正

2020/04/29 12:16

投稿

episteme
episteme

スコア16614

test CHANGED
@@ -44,9 +44,9 @@
44
44
 
45
45
 
46
46
 
47
- if (check.count(i)) continue;の文がどういう意味なのかわからなくていい。
47
+ 実際checkは何もつかわていい。
48
48
 
49
- 実際checkは何もつかわていい。
49
+ まったくの無駄なので、if (check.count(i)) continue;の文がどういう意味なのかわからなくていい。
50
50
 
51
51
 
52
52
 

1

追記

2020/04/29 12:10

投稿

episteme
episteme

スコア16614

test CHANGED
@@ -47,3 +47,39 @@
47
47
  if (check.count(i)) continue;の文がどういう意味なのかわからなくていい。
48
48
 
49
49
  実際checkは何もつかわれていない。
50
+
51
+
52
+
53
+ [追記] ここまで短くなる。multiset::count を使った例
54
+
55
+ ```C++
56
+
57
+ #include <iostream>
58
+
59
+ #include <string>
60
+
61
+ #include <algorithm>
62
+
63
+ #include <set>
64
+
65
+
66
+
67
+ int main() {
68
+
69
+ std::string s;
70
+
71
+ std::cin >> s;
72
+
73
+
74
+
75
+ std::multiset<char> hist(s.begin(), s.end());
76
+
77
+ bool beautiful = std::all_of(s.begin(), s.end(),
78
+
79
+ [&](char ch) { return hist.count(ch) % 2 == 0;});
80
+
81
+ std::cout << (beautiful ? "Yes" : "No") << std::endl;
82
+
83
+ }
84
+
85
+ ```