Problem:


Score : 300 points

Problem Statement

Takahashi participated in a contest on AtCoder.

The contest had N problems.

Takahashi made M submissions during the contest.

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

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

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

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

Constraints

N, M, and p_i are integers.

1 \leq N \leq 10^5

0 \leq M \leq 10^5

1 \leq p_i \leq N

S_i is AC or WA.

Input

Input is given from Standard Input in the following format:

N M
p_1 S_1
:
p_M S_M

Output

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

Sample Input 1

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

Sample Output 1

2 2

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

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

Thus, he has two correct answers and two penalties.

Sample Input 2

100000 3
7777 AC
7777 AC
7777 AC

Sample Output 2

1 0

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

Sample Input 3

6 0

Sample Output 3

0 0



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


Sample output:
2 2

Submission status: Accepted

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

AC = {}
WA = {}

if M == 0:
    print("0 0")
    exit()
for i in range(M):
    prob,sub = input().split()
    if sub == "WA":
        if (prob in AC) == False:
            if (prob in WA) == False:
                WA[prob] = 1
            else:
                WA[prob] += 1
    
    if sub == "AC":
         if (prob in AC) == False:
            AC[prob] = 1
         else:
            AC[prob] += 1
            
ans_WA = 0
for prob,sub in WA.items():
    if (prob in AC) == True:
        ans_WA += int(sub)
            
print(len(AC.values()),ans_WA)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
d = {}
s_ac = set()
ac = 0
pen = 0
for i in range(m):
    p, s = map(str, input().split())
    p = int(p)
    if s == 'AC':
        if p not in s_ac:
            ac += 1
            s_ac.add(p)
            if p in d:
                pen += d[p]
    else:
        if p not in d:
            d[p] = 1
        else:
            d[p] += 1
print(ac, pen)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
t = [0] * (N + 1)
vis = set()
res = 0
for i in range(M):
  p, s = input().split()
  p = int(p)
  if s == "WA": t[p] += 1
  else:
    if p in vis: continue
    res += t[p]
    vis.add(p)
print(len(vis), res)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
ac = [False] * N
wa = [0] * N
ac_count = 0
wa_count = 0
for i in range(M):
    p, S = input().split()
    p = int(p)
    p -= 1
    if ac[p]:
        continue
    if S == 'AC':
        ac[p] = True
        ac_count += 1
        wa_count += wa[p]
    else:
        wa[p] += 1
print(ac_count, wa_count)

Submission status: Accepted

Solution code:
N, M = map(int,input().split())
L = [0 for k in range(N)]
a = 0
p = 0
for k in range(M):
    s, t = input().split()
    if t == "WA":
        L[int(s)-1] += 1
    else:
        if L[int(s)-1] >= 0:
            a += 1
            p += L[int(s)-1]
            L[int(s)-1] = -100001
print(a,p)

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin

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

n, m = na()
wa = [0] * n
ac = [0] * n
ans = 0
for _ in range(m):
    p, s = ns().split()
    p = int(p) - 1
    if s == "WA" and ac[p] == 0:
        wa[p] = wa[p] + 1
    if s == "AC" and ac[p] == 0:
        ans += wa[p]
        ac[p] = 1
print(sum(ac), ans)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
ac_list=[None]*n
wa_list=[0]*n
ans=0
for i in range(m):
    q,status=input().split()
    q=int(q)
    if status=="AC" and ac_list[q-1]==None:
        ac_list[q-1]=True
        ans+=wa_list[q-1]
    elif status=="WA" and ac_list[q-1]==None:
        wa_list[q-1]+=1
x=ac_list.count(True)
print(x,ans)

Submission status: Accepted

Solution code:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,M=MI()
    PS=[ST().split() for _ in range(M)]
    AC=set()
    WA=defaultdict(int)
    pena = 0
    for p,s in PS:
        if p in AC:
            continue
        if s == "AC":
            AC.add(p)
            pena += WA[p]
        else:
            WA[p]+=1
    print(len(AC), pena)
    

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# Welcome to AtCoder

