File tree Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Original file line number Diff line number Diff line change
1
+ // Authored by : scsc3204
2
+ // Co-authored by : -
3
+ // http://boj.kr/c6e7465dfe8448a39b394e9f48c57aa0
4
+ #include < bits/stdc++.h>
5
+ using namespace std ;
6
+
7
+ string rec_sound, input, s;
8
+ stringstream ss;
9
+ unordered_map<string, bool > um;
10
+
11
+ void solve () {
12
+ getline (cin, rec_sound);
13
+ getline (cin, input);
14
+ while (input != " what does the fox say?" ) {
15
+ ss = stringstream (input);
16
+ ss >> s >> s >> s;
17
+ um[s] = 1 ;
18
+ getline (cin, input);
19
+ }
20
+
21
+ ss = stringstream (rec_sound);
22
+ while (ss >> s)
23
+ if (!um[s]) cout << s << ' ' ;
24
+ cout << ' \n ' ;
25
+ um.clear ();
26
+ }
27
+
28
+ int main () {
29
+ ios::sync_with_stdio (0 );
30
+ cin.tie (0 );
31
+
32
+ getline (cin, input);
33
+ int t = stoi (input);
34
+
35
+ while (t--) solve ();
36
+ }
37
+ /*
38
+ 해쉬(unordered_map)와 stringstream을 이용한 풀이입니다.
39
+ stringstream은 공백을 분리해서 문자열을 보내줍니다.
40
+ 14-19번째 줄은 입력받은 동물의 소리를 구분해서 해쉬에 기록합니다.
41
+
42
+ 이후 녹음했던 소리를 stringstream으로 생성하고
43
+ 이를 문자열에 흘려보내면서 해쉬에 없는 소리는 출력합니다.
44
+ 이후 해쉬를 비워줍니다(25번째 줄).
45
+
46
+ 32-33번째 줄에선 cin.ignore()를 쓰지 않기 위하여
47
+ getline 후 stoi로 t 값을 받습니다.
48
+ */
You can’t perform that action at this time.
0 commit comments