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:
n, m = map(int, input().split())
ac = 0
wa = [0 for i in range(n + 1)]
al = [0 for i in range(n + 1)]
if m == 0:
  k = [0, 0]
  print(*k)
  exit()
for i in range(m):
  k = list(input().split())
  a = int(k[0])
  if al[a] == 1:
    continue
  elif al[a] == 0 and k[1] == "WA":
    wa[a] += 1
  elif al[a] == 0 and k[1] == "AC":
    ac += 1
    al[a] = 1
wan = 0
for i in range(n+1):
  if al[i] == 1:
    wan += wa[i]
lis = [ac, wan]
print(*lis)

Submission status: Accepted

Solution code:
import sys

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

L = []

d = {}

for _ in range(M):
    P,S = input().split()
    P = int(P)
    L.append([P,S])

for i in range(M):
    p,s = L[i]
    if p in d:
        if s=="AC" and d[p]["AC"]==0:
            d[p]["AC"] = 1
        elif s=="WA" and d[p]["AC"]==0:
            d[p]["WA"] = d[p]["WA"] + 1
    else:
        d[p] = {}
        d[p]["AC"] = 0
        d[p]["WA"] = 0
        if s=="AC":
            d[p]["AC"] = 1
        else:
            d[p]["WA"] = 1

ac_count = 0
wa_count = 0

for i in range(1,N+1,1):
    if not (i in d):
        continue    
    ac_count = ac_count + d[i]["AC"]
    if d[i]["AC"]!=0:
        wa_count = wa_count + d[i]["WA"]

print(ac_count, wa_count)

Submission status: Accepted

Solution code:
# N: 問題数
# M: 提出数
N, M = list(map(int, input().split()))

# 各問題の正答状態
answer_dict = {}

# 問題解答状態
class AnswerState:
    
    def __init__(self):
        self.wrong_num = 0         # 正解するまでのWA数
        self.is_corrected = False # 正解しているか
    
    def submit(self, is_correct):
        # まだ正解していない状態でWAを出した場合はペナルティ数を増やす
        if not is_correct and not self.is_corrected:
            self.wrong_num += 1
        # 正解したかどうか記録
        if is_correct:
            self.is_corrected = True

for _ in range(M):
    tmp = input().split()
    p_index = int(tmp[0])
    p_result = tmp[1]
    
    if not p_index in answer_dict:
        answer_dict[p_index] = AnswerState()
    
    answer_dict[p_index].submit(p_result == 'AC')

# 正解数、ペナルティ数を数える
correct_num = 0
penalty_num = 0

for state in answer_dict.values():
    if state.is_corrected:
        correct_num += 1
        penalty_num += state.wrong_num

print('%d %d' % (correct_num, penalty_num))

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
counter = {}
for i in range(n):
  counter[i] = [0,0]

for i in range(m):
  p,s = input().split()
  p = int(p)
  if counter[p-1][1] == 1:
    continue
  elif s == "WA":
    counter[p-1][0] += 1
  elif s =="AC":
    counter[p-1][1] = 1

crt = 0
pen = 0
for i in range(n):
  if counter[i][1] == 1:
    crt+=1
    pen+=counter[i][0]

print(crt,pen)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
p = [0] * M
S = [0] * M
count_AC = [0] * N
count_WA = [0] * N
for i in range(M):
    p[i],S[i] =  input().split()
    p[i] = int(p[i]) - 1

    if S[i] == 'AC':
        if count_AC[p[i]] == 0:
            count_AC[p[i]] = 1
            
    if S[i] == 'WA':
        if count_AC[p[i]] == 0:
            count_WA[p[i]] = count_WA[p[i]] + 1
            
print(sum(count_AC) , sum([x * y for (x, y) in zip(count_AC, count_WA)]))

Submission status: Accepted

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

li = ['WA'] * n
countwa = [0] * n
ac = 0
wa = 0

for p,s in ps:
    if s == 'AC':
        if li[int(p)-1] == 'WA':
            li[int(p)-1] = 'AC'
            ac += 1
    else:
        if li[int(p)-1] == 'WA':
            countwa[int(p)-1] += 1

