-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUva123.cpp
More file actions
93 lines (82 loc) · 2 KB
/
Copy pathUva123.cpp
File metadata and controls
93 lines (82 loc) · 2 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#include <iostream>
#include <math.h>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <algorithm>
#include <map>
#include <sstream>
#include <locale>
using namespace std;
vector<string> getWords(string &str,char delim){
stringstream ss(str);
vector<string> ret;
string tmp;
while(getline(ss,tmp,delim)){
ret.push_back(tmp);
}
return ret;
}
bool WordNotImportant(string word,vector<string> ¬ImportantWords){
for(string s : notImportantWords){
if(s==word)return true;
}
return false;
}
int main()
{
string line;
vector<string> notImportantWords;
vector<string> titles;
bool TitlesOn=false;
while(getline(cin,line)){
if(line=="::"){
TitlesOn=true;
continue;
}
if(line=="END")break;
if(!TitlesOn){
notImportantWords.push_back(line);
}
else{
for(int i=0;i<line.size();i++){
line[i]=tolower(line[i]);
}
titles.push_back(line);
}
line.clear();
}
vector<string> Coll;
for(int i=0;i<titles.size();i++){
vector<string> tmp=getWords(titles[i],' ');
for(string s : tmp){
Coll.push_back(s);
}
}
vector<string> newColl;
for(int i=0;i<Coll.size();i++){
if(WordNotImportant(Coll[i],notImportantWords)==false){
newColl.push_back(Coll[i]);
}
}
sort(newColl.begin(),newColl.end());
for(int i=0;i<newColl.size();i++){
for(int j=0;j<titles.size();j++){
string title=titles[j];
string needle=newColl[i];
size_t found=title.find(needle);
if(found!=string::npos){
int l=found + needle.size();
for(int k=found;k<l;k++){
title[k]=toupper(title[k]);
}
cout<<title<<endl;
}
}
}
return 0;
}