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 = 0
wa = 0

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

print(ac, wa)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import math


def inputIntList():
  return [int(s) for s in input().split()]


def inputInt():
  return int(input())


def main():
  N, M = inputIntList()

  ac = 0
  wa = 0
  problem = [['', 0] for _ in range(N)]
  for _ in range(M):
    i, s = input().split()
    i = int(i)-1
    if problem[i][0] == 'AC':
      continue
    else:
      problem[i][0] = s

    if problem[i][0] == 'WA':
      problem[i][1] += 1
    else:
      ac += 1
  for result, wa_cnt in problem:
    if result == 'AC':
      wa += wa_cnt
  return '{} {}'.format(ac, wa)


if __name__ == "__main__":
  print(main())

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
ac = set()
pena = 0
# 問題はn問あり，問題番号は1からスタートするので*(n+1)にすれば十分
wa = [0] * (n+1)
for i in range(m):
    # p:問題番号，s:判定
    p, s = input().split()
    p = int(p)
    if p in ac:
        continue
    if s == 'AC':
        # ACする前のWA数を追加
        pena += wa[p]
        # ACした問題番号の追加
        ac.add(p)
    else:
        # WA数を1増やす
        wa[p] += 1
print(len(ac), pena)

Submission status: Accepted

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

ac = [False] * N
pena = [0] * N

for p, s in PS:
    p -= 1
    if ac[p]:
        continue

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

a_cnt = 0
w_cnt = 0
for i in range(N):
    if ac[i]:
        a_cnt += 1
        w_cnt += pena[i]

print(a_cnt, w_cnt)

Submission status: Accepted

Solution code:
def main():
    N, M = [int(x) for x in input().split()]

    accepted = set()
    ans = 0
    from collections import defaultdict
    wa_count = defaultdict(int)
    for i in range(M):
        p, s = input().split()
        if p in accepted:
            continue
        if s == "WA":
            wa_count[p] += 1
        else:
            accepted.add(p)
            ans += wa_count[p]
    print(len(accepted), ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
X = [[] for _ in range(N)]
for _ in range(M):
    p, s = input().split()
    p = int(p) - 1
    X[p].append(s)

def wacnt(y):
    if y.count("AC") == 0: return 0
    re = 0
    for a in y:
        if a == "AC": return re
        re += 1
ac = sum([min(x.count("AC"), 1) for x in X])
wa = sum([wacnt(x) for x in X])
print(ac, wa)

Submission status: Accepted

Solution code:
#input
N, M = map(int, input().split())
L = [[] for _ in range(N)]
for i in range(M):
    x, y = input().split()
    x = int(x)
    L[x-1].append(y)

#output
point = 0
penalty = 0
for i in range(N):
    if not "AC" in L[i]:
        continue
    else:
        for j in range(len(L[i])):
            if L[i][j] == "WA":
                penalty += 1
            else:
                point += 1
                break

print(point, penalty, sep = " ")

Submission status: Accepted

Solution code:
#coding:utf-8
from collections import defaultdict
dd = defaultdict(int)
N,M = map(int, input().split())
ans = 0
ac = 0
for m in range(M):
    p, s = input().split()
    p = int(p)
    if dd[p] != -1:
        if (s=="WA"):
                dd[p]+=1
        else:
            ans += dd[p]
            ac += 1
            dd[p] = -1
print (ac,ans)

Submission status: Accepted

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

# 正解した問題を入れるlist

correct = 0
pn = 0
done_list = [0] * n
pn_list = [0] * n

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

print(correct, pn)

Submission status: Accepted

Solution code:
s = input().split()
n=int(s[0])
m=int(s[1])
acc=0
penalty={}
ans={}
pen=0
for i in range(n+1):
    penalty[str(i)]=0
    ans[str(i)]=0
for i in range(m):
    s = input().split()
    if s[1]=='AC':
        ans[s[0]]=1
    if ans[s[0]]==0 and s[1]=='WA':
        penalty[s[0]]+=1
for p in penalty:
    if ans[p]==1:
        pen+=penalty[p]
print(list(ans.values()).count(1),pen)

Submission status: Accepted

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

a_w = []
for i in range(N+1):
    a_w.append([False, 0])

a_cnt = 0
w_cnt = 0
for p, s in PS:
    # 正解済み
    if a_w[p][0]:
        continue

    # 初めて正解した
    if s == 'AC':
        a_w[p][0] = True
        a_cnt += 1
        w_cnt += a_w[p][1]
    else:
        a_w[p][1] += 1

# print(a_w)
print(a_cnt, w_cnt)

Submission status: Accepted

Solution code:
from collections import defaultdict
N, M = map(int, input().split())
L = []
for i in range(M):
  L += [input().split()]

WA = defaultdict(lambda: 0)
cnt_AC = 0
alr = set()
for j, k in L:
  j = int(j)
  if j in alr:
    continue
  if k == 'AC':
    cnt_AC += 1
    alr.add(int(j))
  else:
    WA[j] += 1

print(cnt_AC, sum(WA[l] for l in alr))

Submission status: Accepted

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

a_w = []
for i in range(N+1):
    a_w.append([False, 0])

for p, s in PS:
    if s == 'AC':
        a_w[p][0] = True
    else:
        if not a_w[p][0]:
            a_w[p][1] += 1

a_cnt = 0
w_cnt = 0
for a, w in a_w:
    if a:
        a_cnt += 1
        w_cnt += w
print(a_cnt, w_cnt)

Submission status: Accepted

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

for i in range(m):
  p,s = input().split()
  p=int(p)-1
  #print(ac,wa,flag)
  if flag[p]!='AC':
    if s=='WA':
      #wa+=1
      flag[p]+=1
    else:
      ac+=1
      wa+=flag[p] #ACになったときにwaを加算する
      flag[p]='AC'
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):
    p,s = input().split()
    p = int(p)
    p -= 1
    if ac[p]:
        continue
    if s == 'AC': 
        ac[p] = 1
    else:
        wa[p] += 1