ac = li.count('AC')
for i in range(n):
    if li[i] == 'AC':
        wa += countwa[i]

print(ac, wa)

Submission status: Accepted

Solution code:
from sys import stdin
N, M = [int(i) for i in stdin.readline().rstrip().split()]
ans_list = []
for m in range(M):
    ans_list.append([i for i in stdin.readline().rstrip().split()])
ac = 0
wa = 0
result_dict = {}
wa_count = {}
for n in range(1, N + 1):
    result_dict[n] = False
    wa_count[n] = 0
for q, r in ans_list:
    q_now = int(q)
    if result_dict[q_now] == False:
        if r == "WA":
            wa += 1
            wa_count[q_now] += 1
        if r == "AC":
            ac += 1
            result_dict[q_now] = True
for n in range(1, N + 1):
    if result_dict[n] == False:
        wa -= wa_count[n]
print(ac, wa)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
l = []
ansewered_question = set()
submit_for = {}

for i in range(M):
  a = input().split()
  l.append([int(a[0]), a[1]])
  ansewered_question.add(int(a[0]))
for submition in l:
    if submition[0] in submit_for:
        submit_for[submition[0]].append(submition[1])
    else:
        submit_for[submition[0]] = [submition[1]]
AC = 0
WA = 0
for i in ansewered_question:
    wa = 0
    for submit in submit_for[i]:
      if submit == "WA":
        wa += 1
      else:
          AC += 1
          WA += wa
          break
print(AC, WA)

Submission status: Accepted

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

is_ac = [0] * n
ac_cnt = 0
wa_cnt_lst = [0] * n
for i in range(m):
    p_s[i][0] = int(p_s[i][0])
    if p_s[i][1] == 'AC' and is_ac[p_s[i][0] - 1] == 0:
        ac_cnt += 1
        is_ac[p_s[i][0] - 1] += 1
    if p_s[i][1] == 'WA' and is_ac[p_s[i][0] - 1] == 0:
        wa_cnt_lst[p_s[i][0] - 1] += 1

wa_cnt = 0
for i in range(n):
    if is_ac[i] > 0:
        wa_cnt += wa_cnt_lst[i]

print(ac_cnt, end = " ")
print(wa_cnt)

Submission status: Accepted

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

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

for i in range(m):
  a,b=input().split()
  a=int(a)
  if ac[a] ==0:
    if b=="WA":
      wa[a]+=1
    else:
      ac[a]+=1
wcon=0
accon=0
for i in range(n+1):
  if ac[i]>0:
    accon+=1
    wcon+=wa[i]
print(accon,wcon)

Submission status: Accepted

Solution code:
N, M = [int(x) for x in input().split()]


correct = 0
penalty = {i: 0 for i in range(1, N+1)}
final = 0

ans = set([])

for _ in range(M):
    p, S = input().split()
    p = int(p)
    if p in ans:
        continue
    elif S == 'WA':
        penalty[p] += 1
    else:
        correct += 1
        ans.add(p)
for i in range(1, N+1):
    if i in ans:
        final += penalty[i]

print(correct, final)

Submission status: Accepted

Solution code:
# coding: utf-8
n, m = [int(x) for x in input().split(" ")]
ans = 0
pens = 0
prbstate = {}
fins = {}
A = []
for i in range(m):
    A.append(input().split(" "))
for a in A:
    if a[1] == "AC":
        fins.setdefault(a[0], 1)
for x in fins.values():
    ans += x
for i in range(m):
    p, s = A[i]
    prbstate.setdefault(p, 0)
    fins.setdefault(p, 0)
    if s == "AC":
        prbstate[p] += 1
    if s == "WA" and prbstate[p] < 1 and fins[p] == 1:
        pens += 1
print(ans, pens)

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
d = {}
for i in range(m):
  p,s = input().split()
  if p not in d:
    d[p] = [s]
  else:
    d[p].append(s)

wa_c = 0
ac_c = 0
for k in d.keys():
  target = d[k]
  if target.count("AC") != 0:
    ind = d[k].index("AC")
    ac_c += 1
    wa_c += target[:ind].count("WA")
print(ac_c,wa_c)

