Created
February 8, 2019 10:23
-
-
Save dlbas/5f1cd03603435487c97de69f705667e9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <map> | |
#include <stdio.h> | |
#include <utility> | |
#include <string> | |
#include <vector> | |
using namespace std; | |
int main() { | |
freopen("input.txt", "r", stdin); | |
int n; | |
map <int, vector <pair <string, string>>> data; | |
int min_freq = 99999; | |
cin >> n; | |
for (int i = 0; i < n; i++) { | |
string name, number; | |
int region; | |
cin >> name >> number >> region; | |
if (data.count(region)) { | |
data[region].push_back(make_pair(name, number)); | |
} else { | |
vector < pair < string, string >> vec; | |
vec.push_back(make_pair(name, number)); | |
data[region] = vec; | |
} | |
if (data[region].size() < min_freq) { | |
min_freq = data[region].size(); | |
} | |
} | |
cout << "Min frequency is: " << min_freq << endl; | |
for (auto it: data) { | |
if (it.second.size() == min_freq) { | |
for (auto it_inner = it.second.begin(); it_inner != it.second.end(); it_inner++) { | |
cout << it.first << " " << it_inner->first << " " << it_inner->second << " " << it.second.size() << " " << endl; | |
} | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment