티스토리 뷰
https://www.acmicpc.net/problem/9536
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | #include <iostream> #include <vector> #include <string> #include <map> using namespace std; int main() { cin.sync_with_stdio(false); int t; cin>>t; cin.ignore(); while(t--) { map<string,int> map; string sound; getline(cin,sound); sound+=' '; vector<string> word; int n=sound.size(); for(int i=0,j=0;j<n;j++) { if(sound[j]==' ') { word.push_back(sound.substr(i,j-i)); i=j+1; } } while(true) { string str; getline(cin,str); if(str=="what does the fox say?") { for(auto w : word) if(map[w]==0) cout<<w<<' '; break; } else { int n=str.size(); for(int i=n-1;i>=0;i--) { if(str[i]==' ') { map[str.substr(i+1,n-1-i)]++; break; } } } } } return 0; } | cs |
'Algorithm > BOJ' 카테고리의 다른 글
1890 점프 (0) | 2019.10.12 |
---|---|
11048 이동하기 (0) | 2019.10.12 |
1620 나는야 포켓몬 마스터 이다솜 (0) | 2019.01.27 |
1707 이분 그래프 (0) | 2019.01.27 |
2606 바이러스 (0) | 2019.01.27 |