Submission status: Accepted

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

sumi = set()

correct = 0
penalty = 0

dic = dict()

for i in range(NM[1]):
    s = input().split()
    if (s[0] in sumi):
        continue
    else:
        if (s[1] == "WA"):
            if (s[0] in dic.keys()):
                dic[s[0]] = dic[s[0]] + 1
            else:
                dic[s[0]] = 1
        else:
            correct += 1
            sumi.add(s[0])

for i in sumi:
    if (i in dic.keys()):
        penalty += dic[i]

print(correct,penalty)

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
check = [0]*(N+3)
fail = [0]*(N+3)

wa=0
cnt=0
for i in range(M):
    pi,si=input().split()
    pi = int(pi)
    if si=='AC':
        if check[pi]==0:
            check[pi]=1
    else:
        if check[pi]==0:
            fail[pi]+=1
fa=0
for ans, fail in zip(check, fail):
    if ans>0:
        fa += fail
print(sum(check), fa)

Submission status: Accepted

Solution code:
input1 = input().split()
N = int(input1[0])
M = int(input1[1])
SUBMIT = []

#提出履歴
for i in range(M):
    input2 = list(input().split())
    SUBMIT.append(input2)

#提出状況
CHECK = []

for i in range(N):
    CHECK.append([i+1,0,"yet"])


for i in range(M):
    if SUBMIT[i][1] == "WA":
        if CHECK[int(SUBMIT[i][0]) - 1][2] == "yet":
            CHECK[int(SUBMIT[i][0]) - 1][1] += 1
    else:
        CHECK[int(SUBMIT[i][0]) - 1][2] = "done"
    
result_1 = 0
result_2 = 0

for i in range(N):
    if CHECK[i][2] == "done":
        result_2 += 1
        result_1 += CHECK[i][1]
        
print(result_2,result_1)

Submission status: Accepted

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

uni_p = list(set(p))
AC_numbers = {key:0 for key in uni_p}
WA_numbers = {key:0 for key in uni_p}

for num, res in zip(p, S):
	if res == "WA":
		if AC_numbers[num] != 1:
			WA_numbers[num] += 1

	else:
		AC_numbers[num] = 1

ac = 0
wa = 0
for i in uni_p:
	ac += AC_numbers[i]
	if AC_numbers[i] == 1:
		wa += WA_numbers[i]
	
print(ac, wa)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
AC_list = set()
WA_list = {}
WA = 0
AC = 0
for i in range(M):
    p, S = map(str, input().split())
    p = int(p)

    if S == "AC":
        if p in AC_list:
            continue
        else:
            AC += 1
            AC_list.add(p)
    elif S == "WA":
        if p not in AC_list:
            if p not in WA_list:
                WA_list[p] = 1
            else:
                WA_list[p] += 1
        else:
            continue

for key, val in WA_list.items():
    if key in AC_list:
        WA += val
    else:
        continue

print(AC, WA)

Submission status: Accepted

Solution code:
import math
import itertools
import fractions
import heapq
import collections
import bisect
import sys

sys.setrecursionlimit(10**9)
mod = 998244353
inf = 10**20

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

n,m = LI()

l = [False]*n
c = [0]*n
ans=0
for i in range(m):
    p,s = LS()
    if s=="AC":
        l[int(p)-1]=True

    else:
        if l[int(p)-1]==False:
            c[int(p)-1]+=1

for i in range(n):
    if l[i]:
        ans+=c[i]

print(l.count(True),ans)

Submission status: Accepted

Solution code:
n,m=map(int, input().split())
al=[]
for i in range(m):
    a=list(map(str, input().split()))
    al.append(a)
l_all=[[] for i in range(n)]
for i in range(m):
    l_all[int(al[i][0])-1].append(al[i][1])
ac=0
pn=0
for j in range(n):
    if l_all[j].count('AC')!=0:
        pn+=l_all[j].index('AC')
        ac+=1
print('{} {}'.format(ac,pn))

Submission status: Accepted

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

'''
a = [0] * M
for i in range(M):
    a[i] = [p[i],s[i]]
'''
maru = [0] * (N+1)
batu = [0] * (N+1)

