Problem:


Score : 300 points

Problem Statement

Takahashi participated in a contest on AtCoder.

The contest had N problems.

Takahashi made M submissions during the contest.

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

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

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

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

Constraints

N, M, and p_i are integers.

1 \leq N \leq 10^5

0 \leq M \leq 10^5

1 \leq p_i \leq N

S_i is AC or WA.

Input

Input is given from Standard Input in the following format:

N M
p_1 S_1
:
p_M S_M

Output

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

Sample Input 1

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

Sample Output 1

2 2

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

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

Thus, he has two correct answers and two penalties.

Sample Input 2

100000 3
7777 AC
7777 AC
7777 AC

Sample Output 2

1 0

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

Sample Input 3

6 0

Sample Output 3

0 0



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


Sample output:
2 2

Submission status: Accepted

Solution code:
import numpy as np

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

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

for _ in range(m):
  p,s = map(str,input().split())
  if s == "AC" and ac[int(p)] == 0:
    ac[int(p)] = 1
  if s == "WA" and ac[int(p)] == 0:
    wa[int(p)] += 1
print(sum(ac),sum(np.array(ac)*np.array(wa)))

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
p_s = [ list(map(str, input().split())) for _ in range(m) ]
ac = [False] * n
wa = [0] * n
for p, s in p_s:
    if ac[int(p)-1] is False:
        if s == 'AC':
            ac[int(p)-1] = True
        else:
            wa[int(p)-1] += 1