# 入力の準備
N, M = map(int, input().split())
result_list = []
for i in range(M):
    result_list.append(input().split())

ans_num = 0 # 正答数
penalty_num = 0 # ペナルティ数

correct_memo = {} # 正答されたものを保管するメモ
penalty_memo = [0 for i in range(N+1)] # ペナルティ数のメモ

for r in result_list:
    key = int(r[0])
    if key in correct_memo: # すでにACが出ていればスキップ
        continue

    if r[1]=='WA': # ペナルティ数のメモ
        penalty_memo[key] = penalty_memo[key] + 1
    elif r[1]=='AC':
        correct_memo[key] = 1 # メモをしておく
        ans_num = ans_num + 1
        penalty_num = penalty_num + penalty_memo[key]

print(ans_num, penalty_num)

Submission status: Accepted

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

# True -> AC済み
AC = [False] * N
WA_cnt = [0] * N

pena = 0
for p,S in pS:
    p = int(p) - 1

    if AC[p]:
        continue

    if S == "WA":
        WA_cnt[p] += 1
    else:
        AC[p] = True
        pena += WA_cnt[p]
    
ac = sum(AC)
print(ac,pena)

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
PS = [input().split() for i in range(M)]
penas = {}
acs = set()
pena = 0
for p,s in PS:
    if s=='AC':
        if p in acs: continue
        acs.add(p)
        if p in penas:
            pena += penas[p]
    else:
        if p in penas:
            penas[p] += 1
        else:
            penas[p] = 1
print(len(acs), pena)

Submission status: Accepted

Solution code:
def main():
    N, M = (int(i) for i in input().split())
    PS = [[i for i in input().split()] for j in range(M)]
    dic = {i: ["?", 0] for i in range(1, N+1)}
    for p, s in PS:
        p = int(p)
        if dic[p][0] != "AC" and s == "WA":
            dic[p][1] += 1
        elif s == "AC":
            dic[p][0] = "AC"
    ans = [0, 0]
    for k, v in dic.values():
        if k == "AC":
            ans[0] += 1
            ans[1] += v
    print(*ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys

def solve():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    penalty = [0] * N
    accepted = [False for _ in range(N)] 
    totalPenalty = 0
    totalAccepted = 0
    for _ in range(M):
        p, s = map(str, input().strip("\n").split())
        if s == "WA" and not accepted[int(p) - 1]: penalty[int(p) - 1] += 1
        else:
            if not accepted[int(p) - 1]:
                accepted[int(p) - 1] = True
                totalAccepted += 1
                totalPenalty += penalty[int(p) - 1]
    print(totalAccepted, totalPenalty)

    return 0

if __name__ == "__main__":
    solve()

Submission status: Accepted

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

AC = [0]*N
WA = [0]*N
miss = 0

for i in range(M):
    p,S = list(map(str,input().split()))
    p = int(p)-1
    
    if S == 'AC' and AC[p] == 0:
        AC[p] = 1
        miss += WA[p]
        
    WA[p] += 1
        
print(sum(AC),miss)

Submission status: Accepted

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

AC = [False] * (N+1)
WA_cnt = [0] * (N+1)
ans = 0
pena = 0

for p, s in PS:
    p = int(p)
    if AC[p]:
        continue
    elif s == "WA":
        WA_cnt[p] += 1
        # pena = 1 これだと、AC確定時にpenalty加算されるというルールが守られない
    elif s == "AC":
        ans += 1
        pena += WA_cnt[p]
        AC[p] = True

print(ans, pena, sep=' ')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    k, n = map(int, input().split())
    dp = [0] * (k+1)
    dq = [0] * (k+1)
    pen = 0
    for i in range(n):
        p,q = input().split()
        p = int(p)
        if dp[p] == 0:
            if q == 'WA':
                dq[p] += 1
            elif q == 'AC':
                dp[p] = 1
                pen += dq[p]
    print(sum(dp), pen)

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]= map(str,input().split())
AC = [0]*(N+1)
WA = [0]*(N+1)
i = 0
for i in range(M):
  if S[i] == 'WA':
    if AC[int(p[i])] == 0:
      WA[int(p[i])] = WA[int(p[i])]+1
    else:
      None
  else:
    AC[int(p[i])]=1