for i in range(M):
    if s[i] == "AC" and maru[p[i]] == 0:
        maru[p[i]] += 1 
    elif s[i] == "AC" and maru[p[i]] != 0:
        continue
    elif s[i] == "WA" and maru[p[i]] != 0:
        continue
    elif s[i] == "WA" and maru[p[i]] == 0:
        batu[p[i]] += 1

batu_ans = 0
for i in range(1, N+1):
    if maru[i] != 0:
        batu_ans += batu[i]

print(sum(maru), batu_ans)

Submission status: Accepted

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

ps = sorted(ps, key=lambda x: x[0])

flag = 0
wa = {}
AC_count = 0
WA_count = 0
for i in range(m):
    if ps[i][0] != flag:
        if ps[i][1] == 'AC':
            AC_count += 1
            if ps[i][0] in wa.keys():
                WA_count += wa[ps[i][0]]
            flag = ps[i][0]
        else:
            if ps[i][0] in wa.keys():
                wa[ps[i][0]] += 1
            else:
                wa[ps[i][0]] = 1
print(AC_count, WA_count)

Submission status: Accepted

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

import numpy as np
p = [0] * m
s = [''] * m
mat=[]

for i in range(m):
    p[i],s[i]=input().split()
    mat.append([p[i],s[i]])

#print(n,m)
#print(p)
#print(s)
#print(mat)

kariwa=[0]*n
wa=[0]*n
anstrue=[False]*n

for i in range(m):
    if mat[i][1] == "WA" and anstrue[int(mat[i][0])-1]==False:
        kariwa[int(mat[i][0])-1]+=1
    elif mat[i][1] == "AC" and anstrue[int(mat[i][0])-1]==False:
        anstrue[int(mat[i][0])-1]=True
        wa[int(mat[i][0])-1]=kariwa[int(mat[i][0])-1]

print(sum(anstrue),sum(wa))

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
d=[ input().split() for i in range(m)]
ans=[[0,0] for i in range(m+n+1)]
count=0
ac=0
wa=0

for i in range(m):
  if count!=d[i][0]:
    count=int(d[i][0])
  if d[i][1]=="WA" and ans[count][0]==0:
    ans[count][1]+=1
  elif d[i][1]=="AC" and ans[count][0]==0:
    ans[count][0]+=1
for i in range(n+m+1):
  ac+=int(ans[i][0])
  if int(ans[i][0])>=1:
    wa+=int(ans[i][1])
print(ac,wa)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
AC = [0 for i in range(N)]
WA = [0 for i in range(N)]
for i in range(M):
    p, v = input().split()
    p = int(p) - 1
    if v == "WA" and AC[p] == 0:
        WA[p] += 1
    elif v == "AC":
        AC[p] = 1

C = sum(AC)
F = 0
for i in range(N):
    if AC[i]: F += WA[i]
print(C, F)

Submission status: Accepted

Solution code:
#N=int(input())
#N,M=map(int, input().split())
#L=list(map(int, input().split()))
N,M=map(int, input().split())
ifACL=[0]*N
cWAL=[0]*N
psL=[]
AC=0
WA=0
p=0
s=0
for _ in range(M):
  p,s=map(str, input().split())
  p=int(p)
  if ifACL[p-1]==0 and s=="WA":
    cWAL[p-1]+=1
  elif ifACL[p-1]==0 and s=="AC":
    AC+=1
    WA+=cWAL[p-1]
    ifACL[p-1]=1

print(AC,WA)

Submission status: Accepted

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

nAC = 0
nWA = 0
result_dic = {}

for i in range(M):
    pi, si = input().split()
    
    if pi not in result_dic.keys():
#         result_dic[pi] = si
        if si == "AC":
            result_dic[pi] = [si,0]
            nAC += 1
        else:
            result_dic[pi] = [si,1]
    else:
        pi_res = result_dic[pi][0]
        if pi_res == "AC":
            pass
        elif pi_res == "WA":
            if si == "AC":
                nWA += result_dic[pi][1]
                nAC += 1
                result_dic[pi] = [si,0]
            elif si == "WA":
                result_dic[pi][1] += 1
#     print(result_dic)

print(nAC,nWA)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
p = []
s = []
seikai = [0]*(n+1)
penalty = [0]*(n+1)

for i in range(m):
    a,b = input().split()#文字
    p.append(int(a))
    s.append(b)

for i in range(m):
    if s[i] == 'AC':
        seikai[p[i]] = 1
    elif s[i] == 'WA' and seikai[p[i]]==0:
        penalty[p[i]] = penalty[p[i]]+1

for i in range(n+1):
    penalty[i] = penalty[i] * seikai[i]

c = sum(seikai)
d = sum(penalty)

print(c, end=' ')
print(d)

Submission status: Accepted

Solution code:
#coding: utf-8

import bisect
import math

N, M = (int(v) for v in input().split())

seen = {}
WA = {}

acs = 0
was = 0

for i in range(M):
    q, tmp = input().split()
    if tmp == "AC":
        if q not in seen:
            acs += 1
            if q not in WA:
                WA[q] = 0
            was += WA[q]
            seen[q] = 1
    else:
        if q not in WA:
            WA[q] = 1
        else:
            WA[q] += 1

print (acs, was)

Submission status: Accepted

Solution code:
n, m = input().split()
a = [False] * int(n)
penalty = [0] * int(n)
AC = 0
WA = 0
for i in range(int(m)):
  p, s = input().split()
  if(s == "AC" and a[int(p) - 1] == False):
    a[int(p) - 1] = True
    WA += penalty[int(p) - 1]
    AC += 1
  if(s == "WA" and a[int(p) - 1] == False):
    penalty[int(p) - 1] += 1

print(AC, WA)

Submission status: Accepted

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

import numpy as np

contest = np.zeros((2, n), dtype=int)

for i in range(m):
  a = list(input().split())
  t_num = int(a[0]) - 1
  if a[1] == "AC":
    if contest[0, t_num] == 0:
      contest[0, t_num] = 1
  else:
    if contest[0, t_num] == 0:
      contest[1, t_num] += 1

contest[1,:] = contest[0,:]*contest[1,:]

ans = np.sum(contest, axis = 1)
print(ans[0], ans[1])

Submission status: Accepted

Solution code:
from sys import stdin as s
n,m=map(int,s.readline().split())
l=[0]*n
wa=[0]*n
cor,pen=0,0
for i in range(m):
  x,y=s.readline().split()
  x=int(x)-1
  if y=="AC":
    l[x]=1
  elif not l[x]:
    wa[x]+=1
for i in range(n):
  if l[i]:
    cor+=1
    pen+=wa[i]
print(cor,pen)

Submission status: Accepted

Solution code:
import string
N,M=map(int,input().split())
A=list(range(N))
B=list(range(N))
for i in range(N):
 A[i]=0
for i in range(N):
 B[i]=0
CL=0
PN=0
for i in range(M):
 P,s=input().split()
 p=int(P)
 if A[p-1]==0:
  if s=="WA":
   B[p-1]+=1
  else:
   CL+=1
   PN+=B[p-1]
   A[p-1]=1
print("{0} {1}".format(CL,PN))

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10000000)

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

ac_set = set()
wa_dict = {}

for i in range(M):
    p, s = input().split()

    #  ACだった時の処理
    if s == 'AC':
        ac_set.add(p)
    elif s == 'WA':
        if p not in ac_set:
            if wa_dict.get(p) is None:
                wa_dict[p] = 1
            else:
                wa_dict[p] += 1
    else:
        pass

ac_count = len(ac_set)
wa_count = 0

for k, v in wa_dict.items():
    if k in ac_set:
        # WAにカウントする
        wa_count += v

print('{} {}'.format(ac_count, wa_count))

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
ans = 0
lstn = [False for i in range(n)]
lstc = [0 for i in range(n)]
for i in range(m):
  p, s = input().split()
  pp = int(p)
  status = lstn[pp-1]
  if not status:
    if s == "WA":
      lstc[pp-1] += 1
    else:
      lstn[pp-1] = True
seikai = lstn.count(True)
for i in range(len(lstn)):
  tf = lstn[i]
  if tf:
    ans += lstc[i]
print(seikai, ans)

Submission status: Accepted

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

p = [int(i[0]) for i in pS]
S = [i[1] for i in pS]

aced = [False for _ in range(N)]
penalty = [0 for _ in range(N)]
# pena = 0

for i in range(M):
    if not aced[int(pS[i][0])-1]:
        if pS[i][1] == 'WA':
            penalty[int(pS[i][0])-1] += 1
            # pena += 1
        if pS[i][1] == 'AC':
            aced[int(pS[i][0])-1] = True

# print(aced.count(True), pena)
penaltyCount = 0
for i in range(N):
    if aced[i]:
        penaltyCount += penalty[i]

print(aced.count(True), penaltyCount)

Submission status: Accepted

Solution code:
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    N, M = map(int, input().split())
    PS = [(int(p), s) for p, s in (input().split() for _ in [0] * M)]

    taka = [['WA', 0] for _ in [0] * (N + 1)]
    for p, s in PS:
        if taka[p][0] == 'AC':
            continue
        taka[p][0] = s
        if s == 'WA':
            taka[p][1] += 1
    ac, wa = 0, 0
    for a, b in taka:
        if a == 'AC':
            ac += 1
            wa += b
    print(ac, wa)


main()

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
P = [0] * M
S = ["a"] * M
flg = [0] * N
C = 0
D = 0
E = [0] * N

for i in range(M):
	tmp, S[i] = map(str, input().split())
	P[i] = int(tmp)

	if S[i]=="AC":
		if flg[P[i]-1]==0:
			C += 1
			flg[P[i]-1] = 1
			E[P[i]-1] = 0
	elif S[i]=="WA":
		if flg[P[i]-1]==0:
			D += 1
			E[P[i]-1] += 1

print(C, D-sum(E))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

def main():
	N,M = inputMap()
	ansrs_AC = [0 for i in range(N)]
	ansrs_WA = [0 for i in range(N)]
	ans1 = 0
	ans2 = 0
	for i in range(M):
		inp = input()
		inp = inp[:-1]
		p, S = inp.split(" ")
		pp = int(p)
		if S == "AC":
			if ansrs_AC[pp-1] == 1:
				continue
			else:
				ansrs_AC[pp-1] = 1
		else:
			if ansrs_AC[pp-1] == 1:
				continue
			else:
				ansrs_WA[pp-1] += 1

	for i in range(N):
		if ansrs_AC[i] == 1:
			ans1 += 1
			ans2 += ansrs_WA[i]
	print("{} {}".format(ans1, ans2))

if __name__ == "__main__":
	main()

Submission status: Accepted

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

tmp = [0] * n
wa = [0] * n
ac = [0] * n

for _ in range(m):
    p, s = input().split()
    p = int(p)
    p = p - 1
    
    # print(p)
    # print(s)
    
    if s == 'WA':
        if ac[p] == 0:
            tmp[p] += 1
        
    if s == 'AC':
        if ac[p] == 0:
            ac[p] = 1
            wa[p] = tmp[p]
        
print("{} {}".format(sum(ac), sum(wa)))

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
#nは問題数　mは提出数（AC_WAの配列長）

p = [0]*m
p_tmp = "0"
s = [0]*m
check = [0]*n
memory_penalty = [0]*n
for i in range(m):
  p_tmp, s[i] = (map(str, input().split()))
  p[i] = int(p_tmp)
  #pは問題No. 　sはAC or WA
  #check[i] = 0 ならwa 1なら既にac
  
for i in range(n):
  check[i] = 0
  memory_penalty[i] = 0
  
num_correct = 0
num_penalty = 0

for i in range(m):
  if( check[ p[i]-1 ] == 0 and s[i] == "WA"):
    memory_penalty[ p[i]-1 ] = memory_penalty[ p[i]-1 ] + 1
  elif( check[ p[i]-1 ] == 0 and s[i] == "AC"):
    num_correct = num_correct + 1
    num_penalty = num_penalty + memory_penalty[ p[i]-1 ]
    check[p[i]-1] = 1

print(num_correct, num_penalty)

Submission status: Accepted

