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:
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n,m = readInts()
dic = defaultdict(int)
ac,wa = 0,0
for i in range(m):
    p,S = input().split()
    if dic[p] != -1:
        if S == 'AC':
            wa += dic[p]
            ac += 1
            dic[p] = -1
        else:
            dic[p] += 1
print(ac,wa)

Submission status: Accepted

Solution code:
def solve():
  ans = [0,0]
  N, M = map(int, input().split())
  WAs = [0]*N
  for i in range(M):
    p, S = input().split()
    p = int(p)
    if WAs[p-1]>=0:
      if S=='WA':
        WAs[p-1] += 1
      if S=='AC':
        ans[0] += 1
        ans[1] += WAs[p-1]
        WAs[p-1] = -1
  return ans
print(*solve())

Submission status: Accepted

Solution code:
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N,M = map(int,readline().split())
WA_cnt = [0]*(N+1)
WA_use = [0]*(N+1)
A = []
cnt = 0
for _ in range(M):
    p,S = readline().decode().split()
    p = int(p)
    if S == 'AC' and WA_use[p] == 0:
        A.append(p) 
        cnt += WA_cnt[p]
        WA_use[p] = 1
    else:
        WA_cnt[p] += 1
        
print(len(set(A)),cnt)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
pena = [0 for i in range(n)]
cor = set([])
for i in range(m):
    pi, si = input().split()
    pi = int(pi) - 1
    if si == 'AC':
        cor.add(pi)
    else:
        if pi not in cor:
            pena[pi] += 1

ans = 0
for i in cor:
    ans += pena[i]
print(len(cor), ans)

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
A = [list(input().split()) for _ in range(M)]
C = {str(i):0 for i in range(1,N+1)}
for i in range(M):
    p,s = A[i]
    if s=="AC":
        C[p] = 1
D = {str(i):0 for i in range(1,N+1)}
cnt = 0
for i in range(M):
    p,s = A[i]
    if C[p]==1 and D[p]==0 and s=="WA":
        cnt += 1
    elif s=="AC":
        D[p] = 1
ac = 0
for i in range(1,N+1):
    ac += C[str(i)]
print(ac,cnt)

Submission status: Accepted

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

ac = [0] * (n+1)
pena = [0] * (n+1)
for p,s in ps:
    p = int(p)
    if s == "AC":
        ac[p] = 1
        continue
    if ac[p] == 0:
        pena[p] += 1
ans = [0,0]
for x,y in zip(ac[1:],pena[1:]):
    if x == 1:
        ans[0] += 1
        ans[1] += y
print(" ".join(map(str, ans)))

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())
ps = [input().split() for _ in range(m)]

p_ac = dict()
ac = 0
wa = 0
for i in range(m):
    p, s = ps[i]
    if p not in p_ac and s == 'AC':
        p_ac[p] = i
        ac += 1

for i in range(m):
    p, s = ps[i]
    if p in p_ac.keys() and s == 'WA':
        if i < p_ac[p]:
            wa += 1
print(ac, wa)

Submission status: Accepted

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

ok = 0
ng = 0
ng_l = {}
end = set()

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

    if not p in end:
        if S == 'AC':
            ok += 1
            end.add(p)

            if p in ng_l:
                ng += ng_l[p]
        else:
            if p in ng_l:
                ng_l[p] += 1
            else:
                ng_l[p] = 1

print('{} {}'.format(ok, ng))

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
wro = dict()
cor = set()

for _ in range(M):
    p, s = input().split()
    if s == 'AC':
        cor.add(p)
    elif s == 'WA' and p not in cor:
        wro[p] = wro.get(p, 0) + 1

wro_num = 0
for i in cor:
    wro_num += wro.get(i, 0)

print(len(cor), wro_num)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
p = dict()
ac = dict()
ans, penalty = 0, 0
for _ in range(M):
  tmp = input().split()
  if tmp[0] in ac:
    continue
  if tmp[1] == 'AC':
    ans += 1
    ac[tmp[0]] = 1
    penalty += p.get(tmp[0], 0)
  else:
    p[tmp[0]] = p.get(tmp[0], 0) + 1
