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())

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

for i in range(m):
  p, s = input().split()
  if s == "AC":
    if ac[int(p)-1] == 0:
      ac[int(p)-1] += 1
  if s == "WA":
    if ac[int(p)-1] != 1:
      wa[int(p)-1] += 1
      
sum_ac = sum(ac)
sum_wa = 0
for i in range(n):
  if ac[i] == 1:
    sum_wa += wa[i]
    
print(sum_ac, sum_wa)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
ac_count=[0]*n
wa_count=[0]*n
ac=0
wa=0
for i in range(m):
  p,s=input().split()
  p=int(p)-1
  if s=="AC" and ac_count[p]==0:
    ac_count[p]=1
    ac+=1
    wa+=wa_count[p]
  elif s[0]=="W":
      wa_count[p]+=1
print(ac,wa)

Submission status: Accepted

Solution code:
N, M = list(map(int, input().split()))
ac = [0]*N
wrong = [0]*N
ans = 0
for i in range(M):
  temp = input().split()
  if temp[1] == "AC":
    ac[int(temp[0])-1] = 1
  elif ac[int(temp[0])-1] ==0:
    wrong[int(temp[0])-1] += 1

for i in range(N):
  if ac[i]==1:
    ans += wrong[i]
  
print(str(sum(ac)) + " " + str(ans))

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
ans=['WA' for i in range(N)]
crt=0
mis=0
A=[0 for i in range(N)]
for i in range(M):
    p,S=map(str,input().split())
    if ans[int(p)-1]=='WA':
        if S=='WA':
            A[int(p)-1]+=1
        else:
            crt+=1
            ans[int(p)-1]='AC'
            mis+=A[int(p)-1]
    else:
        continue
print(crt,mis)

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
dic = {}
ans = 0
for i in range(M):
    p,s = input().split()
    if s == "AC":
        if p in dic:
            ans += dic[p]
        dic[p] = 0
    else:
        if p in dic:
            if dic[p] != 0:
                dic[p] += 1
        else:
            dic[p] = 1

print(len([1 for i in dic.values() if i==0]),ans)

Submission status: Accepted

Solution code:
N,M =  map(int,input().split())
n = [[] for i in range (N)]
for i in range(M):
  p,S = input().split()
  p = int(p)-1
  n[p].append(S)
ans = 0
ac = 0
for j in n:
  count=0
  for i in j:
    if i=="WA":
      count+=1
    else:
      ans+=count
      ac+=1
      break
print(ac,ans)

Submission status: Accepted

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

ac=0
wa=0
for i,a in enumerate(probs):
    if a == True:
        ac+=1
        wa+=wrongs[i]
print(ac,wa)

Submission status: Accepted

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

m = [0]*(N+1)
r = [0]*(N+1)
for i in range(M):
    p,S = input().split()
    p = int(p)
    if r[p] == 0:
        if S == "WA":
            m[p] += 1
        else:
            r[p] = 1
mistake = sum([r[i]*m[i] for i in range(N+1)])
print(sum(r),mistake)

Submission status: Accepted

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

penal = [0] * n
check = [0] * n

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

Check = 0
Penal = 0
for i in range(n):
    Check += check[i]
    if check[i] == 1:
        Penal += penal[i]
print(Check, Penal)

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
ac = [False]*n
count = [0]*n
a=0
b=0
for _ in range(m):
    p,s = input().split()
    if s == 'AC':
        if ac[int(p)-1]==False:
            ac[int(p)-1]=True
            a+=1
            b+=count[int(p)-1]
    else:
        if ac[int(p)-1]==False:
            count[int(p)-1]+=1
            
print(str(a)+' '+str(b))

Submission status: Accepted

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

for _ in range(m):
    P,S=map(str,input().split()) 
    p=int(P)-1
    if AC[p]==1:
        continue 
    else:
        if S=="AC":
            AC[p]=1 
            penalty2[p]=penalty1[p]
        else:
            penalty1[p]+=1 
            
print(sum(AC),sum(penalty2))

Submission status: Accepted

