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()) #n:問題数 ,m:提出回数

check_ac = [0]*n #ACかどうか
cnt_wa = [0]*n #WAの回数

for i in range(m):
    p, s = map(str, input().split())
    p = int(p)-1
    if s == "AC": #正解
        if check_ac[p]==0:
            check_ac[p] = 1
    else:
        if not check_ac[p]:
            cnt_wa[p] += 1

for i in range(n):
    if not check_ac[i]:
        cnt_wa[i]=0

print(sum(check_ac), sum(cnt_wa))

Submission status: Accepted

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

main()

Submission status: Accepted

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

ps = []
for i in range(m):
  ps.append(input())

ans = [0] * (n+1)
pen = [0] * (n+1)
sum1 = 0
for i in range(m):
  p,s = ps[i].split()
  if ans[int(p)] == 0:
    if s == "AC" :
      ans[int(p)] += 1
      sum1 += pen[int(p)]
    else:
      pen[int(p)] += 1

print("{} {}".format(sum(ans),sum1))

Submission status: Accepted

Solution code:
def main():
    from sys import stdin
    input = stdin.readline
    N, M = map(int, input().split())
    SP = [list(input().split()) for i in range(M)]
    was = [0] * N
    acs = [0] * N
    penaltyCount = 0
    for sp in SP:
        if acs[int(sp[0])-1] == 1:
            continue
        if acs[int(sp[0])-1] == 0 and sp[1] == "WA":
            was[int(sp[0])-1] += 1
        elif acs[int(sp[0])-1] == 0 and sp[1] == "AC":
            acs[int(sp[0])-1] = 1
            penaltyCount += was[int(sp[0])-1]

    print(sum(acs), penaltyCount)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import numpy as np

n,m = map(int,input().split())
base = np.zeros(n)
pena = np.zeros(n)

for i in range(m):
  s = list(input().split())
  if (s[1] == "WA") and (base[int(s[0])-1] == 0):
    pena[int(s[0])-1] += 1
  elif (s[1] == "AC"):
    base[int(s[0])-1] = 1
    
ans_1 = np.multiply(base,pena)
print(int(np.sum(base)),int(np.sum(ans_1)))

Submission status: Accepted

Solution code:
N,M = map(int, input().split())
WL = [0]*(N+1)
AL = [0]*(N+1)
WLsum = 0
for _ in range(M):
    xx = input().split()
    p = int(xx[0])
    if xx[1]=='AC':
        if AL[p] == 0:
            AL[p] = 1
            WLsum += WL[p]
    else:
        WL[p] += 1

print(str(AL.count(1)) + ' ' + str(WLsum))

Submission status: Accepted

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

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def main():
    N, M = map(int, readline().split())
    submit = [line.split() for line in readlines()]
    submit = [[int(p), S.decode()] for p, S in submit]
    WA_count = [0] * (N + 1)
    correct_list = [False] * (N + 1)
    correct = 0
    penalty = 0
    for p, S in submit:
        if not correct_list[p]:
            if S == 'WA':
                WA_count[p] += 1
            else:
                correct += 1
                penalty += WA_count[p]
                correct_list[p] = True
    print(correct, penalty)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
results = {}
penalty = 0
acs = 0

for i in range(M):
    ans = input().split()
    try:
        results[ans[0]].append(ans[1])
    except KeyError:
        results[ans[0]] = [ans[1]]

for data in results.values():
    if "AC" in data:
        acs += 1
        penalty += data[:data.index("AC")].count("WA")

print(acs, penalty)

Submission status: Accepted

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

Submission status: Accepted

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

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

for _ in range(m):
    a, b = input().split()
    a = int(a)
    if b == 'AC':
        ac[a] = 1
    else: 
        if ac[a] == 0:
            wa[a] = wa[a] + 1

for i in range(n+1):
    wa[i] = wa[i] * ac[i]

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):
  p,s=map(str,input().split())
  if ac[int(p)-1]==0:
    if s=="AC":
      ac[int(p)-1]=ac[int(p)-1]+1
    else:
      wa[int(p)-1]=wa[int(p)-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())
