Problem:


Score : 300 points

Problem Statement

Takahashi participated in a contest on AtCoder.

The contest had N problems.

Takahashi made M submissions during the contest.

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

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

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

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

Constraints

N, M, and p_i are integers.

1 \leq N \leq 10^5

0 \leq M \leq 10^5

1 \leq p_i \leq N

S_i is AC or WA.

Input

Input is given from Standard Input in the following format:

N M
p_1 S_1
:
p_M S_M

Output

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

Sample Input 1

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

Sample Output 1

2 2

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

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

Thus, he has two correct answers and two penalties.

Sample Input 2

100000 3
7777 AC
7777 AC
7777 AC

Sample Output 2

1 0

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

Sample Input 3

6 0

Sample Output 3

0 0



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


Sample output:
2 2

Submission status: Accepted

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

Submission status: Accepted

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

correct_questions = [False] * N
incorrect_questions = [0] * N
num_of_correct = 0
num_of_penalties = 0
for pi, Si in pS:
    nth = int(pi) - 1
    
    if Si == 'AC' and correct_questions[nth] is False:
        correct_questions[nth] = True
        num_of_correct += 1
        num_of_penalties += incorrect_questions[nth]
    elif Si == 'WA' and correct_questions[nth] is False:
        incorrect_questions[nth] += 1

print("{} {}".format(num_of_correct, num_of_penalties))

Submission status: Accepted

Solution code:
def main():
    n, m = map(int, input().split())
    ary = [input().split() for _ in range(m)]
    ac_cnt = 0
    wa_cnt = 0
    ac_ary = [[0, 0] for i in range(n)]
    for toi_num, kekka in ary:
        num = int(toi_num) - 1
        if ac_ary[num][0] == 0:
            if kekka == 'WA':
                ac_ary[num][1] += 1
            elif kekka == 'AC':
                ac_ary[num][0] = 1
                ac_cnt += 1
                wa_cnt += ac_ary[num][1]
    print(ac_cnt, wa_cnt)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(str,input().split()))





N,M=input2()
ps=[]
for _ in range(M):
	ps.append(input_array())
ans_dict={i:False for i in range(N)}
ans_list=[0]*N
wa_list=[0]*N

wa=0


for x in ps:
	num=int(x[0])-1
	ans=x[1]
	if ans_dict[num] ==True:
		continue
	elif ans=="WA" and ans_dict[num]==False:
		wa_list[num]+=1
	elif ans=="AC" and ans_dict[num]==False:
		wa+=wa_list[num]
		ans_dict[num]=True
		ans_list[num]=1

print(sum(ans_list),wa)

Submission status: Accepted

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

d = [0]*10**5
a = set()
w = 0


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

for p,s in ps:
    if "AC" == s and p not in a:
        w += d[p]
        a.add(p)
    if "WA" == s:
        d[p] += 1
print(len(a),w)

Submission status: Accepted

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

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

a = 0
b = 0
for i in range(m):
    p, s = input().split()
    p = int(p)
    if s == 'AC' and dic[p] != 'AC':
        b += dic[p]
        dic[p] = 'AC'
    elif dic[p] != 'AC':
        dic[p] += 1
    
for i in range(1, n+1):
    if dic[i] == 'AC':
        a += 1
    
print(a, b)

Submission status: Accepted

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

N = a[0]
M = a[1]

AC = [0] * N #ACの問題番号を1にする i = id -1
WA = [0] * N #WAの回数を入れる
WA_sum = 0
for i in range(M):
    a = list(map(str,input().split()))
    id_num = int(a[0])-1
    if AC[id_num] == 1:
        continue
    elif a[1] == 'WA':
        WA[id_num] += 1
    elif a[1] == 'AC':
        AC[id_num] = 1 
        WA_sum += WA[id_num]
        
print('{} {}'.format(sum(AC),WA_sum))

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
if m==0:
  print(0,0)
else:
  q=[0]*(n+1)
  s=[0]*(n+1)
  t=0
  for i in range(m):
    p,u=map(str,input().split())
    p=int(p)
    if q[p]==1:
      continue
    
    elif u=='AC':
      q[p]=1
      
      t+=s[p]
      
      
    elif u=="WA":
      if q[p]==0:
        s[p]+=1
        
  
  
  
  
  print(sum(q),t)