Solution code:
def main():
    N, M = list(map(int, input().split(' ')))
    accepted = [0 for _ in range(N)]
    wa_count = [0 for _ in range(N)]
    for _ in range(M):
        p, S = input().split(' ')
        p = int(p) - 1
        if accepted[p] == 1:
            continue
        # non-accepted cases
        if S == 'WA':
            wa_count[p] += 1
        else:
            accepted[p] = 1
    score = sum(accepted)
    penalty = sum([is_ac * wa for is_ac, wa in zip(accepted, wa_count)])
    print('{} {}'.format(score, penalty))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

no = [0] * (N + 1)
ok = 0
x = 0
for i in range(M):
    p, s = input().split()
    p = int(p)
    if s == 'AC' and no[p] != -1:
        ok += 1
        x += no[p]
        no[p] = -1
    elif s == 'WA' and no[p] != -1:
        no[p] += 1

print(ok, x)

Submission status: Accepted

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

d = [False for _ in range(n)]
w = 0
a = 0
for i in range(m):
    P,S = input().split()
    P = int(P)
    if(S == 'WA'):
        if(d[P-1] >= 0):d[P-1] += 1
    elif(S == 'AC'):
        if(d[P-1] >= 0):
            a += 1
            w += d[P-1]
            d[P-1] = -1

print(a,w)

Submission status: Accepted

Solution code:
N , M = map(int,input().split())
p = [''] * M
S = [''] * M
A = [0] * N
W = [0] * N
for i in range(M):
    p[i],S[i] = map(str,input().split())
    p[i] = int(p[i])
    if A[p[i]-1] == 0:
        if S[i] == 'WA':
            W[p[i]-1] += 1
        else:
            A[p[i]-1] += 1

for j in range(N):
    if A[j] == 0:
        W[j] =0
print(sum(A),sum(W))

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
p = [0]* m
s = ["a"] * m


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



ac_num = [0] * n
wa_num = [0] * n

for i in range(m):
    if s[i] == "AC":
        ac_num[p[i]-1] = 1
    elif s[i] == "WA":
        if ac_num[p[i]-1] == 0:
            wa_num[p[i]-1] += 1

for i in range(n):
    if ac_num[i] == 0:
        wa_num[i] = 0
#print(ac_num,wa_num)

print(sum(ac_num),sum(wa_num))

Submission status: Accepted

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

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

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

print(sum(ac),wa1)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
c = {}
for i in range(n):
    c[i] = 0
ac = [False] * n
acn = 0
for _ in range(m):
    p,s = tuple(input().split())
    p = int(p)
    if s == 'AC' and ac[p-1]==False:
        ac[p-1] = True
        acn+=1
    elif s== 'WA' and ac[p-1]==False:
        c[p-1]+=1
pen = 0
for i,p in c.items():
    if ac[i]: pen+=p
print(acn, pen, sep=' ')

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
words=[[] for _ in range(N)]
for _ in range(M):
    p,S=input().split()
    p=int(p)-1
    words[p].append(S)
AC=0
WA=0
for a in words:
    if a.count('WA') != 0 and len(a) == a.count('WA'):
        continue
    for b in a:
        if b=='AC':
            AC+=1
            break
        elif b=='WA':
            WA+=1
print(AC,WA)

Submission status: Accepted

Solution code:

def solve(N,M,P,S):
    counterAC = 0
    counterWA = 0
    dic = {key:"WA" for key in set(P)}
    counter = {key:0 for key in set(P)}
    for p,s in zip(P,S):
        if(dic[p] == "AC"):
            continue
        else:
            if(s == "AC"):
                counterAC += 1
                counterWA += counter[p]
                dic[p] = "AC"
            else:
                counter[p]+=1
    print(counterAC,counterWA)
def main():
    N,M = map(int,input().split())
    P = []
    S = []
    for _ in range(M):
        p,s=map(str,input().split())
        P.append(int(p))
        S.append(s)
    solve(N,M,P,S)
    # print(solve())

if __name__ == "__main__":
    main()

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] = input().split()
    p[i] = int(p[i])

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

ans_count = 0
penalty_count = 0

for i in range(m):
    if s[i] == "AC":
        ac[p[i]-1] += 1
        if ac[p[i]-1] == 1:
            ans_count += 1
            penalty_count += wa[p[i]-1]
    else:
        wa[p[i]-1] += 1

print(ans_count, penalty_count)

Submission status: Accepted

