AtCoder Beginner Contest 173 B Problem I will explain the "Judge Status Summary".
Problem URL: https://atcoder.jp/contests/abc173/tasks/abc173_b
$ N $ of string $ S_i $ representing the test case judge result is given. Find the number of judges whose results were'AC',' WA',' TLE', and'RE', respectively.
・ $ 1 \ leq N \ leq 10 ^ 5 $ ・ $ S_i $ is one of'AC','WA','TLE','RE'
You can implement it according to the problem statement. For example ・ The number of'AC'is $ C_0 $, ・ The number of'WA'is $ C_1 $, ・ The number of'TLE'is $ C_2 $, ・ The number of'RE'is $ C_3 $, Create four variables called Initialize each with 0, Conditional branching is performed for $ N $ $ S_i $ to manage variables. After that, if you output as shown in the output example, you can AC.
Below are examples of solutions in Python3, C ++, and Java.
{B.py}
N = int(input())
c0 = 0
c1 = 0
c2 = 0
c3 = 0
for i in range(N):
  S = input()
  if S == "AC":
    c0 += 1
  elif S == "WA":
    c1 += 1
  elif S == "TLE":
    c2 += 1
  elif S == "RE":
    c3 += 1
print("AC", "x",c0)
print("WA", "x",c1)
print("TLE", "x",c2)
print("RE", "x",x3)
{B.cpp}
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int c0 = 0;
  int c1 = 0;  
  int c2 = 0;
  int c3 = 0;
  for (int i = 0; i < n; i++){
    string S;
    cin >> S;
    if (S == "AC"){
      c0 += 1;
    }else if (S == "WA"){
      c1 += 1;
    }else if (S == "TLE"){
      c2 += 1;
    }else if (S == "RE"){
      c3 += 1;
    }
  }
  cout << "AC" << " " << "x" << " " << c0 << endl;
  cout << "WA" << " " << "x" << " " << c1 << endl;
  cout << "TLE" << " " << "x" << " " << c2 << endl;
  cout << "RE" << " " << "x" << " " << c3 << endl;
}
{B.java}
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int c0 = 0;
    int c1 = 0;
    int c2 = 0;
    int c3 = 0;
    for (int i = 0; i < n; i++){
      String S = scan.next();
      if (S.equals("AC")){
        c0 += 1;
      }else if (S.equals("WA")){
        c1 += 1;
      }else if (S.equals("TLE")){
        c2 += 1;
      }else if (S.equals("RE")){
        c3 += 1;
      }
    }
    System.out.println("AC"+" "+"x"+" "+c0);
    System.out.println("WA"+" "+"x"+" "+c1);
    System.out.println("TLE"+" "+"x"+" "+c2);
    System.out.println("RE"+" "+"x"+" "+c3);
  }
}
Recommended Posts