Submission status: Accepted

Solution code:
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [[input().split()] for _ in range(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

n,m=n1()
ps=s2(m)
OK=NG=0
d={str(i):[False,0] for i in range(1,n+1)}
for line in ps:
    num=line.split()[0]
    ans=line.split()[1]
    if d[num][0]==False:
        if ans=="AC":
            OK+=1
            d[num][0]=True
        else:
            d[num][1]+=1
for i,b in d.items():
    if b[0]:
        NG+=b[1]
print(OK,NG)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
ac, wa = [0]*(n+1), [0]*(n+1)
ans1, ans2 = 0, 0
for i in range(m):
    p, s = map(str, input().split())
    if ac[int(p)]==1: continue
    if s=='AC':
        ac[int(p)] = 1
        ans1 += 1
        ans2 += wa[int(p)]
    else:
        wa[int(p)] += 1
print(ans1, ans2)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
ac, wa = 0, 0
ac = [0]*(n+1)
wa = [0]*(n+1)
ans1, ans2 = 0, 0
for i in range(m):
    p, s = map(str, input().split())
    if ac[int(p)]==1: continue
    if s=='AC':
        ac[int(p)] = 1
        ans1 += 1
        ans2 += wa[int(p)]
    else:
        wa[int(p)] += 1
print(ans1, ans2)

Submission status: Accepted

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

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

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

print(ac, wa)

Submission status: Accepted

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

for i in range(M):
    # for文で回しつつ処理する
    p, S = input().split(' ')
    p = int(p)
    #  ACの場合
    if S == 'AC':
        #  結果番号を格納
        AC[p-1] = 1
    #  WAの場合, かつ前回正解していない
    elif S == 'WA' and AC[p-1] == 0:
        #  不正解番号を格納
        WA[p-1] += 1
 
AC_cnt = 0
WA_cnt = 0
for i in range(N):
    # 正解があった場合
    if AC[i] == 1:
        # 正解数とカウント
        AC_cnt += 1
        # ペナルティとカウント
        WA_cnt += WA[i]
 
print(AC_cnt, WA_cnt)

Submission status: Accepted

Solution code:
n, m = map(int,input().split())
pS = [input().split() for _ in range(m)]
correct = 0
flag = [False] * n
pena = [0] * n
sum = 0
for p, s in pS:
    p = int(p)
    if flag[p-1] == True:
        continue
    else:
        if s == "WA":
            pena[p-1] += 1
        elif s == "AC":
            sum += pena[p-1]
            correct += 1
            flag[p-1] = True
print(correct, sum)

Submission status: Accepted

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

AC = set()
cnt = {i: 0 for i in range(1, N + 1)}
for _ in range(M):
    p, S = input().split()
    p = int(p)
    if (S == "AC"):
        AC.add(p)
    elif (S == "WA" and p not in AC):
        cnt[p] += 1

WA = sum([v for k, v in cnt.items() if k in AC])
print(len(AC), WA)

Submission status: Accepted

Solution code:
d = [0]*10**5

a = set()
w = 0

for t in open(0):
    p, s = t.split()
    p = int(p)
    if "AC" == s and p not in a:
        w += d[p]
        a.add(p)
    if "WA" == s:
        d[p] += 1

print(len(a), w)

Submission status: Accepted

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


def solve(N: int, M: int, p: "List[int]", S: "List[str]"):
    c = np.array([0] * N)
    penalty = np.array([0] * N)

    pp = 0

    for i in range(M):
        if S[i]=='AC':
            if c[p[i]-1]==1:
                pass
            else:
                c[p[i]-1] = 1
                pp+=penalty[p[i]-1]
        else:
            if c[p[i]-1]:
                pass
            else:
                penalty[p[i]-1]+=1
    
    print(c.sum(), pp)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    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)
    solve(N, M, p, S)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

for i in range(N):
    if rec[i][1] == 1:
        AC += 1
        pe += rec[i][0]

print(AC,pe)

Submission status: Accepted

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

sx=0
sy=0
for i in range(n):
  sx+=x[i]
  if x[i]==1:
    sy+=y[i]
  
print(str(sx),str(sy))

Submission status: Accepted

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

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

print(ac, wa)

Submission status: Accepted

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

for i in range(m):
    p, s = input().split()
    p = int(p)
    if l[p][0] == 0: #ACが0の場合
        if s == "AC":
            l[p][0] = 1
        else:
            l[p][1] += 1

for i in range(1, n + 1):
    ac += int(l[i][0])
    if int(l[i][0]) != 0:
        wa += int(l[i][1])
print(ac, wa)

Submission status: Accepted

Solution code:
N,M = list(map(int,input().split()))
p = []
for i in range(M):
    x,y = list(map(str, input().split()))
    p.append([int(x),y])
count = [[0,0]for i in range(N)]
ansac = 0
answa = 0
for i in range(M):
    if count[p[i][0]-1][1] != 0:
        pass
    else:
        if p[i][1] == 'AC':
            count[p[i][0]-1][1] += 1
        else:
            count[p[i][0]-1][0] += 1
for i in range(N):
    if count[i][1] > 0:
        answa += count[i][0]
    ansac += count[i][1]
print(str(ansac) + ' ' + str(answa))

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import defaultdict
def main():
    n,m=map(int,input().split())
    ac=[False]*n
    wa=[0]*n
    pena=0
    for i in range(m):
        k,s=input().split()
        k=int(k)-1
        if s=="WA":wa[k]+=1
        elif ac[k]:continue
        else:
            ac[k]=True
            pena+=wa[k]
    print(sum(ac),pena)


if __name__=='__main__':
    main()

Submission status: Accepted

Solution code:
n, m = (int(x) for x in input().split())
sub = [0] * (n+1)
ok = ng = 0
for i in range(m):
  p, s = input().split()
  p = int(p)
  if sub[p] == -1:
    continue
  if s == 'WA':
    sub[p] += 1
  if s == 'AC':
    ok += 1
    ng += sub[p]
    sub[p] = -1
print(ok, ng)

Submission status: Accepted

Solution code:
x, y = map(int, input().split())
dd = {}
c = 0 #間違い数
p = 0 #AC数
for i in range(x):
    dd[i+1] = 0
for _ in range(y):
    a, b = map(str, input().split())
    a = int(a)
    if b == 'WA':
        if dd[a] == 'o':
            continue
        else:
            dd[a] += 1
    else:
        if dd[a] == 'o':
            continue
        else:
            c += dd[a]
            p += 1
            dd[a] = 'o'
            
print(p, c)

Submission status: Accepted

Solution code:
import math
import sys

pena=0
N,M=map(int,input().split())
AClist=[0]*N
penalist=[0]*N
for i in range(M):
    pm,sm=input().split()
    pm=int(pm)
    if sm=="AC":
        AClist[pm-1]=1
    else:
        if AClist[pm-1]==0:
            penalist[pm-1]+=1
for i in range(N):
    if AClist[i]==1:
        pena+=penalist[i]



print(AClist.count(1),pena)

Submission status: Accepted

Solution code:
from itertools import groupby


n, m = map(int, input().split())
WA = [0] * (n + 1)
AC = [False] * (n + 1)
wanum = 0
acnum = 0
for i in range(m):
    p, s = input().split()
    if AC[int(p)]:
        continue
    if s == 'AC':
        acnum += 1
        wanum += WA[int(p)]
        AC[int(p)] = True
    elif s == 'WA':
        WA[int(p)] += 1
print(acnum, wanum)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import os

def main():
	
	N,M = map(int, input().split())
	ac = [0]*N
	wa = [0]*N
	for i in range(M):
		p,s = input().split()
		if s == 'AC':
			if ac[int(p) - 1] != 0:
				continue
			else:	
				ac[int(p) - 1] = 1
		else:
			if ac[int(p) - 1] != 0:
				continue
			else:
				wa[int(p) - 1] += 1
	AC,WA = 0,0

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

if __name__ == '__main__':
	main()

Submission status: Accepted

Solution code:
n,m = map(int, input().split())
a = []
for _ in range(n):
  a.append(0)
w = a.copy()
x = a.copy()
for _ in range(m):
  q,r = input().split()
  q = int(q)-1
  if r == "WA" and a[q] != 1:
    w[q] += 1
  elif r == "AC" and a[q] != 1:
    x[q] = w[q]
    a[q] = 1
print(sum(a), sum(x))

Submission status: Accepted

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

lst = [0] * (N + 1)
check = [0] * (N + 1)
AC = 0
WA = 0
for _ in range(M):
    p, S = map(str, input().split())
    if S == 'WA':
        lst[int(p)] += 1
    else:
        if check[int(p)] == 0: #初めてのACのときだけ処理する
            AC += 1
            check[int(p)] = 1
            WA += lst[int(p)]

print (AC, WA)

Submission status: Accepted

Solution code:
n,m = map(int, input().split())
la = []
lw = []
lwa = []
for i in range(n):
  la.append(0)
  lw.append(0)
  lwa.append(0)
for _ in range(m):
  q,a = input().split()
  if a == "WA" and la[int(q)-1] != 1:
    lw[int(q)-1] += 1
  elif a == "AC" and la[int(q)-1] != 1:
    la[int(q)-1] = 1
    lwa[int(q)-1] = lw[int(q)-1]
    
print(sum(la), sum(lwa))

Submission status: Accepted

Solution code:
from collections import deque

N, M = map(int,input().split())
ac = [0] * N
pena = [0] * N

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

    if ac[p]:
        continue
    if s == 'AC':
        ac[p] = 1
    else:
        pena[p] += 1

AC = 0
PENA = 0

for a in range(N):
    AC += ac[a]
    if ac[a]:
        PENA += pena[a]

print(AC,PENA)

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
record = [[0,0] for _ in range(n)]
for i in range(m):
    p,s = input().split()
    p = int(p)
    if s == 'AC':
        record[p-1][1] = 1
    else:
        # 既に正解してる奴にはwaを加算しない
        if record[p-1][1] == 0:
            record[p-1][0] += 1

ac = 0
pe = 0
for i in range(n):
    if record[i][1] == 1:
        ac += 1
        pe += record[i][0]
print(ac, pe)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
pe=[-1 for i in range(n)]#ぺな
for i in range(m):
    p,s=input().split()
    p=int(p)
    if s=='WA' and pe[p-1] < 0:
        pe[p-1] -= 1
    elif s =='AC' and pe[p-1] < 0:
        pe[p-1] = abs(pe[p-1])
#print(pe)
print('{} {}'.format(len([i for i in pe if i > 0]),sum([i-1 for i in pe if i > 0])))

Submission status: Accepted

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

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


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

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

Submission status: Accepted

Solution code:
#C - Welcome to AtCoder

N, M = map(int, input().split())
Score = [[]*i for i in range(N)]
Count_AC = 0
Count_WA = 0

#小問毎の正誤リスト作成
for i in range(M):
  p, S = input().split()
  Score[int(p)-1].append(S)

for i in range(N):
  for j in range(len(Score[i])):
    if Score[i][j] == "WA":
      continue
    else:
      Count_AC += 1
      Count_WA += j
      break

print(Count_AC, Count_WA)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
l = [[] for i in range(N)]
old_p = 0
for i in range(M):
    tmp = list(input().split())
    # if tmp[0] != str(old_p + 1):
    #     old_p += 1
    # l[old_p].append(tmp[1])
    l[int(tmp[0]) - 1].append(tmp[1])
ac = 0
wa = 0
#print(l)
for i in range(N):
    wa_tmp = 0
    for j in range(len(l[i])):
        if l[i][j] == 'WA':
            wa_tmp += 1
        else:
            ac += 1
            wa += wa_tmp
            break
print('{} {}'.format(ac, wa))

Submission status: Accepted

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

AC = 0
WA = 0
WA_dict = {i: 0 for i in range(1, N+1)}
AC_dict = {i: 0 for i in range(1, N+1)}

for _ in range(M):
    p, s = input().split()
    if AC_dict[int(p)]==1:
        continue
    elif s=='WA':
        WA_dict[int(p)] += 1
    else:
        AC += 1
        AC_dict[int(p)] = 1
        WA += WA_dict[int(p)]
print(AC, WA)

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, m = map(int, readline().split())
ps = [list(input().split()) for i in range(m)]
check = [True] * n
ac = 0
wa = [0] * n
cnt_wa = 0
for p, s in ps:
    p = int(p)
    if check[p - 1]:
        if s == 'AC':
            check[p - 1] = False
            ac += 1
        else:
            wa[p - 1] += 1
for i in range(n):
    if not check[i]:
        cnt_wa += wa[i]
print(ac, cnt_wa)

Submission status: Accepted

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

penal = {}
ac = 0
wa = 0
for i in range(m):
    p, s = input().split()
    
    #初めて解く問題を辞書に追加
    if p not in penal:
        if s == 'AC':
            ac += 1
            penal[p] = -1
        elif s == 'WA':
            penal[p] = 1

    #２回目以降の挑戦
    elif p in penal:
        #すでにACしている時
        if penal[p] == -1:
            continue
        #まだACしていない時
        if s == 'WA':
            penal[p] += 1
        if s == 'AC':
            wa += penal[p]
            penal[p] = -1
            ac += 1

print(ac, wa)

Submission status: Accepted

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

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

for i in range(n):
    AC += ac[i]
    if ac[i] >= 1:
        WA += wa[i]
print("{} {}".format(AC, WA))

Submission status: Accepted

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

A = [0] * (n+1)
AC = [0] * (n+1)
WA = [0] * (n+1)

for i in range(m):
    a, b = input().split()
    a = int(a)
    if AC[a] == 0 and b == 'WA':
        WA[a] += 1
    elif AC[a] == 0 and b == "AC":
        AC[a] += 1

t = 0
for i in range(len(AC)):
    if AC[i] == 1:
        t += WA[i]
print(sum(AC), t)

Submission status: Accepted

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

accepted = set()
pena = 0
wa_cnt = [0]*(n+1)

for i in range(m):
    p, s = input().split()
    p = int(p)
    if p in accepted:
        continue
    if s == "AC":
        pena += wa_cnt[p]
        accepted.add(p)

    else:
        wa_cnt[p] += 1

print(len(accepted), pena)

Submission status: Accepted

Solution code:

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from collections import Counter
N, M = list(map(int, input().split()))
results = []
for _ in range(M):
    p, s = input().split()
    results.append((int(p), s))

wa_counter = Counter() # ACされていない問題についてのWAのカウンタ
is_active = [True for _ in range(N)] # ACしたかどうか。Trueのとき、まだACされてない。
for p, s in results:
    p -= 1
    if s == 'WA':
        if is_active[p]:
            wa_counter[p] += 1
        else:
            pass
    elif s == 'AC':
        if is_active[p]:
            is_active[p] = False
        else:
            pass

correct = 0 # ACした問題の数
incorrect = 0 # ACした問題のACするまでのWAの数
for i in range(N):
    if is_active[i] is False: # ACされている
        correct += 1
        incorrect += wa_counter[i]
print(correct, incorrect)

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] == 0:
    if s == "AC":
      AC[p-1] = 1
    else:
        WA[p-1] += 1
        