count = 0
for i in range(N+1):
  if AC[i]==0:
    count = count+WA[i]
print(sum(AC),sum(WA)-count)

Submission status: Accepted

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

print(AC, WA)

Submission status: Accepted

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

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

for i in range(m):
  p,s = input().split()
  p = int(p)-1
  if s == 'AC':
    ac[p] = True
  else:
    if ac[p] == False:
      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:
x=input().split()
n=int(x[0])
m=int(x[1])
p=[]
ref=[]
for k in range(m):
  x=input().split()
  p.append(int(x[0]))
  ref.append(x[1])
first=[-1]*(n+1)
penal=[0]*(n+1)
for k in range(m):
  if first[p[k]]!=-1:
    continue
  prob=p[k]  
  if ref[k]=='AC':
    first[prob]=k
  else:
    penal[prob]+=1
pb=0
pen=0
for k in range(n+1):
  if first[k]!=-1:
    pb+=1
    pen+=penal[k]
print(pb,pen)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
submit=[]
ans_table={}
ans1=0
ans2=0
cnt1=0
cnt2=0
if m==0:
    print("0 0")
else:
    for i in range(m):
        submit.append(list(input().split()))
    submit.sort(key=lambda x:x[0])

    tmp=submit[0][0]
    for i in submit:
        if i[0]!=tmp:
           tmp = i[0]
           cnt2 = 0
        if i[1]=="WA":
            cnt2+=1
        else:
            if i[0] in ans_table:
                continue
            else:
                ans_table[i[0]]="AC"
                ans2+=cnt2
                ans1+=1
    print(ans1,ans2)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
L = ["WA" for i in range(n + 1)]
wa = [0 for i in range(n + 1)]

ac = 0
penalty = 0
for i in range(m):
    s, p = map(str, input().split())
    s = int(s)
    if L[s] == "AC":
        continue

    if L[s] == "WA" and p == "WA":
        wa[s] += 1
    elif L[s] == "WA" and p == "AC":
        L[s] = "AC"
        ac += 1
        penalty += wa[s]


print(ac, penalty)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
t = {}
W = [0 for i in range(0, n+1)]
A = [0 for i in range(0, n+1)]
w = 0
a = 0
for i in range(m):
    p, s = input().split()
    p = int(p)
    if A[p] == 0 and s == "WA":
        W[p] += 1
    elif A[p] == 0 and s == "AC":
        a += 1
        A[p] = 1
        w += W[p]
print(a, w)

Submission status: Accepted

Solution code:
a,b = map(int,input().split())
AC = [0]*(a+1)
WA = [0]*(a+1)
ac = 0
wa = 0
wat = 0

for i in range(b):
  x,y = map(str,input().split())
  if y == "WA":
    WA[int(x)] += 1
  elif AC[int(x)] == 0 and y == "AC":
    wa += WA[int(x)]
    ac += 1
    AC[int(x)] = 1

print(ac,wa)

Submission status: Accepted

Solution code:
a,b = map(int,input().split())
AC = [0]*(a+1)
WA = [0]*(a+1)
ac = 0
wa = 0
wat = 0

for i in range(b):
  x,y = map(str,input().split())
  if y == "WA":
    WA[int(x)] += 1
  elif AC[int(x)] == 0 and y == "AC":
    wa += WA[int(x)]
    ac += 1
    AC[int(x)] = 1

print(ac,wa)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
q_list = [3] * n
p_count = 0
c_count = 0
#各問いについて[問題番号, WA数, ACしたかどうか]のリストを作る
for i in range(n):
    q_list[i] = [i, 0, False]

for j in range(m):
    p, s = input().split()
    p = int(p) - 1
    if s == 'WA':
        q_list[p][1] += 1
    elif s == 'AC' and q_list[p][2] == False:
        p_count += q_list[p][1]
        c_count += 1
        q_list[p][2] = True

print('{} {}'.format(c_count, p_count))

Submission status: Accepted

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