print(ans, penalty)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
(n, m,), *sub = [i.split() for i in open(0)]

r = {str(i+1): 0 for i in range(int(n))}
pen = 0
ac = 0
for p, s in sub:
    if r[p]>-1:
        if s == "WA":
            r[p]+=1
        else:
            ac += 1
            pen += r[p]
            r[p] = -1
print(ac, pen)

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

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

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

print(sum(ac), wa)

Submission status: Accepted

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


ac = 0
wa = 0
for i in range(1,N+1):
    flg = 0
    tmp_wa = 0
    for submit in lst[i]:
        if submit == 'WA':
            tmp_wa += 1
        else:
            ac += 1
            wa += tmp_wa
            break
print(ac,wa)

Submission status: Accepted

Solution code:
import sys
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def Main():
    n,m = IL()
    sub = [0]*n
    c = 0
    t = 0
    for _ in range(m):
        p,s = SL()
        p = int(p)
        if sub[p-1]==-1: continue

        if s=='AC':
            t += sub[p-1]
            sub[p-1] = -1
            c += 1
        elif s=='WA':
            sub[p-1] += 1
    print(c,t)
    return

if __name__=='__main__':
    Main()

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
A = [list(input().split()) for _ in range(M)]
C = {str(i):0 for i in range(1,N+1)}
for i in range(M):
    p,s = A[i]
    if s=="AC":
        C[p] = 1
D = {str(i):0 for i in range(1,N+1)}
cnt = 0
for i in range(M):
    p,s = A[i]
    if s=="WA":
        if C[p]==1 and D[p]==0:
            cnt += 1
    else:
        D[p] = 1
ac = 0
for i in range(1,N+1):
    if C[str(i)]==1:
        ac += 1
print(ac,cnt)

Submission status: Accepted

Solution code:
import math
import collections
import fractions
import itertools

def solve():
    n, m = map(int, input().split())
    mon = [0]*n
    mon2 = [0]*n
    for i in range(m):
        q, a = input().split()
        q = int(q)
        if a == "AC":
            mon[q-1] = 1
        else:
            if mon[q-1] == 0:
                mon2[q-1] += 1
    ac, pena = 0, 0
    for i in range(n):
        if mon[i] == 1:
            ac += 1
            pena += mon2[i]
    print(ac, pena)
    return 0

if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
cnt = 0
pena = 0
L = [-1]*(n+1)
C = [0]*(n+1)
for _ in range(m):
  p, s = input().split()
  p = int(p)
  if s == "WA":
    if L[p] == -1:
      C[p] += 1
  else:
    if L[p] == -1:
      L[p] = 1
      cnt += 1
      pena += C[p]
print(cnt, pena)

Submission status: Accepted

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

WA=[0 for _ in range(N+1)]
solved=[False for _ in range(N+1)]
AC=0

for _ in range(M):
    P,S=input().split()
    P=int(P)
    
    if S=="AC" and solved[P]==False:
        AC+=1
        solved[P]=True
    elif S=="WA" and solved[P]==False:
        WA[P]+=1

U=0
for i in range(1,N+1):
    if solved[i]:
        U+=WA[i]

print(AC,U)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
l1=[list(input().split()) for i in range(m)]
l2=["WA"]*n
l3=[0]*n
account=0
wacount=0
for i in range(m):
  if l1[i][1]=="WA" and l2[int(l1[i][0])-1]=="WA":
    wacount+=1
    l3[int(l1[i][0])-1]+=1
  if l1[i][1]=="AC":
    l2[int(l1[i][0])-1]="AC"

for i in range(n):
  if l2[i]=="AC":
    account+=1
  else:
    wacount-=l3[i]
print(account,wacount)

Submission status: Accepted

Solution code:
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
def gcd(*numbers): reduce(math.gcd, numbers)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
count = 0
ans = 0

N,M=map(int,input().split())
L=[0]*N
R=[0]*N
right=0
pena=0
for _ in range(M):
    p,s=input().split()
    p=int(p)
    p-=1
    if R[p]==0:
        if s=='AC':
          right+=1
          R[p]=1
          pena+=L[p]
        else:
            L[p]+=1

