Problem:


Score : 300 points

Problem Statement

Takahashi participated in a contest on AtCoder.

The contest had N problems.

Takahashi made M submissions during the contest.

The i-th submission was made for the p_i-th problem and received the verdict S_i (AC or WA).

The number of Takahashi's correct answers is the number of problems on which he received an AC once or more.

The number of Takahashi's penalties is the sum of the following count for the problems on which he received an AC once or more: the number of WAs received before receiving an AC for the first time on that problem.

Find the numbers of Takahashi's correct answers and penalties.

Constraints

N, M, and p_i are integers.

1 \leq N \leq 10^5

0 \leq M \leq 10^5

1 \leq p_i \leq N

S_i is AC or WA.

Input

Input is given from Standard Input in the following format:

N M
p_1 S_1
:
p_M S_M

Output

Print the number of Takahashi's correct answers and the number of Takahashi's penalties.

Sample Input 1

2 5
1 WA
1 AC
2 WA
2 AC
2 WA

Sample Output 1

2 2

In his second submission, he received an AC on the first problem for the first time. Before this, he received one WA on this problem.

In his fourth submission, he received an AC on the second problem for the first time. Before this, he received one WA on this problem.

Thus, he has two correct answers and two penalties.

Sample Input 2

100000 3
7777 AC
7777 AC
7777 AC

Sample Output 2

1 0

Note that it is pointless to get an AC more than once on the same problem.

Sample Input 3

6 0

Sample Output 3

0 0



Sample input:
2 5
1 WA
1 AC
2 WA
2 AC
2 WA


Sample output:
2 2

Submission status: Accepted

Solution code:
import collections
n,m = map(int, input().split())
ps = [list(input().split()) for _ in range(m)]

q = [0]*n
t = [0]*n

for [p,s] in ps:
    p = int(p) - 1
    if s == "AC" and q[p] == 0:
        q[p] += 1
    elif s == "WA" and q[p]== 0:
        t[p] += 1


"""
for [u,r] in ps:
    u = int(u) -1
    if q[u] == 0 and t[u] != 0:
        t[u] == 0
"""

w = 0
for i, uc in enumerate(q):
    if uc == 1:
        w += t[i]
    


print(sum(q),w)

Submission status: Accepted

Solution code:
#n=int(input())
n,m=map(int,input().split())
#pl=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
solved_dic={}
pena_dic={}
for i in range(n):
    solved_dic[i+1]=False
    pena_dic[i+1]=0

pena=0
solved=0

for i in range(m):
    p,s=map(str,input().split())
    p=int(p)
    if s=="WA":
        if not solved_dic[p]:
            pena_dic[p]=pena_dic[p]+1        
    else:
        if not solved_dic[p]:
            solved+=1
            solved_dic[p]=True

for p in range(n):
    if solved_dic[p+1]:
        pena+=pena_dic[p+1]
print("{} {}".format(solved,pena))

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
answers = [input().split() for _ in range(m)]

num_ac = 0
num_wa = 0
q_d = dict()
done = set()

for q_num, result in answers:
    q_num = int(q_num)
    if q_num in done:
        continue

    if result == "AC":
        num_ac += 1
        num_wa += q_d.get(q_num, 0)
        done.add(q_num)
    elif result == "WA":
        q_d[q_num] = q_d.get(q_num, 0) + 1

print(num_ac, num_wa)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

n, m = map(int, input().split())
ps = list(list(input().split()) for _ in range(m))

wal = [0]*n
acl = [0]*n
for [p, s] in ps:
    p = int(p)-1
    if s == 'AC' and acl[p] == 0:
        acl[p] += 1
    elif s == 'WA'and acl[p] == 0:
        wal[p] += 1

wa = 0
for i, ac in enumerate(acl):
    if ac == 1:
        wa += wal[i]

print(sum(acl),wa)

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
if M==0:
  print(0,0)
else:
  ac = [0]*N
  wa = [0]*N
  score=0
  mis=0
  for i in range(M):
    p,s = input().split()
    p=int(p)
    if s =="AC":
      if ac[p-1]==0:
        ac[p-1] = 1
        score += 1
    else:
    
      if ac[p-1] == 0:
        wa[p-1] += 1
  
  
  for i in range(N):
    if ac[i-1] == 1:
      mis += wa[i-1]
  print(score,mis)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