ps = [[i for i in input().split()] for i in range(M)]

ac = 0
penalty = 0
check = [0 for i in range(N)]
for i in range(M):
    p, S = ps[i]
    if check[int(p)-1] != -1:
        if S == "AC":
            ac += 1
            penalty += check[int(p)-1]
            check[int(p)-1] = -1
        if S == "WA":
            check[int(p)-1] += 1

print("{} {}".format(ac, penalty))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
A=[input().split(' ') for i in range(m)]
 
ac={i:0 for i in range(1,n+1)}
wa={i:0 for i in range(1,n+1)}
wa2={i:0 for i in range(1,n+1)}
 
for i in range(m):
    if A[i][1]=='AC':
        tmp=int(A[i][0])
        ac[tmp]=1
    else:
        tmp=int(A[i][0])
        if ac[tmp]==1:
            pass
        else:
            wa[tmp]+=1
for i in range(1,n+1):
    if ac[i]==1:
        wa2[i]=wa[i]
    else:
        pass

print(str(sum(ac.values()))+' '+str(sum(wa2.values())))

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
W = dict()
A = dict()
ac = 0
pt = 0
Q = []
for i in range(M):
    p, S = input().split()
    p = int(p)
    if not p in W.keys():
        W[p] = 0
        A[p] = 0
    if S == 'WA':
        W[p] += 1
    if S == 'AC':
        if A[p] != 'AC':
            A[p] = 'AC'
            pt += W[p]
            ac += 1
print(ac,pt)

Submission status: Accepted

Solution code:
from collections import defaultdict

def main():
	N,M = map(int,input().split())
	submit = defaultdict(lambda : [0,0])
	for _ in range(M):
		p,s = input().split()
		p = int(p)
		if(s == "AC"):
			submit[p][0] = 1
		else:
			if(submit[p][0] == 0):
				submit[p][1] +=1
	num_AC = 0
	num_WA = 0
	for _,value in submit.items():
		if(value[0] == 1):
			num_AC += 1
			num_WA += value[1]
	print(num_AC,num_WA)

if __name__ == "__main__":
	main()

Submission status: Accepted

Solution code:
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n,m = mi()

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

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

Submission status: Accepted

Solution code:
#https://atcoder.jp/contests/abc151/tasks/abc151_c

n,m=map(int,input().split())
res_ac=[-1 for i in range(n)]
tmp_wa=[0 for i in range(n)]
ac=0
wa=0


for i in range(m):
    sbmt=input().split()
    problem_num=int(sbmt[0])-1
    problem_ans=sbmt[1]
    if (problem_ans=="WA")&(res_ac[problem_num]==-1):#まだACしてない
        tmp_wa[problem_num]+=1
    if (problem_ans=="AC")&(res_ac[problem_num]==-1):
        res_ac[problem_num]=1
        ac+=1
        wa+=tmp_wa[problem_num]

print(ac,wa)

Submission status: Accepted

Solution code:
def main():
    n, m = map(int, input().split())
    ac = [0] * n
    pena = [0] * n
    for i in range(m):
        p = input().split()
        if ac[int(p[0])-1] > 0:
                continue
        elif p[1] == "AC":
            ac[int(p[0])-1] += 1
        else:
            pena[int(p[0])-1] += 1
    for i in range(n):
        if ac[i] == 0:
            pena[i] = 0
    print(sum(ac), sum(pena))

if __name__ == '__main__':
    main()

Submission status: Accepted

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

ans=[0]*N
pen=[0]*N
AC=[0]*N

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

print(AC.count(1),sum(ans))

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
AC = [0]*N
WA = [0]*N
L = []
for m in range(M):
    p, S = map(str, input().split())
    p = int(p)
    L.append([p, S])
for m in range(M):
    if not AC[L[m][0]-1] == 0:
        continue    
    if L[m][1] == 'AC':
        AC[L[m][0]-1] = 1
    elif L[m][1] == 'WA':
        WA[L[m][0]-1] += 1