print(sum([1 for i in ac if i == True ]), sum([i for i,j in zip(wa,ac) if j == True ]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, M = map(int, input().split(' '))
ac_set = set()
wa_cnt, wa_cnt_ls = 0, [ 0 for i in range(N) ]

for i in range(M):
    p, s = input().split(' ')
    idx = int(p) - 1
    if not idx in ac_set:
        if s == 'AC':
            ac_set.add(idx)
            wa_cnt += wa_cnt_ls[idx]
        else:
            wa_cnt_ls[idx] += 1
print(len(ac_set), wa_cnt)

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
p,s = [],[]
for _ in range(m):
  a,b = map(str,input().split())
  p.append(a)
  s.append(b)
p = list(map(int,p))
checker = [0] * n
penalty = [0] * n
ans = 0
for i,j in enumerate(s):
  if j == "AC" and checker[p[i]-1] == 0:
    checker[p[i]-1] = 1
  elif j == "WA" and checker[p[i]-1] == 0:
    penalty[p[i]-1] += 1
for k,l in enumerate(checker):
  if l:
    ans += penalty[k]
print(sum(checker),ans)

Submission status: Accepted

Solution code:
N, M = map(int, input().split(' '))
ac_set = set()
wa_cnt_ls, wa_cnt = [ 0 for i in range(N) ], 0
for i in range(M):
    p, s = input().split(' ')
    idx = int(p) - 1
    if not idx in ac_set:
        if s == 'AC':
            ac_set.add(idx)
            wa_cnt += wa_cnt_ls[idx]
        else:
            wa_cnt_ls[idx] += 1
print(len(ac_set), wa_cnt)

Submission status: Accepted

Solution code:
import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

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

dic={}
anslst=[0]*n
for i in range(m):
    p,s=ps[i]
    if s=="AC":
        dic[p]=1
    else:
        if p in dic:
            continue
        else:
            anslst[int(p)-1]+=1


ans=0
for i in dic.keys():
    ans+=anslst[int(i)-1]
print(len(dic),ans)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
S = [[0 for j in range(2)] for i in range(M)]
for i in range(M):
  X = input().split()
  S[i][0] = int(X[0])
  S[i][1] = str(X[1])
A = [0] * N
p = 0
s = 0
for i in range(M):
  if S[i][1] == "WA":
    if A[S[i][0]-1] != "x": 
      A[S[i][0]-1] += 1
  if S[i][1] == "AC":
    if A[S[i][0]-1] != "x":
      p +=  A[S[i][0]-1]
      A[S[i][0]-1] = "x"
      s += 1
arr = [s, p]
print(*arr)

Submission status: Accepted

Solution code:
import math , sys

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

cor = 0
pen = 0

F = [False]*N
C = [0]*N

for i in range(M):
    A , B = list( input().split() )
    A = int(A)-1

    if B == "WA" and not F[A]:
        C[A]+=1

    #print(C)

    if B == "AC" and not F[A]:
        F[A] = True
        cor += 1
        pen +=C[A]
print(cor,pen)

Submission status: Accepted

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

wa=[0]*N
ac=[False]*N
for i in range(M):
	p, S = input().split()
	p=int(p)-1
	
	if S=="AC":
		ac[p]=True

	else:#一度ACしたらWAをカウントしない
		if not ac[p]:
			wa[p]+=1

a=0
b=0

for i in range(N):
	if ac[i]:
		a+=1
		b+=wa[i]
print(*[a,b])

Submission status: Accepted

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

Submission status: Accepted

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

print(Accepted,Penalty)

Submission status: Accepted

Solution code:
N, M = map(int, input().split(' '))
ac_set = set()
wa_cnt, wa_cnt_ls = 0, [0] * N
for i in range(M):
    p, s = input().split(' ')
    idx = int(p) - 1
    if not idx in ac_set:
        if s == 'AC':
            ac_set.add(idx)
            wa_cnt += wa_cnt_ls[idx]
        else:
            wa_cnt_ls[idx] += 1
print(len(ac_set), wa_cnt)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N, M = map(int, input().split(' '))
ac_set = set()
wa_cnt_ls, wa_cnt = [0] * N, 0

for i in range(M):
    p, s = input().split(' ')
    idx = int(p) - 1
    if not idx in ac_set:
        if s == 'AC':
            ac_set.add(idx)
            wa_cnt += wa_cnt_ls[idx]
        else:
            wa_cnt_ls[idx] += 1
print(len(ac_set), wa_cnt)

Submission status: Accepted

Solution code:
N, M = map(int, input().split(' '))
ac_set = set()
wa_cnt_ls = [0] * N
wa_cnt = 0
for i in range(M):
    p, s = input().split(' ')
    idx = int(p) - 1
    if not idx in ac_set:
        if s == 'AC':
            wa_cnt += wa_cnt_ls[idx]
            ac_set.add(idx)
        else:
            wa_cnt_ls[idx] += 1
print(len(ac_set), wa_cnt)

Submission status: Accepted

Solution code:
N, M = map(int, input().split(' '))
ac_set = set()
wa_cnt_ls, wa_cnt = [0] * N, 0
for i in range(M):
    p, s = input().split(' ')
    idx = int(p) - 1
    if not idx in ac_set:
        if s == 'AC':
            wa_cnt += wa_cnt_ls[idx]
            ac_set.add(idx)
        else:
            wa_cnt_ls[idx] += 1
print(len(ac_set), wa_cnt)

Submission status: Accepted

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

#AC,WA
P = [0]*N
Penalty = 0
Accepted = 0

for i in range(M) :
    p,S = input().split()
    p = int(p)
    
    if S == "AC" and P[p-1] != -1:
        Penalty += P[p-1]
        Accepted += 1
        P[p-1] = -1
    elif S == "WA" and P[p-1] != -1:
        P[p-1] += 1

print(Accepted,Penalty)

Submission status: Accepted

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

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

print(ans, pena)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
AC = [0]*(N+1)
WA = [0]*(N+1)

for i in range (0, M):
    A, B = map(str, input().split())
    A = int(A)
    if B == 'WA':
        if AC[A] == 0:
            WA[A]+=1
    else:
        if AC[A] == 0:
            AC[A] = 1

Wronganswer = 0
for i in range (0, N+1):
    Wronganswer+=(AC[i]*WA[i])
print(sum(AC), Wronganswer)

Submission status: Accepted

Solution code:
#nは問題数　mは提出した回数　
n,m = map(int,input().split())
submit = []
check = [0] * n

for x in range(m):
    a,b = input().split()
    a = int(a)
    x = [a,b]
    submit.append(x)

o = 0
x = 0


for y in submit:
    if check[y[0]-1] == 0:
        if y[1] == "AC":
            o += 1
            check[y[0]-1] = 1
        elif y[1] == "WA":
            x += 1

for z in submit:
    if check[z[0]-1] == 0:
        if z[1] == "WA":
            x -= 1


print(o,x)

Submission status: Accepted

Solution code:
N, M = map(int, input().split(' '))
ac_set = set()
wa_cnt_list = [0] * N
ac_cnt, wa_cnt = 0, 0
for i in range(M):
    num, res = input().split(' ')
    num = int(num) - 1
    if num not in ac_set:
        if res == 'AC':
            ac_cnt += 1
            wa_cnt += wa_cnt_list[num]
            ac_set.add(num)
        else:
            wa_cnt_list[num] += 1
print(ac_cnt, wa_cnt)

Submission status: Accepted

Solution code:
import numpy as np
N,M=map(int,input().split())
flag=[False]*(N+1)
ac=0
wa=[0]*(N+1)
for _ in range(M):
    p,s=input().split()
    p=int(p)
    if flag[p]==False:
        if s=='AC':
            flag[p]=True
        else:
            wa[p]+=1
print(sum(np.array(flag)),sum(np.array(wa)*np.array(flag)))

Submission status: Accepted

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

#%%

ACs = [False for _ in range(N)]
WAs = [0 for _ in range(N)]

for pS in pSs:
    problem = int(pS[0]) -1
    answer = pS[1]
    if ACs[problem] == True:
        continue
    else:
        if answer == "WA":
            WAs[problem] += 1
        else:
            ACs[problem] = True

num_WA = 0
for i, WA in enumerate(WAs):
    if ACs[i] == True:
        num_WA += WA

print(sum(ACs), num_WA)

Submission status: Accepted

Solution code:
from collections import defaultdict as dc
n, m = [int(i) for i in input().split()]
cq_dic = {}
wa_dic = dc(int)
for _ in range(m):
  p, w = input().split()
  if w == 'AC':
    cq_dic[p] = 1
  elif (not p in cq_dic) and  w == 'WA':
    wa_dic[p] += 1
ans = sum([wa_dic[k] for k in cq_dic])
print(len(cq_dic), ans)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
l = [list(input().split()) for i in range(m)]
ans=[0]*n
for i in range(m):
    if l[i][1]=="AC":
        if ans[int(l[i][0])-1]==0:
            ans[int(l[i][0])-1]+=0.5
        if ans[int(l[i][0])-1]<0:
            ans[int(l[i][0])-1]=ans[int(l[i][0])-1]*(-1)
    else:
        if ans[int(l[i][0])-1]<=0:
            ans[int(l[i][0])-1]-=1
ac=0
wa=0
for i in range(n):
    if ans[i]>0:
        ac+=1
        if ans[i]!=0.5:
          wa+=ans[i]
print(ac,wa)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
from collections import defaultdict


def main():
    N, M = map(int, input().split())
    passed = set([])
    penalty = defaultdict(int)
    for _ in range(M):
        p, S = input().split()
        if S == "WA" and p not in passed:
            penalty[p] += 1
        elif S == "AC":
            passed.add(p)
    ans = sum([penalty[p] for p in passed])
    print(len(passed), ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
x=[0]*N
y=[0]*N
P=[]
s=[]

for i in range(M):
    p,S=map(str,input().split())
    P.append(int(p))
    s.append(S)
for j in range(M-1,-1,-1):
    if s[j]=='AC':
        if x[P[j]-1]==0:
            x[P[j]-1]=1
        else:
            y[P[j]-1]=0
    elif s[j]=='WA':
        if x[P[j]-1]==1:
            y[P[j]-1]+=1
print(x.count(1),sum(y))

Submission status: Accepted

Solution code:

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N,M=MI()
    AC=[0]*N
    WA=[0]*N
    
    for _ in range(M):
        p,s=input().split()
        p=int(p)-1
        if s=="AC":
            AC[p]=1
        else:
            if AC[p]==0:
                WA[p]+=1
       
    acs=sum(AC)     
    was=0
    for i in range(N):
        was+=AC[i]*WA[i]
        
    print(acs,was)
        

main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
from itertools import chain

# import numpy as np
# from itertools import combinations as comb
# from bisect import bisect_left, bisect_right, insort_left, insort_right
# from collections import Counter


def solve(N: int, M: int, P: "List[int]", S: "List[str]"):
    ac = [0] * N
    wa = [0] * N
    for p, s in zip(P, S):
        if s == "AC":
            ac[p - 1] = 1
        else:  # WA
            if ac[p - 1] == 0:
                wa[p - 1] += 1
    for i in range(N):
        if ac[i] == 0:
            wa[i] = 0

    return sum(ac), sum(wa)


def main():
    tokens = chain(*(line.split() for line in sys.stdin))
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    P = [int()] * (M)  # type: "List[int]"
    S = [str()] * (M)  # type: "List[str]"
    for i in range(M):
        P[i] = int(next(tokens))
        S[i] = next(tokens)
    a1, a2 = solve(N, M, P, S)
    print(a1, a2)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N,M=map(int, input().split())
ACList=[0]*(N+1)
ansAC=0
ansP=0
for i in range(M):
	p,S=map(str, input().split())
	p=int(p)
	if S=="AC" and ACList[p]!=-1:
		ansAC+=1
		ansP+=ACList[p]
		ACList[p]=-1
	elif S=="WA" and ACList[p]!=-1:
		ACList[p]+=1
	else:
		continue

print(ansAC,ansP)

Submission status: Accepted

Solution code:
# row = [int(x) for x in input().rstrip().split(" ")]
# n = int(input().rstrip())
# s = input().rstrip()

def resolve():
    import sys
    input = sys.stdin.readline

    n, m = [int(x) for x in input().rstrip().split(" ")]

    ac = [False for _ in range(n)]
    wa = [0 for _ in range(n)]
    wa_sum = 0

    for i in range(m):
        p, s = input().rstrip().split(" ")
        p = int(p) - 1
        if ac[p]:
            continue
        if s == "WA":
            wa[p] += 1
        else:
            ac[p] = True
            wa_sum += wa[p]
    print(len([x for x in ac if x]), wa_sum)


if __name__ == "__main__":
    resolve()

Submission status: Accepted

Solution code:
N, M = list(map(int, input().split()))
WA = [0]*N
AC = [False]*N
for _ in range(M):
    p, S = input().split()
    p = int(p)-1
    if S == 'WA':
        if AC[p] == False:
            WA[p] += 1
    else:
        AC[p] = True

ans = [0, 0]
for i in range(N):
    if AC[i] == False:
        continue
    ans[0] += 1
    ans[1] += WA[i]

print(*ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
answer = 0
penalty = 0
ans = [0] * n
pen = [0] * n
 
for x in range(m):
  p, s = input().split()
  pi = int(p) - 1
  if ans[pi] == 1:
    continue
 
  if s == 'AC':
    answer += 1
    ans[pi] = 1
    penalty += pen[pi]
  elif s == 'WA':
    pen[pi] += 1
 
print(f'{answer} {penalty}')

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
sub = []
for i in range(m):
    tmp= [x for x in input().split()]
    sub.append(tmp)
ac = [0]*n
wa = [0]*n
for i in range(m):
    res = sub[i][1]
    que = int(sub[i][0]) - 1
    if res == "AC" and ac[que] == 0:
        ac[que] += 1
    elif res == "WA" and ac[que] == 0:
        wa[que] += 1
for i in range(n):
    if ac[i] != 1:
        wa[i] = 0
print(sum(ac),sum(wa))

Submission status: Accepted

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

# N, M=O(10^5)なので、O(N+M)で解く！
AC = [False]*N
WA = [0]*N
 
# i番目の提出において、
# (1) まだ'AC'されておらず、提出がWAだった場合：WA += 1
# (2) まだ'AC'されておらず、提出がACだった場合：AC += 1 
# (3) すでに'AC'されている場合：何もしない
for i in range(M):    
  num = int(p_S[i][0])-1
  if AC[num] == 0 and p_S[i][1] == 'WA': WA[num] += 1
  elif AC[num] == 0 and p_S[i][1] == 'AC': AC[num] = True
  else: continue

# 'AC'を出した各問題において、初めて'AC'を出すまでに出した'WA'の数の和を求める
s = 0
for i in range(N):
  if AC[i]:
    s += WA[i]
    
print(sum(AC), s)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
answer = 0
penalty = 0
ans = [0] * n
pen = [0] * n

for x in range(m):
  p, s = input().split()
  pi = int(p) - 1
  if ans[pi] == 1:
    continue

  if s == 'AC':
    answer += 1
    ans[pi] = 1
    penalty += pen[pi]
  elif s == 'WA':
    pen[pi] += 1

print(f'{answer} {penalty}')

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
l1 = [0]*n
l2 = [0]*n
for i in range(m):
        p,s=map(str,input().split())
        p= int(p)
        if s == 'AC':
                l2[p-1] +=1
        else:
                if l2[p-1] == 0:
                        l1[p-1] +=1
cntac = 0
cntwa = 0
for i in range(n):
        if l2[i] != 0:
                cntac +=1
                cntwa += l1[i]

                
                
print(cntac,cntwa)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
ac = set()
pena = 0
walen = [0]*N

for i in range(M):
    p, S = map(str, input().split())
    p = int(p) - 1
    if p in ac:
        continue
    elif S == 'AC':
        ac.add(p)
        pena += walen[p]
    else:
        walen[p] += 1

print(len(ac), pena)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Tue Sep  8 16:23:28 2020

@author: liang
"""

N, M = map(int, input().split())
AC_list = [0]*N
WA_list = [0]*N

for i in range(M):
    p, j = input().split()
    p = int(p)
    if j == 'AC':
        AC_list[p-1] += 1
    else:
        if AC_list[p-1] == 0:
            WA_list[p-1] += 1

AC = 0
WA = 0
for i in range(N):
    if AC_list[i] >= 1:
        AC += 1
        WA += WA_list[i]
    
print(AC, WA)

Submission status: Accepted

Solution code:
n,m = list(map(int, input().split()))
wa = [0] * (n + 1)
ac = [0] * (n + 1)
for _ in range(m):
    p,s = input().split()
    p = int(p)
    if s == 'WA' and ac[p] == 0:
        wa[p] += 1
    elif s == 'AC':
        ac[p] = 1

for i,ok in enumerate(ac):
    if not ok:
        wa[i] = 0

print('{} {}'.format(sum(ac), sum(wa)))

Submission status: Accepted

Solution code:
N,M = map(int, input().split())
d = {'AC':0,'WA':0,}
b = 0
for i in range(N + 1):
  d[i] = 0
for j in range(M):
  p,s = input().split()
  p = int(p)
  if s == 'AC':
    if d[p] != -1:
      b = d[p]
      d[p] = -1
      d['AC'] += 1
      d['WA'] += b
      b = 0  
  if s == 'WA':
    if d[p] != -1:
       d[p] += 1
print(d['AC'],end = ' ')
print(d['WA'])

Submission status: Accepted

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

flag = dict()
for i in range(m):
  q, s = input().split()
  if q not in flag:
    flag[q] = [0,0]
    if s == "AC":
      flag[q][0] += 1
    else:
      flag[q][1] += 1
  else:
    if flag[q][0] != 1:
      if s == "AC":
        flag[q][0] += 1
      else:
        flag[q][1] += 1
      
ans = [0,0]
for v in flag.values():
  if v[0]:
    ans[0] += 1
    ans[1] += v[1]

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

Submission status: Accepted

Solution code:
from collections import defaultdict
def main():
    n, m = map(int, input().split(" "))
    d = defaultdict(lambda:"")
    dp = defaultdict(lambda:0)
    cnt_p=0
    cnt_ca=0
    for i in range(m):
        p,s = input().split(" ")
        if d[p] == "":
            if s == "AC":
                d[p] = 1
                cnt_ca += 1
                cnt_p += dp[p]
            else:
                dp[p] += 1
    print(f"{cnt_ca} {cnt_p}")


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
count1 = 0
count2 = 0
lis = [0] * N
lis2 = [0] * N
for i in range(M):
  p, S = input().split()
  p = int(p)
  if lis[p-1] == 0 and S == "WA":
    lis2[p-1] += 1
  elif lis[p-1] == 0 and S == "AC":
    count1 += 1
    lis[p-1] = 1
  elif lis[p-1] == 1 and S == "WA":
    continue
  elif lis[p-1] == 1 and S == "AC":
    continue
for i in range(N):
  if lis[i] == 0:
    lis2[i] = 0
count2 = sum(lis2)
print(str(count1) + " " + str(count2))

Submission status: Accepted

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

c = [0] * n
for p, s in ps:
    if s == 'AC':
        c[int(p)-1] = 1
d = [0] * n
wa = 0
ac = 0
for p, s in ps:
    if d[int(p)-1] == 0:
        if s == 'WA':
            if c[int(p)-1] == 1:
                wa += 1
        else:
            ac += 1
            d[int(p)-1] = 1
print(ac, wa)

Submission status: Accepted

Solution code:
def solve():
    N, M = [int(i) for i in input().split()]
    ans = set()
    pen = 0
    arr = [0] * N
    for _ in range(M):
        p, s = input().split()
        if s == 'AC' and int(p) not in ans:
            ans.add(int(p))
            pen += arr[int(p) - 1]
        if s == 'WA':
            arr[int(p) - 1] += 1
    print(f'{len(ans)} {pen}')

if __name__ == "__main__":
    solve()

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(m):
    p, s = input().split()
    if flg[int(p)-1] == 0:
        if s == "WA":
            pe[int(p)-1] += 1
        else:
            flg[int(p)-1] = 1
            ac += 1
spe = 0
for i in range(n):
    if flg[i] == 1:
        spe += pe[i]

print(ac, spe)

Submission status: Accepted

Solution code:
from collections import defaultdict
N, M = map(int, input().split())
wa = defaultdict(int)
ac = {}
for i in range(M):
    p, S = input().split()
    if S == 'AC':        
        ac[p] = True
    else:
        if p not in ac:
            wa[p] += 1
print(len(ac), sum([wa[x] for x in ac.keys()]))

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
f = [False for i in range(n)]
ac = 0
wa = [0 for i in range(n)]
for i in range(m):
  p,s = input().split()
  p = int(p) - 1
  if not f[p]:
    if s == "WA":
      wa[p] += 1
    else:
      f[p] = True
      ac += 1
w = 0
for e,c in zip(f,wa):
  if e:
    w += c
print(ac,w)

Submission status: Accepted

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

dac = {}
for i in range(1,n+1):
    dac[str(i)] = 0
dwa = {}
for i in range(1,n+1):
    dwa[str(i)] = 0

for i in range(m):
    p,s = input().split()
    if s == 'AC':
        dac[p] = 1
    if s == 'WA' and dac[p] == 0:
        dwa[p] += 1

ac = 0
wa = 0

for k,v in dac.items():
    ac += v

for k,v in dwa.items():
    if dac[k] == 1:
        wa += v

print(ac,wa)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
a = [input().split() for i in range(m)]
wa =[0]*n #ACまでのWA数
ac = [0]*n

for i in range(m):
    if a[i][1] == 'AC':
      ac[int(a[i][0])-1] = 1
    else:
      if ac[int(a[i][0])-1]==0:
        wa[int(a[i][0])-1] +=1
cnt1, cnt2= 0,0
for i in range(n):
  if ac[i] ==1:
    cnt1 += ac[i]
    cnt2 += wa[i]
        
print(cnt1, cnt2)

Submission status: Accepted

Solution code:
N, M = map(int,input().split())
results = [0 for _ in range(N+1)]
wa_list = [0 for __ in range(N+1)]
ac_cnt = 0
wa_cnt = 0
for _ in range(M):
  problem, result = input().split()
  if results[int(problem)] == 0 and result == 'AC':
    ac_cnt += 1
    results[int(problem)] = 1
  elif results[int(problem)] == 0 and result == 'WA':
    wa_list[int(problem)] += 1
for i in range(1, N+1):
  if results[i] == 1:
    wa_cnt += wa_list[i]
print(ac_cnt, wa_cnt)

Submission status: Accepted

Solution code:
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    n,m=map(int, readline().rstrip().split())

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

    for i in range(m):
        p,s=readline().rstrip().split()
        p=int(p)-1
        if s=="AC":
            ac[p]=1
            continue
        if ac[p]==0:
            wa[p]+=1
    for i in range(n):
        wa[i]*=ac[i]
    
    print(sum(ac),sum(wa))

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n, m = map(int, input().split())
ck = set()
pe = 0
ac = 0
penalty = 0
cp = [0] * (n+1)
for i in range(m):
    p, s = input().split()
    p = int(p)
    if p in ck:
        continue

    if s == 'WA':
        cp[p] += 1
    else:
        penalty += cp[p]
        pe = 0
        ac += 1
        ck.add(p)

print(ac, penalty)

Submission status: Accepted

Solution code:
from collections import defaultdict as dic
n, m = map(int, input().split())
ac = 0
pena = 0
d = dic(list)
for i in range(m):
    pi, si = input().split()
    d[pi].append(si)

for (k, v) in d.items():
    pe = 0
    flag = False
    for aw in v:
        if aw == 'WA':
            pe += 1
        else:
            ac += 1
            flag = True
            break

    if flag:
        pena += pe

print(ac, pena)

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
num_AC,num_WA = 0,0
res = [list(input().split()) for i in range(M)]
check = ['v']*N
WA_check = [0]*N
for i,j in res:
  i = int(i)
  if check[i-1] == 'v':
    if j == 'WA':
      WA_check[i-1] += 1
    if j == 'AC':
      num_AC += 1
      num_WA += WA_check[i-1]
      check[i-1] = '.'
print(num_AC,num_WA)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
accept = set()
penalty = 0
wa_cnt = [0] * N

for m in range(M):
    p, s = input().split()
    p = int(p) -1 
    if p in accept:
        continue
    elif s == 'AC':
        accept.add(p)
        penalty += wa_cnt[p]
    else:
        wa_cnt[p] += 1

print(len(accept), penalty)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
accepted = set()
penalty = 0
wa_cnt =  [0]*N

for m in range(M):
    p,s = input().split()
    p = int(p) - 1
    if p in accepted:
        continue
    elif s == 'AC':
        accepted.add(p)
        penalty += wa_cnt[p]
    else:
        wa_cnt[p] += 1
print(len(accepted), penalty)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
accepted = set()
penalty = 0
wa_cnt =  [0]*N

for m in range(M):
    p,s = input().split()
    p = int(p) - 1
    if p in accepted:
        continue
    if s == 'AC':
        accepted.add(p)
        penalty += wa_cnt[p]
    else:
        wa_cnt[p] += 1
print(len(accepted), penalty)

Submission status: Accepted

Solution code:
N,M = (int(x) for x in input().split())
AC = [False]*N
WA_count = [0]*N
AC_count = 0
for i in range(M):
  p,S = (y for y in input().split())
  if AC[int(p)-1] == False:
    if S == 'AC':
      AC[int(p)-1] = True
      AC_count += 1
    else:
      WA_count[int(p)-1] += 1
for i in range(N):
  if AC[i] == False:
    WA_count[i] = 0
print(AC_count,sum(WA_count))

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
countlis = [0] * (N+1)
penalty = 0
clear = 0
checkset = set()
for i in range(1,M+1):
    p,s = input().split()
    p = int(p)
    if p in checkset:
        continue
    if s == "WA":
        countlis[p] += 1
    elif s == "AC":
        penalty += countlis[p]
        clear += 1
        checkset.add(p)

print("{0} {1}".format(clear, penalty))

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
l=[0]*(n+1)
miss=[0]*(n+1)
for _ in range(m):
    p,s=input().split()
    p=int(p)
    if l[p]==0:
        if s=='AC':
            l[p]+=1
        else:
            miss[p]+=1
for i in range(1,n+1):
    if l[i]==0 and miss[i]!=0:
        miss[i]=0
a=l.count(1)
b=sum(miss)
print(a,b)

Submission status: Accepted

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

p_list = []
s_list = []
for i in range(M):
    p, s = input().split()
    p_list.append(int(p))
    s_list.append(s)

p_state = [0 for i in range(N)]
pena_list = [0 for i in range(N)]
ans = 0
pena = 0

for i in range(M):
    if p_state[p_list[i]-1] == 0 and s_list[i] == "WA":
        pena_list[p_list[i]-1] += 1
    elif p_state[p_list[i]-1] == 0 and s_list[i] == "AC":
        p_state[p_list[i]-1] = 1
        ans += 1
        pena += pena_list[p_list[i]-1]
    else:
        continue

print(ans, pena)

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
ac_cnt = [0] * (N + 1)
wa_cnt = [0] * (N + 1)

for i in range(M):
  p,S = input().split()
  p = int(p)
  
  if ac_cnt[p] == 0:
    if S == "WA":
      wa_cnt[p] += 1
    else:
      ac_cnt[p] += 1
    
wa_cnt = [wa for i, wa in enumerate(wa_cnt) if ac_cnt[i] == 1]
print(sum(ac_cnt),sum(wa_cnt))

Submission status: Accepted

Solution code:
P,M = map(int,input().split())
dac = {}
dwa = {}
for _ in range(M):
  p,s = input().split()
  p = int(p)
  if s == "AC":
    if p not in dac:
      dac[p] = 1
  else:
    if p not in dac:
      if p not in dwa:
        dwa[p] = 1
      else:
        dwa[p] += 1

score = len(dac)
penalty = sum([val for k,val in dwa.items() if (k in dac)])
print(score,penalty)

Submission status: Accepted

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

for i in range(M):
    P, S = map(str, input().split())
    P = int(P)-1
    if ac[P] != 1 and S == "AC":
        wa += abs(ac[P])
        ac[P] = 1
    elif ac[P] != 1 and S == "WA":
        ac[P] -= 1

print(ac.count(1), wa)