p = [None]*M
S = [None]*M
for i in range(M):
  p[i], S[i] = input().split()

ac_flag = [0]*N
wa_count = [0]*N

penalty = 0
for i in range(M):
  j = int(p[i])-1
  if S[i] == 'AC':
    if ac_flag[j]:
      pass
    else:
      ac_flag[j] = 1
      penalty += wa_count[j]
  else:
    wa_count[j] += 1
print(*[sum(ac_flag), penalty])

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
p = [None]*M
S = [None]*M
for i in range(M):
  p[i], S[i] = input().split()

ac = [0]*N
penalty = [0]*N
for i in range(M):
  if S[i] == 'AC':
    ac[int(p[i])-1] = 1
  else:
    if ac[int(p[i])-1] == 0:
      penalty[int(p[i])-1] += 1
for j in range(N):
  if ac[j] == 0:
    penalty[j] = 0
print(*[sum(ac), sum(penalty)])

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
ac = [0] * n
wrong = [0] * n
seitou = 0
pena = 0
for i in range(m):
         p,s = input().split()
         p = int(p)
         if ac[p-1] == 0:
                  if s == "AC":
                           ac[p-1] = 1
                  else:
                           wrong[p-1] += 1
seitou = sum(ac)
for i in range(n):
         if ac[i] == 1:
                  pena += wrong[i]
print(seitou,pena)

Submission status: Accepted

Solution code:
import math

N, M = map(int, input().split())
wa_list = [0] * N
ac_list = [False] * N
for i in range(M):
    p, s = map(str, input().split())
    p = int(p) - 1
    if s == 'AC':
        ac_list[p] = True
    else:
        if not ac_list[p]:
            wa_list[p] += 1
for i in range(N):
    if not (ac_list[i]):
        wa_list[i] = 0

print(sum(i == True for i in ac_list), sum(wa_list))

Submission status: Accepted

Solution code:
N,M = map(int,input().split(" "))
L = [0] * M
for i in range(M):
    L[i] = input().split(" ")
    
memoAC = [0] * N
memoWA = [0] * N
for list in L:
    if list[1] == "AC":
        memoAC[int(list[0])-1] = 1
    else:
        if memoAC[int(list[0])-1] != 1:
            memoWA[int(list[0])-1] += 1

for j in range(N):
    if memoAC[j] == 0:
        memoWA[j] = 0

AC = sum(memoAC)
WA = sum(memoWA)
print(AC,WA)

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
AC = 0
penalty = 0
AC_list = [0]*N
WA_list = [0]*N

for i in range(M):
  p,s = map(str,input().split())
  p = int(p)-1
  if s == "AC" and AC_list[p] == 0:
    AC += 1
    AC_list[p] = 1
    penalty += WA_list[p]
  elif s == "WA":
    WA_list[p] += 1
  if AC == N:
    break
print(AC,penalty)

Submission status: Accepted

Solution code:
def get_ints():
    return map(int, input().split())

n, m = get_ints()
penalty = 0
oks = 0
ac = []
penalty = []
for i in range(n):
    ac.append(False)
    penalty.append(0)
for i in range(m):
    p, s = input().split()
    p = int(p)
    p -= 1
    if ac[p]:
        continue
    if s == 'AC':
        ac[p] = True
        oks += 1
    else:
        penalty[p] += 1

ans = 0
for i in range(n):
    if ac[i]:
        ans += penalty[i]

print(str(oks) + ' ' + str(ans))

Submission status: Accepted

Solution code:
import sys
N, M = map(int, input().split())

WA_counts = [0] * N
AC_list = [False] * N
for i in sys.stdin:
    p, S = i.split()
    p = int(p) - 1
    if S == 'WA' and not AC_list[p]:
        WA_counts[p] += 1
    elif S == 'AC':
        AC_list[p] = True
for i in range(len(AC_list)):
    if not AC_list[i]:
        WA_counts[i] = 0

print('{} {}'.format(sum(AC_list), sum(WA_counts)))

Submission status: Accepted

Solution code:
n,m = [int(x) for x in input().split()]
ans = [0]*(n+1)
w = [0]*(n+1)
for _ in range(m):
    a,b = input().split()
    a = int(a)
    if ans[a] == 1:
        continue
    if b == "AC":
        ans[a] = 1
    else:
        w[a] += 1