wa = 0
for j in range(N):
  if AC[j] == 1:
    wa += WA[j]
print(sum(AC),wa)

Submission status: Accepted

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

def main():
    sub = [0] * N
    pen = [0] * N
    for _ in range(M):
        p, s = input().split()
        if s == 'AC':
            sub[int(p)-1] += 1
        else:
            if sub[int(p)-1] == 0:
                pen[int(p)-1] += 1

    ac = len([s for s in sub if s > 0])
    pen = sum([p for i, p in enumerate(pen) if sub[i] > 0])
    print(ac, pen)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
p_dict = {}
# value = [ac, wa]
for i in range(m):
    p, s = input().split()
    if p not in p_dict:
        if s == 'AC':
            p_dict[p] = [1, 0]
        elif s == 'WA':
            p_dict[p] = [0, 1]
    else:
        if s == 'WA' and p_dict[p][0] == 0:
            p_dict[p][1] = p_dict[p][1] + 1
        if s == 'AC' and p_dict[p][0] == 0:
            p_dict[p][0] = 1

ac = 0
wa = 0
for key, value in p_dict.items():
    ac = ac + value[0]
    if value[0] == 1:
        wa = wa + value[1]

print(ac, wa)

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
l = [list(map(str,input().split())) for _ in range(m)]
case  = ["WA"]*n
case1 = ["T"]*n
good = 0
bad = 0
for (a,b) in l:
  a = int(a)
  if b =="AC":
    case1[a-1]="AC"
    
