QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#568959 | #9320. Find the Easiest Problem | yylx | WA | 0ms | 3528kb | C++14 | 1.0kb | 2024-09-16 19:32:03 | 2024-09-16 19:32:04 |
Judging History
answer
#include <iostream>
#include <unordered_map>
#include <string>
#include <algorithm>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
// Map to store problem ID and the number of teams that solved it
unordered_map<char, int> problem_counts;
for (int i = 0; i < n; ++i) {
string team_name;
char problem_id;
string result;
cin >> team_name >> problem_id >> result;
if (result == "accepted") {
problem_counts[problem_id]++;
}
}
// Find the easiest problem (most teams solved or lexicographically smallest ID)
char easiest_problem = 'A';
int max_teams = 0;
for (auto const& [problem_id, count] : problem_counts) {
if (count > max_teams) {
max_teams = count;
easiest_problem = problem_id;
} else if (count == max_teams && problem_id < easiest_problem) {
easiest_problem = problem_id;
}
}
cout << easiest_problem << endl;
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3528kb
input:
2 5 teamA A accepted teamB B rejected teamC A accepted teamB B accepted teamD C accepted 4 teamA A rejected teamB A accepted teamC B accepted teamC B accepted
output:
A B
result:
wrong answer 2nd lines differ - expected: 'A', found: 'B'