print(right,pena)

Submission status: Accepted

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

AC = {}
WA = {}

for i in range(M):
    if P[i][0] in AC:  # すでにAC済みの場合
        continue
    if P[i][1] == "AC":  # はじめてのAC
        AC[P[i][0]] = True
        continue
    if not P[i][0] in WA:  # はじめてのWA
        WA[P[i][0]] = 1
    else:  # WA2回目以降
        WA[P[i][0]] += 1

WAsum = 0
for i in AC.keys():
    if i in WA:
        WAsum += WA[i]

print(len(AC), WAsum)

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline
sys.setrecursionlimit(10**7)
inf = 10**17
mod = 10**9+7

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

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

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

print(acn, wan)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
lst=[0]*n
ac=0
wa=0
for i in range(m):
    num,result=input().split()
    num=int(num)-1
    if result=="AC":
        if lst[num]!=-1:
            wa+=lst[num]
            lst[num]=-1
            ac+=1
    else:
        if lst[num]!=-1:
            lst[num]+=1
print(ac,wa)

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
L=[0]*N
R=[0]*N
right=0
pena=0
for _ in range(M):
    p,s=input().split()
    p=int(p)
    p-=1
    if R[p]==0:
        if s=='AC':
          right+=1
          R[p]=1
          pena+=L[p]
        else:
            L[p]+=1

print(right,pena)

Submission status: Accepted

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

accepted = [False for _ in range(N)]
wa = [0 for _ in range(N)]

for _ in range(M):
    p, s = input().split()
    p = int(p)
    if not accepted[p - 1]:
        if s == 'AC':
            accepted[p - 1] = True
        else:
            wa[p - 1] += 1

correct = sum(accepted)
penalty = sum([a * w for a, w in zip(accepted, wa)])

print(correct, penalty)

Submission status: Accepted

Solution code:
N,M = list(map(int,input().split()))
lis_AC = []
lis_WA = []
for i in range(M):
    p,s = input().split()
    if s == "AC":
        lis_AC.append(p)
    else:
        if p not in lis_AC:
            lis_WA.append(p)
lis_AC = set(lis_AC)
cnt_WA = 0
for i in lis_WA:
    if i in lis_AC:
        cnt_WA += 1

print(len(lis_AC), end = " ")
print(cnt_WA)

Submission status: Accepted

Solution code:
N, M = list(map(int, input().split()))
P = [0] * M
S = [0] * M

WA = [0] * (100000+1)
AC = [0] * (100000+1)

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

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

print(sum(AC),end=' ')
print(sum(WA))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
 
ac = [0]*N
p = [0]*N
ans = 0
for _ in range(M):
    a,b = input().split()
    a = int(a)-1
 
    if not ac[a]:
        if b == "AC":
            ac[a] = 1
            ans += p[a]
        else:
            p[a] += 1
 
print(sum(ac),ans)

Submission status: Accepted

Solution code:
def main():
    n, m = map(int, input().split())
    indic = {}
    wadic = {}
    AC = 0
    for i in range(m):
        a, b = map(str, input().split())
        a = int(a)
        if a in indic:
            if indic[a] == "WA" and b == "WA":
                wadic[a] += 1
            elif indic[a] == "WA" and b == "AC":
                indic[a] = "AC"
                AC += 1
        else:
            if b == "AC":
                indic[a] = "AC"
                AC += 1
            else:
                indic[a] = "WA"
                wadic[a] = 1
    WA = 0
    for key in indic:
        if indic[key] == "AC" and key in wadic:
            WA += wadic[key]
    print(AC, WA)
                

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, M = map(int, readline().split())

    AC = [False] * N
    WA = [0] * N
    for _ in range(M):
        p, s = readline().split()
        p = int(p) - 1

        if AC[p]:
            continue
        if s == 'AC':
            AC[p] = True
        else:
            WA[p] += 1

    ac = sum(AC)
    wa = sum(p for flag, p in zip(AC, WA) if flag)

    print(ac, wa)
    return


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import collections

n, m = map(int, input().split())
list_ac = set()
dic = collections.defaultdict(lambda:0)