AC = sum(ac)
WA = 0
for i in range(N):
    if ac[i]:
        WA += wa[i]
print(AC, WA)

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.readline

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

WA = [0] * (N + 1)
wa = 0
AC = [False] * (N + 1)
for _ in range(M):
    p, S = readline().split()
    p = int(p)
    if AC[p]:
        continue

    if S == 'AC':
        AC[p] = True
        wa += WA[p]
    else:
        WA[p] += 1

print(sum(AC), wa)

Submission status: Accepted

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

ACCNT=[False]*N
Asum=0
WACNT=[0]*N

for i in range(M):
    PI,SI=input().split()
    iii=int(PI)-1
    if ACCNT[iii]==False:
        if SI=="WA" :
            WACNT[iii]=WACNT[iii]+1
        elif SI=="AC" :
            ACCNT[iii]=True
            Asum=Asum+1

Wsum=0
for i in range(N):
    if ACCNT[i]==True:
        Wsum=Wsum+WACNT[i]

print(Asum,Wsum)

Submission status: Accepted

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

ac = {}
wa = {}
for i in range(M):
    if ps[i][1] == 'AC':
        if not ac.get(ps[i][0]):
            ac[ps[i][0]] = 1
    else:
        if not ac.get(ps[i][0]):
            wa[ps[i][0]] = wa.get(ps[i][0], 0)
            wa[ps[i][0]] += 1

ansac = len(ac.keys())
answa = 0
for k in wa.keys():
    if ac.get(k):
        answa += wa[k]

print(ansac, answa)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys


def solve(inp):
    (N, M) = map(int, inp.readline().strip().split(' '))
    PS = [inp.readline().strip().split(' ') for i in range(M)]

    total_penalty = 0
    total_ac = 0
    pena = {}
    ac = {}
    for (P, S) in PS:
        P = int(P) - 1
        if S == "WA":
            if P not in pena:
                pena[P] = 0
            pena[P] += 1
        elif S == "AC":
            if P not in ac:
                total_ac += 1
                ac[P] = 1
                if P in pena:
                    total_penalty += pena[P]
    return "{} {}".format(total_ac, total_penalty)


def main():
    result = solve(sys.stdin)
    if result:
        print(result)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