for i in range(m):
    p[i] = input().split()
AC=[[0,-1] for j in range(n)]
k=0
WA=0
for i in range(m):
    if p[i][1]=="AC" and AC[int(p[i][0])-1][0]==0 :
        AC[int(p[i][0])-1][0]=1
        AC[int(p[i][0])-1][1]=i
        k=k+1
for i in range(m):
    if p[i][1]=="WA" and AC[int(p[i][0])-1][0]==1 and AC[int(p[i][0])-1][1]>i:
        WA=WA+1

print(k,WA)

Submission status: Accepted

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

cnt = 0; correct = 0
for v in d.values():
    if "AC" not in v:
        continue
    correct += 1
    cnt += v.index("AC") 

print(correct, cnt)

Submission status: Accepted

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

cnt = 0; correct = 0
for v in d.values():
    if "AC" not in v:
        continue
    correct += 1
    cnt += v.index("AC") 

print(correct, cnt)

Submission status: Accepted

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

AnsN = [0] * N
WrongN = [0] * N
AnsSum = 0
WrongSum = 0

for i in range(M):
    if (input_list[i][1] == 'AC') and (AnsN[int(input_list[i][0])-1] == 0):
        AnsN[int(input_list[i][0]) - 1] = 1
        AnsSum += 1
        WrongSum += WrongN[int(input_list[i][0])-1]
    elif (input_list[i][1] == 'WA') and (AnsN[int(input_list[i][0])-1] == 1):
        continue
    elif (input_list[i][1] == 'WA') and (AnsN[int(input_list[i][0])-1] >= 0):
        WrongN[int(input_list[i][0])-1] += 1

print(AnsSum, WrongSum)

Submission status: Accepted

Solution code:
import sys
lines = sys.stdin.read().split("\n")
n, m = map(int, lines[0].split())

ac_flags = [0] * (n + 1)
wa_counter = [0] * (n + 1)

ac_count = 0
wa_count = 0
for line in lines[1:-1]:
    p, s = line.split()
    p = int(p)
    if ac_flags[p] == 0:
        if s == "AC":
            ac_flags[p] = 1
            ac_count += 1
            wa_count += wa_counter[p]
        else:
            wa_counter[p] += 1

print ac_count, wa_count

Submission status: Accepted

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

for _ in range(m):
  p, s = input().split()
  p = int(p) - 1
  if s == 'AC':
      ac[p] = True
  else:
      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())

AC = [0] * 200000
WA = [0] * 200000

for _ in range(M):
	P, S = map(str, input().split())
	p = int(P)
	if S == 'AC':
		AC[p] = 1
	else:
		if AC[p] == 0:
			WA[p] += 1

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

print(ac, wa)

Submission status: Accepted

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

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

for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    if s == 'AC':
        ac[p] = True
    else:
        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())
c=[0]*(N+1)
w=[0]*(N+1)
AC=0
WA=0
for i in range(M):
    p,s=input().split()
    p=int(p)
    if(c[p]==0 and s=="AC"):
        c[p]+=1
        AC+=1
        WA+=w[p]
    elif(c[p]==0 and s=="WA"):
        w[p]+=1
print(AC,WA)

Submission status: Accepted

Solution code:
###for decant
###num配列修正版

n, m = input().split()
N = int(n)
M = int(m)
P = [input().split() for i in range(M)]

#numをwa_arr(int)とac_flag(bool)に分割
wa_arr=[0 for _ in range(N)]
ac_flag=[False for _ in range(N)]

for i in range(M):
    #問題番号
    q_num=int(P[i][0]) - 1
    #値が True か False になるので==はいらない
    if ac_flag[q_num]:
        #ACしてたらループ内の以下の処理は打ち切る
        continue
    if P[i][1] == "AC":
        ac_flag[q_num]=True
    else:
        wa_arr[q_num] += 1

cntac=0
cntwa = 0

for j in range(N):
    #ACしている問題のみWA数を追加
    if ac_flag[j]:
        cntac += 1
        cntwa += wa_arr[j]
print(cntac, cntwa)

Submission status: Accepted