Solution code:
#C
n, m = map(int, input().split())
probrem = [0] * n
warn = [0] * n
for i in range(m):
    a, b = map(str, input().split())
    a=int(a)
    if probrem[a - 1] == 0 and b == 'AC':
        probrem[a - 1] = 1
    if probrem[a - 1] == 0 and b == "WA":
        warn[a - 1] += 1
# print(probrem,warn)
for i in range(n):
    if probrem[i] == 0:
        warn[i] = 0
print(sum(probrem),sum(warn))

Submission status: Accepted

Solution code:
_, M = map(int, input().split())
PS = [tuple(input().split()) for _ in range(M)]
result = dict()
AC, WA = 0, 0
for p,s in PS:
    i = int(p)
    if not (i in result):
        if s == "WA":
            result[i] = 1
        elif s == "AC":
            AC += 1
            result [i] = "AC"
    else:
        if result[i] != "AC":
            if s == "WA":
                result[i] += 1
            if s == "AC":
                AC += 1
                WA += result[i]
                result[i] = s
print(AC, WA)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
ps_input=[[int(j) if n==0 else j for n,j in enumerate(input().split())]for i in range(m)]

ac_count = [0]*n
penalty= [0]*n
for ps in ps_input:
    if ps[1]=='AC':
        if ac_count[ps[0]-1]==0:
            ac_count[ps[0]-1]=1
    if ps[1]=='WA':
        if ac_count[ps[0]-1]==1:
            continue
        penalty[ps[0]-1]+=1
ans_ac=0
ans_penalty=0
for a,p in zip(ac_count,penalty):
    if a==1:
        ans_ac+=1
        ans_penalty+=p
print(ans_ac,ans_penalty)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve():
    N, M = map(int, input().split())
    ac, wa= 0, 0

    mp = [0] * N
    for _ in range(M):
        p, s = input().split()
        p = int(p) - 1
        if s == "AC":
            if mp[p] != -1:
                ac += 1
                wa += mp[p]
                mp[p] = -1
        else:
            if mp[p] != -1:
                mp[p] += 1
    return ac, wa

print(*solve())

Submission status: Accepted

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


print(AC, WA)

Submission status: Accepted

Solution code:
n,m = map(int, input().split())
state = [0]*n
ac = 0
wa = 0
for i in range(m):
    p,s = input().split()
    p = int(p)-1
    if state[p]>0:
        continue
    elif s == "WA":
        state[p] -= 1
    else:
        wa -= state[p]
        ac += 1
        state[p] = 1
print(ac, wa)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
p=[]
l=[1]*n
for i in range(m):
    P=list(input().split())
    p.append(P)

AC=0
WA=0

x=[0]*n

for i in range(m):
    if l[int(p[i][0])-1]==1:
        if p[i][1]=="WA":
            WA+=1
            x[int(p[i][0])-1]+=1
        else:
            AC+=1
            l[int(p[i][0])-1]=0

for i in range(n):
    if l[i]==1:
        WA-=x[i]

print(AC,WA)

Submission status: Accepted

Solution code:
from collections import defaultdict 

def multi_input():
    return map(int, input().split())

N, M = multi_input()
pS = [input().split() for _ in range(M)]

l = ['WA' for _ in range(N+1)]
d = defaultdict(int)
a = 0
for i, j in pS:
    i = int(i)
    if l[i] == 'WA':
        if j == 'WA':
            d[i] += 1
        else:
            a += 1
            l[i] = 'AC'

p = 0
for key, value in d.items():
    if l[key] == 'AC':
        p += value
           
print(a, p)

Submission status: Accepted

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

for k in range(n):
    if b[k]!=1:
        c[k]-=c[k]
print(str(sum(b)),str(sum(c)))

Submission status: Accepted

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

AC_number = [0 for i in range(N)] #バケット
WA_number = [0 for i in range(N)] #バケット
for i in range(M):
    #WAが出て、まだ終わってない問題なら
    if submits[i][1] != 'AC' and AC_number[submits[i][0] - 1] != 1:
        WA_number[submits[i][0] - 1] += 1
    
    #ACが出たら
    if submits[i][1] == 'AC':
        AC_number[submits[i][0] - 1] = 1

AC_count = 0
WA_count = 0
for i in range(N):
    if AC_number[i] == 1:
        AC_count += 1
        WA_count += WA_number[i]
print(AC_count, WA_count)

Submission status: Accepted

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

