Created
March 27, 2018 16:21
-
-
Save jason790228/461fb5ae30f6a26ef5f4421d5c839852 to your computer and use it in GitHub Desktop.
12015
This file contains 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 <vector> | |
#include <array> | |
#include <iostream> | |
#include <string> | |
using namespace std; | |
#define EACH_TEST_CASE_DATA_NUMBER 10 | |
typedef vector<array<pair<string, int>, EACH_TEST_CASE_DATA_NUMBER>> test_case_struct; | |
typedef vector<vector<string>> result_struct; | |
void input(test_case_struct &t) | |
{ | |
int test_case_number; | |
cin >> test_case_number; | |
for (int i = 0; i < test_case_number; i++) | |
{ | |
array<pair<string, int>, EACH_TEST_CASE_DATA_NUMBER> temp_test_case; | |
for (int j = 0; j < EACH_TEST_CASE_DATA_NUMBER; j++) | |
{ | |
string temp_url; | |
int temp_relevance; | |
cin >> temp_url >> temp_relevance; | |
temp_test_case[j] = pair<string, int>(temp_url, temp_relevance); | |
} | |
t.push_back(temp_test_case); | |
} | |
} | |
void process(const test_case_struct &t, result_struct &r) | |
{ | |
for (int i = 0; i < t.size(); i++) | |
{ | |
int max_relevance(0); | |
for (int j = 0; j < EACH_TEST_CASE_DATA_NUMBER; j++) | |
{ | |
if (t[i][j].second > max_relevance) max_relevance = t[i][j].second; | |
} | |
vector<string> temp_result; | |
for (int j = 0; j < EACH_TEST_CASE_DATA_NUMBER; j++) | |
{ | |
if (t[i][j].second == max_relevance) temp_result.push_back(t[i][j].first); | |
} | |
r.push_back(temp_result); | |
} | |
} | |
void output(const result_struct &result) | |
{ | |
for (int i = 0; i < result.size(); i++) | |
{ | |
cout << "Case #" << i + 1 << ":\n"; | |
for (int j = 0; j < result[i].size(); j++) | |
{ | |
cout << result[i][j] << endl; | |
} | |
} | |
} | |
int main() | |
{ | |
test_case_struct test_cases; | |
input(test_cases); | |
result_struct result; | |
process(test_cases, result); | |
output(result); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment