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())
PS=[list(input().split()) for _ in range(M)]

miss=[[0,False] for _ in range(N)]

for p,s in PS:
  p=int(p)
  if miss[p-1][1]==False and s=="WA":
    miss[p-1][0]+=1
  if s=="AC":
    miss[p-1][1]=True
pena=0
ac=0
for m,tf in miss:
  pena+=m*tf
  ac+=tf

print(str(ac)+" "+str(pena))

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
fin=set()
AC=0
WA=0
WAL=[0]*N
for i in range(M):
  p,s=input().split()
  p=int(p)
  if not p in fin:
    if s=="AC":
      AC+=1
      fin.add(p)      
    if s=="WA":
      WAL[p-1]+=1
for k in fin:
  WA+=WAL[k-1]
print(AC,WA)

Submission status: Accepted

Solution code:
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

acs = set()
wcs = dict()
wc = 0

n,m = nm()
for i in range(m):
  p,s = input().split()
  if s == 'AC':
    if p not in acs:
      if p in wcs:
        wc+=wcs[p]
    acs.add(p)
  elif p not in acs:
    if p not in wcs:
      wcs[p]=0
    wcs[p]+=1

print(len(acs))
print(wc)

Submission status: Accepted

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

num = [0]*n
flag = [False]*n

for _ in range(m):
  p,s = input().split()
  p = int(p)-1
  if flag[p]:
    continue
  else:
    if s == "AC":
      flag[p] = True
    else:
      num[p] += 1

for i in range(n):
  if flag[i] == False:
    num[i] = 0
    
print(flag.count(True),sum(num))

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
P,S=[],[]
ans,pen=0,0
task=[0]*N
for _ in range(M):
    A,B=map(str,input().split())
    P.append(int(A))
    S.append(B)

for j in range(M):
    if task[P[j]-1]!=-1 and S[j]=="WA":
        task[P[j]-1]+=1
    elif task[P[j]-1]!=-1 and S[j]=="AC":
        ans+=1
        pen+=task[P[j]-1]
        task[P[j]-1]=-1
print(ans,pen)

Submission status: Accepted

Solution code:
from collections import defaultdict
n,m = map(int,input().split())
l = [input().split() for _ in range(m)]
d = defaultdict(int)
count1=0 #正解数
count2=0 #ペナルティ数
for i in l:
    if i[1]=="WA" and d[i[0]]!= "OK":
        (d[i[0]]) += 1
    if i[1] =="AC"and d[i[0]]!= "OK":
        count1 += 1
        count2 += int(d[(i[0])])
        d[i[0]] ="OK"
print(count1,count2)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
counts = [0] * n
ac = 0
penalty = 0
for _ in range(m):
    p, s = input().split()
    p = int(p) - 1
    if counts[p] == -1:
        continue
    if s == 'WA':
        counts[p] += 1
    else:
        ac += 1
        penalty += counts[p]
        counts[p] = -1

print(ac, penalty)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
flag = [False]*n
wa = [0]*n
penalty = 0
corr = 0
for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    if s == 'AC':
        if flag[p]:
            continue
        else:
            corr += 1
            flag[p] = True
    else:
        if not flag[p]:
            wa[p] += 1
for j in range(n):
    if flag[j]:
        penalty += wa[j]

print(corr, penalty)

Submission status: Accepted

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

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

wasum=0
for i in range(n):
  if ac[i]==1:
    wasum+=wa[i]

print(sum(ac),wasum)

Submission status: Accepted

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

ac=[None]*n
wa=[0]*n
wa_cnt=0

for i in range(m):
    if ac[int(ps[i][0])-1]==None and ps[i][1]=='AC':
        ac[int(ps[i][0])-1]=1
        wa_cnt+=wa[int(ps[i][0])-1]
    elif ac[int(ps[i][0])-1]==None and ps[i][1]=='WA':
        wa[int(ps[i][0])-1]+=1
print(ac.count(1), wa_cnt)

Submission status: Accepted

Solution code:
N, M = map(int,input().split()) 
p = [0]*M
S = [0]*M
T = [0]*(N+1) 
U = [0,0]
for i in range(M):
  p[i],S[i] = input().split()
  P = int(p[i])
  if T[P] != -1:
    if S[i] == 'WA':
      T[P] += 1
    elif S[i] == 'AC':
      U[0] += 1
      U[1] += T[P]
      T[P] = -1


print(U[0],U[1])

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(m):
    p, s = input().split()
    p = int(p)
    if s == "AC":
        if ACc[p - 1] == 0:
            ACc[p - 1] += 1
    else:
        if ACc[p - 1] != 1:
            WAc[p - 1] += 1
for j in range(n):
    if ACc[j] == 0:
        WAc[j] = 0

print(sum(ACc), sum(WAc))

Submission status: Accepted

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

for i in range(m):
    p,s = input().split()
    p = int(p)
    if s == "AC":
        if ACc[p-1] == 0:
            ACc[p-1] += 1
    else:
        if ACc[p-1] != 1:
            WAc[p-1] += 1
for j in range(n):
    if ACc[j] == 0:
        WAc[j] = 0

print(sum(ACc),sum(WAc))

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
num = [1]*(n + 1)
pena = [0]*(n + 1)
AC_cnt = 0
WA_cnt = 0
for i in range(m):
    p,s=input().split()
    if s == 'AC':
        if num[int(p)]:
            num[int(p)] = 0
            AC_cnt += 1
            WA_cnt += pena[int(p)]
    else:
        pena[int(p)] += 1
print(AC_cnt,WA_cnt)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
ACs = [False]*N
WAs = [0]*N
for i in range(M):
  sp, S = input().split()
  p = int(sp)-1
  if S == "AC":
    ACs[p] = True
  elif S == "WA":
    if not ACs[p]:
      WAs[p] += 1
r1 = 0
r2 = 0
for i in range(N):
  if ACs[i]:
    r1 += 1
    r2 += WAs[i]
print(r1, r2)

Submission status: Accepted

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


correct = 0
penalty = 0
true_flag = [True] * (10 ** 5)
d = {}

for p, s in ps:
    p = int(p)

    # 初回でACのときはスルー
    if p not in d and s == 'AC':
        d[p] = 1
        correct += 1
        true_flag[p] = False
    # 2回目以降でACのときpenaltyを加算
    if not true_flag[p]:
        continue  # 「trueだったら以下の処理を行う」を裏返してこう書けばネストが1つ減らせる

    if s == 'AC':
        penalty += d[p]
        correct += 1
        true_flag[p] = False
    # WAのときはdに追加していく
    elif p not in d:
        d[p] = 1
    else:
        d[p] += 1

print(correct, penalty)

Submission status: Accepted

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

Submission status: Accepted

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


correct = 0
penalty = 0
true_flag = [True] * (10 ** 5)
d = {}

for p, s in ps:
    p = int(p)

    # 初回でACのときはスルー
    if p not in d and s == 'AC':
        d[p] = 1
        correct += 1
        true_flag[p] = False
        # print('hoge1')
        # print(flag)
    # 2回目以降でACのときpenaltyを加算
    if true_flag[p]:
        if s == 'AC':
            penalty += d[p]
            correct += 1
            true_flag[p] = False
            # print('hoge2')
            # print(flag)
        # WAのときはdに追加していく
        else:
            if p not in d:
                d[p] = 1
                # print('hoge3')
                # print(flag)
            else:
                d[p] += 1
                # print('hoge4')
                # print(flag)

print(correct, penalty)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
ans = 0
pen = 0
w = [0]*(N+1)
ac = [False]*(N+1)
for _ in range(M):
    p, s = input().split()
    if s == "AC" and not ac[int(p)]:
        pen += w[int(p)]
        ac[int(p)] = True
        ans += 1
    elif s == "WA":
        w[int(p)] += 1
print(ans, pen)

Submission status: Accepted

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

baselis = []

for _ in range(M):
    temp = [x for x in input().split()]
    baselis.append(temp)

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

for i in range(M):
    result = baselis[i][1]
    question = int(baselis[i][0])

    if result == 'AC' and ac[question] == 0:
        ac[question] = 1
    elif result == 'WA' and ac[question] == 0:
        wa[question] += 1

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

print(sum(ac), sum(wa))

Submission status: Accepted

Solution code:
N, M = map(int,input().split())
ac = [False] * N
wa = [0] * N
for _ in range(M):
    p_, s_ = map(str,input().split())
    p = int(p_)-1
    if s_ == 'AC':
        ac[p] = True
    else:
        if not ac[p]:
            wa[p] += 1

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,M = list(map(int,input().split()))
PS = [input().split() for _ in range(M)]
status = {i[0]:[False,0] for i in PS}
countac = 0
countwa = 0
for ps in PS:
    if ps[1] == 'AC':
        if status[ps[0]][0] == False:
            status[ps[0]][0] = True
            countac += 1
            countwa += status[ps[0]][1]
    else:
        if status[ps[0]][0] == False:
            status[ps[0]][1] += 1
print(str(countac)+' '+str(countwa))

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
a=[[] for ii in range(n)]
for ii in range(m):
  p,s=input().split()
  p=int(p)-1
  a[p].append(s)
r=0
q=0
for ii in range(n):
  #print(a[ii])
  if "AC" in a[ii]:
    r+=1
    q+=a[ii].index("AC")
print(r,q)

Submission status: Accepted

Solution code:
import collections,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
N,M = LI()
pS = [LS() for _ in range(M)]
set_AC = set()
count_WA = collections.defaultdict(int)
ans_AC,ans_WA = 0,0
for x in pS:
    p,S = int(x[0]),x[1]
    if p in set_AC:
        continue
    if S=='AC':
        set_AC.add(p)
        ans_AC += 1
        ans_WA += count_WA[p]
    else:
        count_WA[p] += 1
print(ans_AC,ans_WA)

Submission status: Accepted

Solution code:
import collections,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
N,M = LI()
pS = [LS() for _ in range(M)]
count_AC = collections.defaultdict(int)
count_WA = collections.defaultdict(int)
for x in pS:
    p,S = int(x[0]),x[1]
    if p in count_AC:
        continue
    if S=='AC':
        count_AC[p] += 1
    else:
        count_WA[p] += 1
print(sum(count_AC.values()),sum([count_WA[k] for k in count_AC]))

Submission status: Accepted

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

ans_dic = {}
pen_dic = {}
for ps in ps_list:
    p = int(ps[0])
    ans_dic[p] = 0
    pen_dic[p] = 0
ans = 0
pen = 0

for ps in ps_list:
    p, s = ps
    p = int(p)
    if s == 'AC':
        if ans_dic[p] == 0:
            ans += 1
            pen += pen_dic[p]
        ans_dic[p] = 1
    elif s == 'WA':
        pen_dic[p] += 1

print(ans, pen)

Submission status: Accepted

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

ac=[True]*n
d=[0]*n
tw=0
ta=0
for i in a:
  j=int(i[0])-1
  if (ac[j]):
    if (i[1]=="WA"):
      d[j]+=1
    else :
      tw+=d[j]
      ta+=1
      ac[j]=False
print(ta,tw)

Submission status: Accepted

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

Submission status: Accepted

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


# 入力を整数に変換して受け取る
def input_int():
    return int(input())


# マイナス1した値を返却
def int1(x):
    return int(x) - 1


# 半角スペース区切り入力をIntに変換してMapで受け取る
def input_to_int_map():
    return map(int, input().split())


# 半角スペース区切り入力をIntに変換して受け取る
def input_to_int_tuple():
    return tuple(map(int, input().split()))


# 半角スペース区切り入力をIntに変換してマイナス1した値を受け取る
def input_to_int_tuple_minus1():
    return tuple(map(int1, input().split()))


def main():
    n, m = input_to_int_map()
    ps = [input().split() for i in range(m)]

    success_cnts = [0] * (n + 1)
    wrong_cnts = [0] * (n + 1)

    for p, s in ps:
        if success_cnts[int(p)] > 0:
            continue

        if s == "AC":
            success_cnts[int(p)] += 1
        elif s == "WA":
            wrong_cnts[int(p)] += 1

    success_cnt = 0
    wrong_cnt = 0
    for i, success in enumerate(success_cnts):
        if success > 0:
            success_cnt += 1
            wrong_cnt += wrong_cnts[i]

    print(" ".join([str(success_cnt), str(wrong_cnt)]))


if __name__ == "__main__":
    main()

Submission status: Accepted

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

ac = [False] * N
wa = [0] * N
for _ in range(M):
    q, res = input().split()
    q = int(q) - 1
    if res == 'AC':
        ac[q] = True
    else:
        if not ac[q]:
            wa[q] += 1

num_corr, num_wro = 0, 0
for q in range(N):
    if ac[q]:
        num_corr += 1
        num_wro += wa[q]

print(num_corr, num_wro)

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
AC = 0
WA = 0
tmp_WA = [0]*N
lst = []
for _ in range(M):
    lst.append(list(input().split()))
#print(lst)

#ques = [[0,0]]*N # lest:AC right:WA
ques = [0]*N
#print(ques)

#tries = []
for i in range(M):
#    print(lst[i] in tries)
#    tries.append(lst[i])
    if ques[int(lst[i][0])-1] != 1:
        if lst[i][1] == 'WA':
            tmp_WA[int(lst[i][0])-1] += 1
        else:
            AC += 1
            ques[int(lst[i][0])-1] = 1
for j in range(N):
    if ques[j] != 1:
        tmp_WA[j] = 0

print(str(AC) + ' ' + str(sum(tmp_WA)))

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
ac_c = [False]*(n+1)
wa_c = [0]*(n+1)

for i in range(m):
    p,s=input().split()
    p = int(p)
    if(ac_c[p]):
        continue
    if(s=='WA'):
        wa_c[p] += 1
    if(s=='AC'):
        ac_c[p] = True

wa_ans = 0
for i in range(1,n+1):
    if(ac_c[i]):
        wa_ans += wa_c[i]
print(sum(ac_c),wa_ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

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

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

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
dicts = {key: [False,0] for key in range(1, n+1)}
for i in range(m):
    p, s = input().split()
    p = int(p)
    if s == "AC":
        dicts[p][0] = True
        continue
    else:
        if dicts[p][0]==True:
            continue
        else:
            dicts[p][1] += 1
ans_list = [v[1] for k, v in dicts.items() if v[0]==True]
ans_n = len(ans_list)
penal = sum(ans_list)
print(ans_n,penal)

Submission status: Accepted

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

AC, WA = [0] * n, [0] * n

ac, wa = 'AC', 'WA'

for i in range(m):
    if L[i][1] == ac and AC[int(L[i][0]) - 1] == 0:
        AC[int(L[i][0]) - 1] = 1
    elif L[i][1] == wa and AC[int(L[i][0]) - 1] == 0:
        WA[int(L[i][0]) - 1] += 1
sum_ac, sum_wa = 0, 0
for i in range(n):
    sum_ac += AC[i]
    if AC[i] > 0:
        sum_wa += WA[i]
print(sum_ac, end = ' ')
print(sum_wa)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
dicts = {key: [False,0] for key in range(1, n+1)}

for i in range(m):
    p, s = input().split()
    p = int(p)
    if s == "AC":
        dicts[p][0] = True
        continue
    else:
        if dicts[p][0]==True:
            continue
        else:
            dicts[p][1] += 1
        
ans_list = [v[1] for k, v in dicts.items() if v[0]==True]
ans_n = len(ans_list)
penal = sum(ans_list)
print(ans_n, penal)

Submission status: Accepted

Solution code:
import sys
from io import StringIO
import unittest


def resolve():
    N, M = [int(i) for i in input().split()]
    pp = []
    SS = []
    for _ in range(M):
        p, s = [i for i in input().split()]
        pp.append(int(p))
        SS.append(s)
    AC = 0
    WA = 0
    WAtmp = {}
    flgs = [False] * N
    for i in range(M):
        if not flgs[pp[i] - 1]:
            if SS[i] == "AC":
                AC += 1
                flgs[pp[i] - 1] = True
                if pp[i] - 1 in WAtmp.keys():
                    WA += WAtmp[pp[i] - 1]
            else:
                if pp[i] - 1 in WAtmp.keys():
                    WAtmp[pp[i] - 1] += 1
                else:
                    WAtmp[pp[i] - 1] = 1

    print(AC, WA)


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """2 5
1 WA
1 AC
2 WA
2 AC
2 WA"""
        output = """2 2"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """100000 3
7777 AC
7777 AC
7777 AC"""
        output = """1 0"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """6 0"""
        output = """0 0"""
        self.assertIO(input, output)

    def test_入力例_n(self):
        input = """3 5
1 WA
1 AC
2 WA
2 AC
3 WA"""
        output = """2 2"""
        self.assertIO(input, output)


if __name__ == "__main__":
    # unittest.main()
    resolve()

Submission status: Accepted

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

Submission status: Accepted

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

ac_list=[]
ac_flags=[False]*n
wa_count=[0]*n
penalty = 0

for i in range(m):
    pi,si=input().split()
    pi=int(pi)
    if si=='AC':
        if ac_flags[pi-1]==False:
            ac_list.append(pi-1)
            penalty += wa_count[pi-1]
            ac_flags[pi-1]=True
    else:
        wa_count[pi-1]+=1

print(len(ac_list),penalty)

Submission status: Accepted

Solution code:
import collections

N, M = map(int, input().split())
ac = 0
wa = 0
aced = set()
dic = collections.defaultdict(lambda:0)
for _ in range(M):
  p, s = input().split()
  if s == 'WA' and p not in aced:
    dic[p] += 1
  elif s == 'AC' and p not in aced:
    aced.add(p)
    ac += 1
    if p in dic:
      wa += dic[p]

print(ac, wa)

Submission status: Accepted

Solution code:
n,m= list(map(int, input().split()))
ans_box=[0]*n
wa=[0]*n
ac=0
wa_cnt=0
for j in range(m):
    k,l=input().split()
    h=int(k)-1
    if ans_box[h]==0:
        if l=="AC":
            ac+=1
            ans_box[h]+=1
            wa_cnt+=wa[h]
        else:
            wa[h]+=1
print(ac,wa_cnt)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
d = {}
cnt_ac = 0
cnt_wa = 0
for _ in range(m):
    p, s = input().split()
    if p not in d:
        d[p] = [s]
    else:
        d[p].append(s)
for i in d:
    if 'AC' in d[i]:
        cnt_ac += 1
        cnt_wa += d[i].index('AC')
print(cnt_ac, cnt_wa)

Submission status: Accepted

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

AC_count = 0
WA_count = 0
WA_count_dict = {}
is_not_AC = {}

for m in range(M):
    p, S = input().split()
    p = int(p)
    
    if p not in is_not_AC.keys():
        is_not_AC[p] = True
        WA_count_dict[p] = 0
        
    if is_not_AC[p]:
        if S=="WA":
            WA_count_dict[p] += 1
        else:
            AC_count += 1
            is_not_AC[p] = False
            
for k in is_not_AC.keys():
    if is_not_AC[k] == False:
        WA_count += WA_count_dict[k]

print(AC_count, WA_count)

Submission status: Accepted

Solution code:
import sys
stdin=sys.stdin

ns = lambda:stdin.readline().rstrip()
ni = lambda:int(stdin.readline().rstrip())
nm = lambda:map(int,stdin.readline().split())
nl = lambda:list(map(int,stdin.readline().split()))

N,M=nm()
Al=[0]*N
Wl=[0]*N
ac=0
wa=0
for i in range(M):
    tmp1,tmp2=map(str,stdin.readline().split())
    p=int(tmp1)-1
    s=tmp2
    if(s=='AC'):
        Al[p]+=1
        if(Al[p]==1):
            ac+=1
            wa+=Wl[p]
    else:
        Wl[p]+=1

ans=[ac,wa]
print(*ans)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
hist = [0]*n
pena = 0
collect = 0
for i in range(m):
    p, s = input().split()
    p = int(p)
    p -= 1
    if hist[p] != -1 and s == "WA":
        hist[p] += 1
    if hist[p] != -1 and s == "AC":
        pena += hist[p]
        hist[p] = -1

print(hist.count(-1),pena)

Submission status: Accepted

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

ac = 0
pena = [0]*n
flag = [False]*n

for pe, se in zip(p, s):
    if se == "AC":
        flag[pe-1] = True
    else:
        if flag[pe-1] is False:
            pena[pe-1] += 1

psum = 0
for i in range(n):
    if flag[i]:
        ac += 1
        psum += pena[i]

print(ac, psum)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
N,M = map(int, input().split())
List = [list(input().split()) for i in range(M)]

ACList=[0]*N
WAList=[0]*N

i=0
while i<M:
    if List[i][1]=="AC":
        ACList[int(List[i][0])-1]=1
    if List[i][1]=="WA" and ACList[int(List[i][0])-1]==0:
        WAList[int(List[i][0])-1]+=1
    i+=1

j=0
while j<len(WAList):
    if ACList[j]!=1 and WAList[j]!=0:
        WAList[j]=0
    j+=1

print(sum(ACList),sum(WAList))

Submission status: Accepted

Solution code:
import numpy as np
N, M = map(int, input().split())
AC = np.array([0]*N)
WA = np.array([0]*N)

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

print(sum(AC), sum(AC*WA))

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
pl, sl = [], []

for i in range(m):
    p, s = map(str, input().split())
    pl.append(int(p))
    sl.append(s)

ac_F = [False] * (n + 1)
acc = 0
pena = [0] * (n+1)

for i in range(m):
    if sl[i] == "AC":
        if not ac_F[pl[i]]:
            acc += 1
            ac_F[pl[i]] = True
    else:
        if not ac_F[pl[i]]:
            pena[pl[i]] += 1

penac = 0
for i in range(n+1):
    if ac_F[i]:
        penac += pena[i]

print(acc, penac)

Submission status: Accepted

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

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

for i in range(m):
    if ps[i][1]=='WA' and ac[int(ps[i][0])-1]==0:
        wa[int(ps[i][0])-1]+=1
    else:
        if ac[int(ps[i][0])-1]==0:
            ac[int(ps[i][0])-1]+=1
        else:
            pass

ac_num=0
wa_num=0

for i in range(n):
    if ac[i]==1:
        ac_num+=1
        wa_num+=int(wa[i])

print(ac_num,wa_num)

Submission status: Accepted

Solution code:

n,m=map(int,input().split())
ps=[list(input().split()) for i in range(m)]
pen=[0]*n#ペナ数
rig=[0]*n#ACorWA

for i in range(m):
    if ps[i][1]=="AC":
        rig[int(ps[i][0])-1]=1
    else:
        if rig[int(ps[i][0])-1]==0:
            pen[int(ps[i][0])-1]+=1
cnt1,cnt2=0,0
for i in range(n):
    if rig[i]==1:
        cnt1+=rig[i]
        cnt2+=pen[i]

print(str(cnt1)+" "+str(cnt2))

Submission status: Accepted

Solution code:
n, m = list(map(int, input().split()))
S = [input().split() for _ in range(m)]
S = [[int(s[0]), s[1]] for s in S]
ac = [0] * n
wa = [0] * n
for s in S:
    if s[1] == 'AC':
        ac[s[0] - 1] = 1
        continue
    elif ac[s[0] - 1] == 0:
        wa[s[0] - 1] += 1
        continue
wa = [0 if ac[i] == 0 else wa[i] for i in range(n)]
ans = ' '.join(list(map(str, [sum(ac), sum(wa)])))
print(ans)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
WA = [0] * n
AC = [0] * n

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

for i in range(n):
    WA[i] = 0 if AC[i] == 0 else WA[i]

print(sum(AC), sum(WA))

Submission status: Accepted

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

# check
AC_questions = {}
for i in range(M):
    P, S = map(str, input().split())

    if P not in AC_questions:
        AC_questions[P] = {
            "wa_cnt": 0,
            "ac": False
        }

    if AC_questions[P]["ac"] is True:
        continue
    elif S == "AC":
        AC_questions[P]["ac"] = True
    # S == "WA"
    else:
        AC_questions[P]["wa_cnt"] += 1

# 「高橋君のペナルティ数は、高橋君が AC を 1回以上出した各問題において、初めて AC を出すまでに出した WA の数の総和」
# →そもそも不正解の問に関してはカウントしないと読み取る必要がある
target_keys = [key for key in AC_questions.keys() if AC_questions[key]['ac'] is True]
AC_cnt = sum([1 for key in target_keys])
WA_cnt = sum([AC_questions[key]["wa_cnt"] for key in target_keys])

print(AC_cnt, WA_cnt)

Submission status: Accepted

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

# check
AC_questions = {}
for i in range(M):
    P, S = map(str, input().split())

    if P not in AC_questions:
        AC_questions[P] = {
            "wa_cnt": 0,
            "ac": False
        }

    if AC_questions[P]["ac"] is True:
        continue
    elif S == "AC":
        AC_questions[P]["ac"] = True
    # S == "WA"
    else:
        AC_questions[P]["wa_cnt"] += 1

AC_cnt = sum([1 for key in AC_questions.keys() if AC_questions[key]['ac'] is True])
WA_cnt = sum([AC_questions[key]["wa_cnt"] for key in AC_questions.keys() if AC_questions[key]["ac"] is True])

print(AC_cnt, WA_cnt)

Submission status: Accepted

Solution code:
import numpy as np

def solve():
    dp = np.zeros((2, N+1))
#    print(dp)
    ac = 0
    wa = 0
    for i in range(M): 
        if (dp[0][S[i][0]] == 0):
            if(S[i][1] == "WA"):
                dp[1][S[i][0]] += 1
            elif(S[i][1] == "AC"):
                ac += 1
                dp[0][S[i][0]] = 1
                wa += dp[1][S[i][0]]
    print(ac, int(wa))

if __name__=="__main__":

    N, M = list(map(int, input().split()))
    S = []
    for i in range(M):
        a,b = input().split()
        S.append([int(a), b])
#    print(S)
    
    solve()

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
correct = [False] * N
penalty = [0] * N

sum_AC, sum_WA = 0, 0
for i in range(M):
    p, s = input().split()
    p = int(p) - 1
    if correct[p]:
        continue
    if s == "AC":
        correct[p] = True
        sum_AC += 1
        sum_WA += penalty[p]
    else:
        penalty[p] += 1

print(sum_AC, sum_WA)

Submission status: Accepted

Solution code:
n,m=map(int, input().split())
h = [list(map(str,input().split())) for _ in range(m)]
# print(h)
for i in range(m):
    h[i][0] = int(h[i][0])
l=set()
penalty = 0
import numpy as np
p = np.zeros(n)
for i in range(m):
    if h[i][0] not in l:
        if h[i][1] == 'AC':
            l.add(h[i][0])
            penalty += p[h[i][0]-1]
        else:
            p[h[i][0]-1] += 1
ansnum = len(l)

# for i in l:
#     penalty += p[i-1]

print(ansnum,int(penalty))

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
acset=set()
finacset=set()
penalty=0
pslist=[]

for i in range(m):
	p,s=input().split()
	p=int(p)
	pslist.append([p,s])
	
	if s == "AC":
		finacset.add(p)

for ps in pslist:
	p=ps[0]
	s=ps[1]
	
	if s == "AC":
		acset.add(p)
	else:
		if p in finacset and not p in acset:
			penalty += 1

output=[str(len(acset))," ",str(penalty)]
print("".join(output))

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
ps = [input().split() for _ in range(M)]
passed = [0]*(N+1)
cnt = [0]*(N+1)
ac_num = 0
wa_num = 0

for p, s in ps:
  p = int(p)
  if s == "WA":
    cnt[p] += 1
  elif s == "AC" and passed[p] == 0:
    wa_num += cnt[p]
    ac_num += 1
    passed[p] = 1

print(ac_num, wa_num)

Submission status: Accepted

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

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

for p, s in ps:
    i = int(p)
    if s == "WA":
        if ac[i] != 1:
            wa[i] += 1
    else:
        if ac[i] != 1:
            ac[i] = 1

print(sum(ac), sum(wa[i] * ac[i] for i in range(n + 1)))