AC_number = [0 for i in range(N)] #バケット
WA_number = [0 for i in range(N)] #バケット
for i in range(M):
     #ACが出たら
    if submits[i][1] == 'AC':
        AC_number[submits[i][0] - 1] = 1
    #まだ終わってない問題なら
    elif AC_number[submits[i][0] - 1] == 0:
        WA_number[submits[i][0] - 1] += 1

AC_count = 0
WA_count = 0
for i in range(N):
    if AC_number[i] == 1:
        AC_count += 1
        WA_count += WA_number[i]
print(AC_count, WA_count)

Submission status: Accepted

Solution code:
def main():
    import sys
    input = sys.stdin.readline

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

    ac = [False] * N
    wa = [0] * N
    for _ in range(M):
        it = iter(input().split())
        p = int(next(it)) - 1
        s = next(it)
        if s == 'AC':
            ac[p] = True
        else:
            if not ac[p]:
                wa[p] += 1
    print(ac.count(True), sum(w for p, w in enumerate(wa) if ac[p]))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

x=[int(l) for l in x]


ac=0
wa=0
aclist=[0]*n
walist=[0]*n
p=[0]*n

for i in range(m):
  if y[i]=='AC' and p[x[i]-1]==0:
    aclist[x[i]-1]+=1
    p[x[i]-1]=1
  elif y[i]=='WA' and p[x[i]-1]==0:
    walist[x[i]-1]+=1

for j in range(n):
  if 1==aclist[j]:
    ac+=1
    wa+=walist[j]
print(ac,wa)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
ac = set()
wa = 0
wa_stock = [0] * n
for _ in range(m):
    p, s = input().split()
    p = int(p) - 1
    if s == 'AC' and not p in ac:
        ac.add(p)
        wa += wa_stock[p]
    elif not p in ac:
        wa_stock[p] += 1
print(len(ac), wa)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
ps=[list(map(str,input().split())) for _ in range(m)]
acwa=[True]*n
wa=[0]*n
ac=0
for P,s in ps:
  p=int(P)-1
  if acwa[p] and s=='WA':
    wa[p]+=1
  elif acwa[p] and s=='AC':
    ac+=1
    acwa[p]=False
for i in range(n):
  if acwa[i]:
    wa[i]=0
print(ac,sum(wa))

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
wa = [0 for _ in range(n+1)]
ac = 0
q = [False for _ in range(n+1)]

for i in range(m):
    p,s = input().split()
    p = int(p)-1
    if s =="WA":
        if q[p]:
            continue
        else:
            wa[p] += 1
    else:
        if q[p]:
            continue
        else:
            q[p] = True
            ac += 1
p = 0
for i,j in zip(q,wa):
    if i:
        p += j
print(ac,p)

Submission status: Accepted

Solution code:
from collections import deque
def solve():
    solved = set()

    N,M = map(int, input().split())
    wa = [0]*(N+1)
    pn = 0
    for i in range(M):
        p,s = input().split()

        if s == "AC":
            if not (p in solved):
                solved.add(p)
                pn += wa[int(p)]
        else:
            if not (p in solved):
                wa[int(p)] += 1
    print(len(solved), pn)



if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
ac,wa=0,0
ac_set=set()
wa_cnt=[0]*(n+1)
for i in range(m):
  p,s=map(str,input().split())
  p=int(p)
  if s=="AC":
    if p in ac_set:
      continue
    ac_set.add(p)
  else:
    if p in ac_set:
      continue
    wa_cnt[p]+=1
ac=len(ac_set)
for a in ac_set:
  wa+=wa_cnt[a]
print(ac,wa)

Submission status: Accepted

Solution code:
N,M=map(int, input().split())
now=[0]*N
pena=0
for i in range(M):
    num,result=input().split()
    num=int(num)-1
    if result=="AC":
        if now[num]>0:
            pena+=now[num]
        now[num]=-1
    else:
        if now[num]>=0:
            now[num]+=1
print(now.count(-1), pena)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
ps = []
for _ in range(m):
    p, s = input().split()
    ps.append((int(p), s))
was = [0]*(n+1)
total_ac = 0
total_wa = 0
for p, s in ps:
    if was[p]<0:
        continue
    if s=='AC':
        total_wa += was[p]
        total_ac += 1
        was[p] = -1
    else:
        was[p] += 1
print(total_ac, total_wa)