Solution code:
import sys
inputs = sys.stdin.readlines()
n, m = map(int, inputs[0].split())
acs = [0]*n
was = [0]*n
for X in inputs[1:]:
    p, s = X.split()
    p = (int(p)-1)
    if acs[p] == 0:
        if s == 'AC':
            acs[p] = 1
        else:
            was[p] += 1

print(*[sum(acs), sum(w for a, w in zip(acs, was) if a)])

Submission status: Accepted

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

    lst = [[0] for _ in range(N)]
    for i in range(M):
        p, S = input().split()
        p = int(p) -1

        if lst[p][-1] == 0:
            lst[p][-1] = S
        elif lst[p][-1] != 'AC':
            lst[p].append(S)

    clear_count = 0
    penalty_count = 0
    for l in lst:
        if l[-1] == 'AC':
            clear_count += 1
            for j in l:
                if j == 'WA':
                    penalty_count += 1

    print(clear_count, penalty_count)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from collections import defaultdict
n,m=map(int,input().split())
ps=[list(input().split()) for _ in range(m)]
ac=0
wa=0
d=defaultdict(int)
a=defaultdict(int)
for p,s in ps:
  if s=="WA":
    d[p]+=1
  elif s=="AC":
    if a[p]!=1:
      a[p]=1
      ac+=1
      wa+=d[p]
print("{} {}".format(ac,wa))

Submission status: Accepted

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

# ACの個数とACした問題を特定する。
q_a = [0]*N
ans = [0,0]
for i in range(M):
    if S[i] == "AC" and q_a[p[i]-1] == 0:
        q_a[p[i]-1] = 1
        ans[0]+= 1

p_count = 0
i=0
while i<M:
    if q_a[p[i]-1]:
        if S[i] == "WA":
            p_count += 1
        else:
            ans[1] += p_count
            p_count = 0
            q_a[p[i]-1] = 0
    i += 1

print(*ans)

Submission status: Accepted

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

P = []
S = []

clear = 0

q = {}
c = set()

for i in range(M):
    sss = input().split(" ")
    p = int(sss[0])
    s = sss[1]
    P.append(p)
    S.append(s)

    if p not in c:
        if s == "AC":
            clear += 1
            c.add(p)

        if s == "WA":
            q[p] = q.get(p, 0) + 1

warng = sum([
    q[k]
    for k in c
    if k in q
])

print("{} {}".format(clear, warng))

Submission status: Accepted

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

ans = {str(i): [0, 0] for i in range(1, n + 1)}
for i in range(m):
    # p, s = p_list[i], s_list[i]
    p, s = input().split()
    if s == 'WA' and ans[p][0] == 0:
        ans[p][1] += 1
    elif s == 'WA' and ans[p][0] == 1:
        pass
    elif s == 'AC' and ans[p][0] == 0:
        ans[p][0] = 1
    elif s == 'AC' and ans[p][0] == 1:
        pass

sum_ac = 0
sum_wa = 0
for x, y in ans.values():
    sum_ac += x
    if x == 1:
        sum_wa += y

print(sum_ac, sum_wa)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
p = []
s = []
for _ in range(M):
	tp,ts = map(str,input().split())
	p.append(int(tp))
	s.append(ts)

cnt = [0] * (N+1)
flg = [0] * (N+1)
cnt_AC = 0
cnt_WA = 0
for i in range(M):
	cp = p[i]
	if flg[cp] == 1:
		continue
	else:
		if s[i] == 'AC':
			cnt_AC += 1
			cnt_WA += cnt[cp]
			flg[cp] = 1
		else:
			cnt[cp] += 1
print(cnt_AC, end = " ")
print(cnt_WA)

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
ps = []
for i in range(M):
	P,S = map(str,input().split())
	ps.append((int(P),S))
#print(ps)
p_flag = [0]*N
ans_flag = [0]*N
cnt_ans = 0
cnt_p = 0
p_cnt_flag = [0]*N
for i in range(M):
	if(p_flag[ps[i][0]-1] == 0 and ps[i][1] == "WA"):
		p_cnt_flag[ps[i][0]-1]+=1
	if(ans_flag[ps[i][0]-1] == 0 and ps[i][1] == "AC"):
		cnt_ans+=1
		ans_flag[ps[i][0]-1]+=1
		p_flag[ps[i][0]-1]+=1
		cnt_p+=p_cnt_flag[ps[i][0]-1]
