-
Notifications
You must be signed in to change notification settings - Fork 0
/
10420ListofConquests.cpp
73 lines (70 loc) · 1.09 KB
/
10420ListofConquests.cpp
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
#include<iostream>
#include<string>
using namespace std;
string country[200]={" "};
void SortArray(string s,int c){
int i,j;
bool ok=false;
string tmpStr1,tmpStr2;
for(i=0;i<c;i++){
if(s<country[i]){
ok=true;
break;
}
}
if(ok){
for(j=i;j<c+1;j++){
tmpStr1=country[j];
country[j]=s;
s=tmpStr1;
}
}else{
country[c++]=s;
}
}
int main(){
//freopen("in.txt","r+",stdin);
bool found;
int love[200]={0};
int t,pos1,pos2,count,mark;
string s,country2[200]={" "};
cin>>t;
cin.get();
count=0;
while(t--){
getline(cin,s);
pos1=0;
pos2=s.find_first_of(" ");
s=s.substr(pos1,pos2);
if(country[0]==" "){
country[0]=s;
country2[0]=s;
love[0]++;
count++;
}else{
found=false;
for(int i=0;i<count;i++){
if(country2[i]==s){
found=true;
mark=i;
break;
}
}
if(!found){
country2[count]=s;
love[count]++;
SortArray(s,count);
count++;
}else{
love[mark]++;
}
}
}
for(int i=0;i<count;i++){
for(int j=0;j<count;j++){
if(country[i]==country2[j]){
cout<<country[i]<<" "<<love[j]<<endl;
}
}
}
}