A = sum(AC)
W = 0
for n in range(N):
    if AC[n] == 1:
        W += WA[n]
print(A, W)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
tmp  = [0]*n
wtmp = [0]*n
for _ in range(m):
    P, s = map(str, input().split())
    p = int(P)
    p -= 1
    if not tmp[p] == 0:
        continue
    if s == 'AC':
        tmp[p] = 1
    else:
        wtmp[p] += 1
ans1 = sum(tmp)
ans2 = 0
for i in range(n):
    if tmp[i] == 1:
        ans2 += wtmp[i]
print(ans1, ans2)

Submission status: Accepted

Solution code:

N, M = map(int, input().split())
P = []
s = []
for i in range(M):
    p, S = input().split()
    p = int(p) - 1
    P.append(p)
    s.append(S)
A = [[0, 0] for _ in range(N)]
for i in range(M):
    if s[i] == 'AC':
        A[P[i]][0] = 1
    if s[i] == 'WA' and A[P[i]][0] != 1:
        A[P[i]][0] = 2
        A[P[i]][1] += 1

print(len([a for a in A if a[0] == 1]), sum([a[1] for a in A if a[0] == 1]))

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
#p = []
#S = []
AC = [0]*N
WA = [0]*N
for i in range(M):
  pp, SS = input().split()
  #p.append(int(pp))
  #S.append(SS)
  
  if SS == "AC" and AC[int(pp)-1] == 0:
    AC[int(pp)-1] += 1
  elif SS == "WA" and AC[int(pp)-1] == 0:
    WA[int(pp)-1] += 1
    
for i in range(N):
  if AC[i] == 0:
    WA[i] = 0
    
print(sum(AC), sum(WA))
#print(p, S)

Submission status: Accepted

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

for i in range(m):
    p, s = input().split()
    p = int(p)
    p -= 1
    # print(p, s)
    if (s == "AC"):
        if (isac[p] != 1):
            ac += 1
            pena += wa[p]
            isac[p] = 1
    else:
        if (isac[p] == 0):
            wa[p] += 1
    # print(ac, pena, isac[p], wa[p])

print(ac, pena)

Submission status: Accepted

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

inputs = [ input().split() for _ in range(m) ]

collectNum = 0
penaltyNum = 0


# AC前にWAを出した回数をカウントする　ACで'-1'にしてそれ以上カウントしない
waCounts = [0] * (n+1)

for inp in inputs:
    questNum = int(inp[0])
    result = inp[1]

    if waCounts[questNum] != -1:
        if result == 'AC':
            collectNum += 1
            penaltyNum += waCounts[questNum]
            waCounts[questNum] = -1
        elif result == 'WA':
            waCounts[questNum] += 1

print("{} {}".format(collectNum, penaltyNum))

Submission status: Accepted

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

AC_count = 0
WA_count = 0

problem_list = [0]*N
result_list = [0]*N
wa_list = [0]*N

for _ in range(M):
    p, s = map(str, input().split())
    p = int(p)
    p -= 1

    if problem_list[p] == 1:
        if result_list[p] == 'AC':
            continue
        elif result_list[p] == 'WA' and s =='AC':
            result_list[p] = 'AC'
            AC_count += 1
        else:
            wa_list[p] += 1
            
    else:
        problem_list[p] = 1
        result_list[p] = s

        if s == 'AC':
            AC_count += 1
        else:
            wa_list[p] += 1

for i in range(N):
    if result_list[i] == 'AC':
        WA_count += wa_list[i]

print(AC_count, WA_count)

Submission status: Accepted

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

Submission status: Accepted

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

WA=[]
AC=[]
for i in range(N):
    WA.append(0)
    AC.append(0)

for i in range(M):
    if P[i][1]=="WA" and  AC[int(P[i][0])-1]==0:
        WA[int(P[i][0])-1]+=1
    elif P[i][1]=="AC":
        AC[int(P[i][0])-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())

Problem = [[] for _ in range(N)]