p = [list(map(str, input().split())) for _ in range(M)]
aclst = [0] * (N + 1)
walst = [0] * (N + 1)
cntw = 0
cnta = 0
for i in range(M):
    if aclst[int(p[i][0])] == 0:
        if p[i][1] == 'WA':
            walst[int(p[i][0])] += 1
        else:
            cnta += 1
            cntw += walst[int(p[i][0])]
            aclst[int(p[i][0])] = 1


print(cnta, cntw)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
P = [0 for _ in range(N+1)]
S = [0 for _ in range(N+1)]

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

for i in range(N+1):
    if S[i] == 0 and P[i] > 0:
      P[i] = 0
        
print(sum(S), sum(P))

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7 # 998244353
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n,m=map(int,input().split())
    PS=[None]*m
    for i in range(m):
        p,s=input().split()
        PS[i]=int(p)-1,s

    AC=[False]*n
    WA=[0]*n

    ac=0
    wa=0
    for p,s in PS:
        if(AC[p]): continue
        if(s=='WA'):
            WA[p]+=1
        else:
            ac+=1
            wa+=WA[p]
            AC[p]=True

    print(ac,wa)
resolve()

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
AC = {} # 1:AC済のみ
WA = {}
acNum = 0

for i in range(M):
    p,S = input().split()
    p = int(p)
    if S == 'AC':
        if p in AC:
            pass
        else:
            AC[p] = 1
            acNum += 1
    else:
        # S == 'WA'
        if not p in AC:
            if not p in WA:
                WA[p] = 0
            WA[p]+=1


peNum = 0
for k,v in WA.items():
    if k in AC:
        peNum += v

print(acNum,peNum)

Submission status: Accepted

Solution code:
import sys

n, m = map(int, sys.stdin.readline().split())
pv = []
for _ in range(m):
    p, v = sys.stdin.readline().split()
    p = int(p)
    v = 1 if v == 'AC' else 0
    pv.append((p, v))

def main():
    ac = [0] * (n + 1)
    wa = [0] * (n + 1)
    for p, v in pv:
        wa[p] += (ac[p] | v) ^ 1
        ac[p] |= v
    
    for p in range(1, n+1):
        wa[p] *= ac[p]

    return sum(ac), sum(wa)

if __name__ == '__main__':
    ans = main()
    print(*ans, sep=' ')

Submission status: Accepted

Solution code:
n, m = [int(s) for s in input().split()]
a = [0 for _ in range(n)]
for i in range(m):
  p, res = input().split()
  p = int(p) - 1
  if a[p]%2==0:
  	a[p] += 2 if res=='WA' else 1
  