ac = 0
wa = 0

for _ in range(m):
    p, s = input().split()
    if s == "WA" and p not in list_ac:
        dic[p] += 1
    elif s =="AC" and p not in list_ac:
        list_ac.add(p)
        ac += 1
        if p in dic:
            wa += dic[p]
            
print(ac, wa)

Submission status: Accepted

Solution code:
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


from collections import defaultdict
n,m = map(int, input().split())
d = {}
was = 0
acs = 0
for i in range(m):
    p, s = input().split()
    p = int(p)
    if s=="WA":
        if p not in d:
            d[p] = 1
        elif d[p]==-1:
            pass
        else:
            d[p] += 1
    else:
        if p not in d:
            d[p] = -1
            acs += 1
        elif d[p]>=0:
            was += d[p]
            d[p] = -1
            acs += 1
print(acs, was)

Submission status: Accepted

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

li=[0]*M
for i in range(M):
    li[int(i)]=input().split()
#print(li)

count=[0]*N#ペナルティを数える
flg=[0]*N #初期状態０⇒ACを出したら１
for i in range(M):
    if li[int(i)][1] == "AC":#ACを出したら
        flg[int(li[int(i)][0])-1]=1#flg[]に１を格納
    if flg[int(li[int(i)][0])-1] == 0:#まだACを出していないなら
        count[int(li[int(i)][0])-1]+=1#ペナルティ数を１追加

for i in range(N):
    if flg[int(i)] == 0:#１度も正解していないとき
        count[int(i)]=0#ペナルティ数を0にする

print(sum(flg), sum(count))

Submission status: Accepted

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

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

for i in range(m):
    if AC[int(ps[i][0])-1] == 0:
        if ps[i][1] == 'AC':
            AC[int(ps[i][0])-1] = 1
            WA_ans[int(ps[i][0])-1] = WA[int(ps[i][0])-1]

        elif ps[i][1] == 'WA':
            WA[int(ps[i][0])-1] += 1

print(sum(AC), sum(WA_ans))

Submission status: Accepted

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,m = inpl()
a = [False] * (n+1)
cnt = [0] * (n+1)
for _ in range(m):
    x,y = input().split()
    x = int(x)
    if y == 'AC':
        a[x] = True
    else:
        if not a[x]:
            cnt[x] += 1
pena = 0
for i in range(1,n+1):
    if a[i]: pena += cnt[i]
print(sum(a), pena)

Submission status: Accepted

Solution code:
import numpy as np

N, M = map(int, input().split())
AC = np.zeros(N, dtype = int)
WA = np.zeros(N, dtype = int)

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

  if s == 'WA' and AC[int(p) - 1] == 0:
    WA[int(p) - 1] += 1
  else:
    AC[int(p) - 1] = 1

print(sum(AC), sum(AC * WA))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
A = [list(input().split()) for _ in range(M)]
C = {str(i):0 for i in range(1,N+1)}
D = {str(i):0 for i in range(1,N+1)}
for j in range(M):
    p,s = A[j]
    if s=="AC" and C[p]==0:
        C[p] += 1
wa = 0
for j in range(M):
    p,s = A[j]
    if s=="WA":
        if C[p]==1 and D[p]==0:
            wa += 1
    else:
        if D[p]==0:
            D[p] += 1
ac = 0
for i in range(1,N+1):
    ac += C[str(i)]
print(ac,wa)

Submission status: Accepted

Solution code:
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n,m = readInts()
dic = defaultdict(int)
cnt = 0
ans = 0
for i in range(m):
    i,j = input().split()
    if dic[i] != -1:
        if j == 'WA':
            dic[i] += 1
        elif j == 'AC':
            cnt += 1
            ans += dic[i]
            dic[i] = -1
print(cnt,ans)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
AC = [0 for i in range(N)]
WA = [0 for i in range(N)]
for i in range(M):
  p, s = input().split()
  p = int(p)
  if s == 'AC':
    AC[p-1] = 1
  elif AC[p-1] == 0:
    WA[p-1] += 1