for i in  range(M):
    p,S = input().split()
    p = int(p) - 1
    if (len(Problem[p])==0) or (len(Problem[p])>0 and Problem[p][-1]=='WA'):
        Problem[p].append(S)
ans_AC = 0
ans_WA = 0

for i in range(N):
    if 'AC' in Problem[i]:
        ans_AC += 1
        ans_WA += Problem[i].count('WA')

print('{} {}'.format(ans_AC,ans_WA))

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# coding: utf-8

# In[35]:


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


# In[38]:


mydict = {}
for i in range(N):
    mydict[i+1] = {}
    mydict[i+1]["time"] = 0
    mydict[i+1]["AC"] = False
for x in pS:
    if x[1] == "AC":
        mydict[int(x[0])]["AC"] = True
    else: # x[1] == "WA"
        if mydict[int(x[0])]["AC"] == False:
            mydict[int(x[0])]["time"] += 1
t = sum([d["time"] for d in list(mydict.values()) if d["AC"]])
ac = sum([1 for d in list(mydict.values()) if d["AC"]])
print(ac, t)


# In[ ]:

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
countAC = 0
countPena = 0
if M:

    pS = [input().split() for _ in range(M)]
    p, S = [list(i) for i in zip(*pS)]

    dic = {}

    for i in range(M):
        if not p[i] in dic:
            dic[p[i]] = {
                'AC': 0,
                'WA': 0
            }

        if S[i] == 'AC':
            dic[p[i]]['AC'] += 1
        if S[i] == 'WA' and dic[p[i]]['AC'] == 0:
            dic[p[i]]['WA'] += 1

    for k, v in dic.items():
        if v['AC'] > 0:
            countAC += 1
            countPena += v['WA']

print(countAC, countPena)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
tmp=[0]*n
wtmp=[0]*n
for _ in range(m):
    P,s=map(str,input().split())
    p=int(P)
    p-=1
    if not tmp[p]==0:
        continue
    if s=='AC':
        tmp[p]=1
    else:
        wtmp[p]+=1
ans1=sum(tmp)
ans2=0
for i in range(n):
    if tmp[i]==1:
        ans2+=wtmp[i]
print(ans1,ans2)

Submission status: Accepted

Solution code:
import numpy as np
N,M = map(int, input().split())
p, S = [], []
for i in range(M):
  tmp = input().split()
  p.append(int(tmp[0]))
  S.append(tmp[1])

answer = np.zeros([N,2], dtype=int)
for i in range(M):
  if S[i] == 'AC' and answer[p[i]-1][0] == 0:
    answer[p[i]-1][0] += 1
  elif S[i] == 'WA' and answer[p[i]-1][0] == 0:
    answer[p[i]-1][1] += 1

total = [0, 0]
for i in range(N):
  if answer[i][0] == 1:
    total[0] += answer[i][0]
    total[1] += answer[i][1]
print(total[0], total[1])

Submission status: Accepted

Solution code:
import numpy as np
N,M = map(int, input().split())
p, S = [], []
for i in range(M):
  tmp = input().split()
  p.append(int(tmp[0]))
  S.append(tmp[1])

past_p = 0
tmp_AC, tmp_WA = 0, 0
total_AC, total_WA = 0, 0
answer_AC = np.zeros(N)
answer_WA = np.zeros(N)
for i in range(M):
  if S[i] == 'AC' and answer_AC[p[i]-1] == 0:
    answer_AC[p[i]-1] += 1
  elif S[i] == 'WA' and answer_AC[p[i]-1] == 0:
    answer_WA[p[i]-1] += 1
#print(answer_AC)
#print(answer_WA)
total_AC, total_WA = 0, 0
for i in range(N):
  if answer_AC[i] == 1:
    total_AC += answer_AC[i]
    total_WA += answer_WA[i]
print(int(total_AC), int(total_WA))

Submission status: Accepted

Solution code:
n1, n2 = [int(i) for i in input().split()]

d1 = {}
r1 = 0
r2 = 0