print(sum([tmp%2 for tmp in a]), sum([tmp//2 if tmp%2==1 else 0 for tmp in a]))

Submission status: Accepted

Solution code:
N,M = map(int, input().split())
ac = 0
count = [0 for i in range(N)]
done = [False for i in range(N)]
ans = 0
for i in range(M):
    p,s = input().split()
    p = int(p) - 1
    if done[p]:
        continue
    elif s == 'AC':
        done[p] = True
        ac += 1
        ans += count[p]
    else:
        count[p] += 1

print( ac, ans)

Submission status: Accepted

Solution code:
import sys
N,M = map(int,input().split())
if M == 0:
    print('%d %d' % (0,0))
    sys.exit(0)
Liste = dict()
Question = [0] * M
ACorWE = [0] * M
correct = 0
penalty = 0
for i in range(M):
    Question[i], ACorWE[i]= map(str, input().split())
Question = [int(element) for element in Question]
for _ in Question:
    Liste[_] = [0] 
for i in range(M):
    Liste[Question[i]].append(ACorWE[i])
for liste in Liste:
    while 0 in Liste[liste]:
        Liste[liste].remove(0)
AC = []
for key in Liste:
    if 'AC' in Liste[key]:
        correct += 1
        AC.append(key)
j = 0
for key in AC:
    while Liste[key][j] != 'AC' and j<len(Liste[key]):
        penalty += 1
        j += 1 
    j = 0         
print('%d %d' % (correct,penalty))

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
cnt=[0 for i in range(n)]
done=[False for i in range(n)]
ac, pen = 0, 0
for i in range(m):
  p,s=input().split()
  p=int(p)
  p-=1
  if done[p]:
    continue
  elif s=='AC':
    done[p]=True
    ac += 1
    pen += cnt[p]
  else:
    cnt[p] += 1
print('{} {}'.format(ac,pen))

Submission status: Accepted

Solution code:
from operator import mul
N, M = map(int, input().split())
p = [0]*M
S = [None]*M

for i in range(M):
    p[i], S[i] = input().split()

p = list(map(int, p))
clear_flag = [0]*(N+1)
correct_N = 0
wrong_N = [0]*(N+1)

for i in range(M):

    if clear_flag[p[i]] == 0:
        if S[i] == 'AC':
            correct_N += 1
            clear_flag[p[i]] = 1
        else:
            wrong_N[p[i]] += 1

wa =  sum(map(mul, clear_flag, wrong_N))
print(correct_N, wa)

Submission status: Accepted

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

now = 0
false_count = 0
ans_false = 0
ans = 0



for i in range(M):
    p, s = input().split()
    if ans_list[int(p) - 1]:
        continue
    if s == "AC":
        ans += 1
        ans_false +=  WA[int(p) - 1]
        ans_list[int(p) - 1] = True
    else:
        WA[int(p) - 1] += 1
 
print(ans, ans_false)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())  # n: num problem, m: num submit
lst = [input().split() for i in range(m)]

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

for i in range(m):
    p_i = int(lst[i][0])
    s_i = lst[i][1]
    if s_i == 'AC':
        ac[p_i-1] = True
    else:
        if ac[p_i-1] is False:
            wa[p_i-1] += 1

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

Submission status: Accepted

Solution code:
n, m = map(int, input().split())  # n: num problem, m: num submit
lst = [input().split() for i in range(m)]

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

for i in range(m):
    p_i = int(lst[i][0])
    s_i = lst[i][1]
    if s_i == 'AC':
        ac[p_i-1] = True
    else:
        if ac[p_i-1] is False:
            wa[p_i-1] += 1

# num_ac = sum(ac)
# pnlt = sum(wa)

a = 0
b = 0
for i in range(n):
    if ac[i]:
        a += 1
        b += wa[i]
print(*[a, b])
# print(*[num_ac, pnlt])

Submission status: Accepted

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

AC, WA, C = 0, 0, [0] * N
for _ in range(M):
    p, S = input().split()
    p = int(p) - 1
    if C[p] >= 0:
        if S == 'AC':
            AC, WA, C[p] = AC + 1, WA + C[p], -1
        else:
            C[p] += 1

print(AC, WA)

Submission status: Accepted

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

hasAC, pena = [0] * n, [0] * n

for i in range(m):
    li = input().split()
    p = int(li[0]) - 1
    s = li[1]
    if hasAC[p]: continue
    if s == 'AC': hasAC[p] = 1
    else: pena[p] += 1
AC, pena_sum = 0, 0
for i in range(n):
    AC += hasAC[i]
    if hasAC[i]: pena_sum += pena[i]
print(AC, pena_sum)

Submission status: Accepted

Solution code:
from sys import stdin
import sys
import numpy as np
import collections
from functools import cmp_to_key
import heapq

##  input functions for me
def rsa(sep = ''):
    if sep == '' :
        return input().split() 
    else: return input().split(sep)
def rip(sep = ''):
    if sep == '' :
        return map(int, input().split()) 
    else: return map(int, input().split(sep))
def ria(sep = ''): 
    return list(rip(sep))
def ri(): return int(input())
def rd(): return float(input())
def rs(): return input()
##
def main():
    N, M = rip()
    P = [0] * M
    S = [""] * M
    for i in range(M):
        ss = rsa()
        P[i] = int(ss[0]) - 1
        S[i] = ss[1]
    
    accept = [False] * N
    penalty = [0] * N
    for i in range(M):
        if S[i] == 'AC':
            accept[P[i]] = True
            continue
        if not accept[P[i]]:
            penalty[P[i]] += 1
    
    ac_count = 0
    penalty_count = 0
    for i in range(N):
        if accept[i]:
            ac_count += 1
            penalty_count += penalty[i]
    
    print("{0} {1}".format(ac_count, penalty_count))



if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N, M = [int(_) for _ in input().split()]
PS = [input().split() for _ in range(M)]
count = [0] * (N + 1)
isac = [0] * (N + 1)
for p, s in PS:
    p = int(p)
    if isac[p] == 1:
        continue
    if s == 'AC':
        isac[p] = 1
    else:
        count[p] += 1
wa = 0
ac = 0
for i in range(N + 1):
    if isac[i] == 1:
        ac += 1
        wa += count[i]
print(ac, wa)

Submission status: Accepted

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

hasAC, pena, tmpP= [0] * n, [0] * n, [0] * n

for i in range(m):
    li = input().split()
    p = int(li[0]) - 1
    s = li[1]
    if hasAC[p]:
        continue
    if s == 'AC':
        hasAC[p] = 1
        pena[p] += tmpP[p]
    else:
        tmpP[p] += 1

print(sum(hasAC), sum(pena))

Submission status: Accepted

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

for i in range(m):
    p,s = map(str,input().split())
    p = int(p)-1 
    if s == "WA" and ac[p] == 0:
        wa[p] += 1
    elif s == "AC" and ac[p] == 0:
        ac[p] = 1
        pena += wa[p]   #waのみの問題はペナルティカウントされないため、acして初めてwaの回数を加算する
    elif ac[p] == 1:
        continue

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

Submission status: Accepted

Solution code:
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res
def gcd(x, y):
    if x < y: x, y = y, x
    div = x % y
    while div != 0:
        x, y = y, div
        div = x % y
    return y


N,M=LI()
RES=[[0,0] for _ in range(N+1)]
WA=0
AC=0
for i in range(M):
    ps, re = input().split()
    n = int(ps)
    if not RES[n][0]:
        if re == "AC": RES[n][0] = 1
        else: RES[n][1] += 1


for i,j in RES:
    AC += i
    if i: WA += j

print("{} {}".format(AC, WA))

Submission status: Accepted

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

for i in range(M):
    p, s = input().split()
    p = int(p)-1
    if ac[p] == 1:
        continue
    elif s == "WA":
        wa[p] += 1
    else:
        ans[0] += 1
        ans[1] += wa[p]
        ac[p] = 1
print(*ans)

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
x = [0]*(n+1)
t = [0]*(n+1)
p=q=0
for i in range(m):
  k,l = input().split()
  y=int(k)-1
  if x[y]==0:
    if l=='WA':
      t[y]+=1
    else:
      q+=t[y]
      p+=1
      x[y]=1
print(p,q)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
ac = {}
wa = {}
for _ in range(m):
    p, s = input().split()
    p = int(p)
    if s == 'AC':
        ac[p] = 1
    else:
        if not ac.get(p, 0):
            wa[p] = wa.get(p, 0) + 1
pen = 0
for p in ac:
    pen += wa.get(p, 0)
print(len(ac), pen)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
P = [0] * N  # 正解済みは1
wa = [0] * N  # WA の回数を記録
ac, penalty = 0, 0

for _ in range(M):
    # 読み込み
    p, S = input().split()
    p = int(p)
    if P[p-1] == 1:
        # すでに正解済みの場合は何もしない
        continue
    elif S == "WA":
        # 未正解で WA
        wa[p-1] += 1
    else:
        # 未正解で AC
        ac += 1
        penalty += wa[p-1]
        P[p-1] = 1
print(ac, penalty)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
resultList = [[0] * 2 for i in range(n)]
#print(resultList)
ansAC = 0
ansWA = 0
for i in range(m) :
    result = input().split()
    prob = int(result[0]) - 1
    if result[1] == 'AC' and resultList[prob][0] == 0 :
        resultList[prob][0]= 1
        ansAC += 1
        ansWA += resultList[prob][1]
    if result[1] == 'WA' and resultList[prob][0] == 0 :
        resultList[prob][1] += 1

print(ansAC, ansWA)

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()
    p=int(p)
    if ac[p-1] == 1:#このテストをクリアしていたら飛ばす。
        continue
    
    if s=='AC':#テストをクリアしたらフラグをつける
        ac[p-1] = 1
    else:#テストをクリアするまでは失敗を繰り返す。
        wa[p-1] += 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())
ac=[0]*n
wa=[0]*n
for i in range(m):
    p,s=input().split()
    p=int(p)
    if ac[p-1] == 1:
        continue
    if s=='AC':
        ac[p-1] = 1
    else:
        wa[p-1] += 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())