Solution code:
n, m = input().split()
N = int(n)
M = int(m)
P = [input().split() for i in range(M)]

num = [[0 for i in range(2)] for j in range(N)]
cntwa = 0
cntac = 0
for i in range(M):
    if num[int(P[i][0]) - 1][0] == 0:
        if P[i][1] == "AC":
            num[int(P[i][0]) - 1][0] = 1
            cntac += 1
        else:
            num[int(P[i][0]) - 1][1] += 1
            cntwa += 1

for j in range(N):
    if num[j][0] == 0:
        cntwa -= num[j][1]
print(cntac, cntwa)

Submission status: Accepted

Solution code:
n, m = [int(i) for i in input().split()]
p = [0] * m
s = [0] * m

ac = 0
wc = 0
wan = [0] * (n+1)
qj = [False] * (n+1)

for i in range(m):
    p[i], s[i] = input().split()
    p[i] = int(p[i])
    if not qj[p[i]]:
        if s[i] == 'AC':
            qj[p[i]] =  'True'
            ac += 1
            wc += wan[p[i]]
        else:
            wan[p[i]] += 1

print(ac, wc)

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
d={} #正解の辞書
e={} #誤答の辞書
f={} #ペナの辞書
for _ in range(M):
    p,s=input().split()
    d.setdefault(p,0)
    e.setdefault(p,0)
    #f.setdefault(p,0)
    if s=="WA" and d[p]==0:
        e[p]+=1
    elif s=="AC":
        d[p]=1
        f[p]=e[p]

print(sum(d.values()),sum(f.values()))

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
d={} #正解の辞書
e={} #誤答の辞書
f={} #ペナの辞書
for _ in range(M):
    p,s=input().split()
    d.setdefault(p,0)
    e.setdefault(p,0)
    f.setdefault(p,0)
    if s=="WA" and d[p]==0:
        e[p]+=1
    elif s=="AC":
        d[p]=1
        f[p]=e[p]

print(sum(d.values()),sum(f.values()))

Submission status: Accepted

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

p = [0] * m
s = [0] * m
ac = [0] * n
wa = [0] * n

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

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

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

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

Submission status: Accepted

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

for i in range(m):
    x = input().split()
    num = int(x[0]) - 1
    if x[1]=='AC':
        AC[num]=1
    elif x[1]=='WA' and AC[num]==0:
        WA[num]+=1
        
print(sum(AC), sum([w for i, w in enumerate(WA) if AC[i]]))

Submission status: Accepted

Solution code:
from collections import Counter

n,m = map(lambda x: int(x), input().split())
x = [0 for i in range(100005)]
tot=0
ac=0
for i in range(m):
	p, s = input().split()
	p=int(p)
	if x[p] == -1:
		continue
	if s == 'AC':
		ac +=1
		tot+=x[p]
		x[p]=-1
	elif s == 'WA':
		x[p] += 1
print(ac, tot)

Submission status: Accepted

Solution code:
nm = list(map(int, input().split()))
N = nm[0]
M = nm[1]

p = [0] * M
s = [0] * M
for i in range(M):
    ps = list(map(str, input().split()))
    p[i] = int(ps[0])
    s[i] = ps[1]

acc = [0] * N
for i in range(M):
    if s[i] == "AC":
        acc[p[i]-1] = 1

point = 0
for i in range(N):
    point = point + acc[i]

penalty = 0
pnc =[ [0] * N for i in range(2)]
for i in range(M):
    if s[i] == "WA" and pnc[1][p[i]-1] == 0:
        pnc[0][p[i]-1] = pnc[0][p[i]-1] + 1
    elif s[i] == "AC":
        pnc[1][p[i]-1] = 1

for i in range(N):
    if pnc[1][i] == 1:
        penalty = penalty + pnc[0][i]

print(str(point)+" "+str(penalty))

Submission status: Accepted

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

n, m = map(int, input().split())
p = []
s = []
for i in range(m):
    t1, t2 = input().split()
    p.append(int(t1)-1)
    s.append(t2)