Submission status: Accepted

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

AC={}
WA={}
pe=0
ac=0

for i in range(M):
    p,S=map(str,input().split())
    if S=="AC":
        if p in AC.keys():
            pass
        else:
            AC[p]=1
            if p in WA.keys():
                pe+=WA[p]
            ac+=1
    else:
        if p in WA.keys():
            WA[p]+=1
        else:
            WA[p]=1
print(ac,pe)

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
C = {i:[0,0] for i in range(1,N+1)}
for _ in range(M):
    p,S = input().split()
    p = int(p)
    if C[p][0]==0 and S=="WA":
        C[p][1] += 1
    elif C[p][0]==0 and S=="AC":
        C[p][0] = 1
numA = 0
numB = 0
for i in range(1,N+1):
    numA += C[i][0]
    if C[i][0]==1:
        numB += C[i][1]
print(numA,numB)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
#%%code
def resolve():
    N,M=pin()
    ps=[tupin(str) for _ in range(M)]

    WA=[0]*N
    AC=[0]*N
    for m in range(M):
        p,s=ps[m]
        p=int(p)-1#0-indxd
        if AC[p]==0:
            if s=="WA": 
                WA[p]+=1
            else:
                AC[p]=1
    wa=0
    for Wa in range(N):
        if AC[Wa]==1:wa+=WA[Wa]
    print(sum(AC),wa)
        
#%%submit!
resolve()

Submission status: Accepted

Solution code:

import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right

# https://atcoder.jp/contests/abc151/tasks/abc151_c
N, M = read_ints()
is_ac = [False] * N
n_wa = [0] * N
for _ in ra(M):
    p, S = read().split()
    p = int(p) - 1
    if is_ac[p]:  # すでにACしてたら何もしない
        continue
    if S == 'WA':
        n_wa[p] += 1
    else:
        is_ac[p] = True
n_pena = 0
for ac, n in zip(is_ac, n_wa):
    if ac:
        n_pena += n

print(sum(is_ac), n_pena)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
ps = []
for _ in range(m):
    p, s = input().split()
    ps.append((int(p), s))
was = [0]*(n+1)
total_ac = 0
total_wa = 0
for p, s in ps:
    if was[p]<0:
        continue
    if s=='AC':
        total_wa += was[p]
        total_ac += 1
        was[p] = -1
    else:
        was[p] += 1
print(total_ac, total_wa)

Submission status: Accepted

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

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

Submission status: Accepted

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

problem = [0] * n
pp = [0]*n
b = ""
for p,s in ps:
    if problem[int(p)-1] == 0:
        if s == "WA":pp[int(p)-1] += 1
        else: problem[int(p)-1] = 1
ac = 0
pe = 0
for i in range(n):
    if problem[i] == 1:
        ac += 1
        pe += pp[i]
print(ac,pe)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    n, m = map(int, input().split())
    questions = [[0, False] for _ in range(n)]
    for _ in range(m):
        p, s = input().split()
        p = int(p) - 1
        if not questions[p][1]:
            if s == "WA":
                questions[p][0] += 1
            else:
                questions[p][1] = True
    ac = 0
    wa = 0
    for wa_num, is_accepted in questions:
        if is_accepted:
            ac += 1
            wa += wa_num
    print(ac, wa)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

AC = 0
pena = 0

lst = [0] * N
for _ in range(M):
    a, b = map(str, input().split())
    a = int(a) - 1
    if lst[a] < 0:
        continue
    else:
        if b == 'WA':
            lst[a] += 1
        else:
            AC += 1
            pena += lst[a]
            lst[a] = -1

print (AC, pena)

Submission status: Accepted

Solution code:
def examA():
    N = I()
    ans = 0
    print(ans)
    return

def examB():
    N, M = LI()
    P = [0]*N
    S = [LSI()for _ in range(M)]
    pena = 0
    ac = set()
    for p,s in S:
        p = int(p)-1
        if s=="WA":
            P[p] += 1
        else:
            if p in ac:
                continue
            ac.add(p)
            pena += P[p]

    print(len(ac),pena)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(readline())