a = sum(AC)
b = 0
for i in range(N):
  if AC[i] == 1:
    b += WA[i]
print(a, b, sep=' ')

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())
    p = int(p)
    p -= 1
    if s == 'AC':
        AC[p] = 1
    else:
        if AC[p] != 1:
            WA[p] += 1

a = 0
w = 0
for i in range(n):
    if AC[i] == 1:
        a += 1
        w += 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] * (n+1)
pena = [0] * (n+1)
for p,s in ps:
    p = int(p)
    if ac[p] == 0:
        if s == "WA": pena[p] += 1
        else: ac[p] = 1
ans = [0,0]
for i in range(1,n+1):
    if ac[i] == 1:
        ans[0] += 1
        ans[1] += pena[i]
print(" ".join(map(str, ans)))

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

N, M = inm()


def solve():
    accepted = [False] * N
    wacount = [0] * N
    for i in range(M):
        p, s = ins().split()
        p = int(p) - 1
        if s == "AC":
            accepted[p] = True
            continue

        assert s == "WA"
        if accepted[p]:
            continue
        wacount[p] += 1
    ac = wa = 0
    for i in range(N):
        if accepted[i]:
            ac += 1
            wa += wacount[i]
    return ac, wa


print(*solve())

Submission status: Accepted

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

ac = [0]*N
p = [0]*N
ans = 0
for _ in range(M):
    a,b = input().split()
    a = int(a)-1

    if not ac[a]:
        if b == "AC":
            ac[a] = 1
            ans += p[a]
        else:
            p[a] += 1

print(sum(ac),ans)

Submission status: Accepted

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

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

for s in sub:
    if s[1] == 'AC':
        ac[int(s[0])-1] += 1
    elif ac[int(s[0])-1] == 0:
            wa[int(s[0])-1] += 1

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

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
ac=[0]*(n+1)
wa=[0]*(n+1)
for i in range(m):
  a,b=map(str,input().split())
  a=int(a)
  if ac[a]==0:
    if b=='WA':
      wa[a]+=1
    else:
      ac[a]=1
print(sum(ac))
ans=0
for i in range(n+1):
  if ac[i]==1:
    ans+=wa[i]
print(ans)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(4100000)
import math
INF = 10**9

def main():
    n,m = map(int, input().split())
    wa = 0
    ac = 0
    used = {}
    wa_tmp = {}
    for _ in range(m):
        p,s = map(str, input().split())
        if used.get(p):
            continue
        if s == 'WA':
            if not wa_tmp.get(p):
                wa_tmp[p] = 0
            wa_tmp[p] += 1
        if s == 'AC':
            ac += 1
            used[p] = True
            if wa_tmp.get(p):
                wa += wa_tmp[p]
    print(ac, wa)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

questions = {i:[False, 0] for i in range(1, N + 1)}
count_AC = 0
count_WA = 0

for _ in range(M):
    p, S = input().split()
    if not questions[int(p)][0]:
        if S == "WA":
            questions[int(p)][1] += 1
        elif S == "AC":
            questions[int(p)][0] = True

for v in questions.values():
    if v[0]:
        count_AC += 1
        count_WA += v[1]
        
print(count_AC, count_WA)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-06-29 12:50:48 +0900
# LastModified: 2020-06-29 13:21:56 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


def main():
    n, m = map(int, input().split())
    which_ans = [0]*(n+1)
    penalty_cnt = [0]*(n+1)
    for _ in range(m):
        p, s = map(str, input().split())
        if which_ans[int(p)] == 0 and s == 'WA':
            penalty_cnt[int(p)] += 1
        elif which_ans[int(p)] == 0 and s == 'AC':
            which_ans[int(p)] = 1
    penalty_cnt = [0 if which_ans[i] == 0 else penalty_cnt[i] for i in range(1, n+1)]
    print(sum(which_ans), sum(penalty_cnt))

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N, M = (int(x) for x in input().split())
B = [False]*N
cnt = [0]*N
ans = 0
pena = 0
for i in range(M):
  p, S = (str(x) for x in input().split())
  p = int(p)
  if S=="AC" and B[p-1]==False:
    B[p-1]=True
    ans+=1
  elif S=="WA" and B[p-1]==False:
    cnt[p-1]+=1