# 問題iがACしているかどうかを覚えておく配列
ac = [0 for _ in range(n)]
# 問題iがWAしている回数
pena = [0 for _ in range(n)]

# ac[], pena[]を作る。
for i in range(m):
    if ac[p[i]] == 0:
        if s[i] == 'AC':
            ac[p[i]] = 1 
        else:
            pena[p[i]] += 1

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

print("%d %d" % (AC,PENA))

Submission status: Accepted

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

n, m = map(int, input().split())
p = []
s = []
for i in range(m):
    t1, t2 = input().split()
    p.append(int(t1)-1)
    s.append(t2)

# 問題iがACしているかどうかを覚えておく配列
ac = [0 for _ in range(n)]
# 問題iがWAしている回数
pena = [0 for _ in range(n)]

# ac[], pena[]を作る。
for i in range(m):
    if ac[p[i]] == 1:
        continue # XXX
    if s[i] == 'AC':
        ac[p[i]] = 1 
    else:
        pena[p[i]] += 1

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

print("%d %d" % (AC,PENA))

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
ans = [0]*N
pen = [0]*N
for _ in range(M):
  p,S = input().split()
  P = int(p)
  if ans[P-1] == 1:
    continue
  elif ans[P-1] == 0:
    if S == 'AC':
      ans[P-1] += 1
    elif S == 'WA':
      pen[P-1] += 1
      
A = 0
B = 0 
for i in range(N):
  if ans[i] == 1:
    A += 1
    B += pen[i]
print(A,B)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
correct = [0 for _ in range(N)]
missed = [0 for _ in range(N)]
penalty = 0
ans = 0
for _ in range(M):
    p, s = input().split()
    p = int(p)

    if s == "AC" and correct[p - 1] == 0:
        correct[p - 1] = 1
        penalty += missed[p - 1]
    elif s == "WA" and correct[p - 1] == 0:
        missed[p - 1] += 1

print(sum(correct), penalty)

Submission status: Accepted

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

count_ac = count_wa = 0
check_ac = [0] * n
wa_p_i = [0] * n

for i in range(m):
    p, s = input().split()
    now = int(p) - 1

    if s == "AC":
        if check_ac[now] == 0:
            count_ac += 1
            check_ac[now] = 1
            count_wa += wa_p_i[now]
    elif s == "WA":
        wa_p_i[now] += 1

print(count_ac, count_wa)

Submission status: Accepted

Solution code:
import math
n, m = map(int, input().split())
false_count = [1]*n
ans_false_count = [0]*n
ans_success_count = [0]*n

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

    if s=='WA':
        false_count[p-1] = int(false_count[p-1]*2)
    else:
        ans_false_count[p-1] += int(false_count[p-1])
        ans_success_count[p-1] = 1
        false_count[p-1] = 0

for j in range(n):
    if ans_false_count [j] != 0:
        ans_false_count[j] = math.log(ans_false_count[j],2)

new_ans_false_count = ans_false_count
print(sum(ans_success_count), int(sum(new_ans_false_count)))

Submission status: Accepted

Solution code:
import numpy as np

N, M = [int(i) for i in input().split()]
P = []
S = []
for _ in range(M):
    p, s = [x for x in input().split()]
    P.append(int(p)-1)
    S.append(str(s))

AC_list = [0]*N
WA_list = [0]*N
for i in range(M):
    if S[i] == "AC":
        AC_list[P[i]] = 1
    if S[i] == "WA" and AC_list[P[i]] == 0:
        WA_list[P[i]] += 1

correct = sum(AC_list)
penalty = sum(np.array(WA_list)*np.array(AC_list))
print(correct, penalty)

Submission status: Accepted

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

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

for _ in range(m):
    p, s = input().split()
    p = int(p) - 1
    if s == 'AC':
        ac[p] = True
    else:
        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())
box = [0]*N
cor = 0
fal = 0

for i in range(M):
  p,s = input().split()
  p = int(p)
  s = str(s)
  
  if s == "WA":
    if box[p-1] != -1:
      box[p-1] += 1
  else:
    if box[p-1] != -1:
      cor += 1
      fal += box[p-1]
      box[p-1] = -1