pS = [tuple(map(str, input().split())) for _ in range(M)]

AC = [False] * (N+1)
WA = [0] * (N+1)

pena = 0
for p, s in pS:
    p = int(p)
    if AC[p]:
        continue
    if s == 'WA':
        WA[p] += 1
    else:
        AC[p] = True
        pena += WA[p]
ac = sum(AC)
print(ac, pena)

Submission status: Accepted

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

ac_list = [0] * (N + 1)
wa_list = [0] * (N + 1)
a = 0
w = 0
for i in range(M):
    l = input().split()
    if ac_list[int(l[0])]!='AC':
        if l[1] == 'AC':
            ac_list[int(l[0])] = 'AC'
            a += 1
            w += wa_list[int(l[0])]
        else:
            wa_list[int(l[0])] += 1

print('{} {}'.format(a, w))

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
j=[0]*n #当たり保管所
c=[0]*n #はずれ保管所
pe=0
ac=0
for i in range(m):
  p,s=input().split()
  p=int(p)-1
  if s[0]=="A" and j[p]==0:
    #正解かつ当たり保管所のp番目が0(まだ正解はない)なら
    j[p]=1#正解が入る
    ac+=1#出力の正解数+1
    pe+=c[p]#正解が入ったタイミングではずれ保管所に蓄積したWAを出力の不正解に追加
  elif s[0]=="W":c[p]+=1#もしはずれだったらはずれ判定所のp番目を+1する(はずれの蓄積)
print(ac,pe)

Submission status: Accepted

Solution code:
from collections import defaultdict
correct = defaultdict(bool)
local_wa = defaultdict(int)

N, M = map(int, input().split())
p = []
s = []
for i in range(M):
    a, b = input().split()
    p.append(int(a))
    s.append(b)
    
ac = 0
wa = 0


for pp in p:
    correct[pp] = False

for pp, ss in zip(p,s):
    if correct[pp]:
        pass
    else:
        if ss == 'AC':
            correct[pp] = True
            ac += 1
            wa += local_wa[pp]
            local_wa[pp] = 0

        elif ss == 'WA':
            local_wa[pp] += 1
print(ac, wa)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
ac = {}
wa = {}
for _ in range(m):
    p, s = input().split()
    p = int(p)
    if s == 'AC':
        ac[p] = 1
    else:
        if not ac.get(p, 0):
            wa[p] = wa.get(p, 0) + 1
pen = 0
for p in ac:
    pen += wa.get(p, 0)
print(len(ac), pen)

Submission status: Accepted

Solution code:
# ABC151 C

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

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

for i in range(M):
    p, S = input().split()
    p = int(p) - 1
    
    if S == "WA" and AC[p] == 0:
        WA[p] += 1
    elif S == "AC" and AC[p] == 0:
        AC[p] += 1
        WA_count += WA[p]
    else:
        continue

print(sum(AC), WA_count)

Submission status: Accepted

Solution code:
n, m = [int(i) for i in input().split(" ")]
score_dict = {}
 
for i in range(m):
    p, s = input().split(" ")
    if p not in score_dict:
        score_dict[p] = []
    
    score_dict[p].append(s)
 
ac_count = 0
wa_count = 0
 
for i in score_dict.values():

    if "AC" in i:
        ac_count += 1
        wa_count += i.index("AC")
 
print("{0} {1}".format(ac_count, wa_count))

Submission status: Accepted

Solution code:
# coding: utf-8

import sys
input = sys.stdin.readline

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

ac_set = set()
penalty = 0
wa_count = [0] * (n+1)

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

    if s == "AC":
        if not p in ac_set:
            penalty += wa_count[p]
            ac_set.add(p)
    elif s == "WA":
        wa_count[p] += 1


print(len(ac_set), penalty)

Submission status: Accepted

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

n, m = map(int, input().split())
ac = 0
wa = defaultdict(lambda: 0) # wa = {} だと 存在しないkeyにおいて wa[key] = ○ で代入できない
already = set()
sum_wa = 0
for line in range(m):
    p, s = input().split() # forでその都度入力を受け取る
    p = int(p)
    if p in already: # acを見つけたときのみalreadyにpをいれるので、ac後のwaのカウントを避けている。
        continue
    if s == 'AC':
        ac += 1
        already.add(p) # acするとalreadyにpを追加 集合への値追加はaddを用いる。
        # sum_wa += wa[p]
    else:
        wa[p] += 1 #{1: 3, 2: 2, 3: 0, 4: 5 ...}のように辞書が作られていく。