for i1 in range(n2):
    t1, t2 = [i for i in input().split()]
    if t1 in d1:
        t3 = d1.get(t1)
        if t3 != 0:
            if t2 == "AC":
                r1 += 1
                r2 += t3
                d1[t1] = 0 
            else:
                d1[t1] =  t3 + 1
    else:
        if t2 == "AC":
            d1[t1] = 0 
            r1 += 1
        else:
            d1[t1] = 1
        
print(str(r1) + " " + str(r2))

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10000000)
import os
import math
import bisect
import collections
import itertools
import heapq
import re
import queue

# import fractions

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, M = il()
    ANS = [sl() for _ in range(M)]

    keys = set()
    for p, S in ANS:
        keys.add(p)

    ret = {key: False for key in keys}
    acwa = {key:[0, 0] for key in keys}
    for p, S in ANS:
        if ret[p]: continue
        if S == 'WA':
            acwa[p][1] += 1
        if S == 'AC':
            acwa[p][0] += 1
            ret[p] = True

    ac, wa = 0, 0
    for key in keys:
        if ret[key]:
            ac += acwa[key][0]
            wa += acwa[key][1]
    print(ac, wa)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
# import math
# import itertools
# from collections import deque
# from collections import defaultdict
# import heapq
# import copy
# import bisect
# import numpy as np
# from scipy.special import comb


def my_input(): return sys.stdin.readline().rstrip()
# sys.setrecursionlimit(100000)
# INF = 1001001001001
# MOD = 1000000007


def main():

    N, M = map(int, input().split())
    ac = [0 for _ in range(N)]
    wa = [0 for _ in range(N)]

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

    # print(ac)
    # print(wa)

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

    print(str(sum(ac)) + " " + str(sum(wa)))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# import sys
# import math
# import itertools
# from collections import deque
# from collections import defaultdict
# import heapq
# import copy
# import bisect
# import numpy as np
# from scipy.special import comb

# def my_input(): return sys.stdin.readline().rstrip()
# sys.setrecursionlimit(100000)
# INF = 1001001001001
# MOD = 1000000007