for (a,b) in l:
  a = int(a)
  if b=="AC" and case[a-1]=="WA":
    case[a-1]="AC"
    good += 1
  elif b=="WA" and case[a-1]=="WA" and case1[a-1]=='AC':
    bad += 1
print(good,bad)

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] == 0:
        if s == "AC":
            AC[p-1] = 1
        else:
            WA[p-1] += 1
wa = 0
for j in range(N):
    if AC[j] == 1:
        wa += WA[j]
print(sum(AC),wa)

Submission status: Accepted

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

acCount = 0
penaltyCount = 0
wa = [0]*n
aced = [False]*n

for i in ps:
    ind = int(i[0])-1
    if i[1]=='WA' and not aced[ind]:
        wa[ind] += 1
    elif i[1]=='AC' and not aced[ind]:
        aced[ind] = True
        acCount += 1
        penaltyCount += wa[ind]

print(acCount, penaltyCount)

Submission status: Accepted

Solution code:
N,M = map(int, input().split())
f=[0]*(N+1)
ans_a=[0]*(N+1)
ans_w=0
for i in range(M):
    p,s = map(str, input().split())
    if s=='WA' and ans_a[int(p)]==0:
        f[int(p)]+=1
    else:
        if ans_a[int(p)]==0:
            ans_a[int(p)]+=1
            ans_w+=f[int(p)]