def LI(): return list(map(int,readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examB()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

Submission status: Accepted

Solution code:
def main():
    N, M = (int(i) for i in input().split())
    from collections import defaultdict
    waCnt = defaultdict(int)
    ac = set()
    for _ in [0]*M:
        p, s = (i for i in input().split())
        if s == "WA" and p not in ac:
            waCnt[p] += 1
        else:
            ac.add(p)
    sumWA = sum(waCnt[p] for p in ac)
    print(len(ac), sumWA)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

cnt=0
l=[0 for i in range(n)]

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

ac_cnt=l.count(-1)
print(ac_cnt,cnt)

Submission status: Accepted

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

B = [0]*n
C = [0]*n
ans = 0
pna = 0
for i in range(m):
    a,b= input().split()
    a = int(a)
    if b=="AC":
        if B[a-1]==0 :
            B[a-1] =1
            ans += 1
            pna += C[a-1]
    else:
        C[a-1] = C[a-1]+1 
print(ans,pna)

Submission status: Accepted

Solution code:
N,M = [int(x) for x in input().split()]
count = [0]*N
ac = 0
wa = 0
ireta = []
for i in range(M):
    a,b = input().split()
    a = int(a)
    if b == "AC" and count[a-1] == 0:
        count[a-1] = 1
        ac += 1
    elif count[a-1] == 0:
        ireta.append(a)
        wa += 1
for i in range(len(ireta)):
    if count[ireta[i]-1] == 0:
        wa -= 1
print(ac,wa)

Submission status: Accepted

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

score = [0] * 1000000
countWA = 0
countAC = 0

for i in range(m):
    pi, si = input().split()
    pi = int(pi)
    if score[pi] == -1:
        continue
    if si == "WA":
        score[pi] += 1
    if si == "AC":
        countWA += score[pi]
        countAC += 1
        score[pi] = -1

print(countAC, countWA)

Submission status: Accepted

Solution code:
N,M = map(int, input().split())
p = []
S = []
acnum = [-1]*N
for i in range(M):
    tmp1,tmp2 = input().split()
    p.append(int(tmp1))
    S.append(tmp2)
account = 0
wacount = [0]*N
waans = 0
for i in range(M):
    if acnum[p[i] - 1] == -1:
        if S[i] == "AC":
            acnum[p[i] - 1] = 1
            account += 1
            waans += wacount[p[i] - 1]
        else:
            wacount[p[i] - 1] += 1
print(account,waans)

Submission status: Accepted

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

d_1=[0]*N
d_2=[0]*N

for i in range(M):
    p_i,S_i = input().split()
    p_i =int(p_i)-1
    if S_i=='WA' and d_2[p_i]==0:
        d_1[p_i]+=1
    elif S_i=='AC' and d_2[p_i]==0:
        d_2[p_i]=1

penalty=0
for j in range(N):
    if d_2[j]==1:
        penalty+=d_1[j]

print(sum(d_2),penalty)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

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

flag = [0 for _ in range(n)]
wa_num_list = [0 for _ in range(n)]

for i in range(m):
    p, s = list(map(str, input().split()))
    p = int(p)
    if flag[p-1] == 0:
        if s == "WA":
            wa_num_list[p-1] += 1
        else:
            flag[p-1] = 1

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

print(sum(flag), pen)

Submission status: Accepted

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

Submittion = [None]*M
for i in range(M):
    Submittion[i] =input().split()
    Submittion[i][0] =int(Submittion[i][0])

answer = [0]*(N)
WA = [0]*N
for i in range(M):
    if Submittion[i][1] == "AC":
        answer[Submittion[i][0]-1] +=1
    else:
        if answer[Submittion[i][0]-1] == 0:
            WA[Submittion[i][0]-1]+=1

print_ans = 0
print_wa = 0
for i in range(len(answer)):
    if answer[i] >0:
        print_ans+=1

    if answer[i] >0:
        print_wa +=WA[i]

print(print_ans,print_wa)

Submission status: Accepted

Solution code:
N,M = [int(x) for x in input().split()]
count = [0]*N
ac = 0
wa = 0
ireta = []
for i in range(M):
    a,b = input().split()
    a = int(a)
    if b == "AC" and count[a-1] == 0:
        count[a-1] = 1
        ac += 1
    elif count[a-1] == 0:
        ireta.append(a)
        wa += 1
for i in range(len(ireta)):
    if count[ireta[i]-1] == 0:
        wa -= 1
print(ac,wa)

Submission status: Accepted

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

Submission status: Accepted

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