def main():

    N, M = map(int, input().split())
    ac = [0 for _ in range(N)]
    wa = [0 for _ in range(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

    # print(ac)
    # print(wa)

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

    print(str(sum(ac)) + " " + str(sum(wa)))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# For taking integer inputs.
def inp():
    return(int(input()))


# For taking List inputs.
def inlist():
    return(list(map(int, input().split())))


# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.
def instr():
    s = input()
    return(list(s[:len(s)]))


# For taking space seperated integer variable inputs.
def invr():
    return(map(int, input().split()))


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

print(sum(AC), penalty)

Submission status: Accepted

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

List = []
ans = [0  for i in range(N+1)]
WA = [0  for i in range(N+1)]

for i in range(M):
  p,S = input().split()
  p = int(p)
  
  if ans[p] == 0:
    if S == "AC":
      ans[p] = 1
    else:
      WA[p] += 1
      
A = sum(ans)

W= 0

for i in range(N+1):
  W += ans[i] * WA[i]

print(A,W)

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
PS = [list(input().split()) for _ in range(m)]
ac = 0
wa = 0
tac = [0]*n
twa = [0]*n
for ps in PS:
  if tac[int(ps[0])-1]==0:
    if ps[1]=='AC':
      ac += 1
      wa += twa[int(ps[0])-1]
      tac[int(ps[0])-1] = 1
    else:
      twa[int(ps[0])-1] += 1
print(ac,wa)

Submission status: Accepted

Solution code:
n,m = [int(x) for x in input().split(' ')]

info = {
    
}

for i in range(m):
    p,s = [x for x in input().split(' ')]
    if p not in info:
        if s == "WA":
            info[p] = [0, 1]
        elif s == "AC":
            info[p] = [1,0]
    else:
        if s == "WA":
            if info[p][0] == 0:
                info[p][1] += 1
        elif s == "AC":
            if info[p][0] == 0:
                info[p][0] = 1
    
ac = 0
wa = 0

for a in info.values():
    ac += a[0]
    if a[0] > 0:
        wa += a[1]

print(ac, wa)

Submission status: Accepted

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

for i in range(m):
  p,s = input().split()
  if s == 'AC':
    aclist[int(p)-1] = 1
  elif s == 'WA' and aclist[int(p)-1] == 0:
    walist[int(p)-1] += 1 
    
for i in range(n):
  if aclist[i] == 0:
    walist[i] = 0
    
print(sum(aclist),sum(walist))

Submission status: Accepted

Solution code:
import collections
k,n = map(int, raw_input().split(' '))
cc = {'AC': collections.Counter(), 'WA': collections.Counter()}
for _ in range(n):
	i,res = raw_input().split(' ')
	i = int(i)
	if res == 'AC':
		cc['AC'][i] += 1
	elif res == 'WA' and cc['AC'][i] == 0: 
		cc['WA'][i] += 1

print len(cc['AC']), sum([cc['WA'][p] for p in cc['AC']] or [0])

Submission status: Accepted

Solution code:
import collections
k,n = map(int, raw_input().split(' '))


cc = {'AC': collections.Counter(), 'WA': collections.Counter()}
for _ in range(n):
	i,res = raw_input().split(' ')
	i = int(i)
	if res == 'AC':
		cc['AC'][i] += 1
	elif res == 'WA':
		if cc['AC'][i] == 0:
			cc['WA'][i] += 1
s = 0
for p in cc['AC']:
	s += cc['WA'][p]
print len(cc['AC']), s #len(penalties)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
dict={}
ans=[0, 0]
for i in range(M):
	P, S = input().split()
	if P not in dict:
		if S=="AC":
			ans[0]+=1
			dict[P]=S
		else:
			dict[P]=[S, 1]
	else:
		if dict[P][0]=="WA":
			if S=="WA":
				dict[P][1]+=1
			else:
				ans[0]+=1
				ans[1]+=dict[P][1]
				dict[P]=S
		else:
			continue

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

Submission status: Accepted

Solution code:
n,m = list(map(int,input().split(" ")))
ac_count = 0
wa_list = [0]*n
ac_list = [0]*n

for i in range(m):
    x = list(map(str,input().split(" ")))
    x0 = int(x[0])
    x1 = str(x[1])
    if ac_list[x0-1] == 1:
        pass
    else:
        if x1 == "AC":
            ac_count += 1
            ac_list[x0-1] = 1
        else:
            wa_list[x0-1] += 1

acnone =[i for i, x in enumerate(ac_list) if x == 0]
if not acnone:
    pass
else:
    for i in acnone:
        wa_list[i] = 0
wa_count = sum(wa_list)
print(ac_count,wa_count)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
did_ac = [False] * N
pn_cnt = [0] * N
for _ in range(M):
    p, s = input().split()
    p = int(p) - 1
    if did_ac[p]:
        continue
    s = s == 'AC'
    if s:
        did_ac[p] = True
    else:
        pn_cnt[p] += 1
print(sum(did_ac), sum(pn_cnt[i] for i in range(N) if did_ac[i]))

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
acount=0
wcount=0
a=[False]*n
w=[0]*n
for i in range(m):
  p,m=input().split()
  p=int(p)
  if m=="AC":
    if a[p-1]==False:
      acount+=1
      a[p-1]=True
  else:
    if a[p-1]==False:
      w[p-1]+=1
      
for i in range(n):
  if a[i-1]==1:
    wcount+=w[i-1]
    
print(acount,wcount)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
acount=0
wcount=0
a=[0]*n
w=[0]*n
for i in range(m):
  p,m=map(str,input().split())
  p=int(p)
  if m=="AC":
    if a[p-1]==0:
      acount+=1
      a[p-1]+=1
  else:
    if a[p-1]==0:
      w[p-1]+=1
      
for i in range(n):
  if a[i-1]==1:
    wcount+=w[i-1]
    
print(acount,wcount)

Submission status: Accepted

Solution code:
# C - Welcome to AtCoder
# https://atcoder.jp/contests/abc151/tasks/abc151_c

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

ac_cnt = 0
wa_cnt = 0

for i in range(n):
    if ac[i] == True:
        ac_cnt += 1
        wa_cnt += wa[i]

print(ac_cnt,wa_cnt)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
ans = []
for m in range(M):
    ans.append(input().split())

ac = [0 for n in range(N)]
wa = [0 for n in range(N)]
w = 0
for a in ans:
    if ac[int(a[0])-1] == 1:
        continue
    else:
        if a[1] == "AC":
            ac[int(a[0])-1] = 1
            w += wa[int(a[0])-1]
        else:
            wa[int(a[0])-1] += 1
        
print(sum(ac), w)

Submission status: Accepted

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

ps=[]
pena=[[0,False] for _ in range(n)]
for i in range(m):
    ps.append(input().split())
 
for i in range(m):
    if pena[int(ps[i][0])-1][1]==False and ps[i][1]=="WA":
        pena[int(ps[i][0])-1][0]+=1
    else:
        pena[int(ps[i][0])-1][1]=True
ans=0
for i in range(n):
    if pena[i][1]==True:
        ans+=pena[i][0]
        
t=[pena[i][1] for i in range(len(pena))]
print(t.count(True),ans)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
cleared = [0 for i in range(N)]
wrong = [0 for i in range(N)]
penalty = 0
for i in range(M):
  p, s = map(str, input().split())
  p = int(p) - 1
  if cleared[p] == 1:
    continue
  if s == "AC":
    cleared[p] = 1
    penalty += wrong[p]
  else:
    wrong[p] += 1
print(sum(cleared), penalty)

Submission status: Accepted

Solution code:
from collections import defaultdict

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

cleared = set()
penalties = defaultdict(int)

for _ in range(M):
    q, result = input().split(' ')
    if result == 'AC':
        cleared.add(q)
    elif q not in cleared:
        penalties[q] += 1

print(len(cleared), sum([penalties[q] for q in cleared]))

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
p=[True]*n
y=[0]*n
i=0
l=0
for  _ in range(m):
    k,o=input().split()
    k=int(k)-1
    if p[k]==True:
        if o=="AC":
            i+=1
            p[k]=False
        else:
            y[k]+=1
for e in range(n):
    if p[e]==False:
        l+=y[e]
print(i,l)

Submission status: Accepted

Solution code:
import sys
import math
import itertools
import numpy

rl = sys.stdin.readline

n, k= map(int, rl().split())
li = [[0, 0] for _ in range(n)]
for _ in range(k):
    a, b = rl().split()
    b = b.rstrip()
    a = int(a) - 1
    if li[a][1] == 0:
        if b == 'WA':
            li[a][0] += 1
        else:
            li[a][1] = 1
ac = 0
wa = 0
for lis in li:
    i, v = lis
    if v == 1:
        ac += 1
        wa += i
print(ac, wa)

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()
    p = int(p)
    if ac[p-1]==1 :
        continue
    else:
        if s == 'AC':
           ac[p-1]+=1
        else :
            wa[p-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())
wa = [0]*n
ac = [0]*n
for i in range(m):
    p,s = input().split()
    p = int(p)
    if ac[p-1]==1 :
        continue
    else:
        if s == 'AC':
           ac[p-1]+=1
        else :
            wa[p-1]+=1            

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

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

Submission status: Accepted

Solution code:
def main():
    #input
    N,M=map(int,input().strip().split())
    cnt=[0 for n in range(N)]
    flag=[0 for n in range(N)]
    
    for _ in range(M):
        pS=list(input().strip().split())
        x=int(pS[0])
        y=pS[1]
        if flag[x-1]==0:
            if y=="WA":
                cnt[x-1]+=1
            else:
                flag[x-1]=1
                
    num_AC=sum(flag)
    num_WA=sum([cnt[n] for n in range(N) if flag[n]==1])
                
    print(str(num_AC)+" "+str(num_WA))

if __name__=="__main__":
   main()