print(sum(ans_a),ans_w)

Submission status: Accepted

Solution code:
import numpy as np
N,M = map(int,input().split())
AC = np.zeros(N,np.int32)
WA = np.zeros(N,np.int32)
for j in range(M):
    p,S = input().split()
    i = int(p) - 1
    if AC[i] == 1:
        continue
    if S =='AC':
        AC[i] = 1
    else:
        WA[i] += 1
        
print(len(AC[AC == 1]),np.sum(WA[AC==1]))

Submission status: Accepted

Solution code:
n, m = (int(x) for x in input().split())
dic={}
for i in range(m):
    p, s = input().split()
    if p in dic:
        if dic[p][1]>0:
            pass
        elif s=="WA":
            dic[p][0]+=1
        elif s=="AC":
            dic[p][1]+=1
    else:
        if s=="WA":
            dic[p]=[1,0]
        else:
            dic[p]=[0,1]
for value in dic.values():
    if value[1]==0:
        value[0]=0
su_ac = 0
su_wa = 0
for value in dic.values():
    su_ac+=value[1]
    su_wa+=value[0]
print(su_ac, su_wa)

Submission status: Accepted

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

str_list = ["WA"] * n # 問題数分のリスト
int_list = [0] * n    # 問題数分のリスト
num = 0
ac = 0    