for i in range(N):
  if B[i]==True:
    pena+=cnt[i]
print(ans, end=" ")
print(pena)

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
ac_d = {}
wa_d = {}
for i in range(m):
    p, s = input().split()
    if s == "WA":
        if p in wa_d:
            if wa_d[p] == 0:
                pass
            else:
                if p not in ac_d:
                    wa_d[p] += 1
        else:
            wa_d[p] = 1
    else:
        if p not in wa_d:
            wa_d[p] = 0
        ac_d[p] = 1

ac = len(ac_d.keys())

penalty = 0
for key in ac_d.keys():
    penalty += wa_d[key]
print(ac, penalty)

Submission status: Accepted

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

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

for i in range(1,n+1):
    if ac_list[i] == 0:
        wa_list[i] = 0

print(sum(ac_list),sum(wa_list))

Submission status: Accepted

Solution code:
n, m=map(int, input().split())
l = [[] for _ in range(n+1)]
pl=list()
cnt=0
for _ in range(m):
  p, s=map(str, input().split())
  l[int(p)].append(s)
for i in range(1, n+1):
  pen=0
  for h in l[i]:
    if h=="AC":
      cnt+=1
      pl.append(pen)
      break
    else:
      pen+=1
      continue
print(cnt, sum(pl))

Submission status: Accepted

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

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

	if s[i] == 'AC' and ans[p[i]-1] == 0:
		ans[p[i]-1] += 1
		
	if ans[p[i]-1] == 0 and s[i] == 'WA':
		pe[p[i]-1] += 1
for i in range(n):
	if ans[i] == 1:
		anp += pe[i]

print(*[sum(ans),anp])

Submission status: Accepted

Solution code:
N,M  = map(int,input().split())
p_list=["WA"]*N
count = [0]*2
wa_count= [0]*N
for  i in range(M):
    p,s = input().split()
    p = int(p)
    if(p_list[p-1]=="WA" and s=="WA"):
        wa_count[p-1]+=1
    elif(p_list[p-1]=="WA" and s=="AC"):
        p_list[p-1]=s
        count[0]+=1 
        count[1]+=wa_count[p-1]

print(' '.join(list(map(str,count))))

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
ac = [0]*(n+1)
wa = [0]*(n+1)
for _ in range(m):
  p,s = tuple(input().split())
  p = int(p)
  if ac[p]==1: continue
  if s == 'WA': wa[p]+=1
  else: ac[p] = 1
pena = 0
for a,w in zip(ac,wa):
  pena += a*w
print(sum(ac),pena)

Submission status: Accepted

Solution code:
#import sys
#import numpy as np
#from collections import defaultdict



#input = sys.stdin.readline

def main():
    N,M = map(int,input().split())
    accept =[0] *(N+1)

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

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

    print(ac,wrong)



if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

flag = [False]*n
wa = [0]*n
for _ in range(m):
  p,s = input().split()
  p = int(p)-1
  if not flag[p]:
    if s == "WA":
      wa[p] += 1
    else: flag[p] = True

count = 0
for i in range(n):
  if flag[i]: count += wa[i]

print(flag.count(True), count)

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N,M = map(int, readline().split())
PS = [line.split() for line in readlines()]

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

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

Submission status: Accepted

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

co = 0
pe = 0

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

for _ in range(m):
    p, s = map(str, input().split())
    p = int(p)
    if ac[p]==0 and s == 'AC':
        co += 1
        ac[p] =1
        if wa[p]>0:
            pe += wa[p]
    elif ac[p] == 0 and s == 'WA':
        wa[p] += 1

print('{} {}'.format(co, pe))

Submission status: Accepted

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

pro = [0]*n

ac = set([])

ans = 0

pen = 0

for _ in range(m):
    l = input().split()
    s = l[1]
    p = int(l[0])    
    if s == "AC":
        if p not in ac:
            ans += 1
            pen += pro[p-1]
            ac.add(p)
            
    else:
        if p not in ac:
            pro[p-1] += 1
            
print(ans,pen)