QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#568959#9320. Find the Easiest ProblemyylxWA 0ms3528kbC++141.0kb2024-09-16 19:32:032024-09-16 19:32:04

Judging History

你现在查看的是最新测评结果

  • [2024-09-16 19:32:04]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3528kb
  • [2024-09-16 19:32:03]
  • 提交

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'