for p_, s in  ps: # p：問題番号 s：AC or WA
    p = int(p_) - 1
    if s == "AC":
        str_list[p] = "AC" # WAリスト
    else: # s!= WA
        if str_list[p] !="AC": # まだACされていない問題が、WAだったら
            int_list[p] += 1   # 問題ごとのWAの回数

for i in range(n): 
    if str_list[i] == "AC": # ペナルティはACできた問題のみ
        num += int_list[i] # WAの回数}
        ac += 1            # ACの数

print(ac, num)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
P = [0] * (N + 1)
S = [0] * (N + 1)
for i in range(M):
  x, p = input().split()
  s = int(x)
  if P[s] == 0:
    if p == 'AC':
      P[s] = 1
    else:
      S[s] += 1
A = sum([S[i] for i in range(N + 1) if P[i] == 1])
print(P.count(1), A)

Submission status: Accepted

Solution code:
from collections import defaultdict

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

d = defaultdict(int)
ans = 0
pena = 0

for _ in range(m):
    p, s = input().split()
    if s == "AC":
        if d[p] == -1:
            continue
        else:
            ans += 1
            pena += d[p]
            d[p] = -1
    else:
        if d[p] == -1:
            continue
        else:
            d[p] += 1

print(ans, pena)

Submission status: Accepted

Solution code:
import numpy as np

N,M=map(int,input().split())
ac=np.array([0]*N)
wa=np.array([0]*N)

for i in range(M):
    a,b=input().split()
    A=int(a)
    if ac[A-1]==0 and b=="WA":
        wa[A-1]+=1
    else :
        ac[A-1]=1

cal=sum(ac)
ans=sum(ac*wa)
print(cal, ans)