# print(ac, sum(wa[i] for i in wa.keys())) のようにするとac出来ていないwaについても数えてしまうので×
# print(ac, sum_wa)
print(ac, sum(wa[i] for i in already))

Submission status: Accepted

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

n, m = map(int, input().split())
ac = 0
wa = defaultdict(lambda: 0) # wa = {} だと 存在しないkeyにおいて wa[key] = ○ で代入できない
already = set()
sum_wa = 0
for line in range(m):
    p, s = input().split() # forでその都度入力を受け取る
    p = int(p)
    if p in already: # acを見つけたときのみalreadyにpをいれるので、ac後のwaのカウントを避けている。
        continue
    if s == 'AC':
        ac += 1
        already.add(p) # acするとalreadyにpを追加 集合への値追加はaddを用いる。
        # sum_wa += wa[p]
    else:
        wa[p] += 1 #{1: 3, 2: 2, 3: 0, 4: 5 ...}のように辞書が作られていく。

# print(ac, sum(wa[i] for i in wa.keys())) のようにするとac出来ていないwaについても数えてしまうので×
# print(ac, sum_wa)
print(ac, sum(wa[i] for i in already))

Submission status: Accepted

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

n, m = map(int, input().split())
ac = 0
wa = defaultdict(lambda: 0) # wa = {} だと 存在しないkeyにおいて wa[key] = ○ で代入できない
already = set()
sum_wa = 0
for line in range(m):
    p, s = input().split() # forでその都度入力を受け取る
    p = int(p)
    if p in already: # acを見つけたときのみalreadyにpをいれるので、ac後のwaのカウントを避けている。
        continue
    if s == 'AC':
        ac += 1
        already.add(p) # acするとalreadyにpを追加 集合への値追加はaddを用いる。
        sum_wa += wa[p]
    else:
        wa[p] += 1 #{1: 3, 2: 2, 3: 0, 4: 5 ...}のように辞書が作られていく。

# print(ac, sum(wa[i] for i in wa.keys())) のようにするとac出来ていないwaについても数えてしまうので×
print(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 = input().split()
    p = int(p)
    if ac[p-1]:
        continue
    if s == 'AC':
        ac[p-1] = 1
    else:
        wa[p-1] += 1
count_ac = 0
count_wa = 0
for i in range(n):
    count_ac += ac[i]
    if ac[i]:
        count_wa += wa[i]
print(str(count_ac) + " " + str(count_wa))

Submission status: Accepted

Solution code:
'''input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
'''
# A coding delight
from sys import stdin, stdout
import gc
gc.disable()
input = stdin.readline



# main starts
n, m = list(map(int, input().split()))
ac = dict()
wa = dict()
w = 0
for _ in range(m):
	a, t = list(input().split())
	a = int(a)
	if t == 'AC':
		if a in ac:
			pass
		else:
			if a in wa:
				w += wa[a]
			ac[a] = 1

	else:
		if a in ac:
			pass
		else:
			if a in wa:
				wa[a] += 1
			else:
				wa[a] = 1
print(len(ac), w)

Submission status: Accepted

Solution code:
from collections import defaultdict
 
n, m = map(int, input().split())
ac = 0
wa = defaultdict(lambda: 0) # wa = {} だと 存在しないkeyにおいて wa[key] = ○ で代入できない
already = set()
for line in range(m):
    p, s = input().split() # forでその都度入力を受け取る
    p = int(p)
    if p in already: # acを見つけたときのみalreadyにpをいれすので、ac後のwaのカウントを避けている。
        continue
    if s == 'AC':
        ac += 1
        already.add(p) # acするとalreadyにpを追加 集合への値追加はaddを用いる。
    else:
        wa[p] += 1 #{1: 3, 2: 2, 3: 0, 4: 5 ...}のように辞書が作られていく。
# print(ac, sum(wa[i] for i in wa.keys())) のようにするとac出来ていないwaについても数えてしまうので×
print(ac, sum(wa[i] for i in already))