aa = 0
ww = 0
for i in range(1,n+1):
    if ans[i]==1:
        aa += 1
        ww += w[i]
print(aa,ww)

Submission status: Accepted

Solution code:
import sys

N, M = map(int, input().split())

WA = [0] * N
isAC = [False] * N

for _ in range(M):
	p, S = input().split()
	if S == "AC":
		isAC[int(p) - 1] = True
	elif not isAC[int(p) - 1]:
		WA[int(p) - 1] += 1

ACsum, WAsum = 0, 0
for i in range(N):
	if isAC[i]:
		ACsum += 1
		WAsum += WA[i]

print(ACsum, WAsum)

Submission status: Accepted

Solution code:
N, M = list(map(int, input().split()))

ac = [0]*N
pena = [0]*N

for _ in range(M):
    p, s = input().split()
    p = int(p)-1

    if ac[p] == 1:
        continue

    if s == "WA":
        pena[p] += 1
    if s == "AC":
        ac[p] = 1

AC = 0
PENA = 0
for i in range(N):
    AC += ac[i]
    if ac[i]:
        PENA += pena[i]

print(AC, PENA)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
lst = []
ans_list = list([0, False] for i in range(N))
ans = [0, 0]

for i in range(M):
    tup = tuple(input().split())
    lst.append(tup)

for submit in lst:
    if ans_list[int(submit[0]) - 1][1] == True:
        continue
    else:
        if submit[1] == "AC":
            ans_list[int(submit[0]) - 1][1] = True
        if submit[1] == "WA":
            ans_list[int(submit[0]) - 1][0] += 1

for quest in ans_list:
    if quest[1] == True:
        ans[0] += quest[1]
        ans[1] += quest[0]

print(*ans)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
info = [[] for _ in range(n)]
for _ in range(m):
    p, s = input().split()
    info[int(p) - 1].append(s)

AC = 0
WA = 0

for meta in info:
    if meta.count('AC') == 0:
        continue
    for s in meta:
        if s == 'AC':
            AC += 1
            break
        else:
            WA += 1
        

print(AC, WA)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
res = [[0 for i in range(2)] for j in range(N)]
ac = 0
wa = 0

for i in range(M):
  p, s = input().split()
  p = int(p)
  if res[p - 1][0] == 0:
    if s == "AC":
      ac += 1
      res[p - 1][0] = 1
    else:
      res[p - 1][1] += 1

for i in range(N):
  if res[i][0] == 1:
    wa += res[i][1]

print(ac, wa)

Submission status: Accepted

Solution code:
mondaisu, teishutsusu = map(int, input().split())
kekka =[input().split() for i in range(teishutsusu)]
l = [0] * mondaisu
p = [0] * mondaisu
for n, a in kekka:
  if a == 'AC':
    l[int(n) - 1] = 1
  else:
    if l[int(n) - 1] == 0:
      p[int(n) - 1] += 1
for i in range(len(p)):
  if l[i] == 0:
    p[i] = 0  
      
print(sum(l), sum(p))

Submission status: Accepted

Solution code:
input_line = input()
Line = input_line.split()
Line = [int(s) for s in Line]
#mondaisuu
N = Line[0]
#teisyutu
M = Line[1]
 
AC_Lists = [""]*N
# print(AC_Lists)
 
for i in range(M):
    input_line = input()
    Line = input_line.split()
    # print(AC_Lists[int(Line[0])-1])
    AC_Lists[int(Line[0])-1] += Line[1][0]
 
AC_count = 0
WA_count = 0
 
for s in AC_Lists:
    # print(s)
    if 'A' in s:
        AC_count += 1
        my_str = s.split("A")
        # print(my_str)
        # print(len(my_str[0]))
        WA_count += len(my_str[0])
    # else:
    #     print(len(s))
    #     WA_count += len(s)
# print(AC_Lists)
 
print(AC_count,WA_count)

Submission status: Accepted

Solution code:
from __future__ import print_function

import sys

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd
# fractions.gcd() を用いること
# math.log2()はatcoderでは対応していない．留意せよ．

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


def lcm(n, m):
    return int(n * m / gcd(n, m))