print(cor,fal)

Submission status: Accepted

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

import array; ### print(array.typecodes) ###
wacounts = array.array("l", [0] * (n+1))
acflags = array.array("b", [0] * (n+1))

for pi, si in pss:
    pi = int(pi)
    if acflags[pi] == 0:
        if si == "WA": wacounts[pi] += 1
        if si == "AC": acflags[pi] = 1
    ### print(pi, si, wacounts, acflags) ###

print(acflags.count(1), end=" ")
print(sum(x*y for x,y in zip(wacounts, acflags)))

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
ps = [list(input().split()) for _ in range(m)]
aw = ["WA"] * n
wacnt = [0] * n
ac = 0
wa = 0
for i in ps:
    if aw[int(i[0])-1] == "WA":
        if i[1] == "AC":
            ac += 1
            wa += wacnt[int(i[0])-1]
            aw[int(i[0])-1] = "AC"
        else:
            wacnt[int(i[0])-1] += 1
    else:
        pass
print(ac,wa)

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
box = [0] * n
ans = 0
fal = 0
for _ in range(m):
    p,s = input().split()
    p = int(p)
    s = str(s)
    if s == "WA":
        if box[p-1] != -1:
            box[p-1] += 1
        else:
            pass
    else:
        if box[p-1] != -1:
            ans += 1
            fal += box[p-1]
            box[p-1] = -1
        else:
            pass
print(ans,fal)

Submission status: Accepted

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

wa_count = [0] * n
is_accepted = [False] * n
ans_ac = 0
ans_wa = 0

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

    if s == 'AC':
        if not is_accepted[p]:
            is_accepted[p] = True
            ans_ac += 1
            ans_wa += wa_count[p]
    else:
        wa_count[p] += 1

print(ans_ac, ans_wa)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
ac=0
wa=0
boac=[0]*n
bowa=[0]*n
for i in range(m):
    p,s=map(str,input().split())
    p=int(p)-1

    if s=="WA":
        bowa[p]+=1

    if s=="AC" and boac[p]==0:
        boac[p]=1
        ac+=1
        wa+=bowa[p]

print(ac,wa)

Submission status: Accepted

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

chk = [False]*n
wa = [0]*n
c_ac = 0;
c_wa = 0;

for i in range(m):
    _p,_s=input().split()
    j=int(_p)-1
        
    if _s == "WA":
      if chk[j] == False:
        wa[j]+=1
    
    elif _s == "AC":
      if chk[j] == False:
        c_ac += 1
        c_wa += wa[j]
        chk[j] =True

print(c_ac,c_wa,sep= ' ')

Submission status: Accepted

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

result = ["WA"] * N
penalty = [0] * N

for i in range(M):
  I = int(pS[i][0]) - 1
  if result[I] == "WA" and pS[i][1] == "WA":
    penalty[I] += 1
  elif result[I] == "WA" and pS[i][1] == "AC":
    result[I] = "AC"

ans = [0] * 2
for j in range(N):
  if result[j] == "AC":
    ans[0] += 1
    ans[1] += penalty[j]

print(" ".join(map(str, ans)))

Submission status: Accepted

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

ac = [False]*n
c_ac = 0
c_wa = 0
wa = [0]*n
for _ in range(m):
    pi,si = input().split()
    pi = int(pi) - 1
    
    if ac[pi] == False:
        if si == 'WA':
            wa[pi] += 1
        elif si == 'AC':
            c_ac += 1
            c_wa += wa[pi]
            ac[pi] = True

print(c_ac, c_wa)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,M=map(int, input().split())
p=[]
S=[]
for i in range(M):
    P,s=input().split()
    p.append(int(P))
    S.append(s)
A=set()
W=[0 for i in range(0,N)]
w=0
for i in range(0, M):
    if S[i]=='AC' and p[i]-1 not in A:
        w+=W[p[i]-1]
        A.add(p[i]-1)
    elif S[i]=='WA':
        if p[i]-1 not in A:
            W[p[i]-1]+=1
print(len(A), w)