print(cnt_ans,cnt_p)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
question_list = []
score_list = []

for i in range(M):
  q,s = input().split()
  question_list.append(int(q))
  score_list.append(s)

maru_flag = [0] * N
pena_flag = [0] * N
for i in range(M):
  if score_list[i] == "AC":
    maru_flag[question_list[i] - 1] = 1

  if maru_flag[question_list[i] - 1] != 1 and score_list[i] == "WA":
    pena_flag[question_list[i] - 1] += 1

for i in range(N):
  if maru_flag[i] != 1 and pena_flag[i] > 0:
    pena_flag[i] = 0

print(str(sum(maru_flag)) + " " + str(sum(pena_flag)))

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
p=[]
s=[]
for c in range(m):
    k=input().split()
    p.append(int(k[0])-1)
    s.append(k[1])
a=[0]*n
w=[0]*n
for c in range(m):
    if a[p[c]]==1:
        continue
    if s[c]=="AC":
        a[p[c]]=1
    else:
        w[p[c]]+=1
u=0
for c in range(n):
    if a[c]==1:
        u+=w[c]
print(sum(a),u)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N,M=map(int,input().split())
pSlist=[0]*(N+1)
ansA=0
ansWA=0
for i in range(M):
    p,S=map(str,input().split())
    p=int(p)
    if S=="WA" and pSlist[p]!=-1:
        pSlist[p]=pSlist[p]+1
    elif S=="AC" and pSlist[p]!=-1:
        ansA=ansA+1
        ansWA=ansWA+pSlist[p]
        pSlist[p]=-1
print(ansA,ansWA)

Submission status: Accepted

Solution code:
_,M = map(int,input().split())
result = {}
for i in range(M):
    P, Q = input().split()
    if P not in result:
        result[P] = [Q]
    else:
        if result[P][-1]=='AC':
            pass
        else:
            result[P].append(Q)
AC = 0
WA = 0
numbers = list(result.values())
for i in range(len(numbers)):
    AC += numbers[i].count('AC')
    if numbers[i][-1]=='WA':
        pass
    else:
        WA += numbers[i].count('WA')
        
print(AC,WA)

Submission status: Accepted

Solution code:
from operator import itemgetter

n, m = map(int, input().split())

an = [0]*n

sc = 0
er = 0

for i in range(m):
    t, s = map(str, input().split())
    p = int(t)-1
    if (an[p] != m+1 and s == "AC"):
        sc += 1
        er += an[p]
        an[p] = m+1
    elif (an[p] != m+1 and s == "WA"):
        an[p] += 1


print("{} {}".format(sc, er))

Submission status: Accepted

Solution code:
n,m=[int(x) for x in input().split()]
a=[0 for _ in range(n)]
b=[0 for _ in range(n)]
xg=0
for _ in range(m):
  p,q=input().split()
  #print(p,q)
  if q=="AC": 
    #print("fir")
    rg=a[int(p)-1]
    if rg==0: a[int(p)-1]=1; xg+=b[int(p)-1]
  else : 
    #print("sec")
    b[int(p)-1]+=1
print(sum(a),xg)

Submission status: Accepted

Solution code:
# 問題数と提出数
input_data = input().split()
n, m = map(int, input_data)

# 正解状況のリスト
col_list = [0 for i in range(n)]
penal_list = [0 for i in range(n)]

# 正解回数
col = 0
# 不正解数
penal = 0

# 提出数分取得
for i in range(m):
  input_data = input().split()
  
  # チェックする問題
  chk_index = int(input_data[0]) - 1
  
  # 正解済みのため、チェックしない
  if(col_list[chk_index] == 1):
    continue
  if(input_data[1] == "AC"):
    col_list[chk_index] = 1
  else:
    penal_list[chk_index] += 1

# 正解,不正解
for i,v in enumerate(col_list):
  if(v == 1):
    col += 1
    penal += penal_list[i]
# 出力
print(str(col) + " " + str(penal))