def coprimize(p, q):
    common = fractions.gcd(p, q)
    return (p // common, q // common)


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def main():
    #
    n, m = map(int, input().strip().split())
    n_AC = 0
    n_penalty = 0
    l_penalty = [0 for _ in range(n)]
    l_status = [-1 for _ in range(n)]

    #
    for i in range(m):
        id, res = input().strip().split()
        id = int(id) - 1
        if res == "AC" and l_status[id] == -1:
            n_penalty += l_penalty[id]
            l_status[id] = 1
            n_AC += 1
        else:  # res == "WA"
            l_penalty[id] += 1

    #
    print(n_AC, n_penalty)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
ok = [0]*n
x = [0]*n
ac, wa = 0, 0

for i in range(m):
  p, s = input().split()
  p = int(p)-1
  if s == "AC" and ok[p] == 0:
    ac += 1
    ok[p] = 1
    wa += x[p]
  elif s == "WA" and ok[p] == 0:
    x[p] += 1
#正解した問題についてのwaを出力しなければいけないのでxについてもリストが必要
print(ac, wa)

Submission status: Accepted

Solution code:
x,y=list(map(int, input().split()))
z=[0]*x
for i in range(y):
	a,b=list(map(str, input().split()))
	a=int(a)
	if b=='AC' and z[a-1]<10**6:
		z[a-1]=z[a-1]+10**6
	if b=='WA' and z[a-1]<10**6:
		z[a-1]=z[a-1]+1
for i in range(x):
	if z[i]//(10**6)==0:
		z[i]=0
ansa=str(sum(z)//(10**6))
ansb=str(sum(z)%(10**6))
print(ansa+' '+ansb)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

N,M = map(int, input().split())

penalty=[0]*N
correct=[False]*N

for i in range(M):

    p,s = input().split()
    p = int(p)

    if s=="AC":
        correct[p-1]=True

    else:
        if correct[p-1]==False:
            penalty[p-1] += 1

for i in range(N):
    if correct[i]==False:
        penalty[i]=0

print(sum(i == True for i in correct),sum(penalty))

Submission status: Accepted

Solution code:
# -*- coding:utf-8 -*-

def solve():
    N, M = list(map(int, input().split()))

    ac_dic = {}
    wa_lst = [0 for _ in range(N+1)]
    ac_score, wa_score = 0, 0
    for i in range(M):
        p, s = input().split()
        p = int(p)

        if not p in ac_dic:
            if s == "WA":
                wa_lst[p] += 1
                ac_dic[p] = False
            else:
                ac_score += 1
                ac_dic[p] = True
        else:
            if s=="WA" and not ac_dic[p]:
                wa_lst[p] += 1
            elif s=="AC" and not ac_dic[p]:
                ac_score += 1
                ac_dic[p] = True

    # waスコアを数える
    for i, score in enumerate(wa_lst):
        if i in ac_dic and ac_dic[i]:
            wa_score += wa_lst[i]

    print(ac_score, wa_score)


if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
import sys
import numpy as np

i = list(map(int, input().split()))
N = i[0]
M = i[1]
ac = np.array([0]*N)
wa = np.array([0]*N)
for i in range(M):
    line = sys.stdin.readline().split()
    p = int(line[0])
    s = line[1]
    if ac[p - 1] == 0:
        if s == 'AC':
            ac[p - 1] = 1
        else:
            wa[p - 1] += 1
    

print(str(sum(ac)) + " " + str(sum(ac * wa)))

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
res=[0]*N
ac,wa=0,0
for i in range(M):
  p,s=input().split()
  p=int(p)-1
  if res[p]==-1:
    continue
  else:
    if s=="AC":
      wa+=res[p]
      res[p]=-1
      ac+=1
    else:
      res[p]+=1
print(ac,wa)

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
S = [input().split() for i in range(M)]
cntAC = [0] * N
cntWA = [0] * N

for p,s in S:
    if cntAC[int(p)-1] == 0:
        if s == "AC":
            cntAC[int(p)-1] = 1
        elif s == "WA":
            cntWA[int(p)-1] += 1

sumWA = sum([cntWA[p] for p in range(N) if cntAC[p]==1])

print(sum(cntAC),sumWA)

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
AC=[False for i in range(0,N)]
WA=[0 for i in range(0,N)]
for i in range(0,M):
    p,S=map(str,input().split())
    p=int(p)
    if AC[p-1]:
        continue
    if S=="AC":
        AC[p-1]=True
    else:
        WA[p-1]+=1

ac=0
wa=0
for i in range(0,N):
    if AC[i]:
        ac+=1
        wa+=WA[i]
print(ac,wa)

Submission status: Accepted

Solution code:
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate,permutations, combinations,combinations_with_replacement,product

def resolve():

    N,M=map(int,input().split())
    P, S = [0] * M, [0] * M
    for i in range(M):
        p, s = input().split()
        S[i] = int(p)
        P[i] = str(s)

    ac=[0]*N
    wa=[0]*N
    for i in range(M):
        if P[i]=='AC':
            ac[S[i]-1]=1
        else:
            if ac[S[i]-1]==0:
                wa[S[i]-1]+=1
            else:
                continue


    print(sum(ac),sum([wa[i] for i in range(N) if ac[i]==1]))






resolve()

Submission status: Accepted

Solution code:
N, M = map(int, input().split())

AC = {}
WA = {}
PE = {}
for x in range(M):
    p, S = input().split()
    if S == "AC":
        AC[p] = {"AC"}
        if p in WA:
            PE[p] = WA[p]
    else:
        if p not in AC:
            if p not in WA:
                WA[p] = 1
            else:
                WA[p] += 1

print(len(AC), sum(PE.values()))

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
ps = [list(map(str, input().split())) for _ in range(M)]

ac = [0]*N
wa = [0]*N

for i, s in ps:
    if ac[int(i)-1]==0:
        if s=='AC':ac[int(i)-1]=1
        elif s=='WA':wa[int(i)-1] += 1
answa = sum([wa[i] for i in range(N) if ac[i]==1])
print(sum(ac), answa)

Submission status: Accepted

Solution code:

import numpy as np
def main():
    
    n,m = map(int, input().split())
    
    pena_list = np.zeros(n)
    ac_list = np.zeros(n)

    for i in range(m):
        p,s = map(str, input().split())
        if s == 'WA':
            if ac_list[int(p)-1] == 0:
                pena_list[int(p)-1] += 1
        
        elif s == 'AC':
            ac_list[int(p)-1] = 1
    
    ans = 0
    for j in range(n):
        if ac_list[j] == 1:
            ans += pena_list[j]
    
    print(str(int(sum(ac_list))), str(int(ans)))



    


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n, m = map(int, input().split())

state = {}
wa_count = {}
wa = 0
ac = 0
for i in range(m):
  no, result = input().split()
  if result == 'AC':
    if not state.get(no):
      ac += 1
      wa += wa_count.get(no, 0)
    state[no] = True
  elif result == 'WA':
    if not state.get(no):
      if no in wa_count.keys():
        wa_count[no] += 1
      else:
        wa_count[no] = 1

print(str(ac) + ' ' + str(wa))

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
li=[input().split() for _ in range(m)]

ac=[0]*(n+1)
wa=[0]*(n+1)

cnt_ac=0
cnt_wa=0

for p,s in li:
  p=int(p)
  if s=="WA":
    wa[p]+=1
  elif s=="AC" and ac[p]==0:
    ac[p]+=1
    cnt_ac+=1
    cnt_wa+=wa[p]
  else:
    continue

print(cnt_ac,cnt_wa)

Submission status: Accepted

Solution code:
# import math
# import bisect
# import heapq
# from collections import deque
# import numpy as np

n,m = map(int, input().split())
# n = int(input())
# a = list(map(int,input().split()))

ans0,ans1 = 0,0
ac = [False] * n
mis = [0] * n
if m>0:
    for i in range(m):
        p,s = input().split()
        p = int(p)-1
        if not ac[p] and s == 'WA':
            mis[p] += 1
        elif ac[p] == False and s == 'AC':
            ans0 += 1
            ac[p] = True

for i in range(n):
    if not ac[i]:
        mis[i] = 0
print(ans0, sum(mis))

Submission status: Accepted

Solution code:
import numpy as np
from collections import Counter
import fractions
import math

def main():
  n, m = map(int, input().split())
  p_list, s_list = ["a"] * m, ["a"] * m
  for i in range(m):
    p_list[i], s_list[i] = map(str, input().split())
    p_list[i] = int(p_list[i])
  pena = 0
  mon_list, pena_list = [0] * n, [0] * n
  for i in range(m):
    if s_list[i] == "AC":
      mon_list[p_list[i] - 1] = 1
    if mon_list[p_list[i] - 1] == 0:
      if s_list[i] == "WA":
        pena_list[p_list[i] - 1] += 1
  for i in range(n):
    if mon_list[i] == 1:
      pena += pena_list[i]
  ac = mon_list.count(1)
  print(ac, pena)

main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
n, m = map(int, input().split())
penalty = 0
ac = [0] * n
wa = [0] * n
for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    if s == "AC":
        if ac[p] == 0:
            penalty += wa[p]
        ac[p] += 1
    else:
        wa[p] += 1
print(sum(x > 0 for x in ac), penalty)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
P=0
AC = [0]*(N+1)
WA = [0]*(N+1)
for i in range(M):
    p, s =input().split()
    if s == "AC":
        AC[int(p)] = 1
    else:
        if AC[int(p)] == 1:
            continue
        else:
            WA[int(p)] += 1
for i in range(N+1):
    if AC[i] == 0:
        WA[i] = 0
print(sum(AC), sum(WA))

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
p = [0] * m
s = ["WA"] * m
result = [[] for _ in range(n)]
for i in range(m):
    p[i],s[i] = input().split()
    p[i] = int(p[i])
    result[p[i]-1].append(s[i])
#
def my_index(l,x,default=False):
    if x in l:
        return str(l.index(x))
    else:
        return default
#
ac = 0
penalty = 0
for j in range(len(result)):
    if my_index(result[j],"AC") != False:
        ac += 1
        penalty += int(my_index(result[j],"AC"))
print(ac,penalty)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
arr = [input().split() for i in range(m)]
q = [int(arr[j][0]) for j in range(m)]
# [q, judges]
judges = [str(arr[h][1]) for h in range(m)]
results = [False]*n
wa_cnt = [0]*n
total_wa = 0
for k in range(m):
    if results[q[k]-1] == False:
        if judges[k] == "AC":
            results[q[k]-1] = True
            total_wa += wa_cnt[q[k]-1]
        else:
            wa_cnt[q[k]-1] += 1
    else:
        continue
print("{} {}".format(results.count(True), total_wa))

Submission status: Accepted

Solution code:


def submit():
    n, m = map(int, input().split())
    wa_count = {i: 0 for i in range(1, n + 1)}
    ac_status = {i: False for i in range(1, n + 1)}
    
    penalty = 0
    for _ in range(m):
        p, s = input().split()
        p = int(p)

        if ac_status[p]:
            continue
        
        if s == "AC":
            ac_status[p] = True
            penalty += wa_count[p]
        else:
            wa_count[p] += 1

    print("{} {}".format(sum(ac_status.values()), penalty))


if __name__ == "__main__":
    submit()

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
ps = [list(input().split()) for _ in range(m)]

ac = [0 for _ in range(n+1)]
wa = [0 for _ in range(n+1)]

result_ac, result_wa = 0, 0

for p, s in ps:
    p = int(p)
    if s=="WA":
        wa[p] += 1
    elif ac[p] == 0:
        ac[p] += 1
        result_ac += 1
        result_wa += wa[p]
    else:
        continue
print(result_ac, result_wa)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
lst = [[0, 0] for i in range(n)]
correct = 0
wrong = 0
for i in range(m):
    p, s = input().split()
    p = int(p)
    if s == "WA":
        lst[p-1][0] += 1
    if s == "AC" and lst[p-1][1] == 0:
        correct += 1
        wrong += lst[p-1][0]
        lst[p-1][1] = 1
print(correct, wrong)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
l=[list(input().split()) for _ in range (m)]

a=0
p=0
al=[0]*n
pl=[0]*n

for i in range (m):
  if al[int(l[i][0])-1]==0:
    if l[i][1]=='AC':
      a+=1
      al[int(l[i][0])-1]=1
    else:
      pl[int(l[i][0])-1]+=1
      
for k in range (n):
  if al[k]==1:
    p+=pl[k]
    
print (a,p)

Submission status: Accepted

Solution code:
N,M = map(int,input().split())

wa = [0]*N
ac = [0]*N

wac = 0
acc = 0

for i in range(M):
  p,s = input().split()
  p = int(p)
  if s == "AC":
    if ac[p-1] != 1:
      ac[p-1] = 1
      acc += 1
      wac += wa[p-1]
  else:
    if ac[p-1] == 0:
      wa[p-1] += 1
print(str(acc) +" "+ str(wac))

Submission status: Accepted

Solution code:
from sys import stdin
import math

n, m = [int(x) for x in stdin.readline().rstrip().split()]

flag = [0] * n
mm = [0] * n
clear = 0
miss = 0
for i in range(m):
    p, s = stdin.readline().rstrip().split()
    if flag[int(p)-1] == 0:
        if s == "AC":
            clear += 1
            flag[int(p)-1] += 1
            miss += mm[int(p)-1]
        else:
            mm[int(p)-1] += 1

print(str(clear) + ' ' + str(miss))

Submission status: Accepted

Solution code:
import numpy as np
N,M=map(int,input().split())
wa=np.zeros(N+1)
ac=np.zeros(N+1)
for _ in range(M):
    p,S=input().split()
    if S=='AC' and ac[int(p)]==0:
        ac[int(p)]+=1
    elif S=='AC' and ac[int(p)]>0:
        pass
    elif ac[int(p)]==0:
        wa[int(p)]+=1
print(int(sum(ac)), int(np.dot(ac>0,wa)))

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
lst=[list(input().split()) for _ in range(m)]
pena_lst=[0]*n
acn_lst=[0]*n

for p,s in lst:
    p=int(p)-1
    if acn_lst[p]==1:
        continue
    if s =="AC":
        acn_lst[p]=1
    else: pena_lst[p]+=1
pena=0
acn=0
for i in range(n):
    acn+=acn_lst[i]
    if acn_lst[i]==1:
        pena+=pena_lst[i]
print(acn,pena)

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
AC = [0]*n
WA = [0]*n
wa = 0
for i in range(m):
    x = input().split()
    x[0] = int(x[0])
    if x[1]=='WA' and AC[x[0]-1]==0:
        WA[x[0]-1] += 1
    elif x[1]=='AC' and AC[x[0]-1]==0:
        AC[x[0]-1] += 1
        wa += WA[x[0]-1]
print(sum(AC),wa)

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N,M = map(int,input().split())
PS = (input().split() for _ in range(M))

ac = [False] * N
wa_cnt = [0] * N
penal = 0
for P,S in PS:
    p = int(P)-1
    if ac[p]:
        pass
    elif S == 'WA':
        wa_cnt[p] += 1
    else:
        ac[p] = True
        penal += wa_cnt[p]

ac = sum(ac)
print(ac, penal)

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N,M = map(int,readline().split())
PS = (line.split() for line in readlines())

ac = [False] * N
wa_cnt = [0] * N
penal = 0
for P,S in PS:
    p = int(P)-1
    if ac[p]:
        pass
    elif S == b'WA':
        wa_cnt[p] += 1
    else:
        ac[p] = True
        penal += wa_cnt[p]

ac = sum(ac)
print(ac, penal)

Submission status: Accepted

Solution code:
def solve():
    N, M = map(int, input().split())
    isAC = [False] * N
    errCnt = [0] * N

    for i in range(M):
        p, S = input().split()
        p = int(p) - 1

        if S == 'WA':
            if not isAC[p]:
                errCnt[p] += 1
        
        if S == 'AC':
            isAC[p] = True
    
    n_penalty = 0
    for i in range(N):
        if isAC[i]:
            n_penalty += errCnt[i]

    print(sum(isAC), n_penalty)

if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
answered = [0] * n
ans = 0
pena = 0
for _ in range(m):
    p, s = input().split()
    pidx = int(p) - 1
    if answered[pidx] == -1:
        continue
    if s == "AC":
        ans += 1
        pena += answered[pidx]
        answered[pidx] = -1
    else:
        answered[pidx] += 1
print("{} {}".format(ans, pena))

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
AC=[0]*n
WA=[0]*n
for _ in range(m):
    p,s = map(str, input().split())
    p=int(p)
    if AC[p-1]==0:
        if s=="AC":
            AC[p-1]=1
        else:
            WA[p-1]+=1
penalty=0
for i in range(n):
    if AC[i]==1:
        penalty+=WA[i]
print(sum(AC),penalty)

Submission status: Accepted

Solution code:
import math

N,M = map(int,input().split())

AC_count = 0
WA_count =  0

check_list = [0 for i in range(N+1)]

for _ in range(M):
  i, res =  map(str,input().split())
  i = int(i)
  if check_list[i] == "AC":
    pass
  else:
    if res == "WA":
      check_list[i] += 1
    else:
      AC_count += 1
      WA_count += check_list[i]
      check_list[i] = "AC"
    
  
print(AC_count,WA_count)

Submission status: Accepted

Solution code:
N,M=[int(s) for s in input().split()]
WAls=[0 for _ in range(N)]
ACls=[0 for _ in range(N)]
wa=0
for i in range(M):
  a,b=input().split()
  a=int(a)-1
  if b=='AC':
    if ACls[a]==0:
      wa+=WAls[a]
      ACls[a]=1
  else:
    if ACls[a]==0:
      WAls[a]+=1
ans=[sum(ACls),wa]
print(*ans)

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
ll = [list(input().split()) for _ in [0]*m]
ac = set()
pena = 0
d = dict(zip(map(str,range(1,n+1)),[0]*n))
for l in ll:
  if l[0] not in ac:
    if l[1] == 'AC':
      ac.add(l[0])
      pena += d[l[0]]
    else:
      d[l[0]]+=1
print(' '.join(map(str,[len(ac),pena])))

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
ans = [0 for i in range(N)]
pen = [0 for i in range(N)]

for i in range(M):
	p, S = input().split()
	p = int(p) - 1
	if ans[p] == 0:
		if S == "AC":
			ans[p] = 1
		else:
			pen[p] += 1

ANS = 0
PEN = 0
for i in range(N):
	ANS += ans[i]
	PEN += ans[i] * pen[i]

print(ANS, PEN)

Submission status: Accepted

Solution code:
n , m = map(int, input().split())
x = [input().split() for _ in range(m)]

ac, wa = 0, 0
ac_wa_table = [[0, 0] for _ in range(n)]
for p, s in x:
    index = int(p) -1
    if ac_wa_table[index][0] != 0:
        continue
    if s == 'AC':
        ac_wa_table[index][0] +=1
        ac += 1
        wa += ac_wa_table[index][1]
    elif s == 'WA':
        ac_wa_table[index][1] +=1
print(ac, wa)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
question = {}
wa = {}
ac_count = 0
wa_count = 0
for i in range(M):
    q, s = input().split()
    question.setdefault(q, '')
    wa.setdefault(q, 0)
    if s == 'AC':
        if question[q] == 'AC':
            continue
        else:
            question[q] = 'AC'
            ac_count += 1
            wa_count += wa[q]
    else:
        wa[q] += 1
print(ac_count, wa_count)

Submission status: Accepted

Solution code:
import sys
import fractions
from functools import reduce
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, m = na()
flgs = [False for i in range(n)]
tmp = [0 for i in range(n)]
for i in range(m):
    p, s = stdin.readline().split()
    p = int(p)
    if flgs[p-1] is False:
        if s == 'WA':
            tmp[p-1] += 1
        else:
            flgs[p-1] = 1
wa = 0
ac = 0
for i in range(n):
    if flgs[i]:
        ac += 1
        wa += tmp[i]
print(ac, wa)

Submission status: Accepted

Solution code:
def solve():
    n, m = list(map(int, input().split()))
    
    ac_list = [0 for i in range(n + 1)]
    wa_before_ac_list = [0 for i in range(n + 1)]
    
    for _ in range(m):
        p, s = input().split()
        p = int(p)
        
        if s == "AC":
            ac_list[p] = 1
        elif s == "WA" and ac_list[p] == 0:
            wa_before_ac_list[p] += 1

    wa_before_ac_num = 0
    for i in range(n+1):
        if ac_list[i] == 1:
            wa_before_ac_num += wa_before_ac_list[i]
    
    
    print("{} {}".format(sum(ac_list), wa_before_ac_num))
if __name__ == "__main__":
    solve()