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 = [False]*n
WA = [0]*n

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

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

wa = 0

for i in range(n):
    if AC[i]:
        wa += WA[i]
        

print(AC.count(True),wa)

Submission status: Accepted

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

ok = [False]*N
wa = [0]*N

for i in range(M):
    p, S = input().split()
    p = int(p) - 1
    if ok[p] == False:
        if S == "WA":
            wa[p] += 1
        else:
            ok[p] = True
    else:
        pass
pena = 0
for i in range(N):
    if ok[i] == True:
        pena += wa[i]
print(sum(ok), pena)

Submission status: Accepted

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

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

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

ans_WA = 0
for i, j in zip(WA, AC):
  ans_WA += i * j
  
print(sum(AC), ans_WA)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
ac=[0]*(n+1)
wa=0
for i in range(m):
  p,c=input().split()
  if c=='WA' and ac[int(p)]!=1:
    ac[int(p)]-=1
  elif c=='AC' and ac[int(p)]!=1:
    wa+=abs(ac[int(p)])
    ac[int(p)]=1
print(ac.count(1),wa)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
p_S = [input().split() for _ in range(M)]
 
AC = [False]*N
WA = [0]*N
 
# i番目の提出において、
# (1) まだACされておらず、提出がWAだった場合：WA += 1
# (2) まだACされておらず、提出がACだった場合：AC += 1 
# (3) すでにACされている場合：何もしない
for i in range(M):    
  num = int(p_S[i][0])-1
  if AC[num] == 0 and p_S[i][1] == 'WA': WA[num] += 1
  elif AC[num] == 0 and p_S[i][1] == 'AC': AC[num] = True
  else: continue

# ACを出した各問題において、初めてACを出すまでに出したWAの数の和を求める
s = 0
for i in range(N):
  if AC[i]:
    s += WA[i]
    
print(sum(AC), s)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
p=[0]*m
s=[0]*m
for i in range(m):
    pi,si=input().split()
    p[i]=int(pi)
    s[i]=si
judge=[0]*(n+1)
ac=0
wa=0
for i in range(m):
    if judge[p[i]]==-1:
        continue
    if judge[p[i]]!=-1:
        if s[i]=='WA':
            judge[p[i]]+=1
        else:
            wa+=judge[p[i]]
            judge[p[i]]=-1
            ac+=1
print(ac,wa)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
ansct=0
ansflag=[0]*n
miss=[0]*n
missct=0
for i in range(m):
    p,s=map(str,input().split())
    if (s=='AC')and(ansflag[int(p)-1]==0):
        ansflag[int(p)-1]=1
        ansct+=1
        missct+=miss[int(p)-1]
    elif ansflag[int(p)-1]==0:
        miss[int(p)-1]+=1
print(str(ansct)+' '+str(missct))

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
pena= 0
ac = [0]*(10**5)
for _ in range(M):
  tmp = input().split()
  if ac[int(tmp[0])-1] < 1:
    if tmp[1] == "AC":
      pena -= ac[int(tmp[0])-1]
      ac[int(tmp[0])-1] = 1
    else: ac[int(tmp[0])-1] -= 1 #penalty
print(ac.count(1), pena)

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
ans_list = [False for _ in range(n+1)]
pe_list = [0 for _ in range(n+1)]
ac=0
pe=0
for _ in range(m):
    p,s = input().split()
    if not ans_list[int(p)]:
        if s == 'AC':
            ac+=1
            pe+=pe_list[int(p)]
            ans_list[int(p)]=True
        else:
            pe_list[int(p)]+=1
            
print(ac,pe)

Submission status: Accepted

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

ac = [0] * N
wa = [0] * N
c1 = 0
c2 = 0

for i in range(M):
  j = li[i][0] - 1
  if li[i][1] == "WA":
    wa[j] += 1
  if ac[j] == 0 and li[i][1] == "AC":
    ac[j] = 1
    c1 += 1
    c2 += wa[j]

print(c1, c2)

Submission status: Accepted

Solution code:
from collections import defaultdict
N,M = map(int,input().split())
AC_List = defaultdict(int)
WA_List = defaultdict(int)

for i in range(M):
    Num,Sta = map(str,input().split())
    if Num in AC_List:
        continue
    else:
        if Sta == "WA":
            WA_List[Num] += 1
        else:
            AC_List[Num] += 1

ansct = 0
for k,v in WA_List.items():
    if k in AC_List:
        ansct += v
            
print(str(len(AC_List))+" " +str(ansct))

Submission status: Accepted

Solution code:
def main():
    n, m = map(int, input().split())
    ac_list = [0 for _ in range(n + 1)] # 1: 正解済 0: 未正解
    wa_list = [0 for _ in range(n + 1)] 

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

        if ac_list[p] == 1: # 正解済
            continue
        
        if s == "AC":
            ac_list[p] = 1
        else:
            wa_list[p] += 1

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

    print(ac_count, wa_count)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def main():
    n, m = map(int, input().split())
    ans_dict = dict() # {問題i : [ACしたかどうか、ACに関係なく累計WA数]}

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

        if p not in ans_dict: # 初見の場合
            if s == "AC": # 正解
                ans_dict[p] = [1, 0]
            else: # 不正解
                ans_dict[p] = [0, 1]
        else: # 初見じゃない場合
            if ans_dict[p][0] == 1: # 正解済み
                continue
            else: # 未正解
                if s == "AC":
                    ans_dict[p][0] = 1
                else:
                    ans_dict[p][1] += 1

    ac_count = 0
    wa_count = 0
    for item in ans_dict.items():
        if item[1][0] == 1: # 正解済み
            ac_count += 1
            wa_count += item[1][1]

    print(ac_count, wa_count)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def main():
    n, m = map(int, input().split())
    ps_lst = [list(map(str, input().split())) for _ in range(m)]
    judge_lst = [0] * n
    penalty_lst = [0] * n
    correct = 0
    penalty = 0

    for i in range(m):
        problem = int(ps_lst[i][0]) - 1
        result = ps_lst[i][1]
        
        if judge_lst[problem] == 0:
            if result == 'AC':
                judge_lst[problem] = 1
            else:
                penalty_lst[problem] += 1

    for i in range(n):
        if judge_lst[i] == 1:
            correct += 1
            penalty += penalty_lst[i]
            
    print(correct, penalty)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
WA = [0 for i in range(N+1)]
AC = [0 for i in range(N+1)]
for i in range(M):
  p, q = input().split()
  p = int(p)
  if q == "AC":
    AC[p] = 1
  else:
    if AC[p] == 0:
      WA[p] += 1
ans_WA = 0
for i, j in zip(WA, AC):
  ans_WA += i * j
print(sum(AC), ans_WA)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

def main():
    N, M = map(int, input().split())
    p = [0] * M
    S = [0] * M
    for i in range(M):
        p[i] , S[i] = map(str, input().split())
    for i in range(M):
        p[i] = int(p[i])

    AC = 0
    WA = 0
    l = [0] * N
    for i in range(M):
        if l[p[i] - 1] != 1:
            if S[i] == 'WA':
                l[p[i] - 1] -= 1
            elif S[i] == 'AC':
                WA += l[p[i] - 1] * (-1)
                l[p[i] - 1] = 1
                AC += 1
    print(AC, WA)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N, M = map(int, readline().split())
    AC = [False] * N
    cnt = [0] * N

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

    ans_a = 0
    ans_p = 0
    for i in range(N):
        if AC[i]:
            ans_a += 1
            ans_p += cnt[i]

    print(ans_a, ans_p)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

dp = [[0 for _ in range(2)] for _ in range(n)] # AC_flg, WA数

for i in range(m):
    if dp[int(lis[i][0])-1][0]==1:
        continue
    else:
        if lis[i][1]=='WA':
            dp[int(lis[i][0])-1][1] += 1
        if lis[i][1]=='AC':
            dp[int(lis[i][0])-1][0] = 1

ac = 0
wa = 0

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

print(ac,wa)

Submission status: Accepted

Solution code:
# input here
_INPUT = """\
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
2 AC
"""

def main():
    n, m = map(int, input().split())

    seikai = [False] * n
    matigai = [0] * n

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

        if q == "AC":
            seikai[p] = True
        else:
            if seikai[p] != True:
                matigai[p] += 1

    num = 0
    ac = 0
    for i in range(n):
        if seikai[i] == True:
            num += matigai[i]
            ac += 1
    print(ac,num)
            
if __name__ == '__main__':
    import io
    import sys
    import math
    import itertools
    from collections import deque

    # sys.stdin = io.StringIO(_INPUT)
    main()

Submission status: Accepted

Solution code:
# input here
_INPUT = """\
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
2 AC
"""

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

    str_l = ["WA"]*n
    int_l = [0]*n
    num = 0
    ac = 0

    for pp, s in ps:
        p = int(pp)-1
        if s == "AC":
            str_l[p] = "AC"
        else:
            if str_l[p] != "AC":
                int_l[p] += 1

    for i in range(n):
        if str_l[i] == "AC":
            num += int_l[i]
            ac += 1

    print(ac,num)
    # n, m = map(int, input().split())

    # seikai = [False] * n
    # matigai = [0] * n

    # for i in range(m):
    #     p,q = map(str, input().split())
    #     p = int(p)-1

    #     if q == "AC":
    #         seikai[p] = True
    #     else:
    #         if seikai[p] != True:
    #             matigai[p] += 1


    # correct = seikai.count(True)
    # mistake = sum(matigai)
    # print(correct, mistake)
            
if __name__ == '__main__':
    import io
    import sys
    import math
    import itertools
    from collections import deque

    # sys.stdin = io.StringIO(_INPUT)
    main()

Submission status: Accepted

Solution code:
import sys


def resolve(in_):
    N, M = map(int, next(in_).split())
    PS = tuple(line.strip().split() for line in in_)
    
    ac = set()
    wa = {}

    for p, s in PS:
        if s == 'AC':
            ac.add(p)
        if s == 'WA' and p not in ac:
            wa[p] = wa.setdefault(p, 0) + 1

    penalties = 0
    for k, v in wa.items():
        if k in ac:
            penalties += v
    
    return '{} {}'.format(len(ac), penalties)


def main():
    answer = resolve(sys.stdin)
    print(answer)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

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

ac, wa=0,0

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

print(ac, wa)

Submission status: Accepted

Solution code:
from collections import Counter

N, M = [int(_) for _ in input().split()]

wa = Counter()

ac = set()

for i in range(M):
    p, s = input().split()
    p = int(p)
    if p in ac: continue
    if s == 'WA':
        wa[p] += 1
    else:
        ac.add(p)
wa_cnt = 0
for v in ac:
    wa_cnt += wa[v]

print(len(ac), wa_cnt)

Submission status: Accepted

Solution code:
from operator import itemgetter

N,M = map(int,input().split())
PS = [list(map(str,input().split())) for i in range(M)]

for i in range(M) :
    PS[i][0] = int(PS[i][0])

submits = [["null"] for i in range(N)]
for i in range(M) :
    submits[PS[i][0]-1][0] = PS[i][0]-1
    submits[PS[i][0]-1].append(PS[i][1])

ac = 0
pena = 0
for i in range(len(submits)) :
    if submits[i][0] == "null" :
        continue

    flag = False
    wabuf1 = 0
    for j in range(1,len(submits[i])) :
        if submits[i][j] == "AC" :
            ac += 1
            flag = True
            break
        else :
            wabuf1 += 1
    if flag == True :
        pena += wabuf1

print(ac,pena)

Submission status: Accepted

Solution code:
import numpy as np

N, M = map(int,input().split())
AC = np.array([0 for i in range(N)])
WA = np.array([0 for i in range(N)])

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

Submission status: Accepted

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

for _ in range(M):
  p,s=input().split()
  p=int(p)
  if s=='AC':
    a[p]=1
  else:
    if a[p]==0:
      w[p]+=1

a2=0
w2=0
for n in range(N+1):
  if a[n]==1:
    a2+=a[n]
    w2+=w[n]
      
print(a2, w2)

Submission status: Accepted

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

AC = [0] * (N+1)
pl = [0] * (N+1)
cole = 0
pena = 0
for target_list in range(M):
    ans = input().split()
    problem = int(ans[0])
    result = ans[1]

    if AC[problem] == 0 and result == 'WA':
        pl[problem] += 1
    elif AC[problem] == 0 and result == 'AC':
        pena += pl[problem]
        cole += 1
        AC[problem] = 1

print(cole, pena)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
Penalty = [0]*(n+1)
AC = [False]*(n+1)
correct = 0
penalty = 0
for i in range(m):
  ans = input().split()
  problem = int(ans[0])
  result = ans[1]
  if AC[problem] == False:
    if result == 'AC':
      AC[problem] = True
      correct += 1
      penalty += Penalty[problem]
    else:
      Penalty[problem] += 1
print(correct, penalty)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
P = [0]*n
AC = [False]*n
correct = 0
penalty = 0
for i in range(m):
  ans = input().split()
  problem = int(ans[0])
  result = ans[1]
  if AC[problem-1] == False:
    if result == 'AC':
      AC[problem-1] = True
      correct += 1
      penalty += P[problem-1]
    else:
      P[problem-1] += 1
print(correct, penalty)

Submission status: Accepted

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

P = [0] * (N + 1)           #各問題のペナルティの回数を記録
ok = [False] * (N + 1)      #その問題でACが出たかどうか記録

correct = 0                 #正答数を記録
penalty = 0                 #ペナルティ数を記録
for i in range(M):
    query = input().split()
    p = int(query[0])
    S = query[1]
    if ok[p] == False:
        if S == 'AC':
            ok[p] = True
            correct += 1
            penalty += P[p]
        else: # S = 'WA'
            P[p] += 1

print(correct, end=' ')
print(penalty)

Submission status: Accepted

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

print(ac, pena)

Submission status: Accepted

Solution code:
N,M = map(int, input().split())
scorebook = [[] for _ in range(N)]
for i in range(M):
    p,S = input().split()
    p = int(p)-1
    scorebook[p].append(S)
maru = 0
batu = 0
for score in scorebook:
    try:
        batu += score.index("AC")
        maru += 1
    except:
        pass
print(maru, batu)

Submission status: Accepted

Solution code:
def abc151c_welcome_to_at_coder():
    n, m = map(int, input().split())
    penalty = [0] * n
    sum_penalty = 0
    ac = [0] * n
    for i in range(m):
        p, s = input().split()
        if ac[int(p) - 1] == 0:
            if s == 'WA':
                penalty[int(p) - 1] += 1
            else:
                ac[int(p) - 1] = 1
                sum_penalty += penalty[int(p) - 1]
    print(sum(ac), sum_penalty)


abc151c_welcome_to_at_coder()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def solve():
    N, M = map(int, input().split())

    ac = [0] * N
    wa = [0] * N
    num_ac = 0
    num_pe = 0
    for i in range(M):
        P, S = input().split()
        P = int(P) - 1

        if S == "AC":
            if ac[P]:
                continue
            else:
                ac[P] = 1
                num_ac += 1
                num_pe += wa[P]
        else:
            if ac[P]:
                continue
            else:
                wa[P] += 1

    print(num_ac, num_pe)


def main():
    solve()


if __name__ == '__main__':
    main()

Submission status: Accepted

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

qq=[True]*n
for i in range(m):
    i,j=input().split()
    i=int(i)
    i-=1
    if j=="AC":
        if qq[i]:
            qq[i]=False
            res+=pp[i]
    else:
        pp[i]+=1

print(qq.count(False),res)

Submission status: Accepted

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

prob = {}


for i in range(m):
  x,y = input().split()
  if x not in prob:
    if y == 'AC':
      prob[x] = [1, 0]
    else:
      prob[x] = [0, 1]
  else:
    if prob[x][0] == 0:
      if y == 'AC':
        prob[x][0] += 1
        answered = True
      else:
        prob[x][1] += 1

ac = 0
wa = 0

for i in prob:
  if prob[i][0] == 1:
    ac += 1
    wa += prob[i][1]

print(ac, wa)

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
A = [0]*(N+1)
ac = 0
pe = 0
for i in range(M):
    p,S = input().split()
    if A[int(p)] == -1:
        continue
    if S == "AC":
        ac += 1
        pe += A[int(p)]
        A[int(p)] = -1
    else:
        A[int(p)] += 1
print(ac,pe)

Submission status: Accepted

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

for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    if s == 'WA' and not ac[p]:
        wa[p] += 1
    elif s == 'AC':
        ac[p] = True

wa_n = sum(wa[i] if ac[i] else 0 for i in range(n))
print("{} {}".format(sum(ac), wa_n))

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
results = [False]*N
penalties = [0]*N
for _ in range(M):
    p,S=input().split()
    p = int(p)
    if S == 'AC':
        results[p-1] = True
    else:
        if not results[p-1]:
            penalties[p-1] += 1

points1 = 0
points2 = 0

for i in range(N):
    if results[i]:
        points1 += 1
        points2 += penalties[i]

print('{} {}'.format(points1,points2))

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
a = [[0, 0] for i in range(N)]
for i in range(M):
  IN = list(input().split())
  p = int(IN[0])
  S = IN[1]
  if S == "AC":
    a[p-1][1] = 1
  else:
    if a[p-1][1] == 0:
      a[p-1][0] += 1
m = 0
n = 0
for i in range(N):
  if a[i][1] == 1:
    m += 1
    n += a[i][0]
print(m)
print(n)

Submission status: Accepted

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

l=[0]*n
w=0
c=0
ac=set()

for i in range(m):
  p,s=map(str,input().split())
  p=int(p)
  if s=='WA':
    l[p-1]+=1
  else:
    if p not in ac:
      c+=1
      w+=l[p-1]
      ac.add(p)

print(c,w)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
li=[0]*n
ok=0
ng=0
pro=set()
for i in range(m):
    p,s=map(str,input().split())
    p=int(p)
    if s=="WA":
        li[p-1]+=1
    else:
        if not p in pro:
            ok+=1
            ng+=li[p-1]
            pro.add(p)
print(ok,ng)

Submission status: Accepted

Solution code:
n,m=input().split()
n=int(n)
m=int(m)
f=[0]*n
wa=[0]*n
ac=0
for i in range(m):
    p,s=input().split()
    p=int(p)-1
    if f[p]==1:
        continue
    if s=="WA":
        wa[p]+=1
    else:
        ac+=1
        f[p]=1
x=0
for i in range(n):
    if f[i]==1:
        x+=wa[i]
print(ac,x)

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
ac = (N+1)*[0]
wa = (N+1)*[0]
pt = 0
for i in range(M):
  p,s = input().split()
  p = int(p)
  if ac[p] == 0 and s == "AC":
    ac[p] = 1
    pt += wa[p]
  wa[p] += 1
print(sum(ac),pt)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
l=[0]*n
d=[0]*n
for i in range(m):
    s=input().split()
    x=int(s[0])
    if(s[1]=='AC'):
        l[x-1]=1
    else:
        if(l[x-1]==1):
            continue
        else:
            d[x-1]+=1
p=0
for i in range(n):
    if(l[i]==1):
        p+=d[i]
print(sum(l),p)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
a, w = 0, 0
P = set()
W = {}
for _ in range(M):
    p, S = map(str, input().split())
    if p in P:
        continue
    if S == 'WA':
        W.setdefault(p, 0)
        W[p] += 1
    if S == 'AC':
        a += 1
        P.add(p)
        if p in W:
            w += W[p]
print(a, w)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
ps = [list(input().split()) for _ in range(m)]
ac = [0]*n
wa = [0]*n
cnt = [0]*n
for i in range(m):
    x = int(ps[i][0]) - 1
    if ps[i][1] == "AC" and ac[x] == 0:
        ac[x] = 1
        wa[x] = cnt[x]
    elif ps[i][1] == "WA" and ac[x] == 0:
        cnt[x] += 1
print(sum(ac), sum(wa))

Submission status: Accepted

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

is_solved = [False] * N
wa_count = [0] * N
wa_total = 0

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

    if s == 'AC':
        if not is_solved[p]:
            is_solved[p] = True
            wa_total += wa_count[p]
    else:
        wa_count[p] += 1

print(sum(is_solved), wa_total)

Submission status: Accepted

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

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

is_ac = [False]*N
wa_cnt = [0]*N

for i in range(M):
    if S[i] == 'AC':
        is_ac[p[i]-1] = True
    else:
        if not is_ac[p[i]-1]:
            wa_cnt[p[i]-1] += 1

ac_cnt = 0
penalty = 0

for j in range(N):
    if is_ac[j]:
        ac_cnt += 1
        penalty += wa_cnt[j]

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

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
AC=[0]*N
WA=[0]*N
pts=0
pena=0
for i in range(M):
    a,b=map(str,input().split())
    if b=='AC':
        if AC[int(a)-1]==0:
            AC[int(a)-1]=1
            pts+=1
            pena+=WA[int(a)-1]
    else:
        WA[int(a)-1]+=1
print(pts,pena)

Submission status: Accepted

Solution code:
N, M, *PS = open(0).read().split()
N, M = [int(_) for _ in [N, M]]
cor = [0] * (N + 1)
pen = [0] * (N + 1)
for p, s in zip(PS[::2], PS[1::2]):
    p = int(p)
    if cor[p] == 1:
        continue
    if s == 'AC':
        cor[p] = 1
    else:
        pen[p] += 1
ans = [0, 0]
for i in range(1, N + 1):
    if cor[i] == 0:
        continue
    ans[0] += 1
    ans[1] += pen[i]
print(*ans)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
account, wacount = 0, 0
acdic = [0] * (n + 10)
for _ in range(m):
    p, s = input().split()
    p = int(p)
    if s == "AC" and acdic[p] <= 0:
        account += 1
        wacount += abs(acdic[p])
        acdic[p] = 1
    elif s == "WA" and acdic[p] <= 0:
        acdic[p] -= 1
print(account, wacount)

Submission status: Accepted

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

Submission status: Accepted

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

ans = [["",0] for i in range(N)]
for i in range(M):
    p,S = map(str,input().split())
    p = int(p)-1
    if ans[p][0] != "AC":
        if S == "AC":
            ans[p][0] = "AC"
        elif S == "WA":
            ans[p][1] += 1

AC = 0
WA = 0
for i in ans:
    if i[0] == "AC":
        AC += 1
        WA += i[1]

print(AC,WA)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
count = [0]*N
ans = 0
ok = 0
for _ in range(M):
    p, s = input().split()
    if count[int(p)-1] >= 0 and s == "WA":
        count[int(p) - 1] += 1
    elif count[int(p)-1] >= 0 and s == "AC":
        ans += count[int(p)-1]
        count[int(p)-1] = -1
        ok += 1
print(ok, ans)

Submission status: Accepted

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

flagac=[False]*N
pnlt=[0]*N
for i in range(M):
    p=P[i]-1
    s=S[i]
    if s=='AC':
        flagac[p]=True
    else:
        pnlt[p]+=(flagac[p]+1)%2
# print(flagac)
# print(pnlt)

ctac=0
ctwa=0
for i in range(N):
    if flagac[i]:
        ctac+=1
        ctwa+=pnlt[i]
print(ctac, ctwa)

Submission status: Accepted

Solution code:
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [input() for _ in range(n)]

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

#コンテスト毎に["AC","WA","AC"]を格納する
d = {}

for i in range(m):
    key = p[i][0]
    val = p[i][1]
    if key in d:
        d[key].append(val)
    else:
        d[key] = [val]

# AC数を求める
acNum = 0

for v in d.values():
    if "AC" in v:
        acNum += 1

# WA数求める
waNum = 0

for v in d.values():
    if "AC" in v:
        for i in range(len(v)):
            if v[i] == "AC":
                break
            else:
                waNum += 1
print(acNum, waNum)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(100000)
input = sys.stdin.readlines

from collections import defaultdict

def main():

    ac_num = 0
    pt_num = 0

    C = defaultdict(lambda: {"status":False, "penaulty":0} )

    lines = input()
    N, M = list(map(int, lines[0].split()))
    for i in range(1, M+1):
        pi, si = lines[i].split()
        pi = int(pi)
        if C[pi]["status"]:
            continue
        else:
            if si == "AC":
                C[pi]["status"] = True
                ac_num += 1
            else:
                C[pi]["penaulty"] += 1

    for i in range(1, N+1):
        if C[i]["status"]:
            pt_num += C[i]["penaulty"]

    print(ac_num, pt_num)

main()

Submission status: Accepted

Solution code:
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1
wa = 0
n,m = map(int,input().split())
data = [0]*(n+1)
ans = [0]*(n+1)
for i in range(m):
  p,s = input().split()
  p = int(p)
  if s == "WA":
    data[p] += 1
  else:
    if ans[p] == 0:
      wa += data[p]
      ans[p] = 1
print(sum(ans),wa)

Submission status: Accepted

Solution code:
#C - Welcome to AtCoder
N,M = map(int,input().split())
S_P_list = []
for _ in range(M):
    p,s = input().split()
    S_P_list.append((int(p),s))
#Pに着目して安定ソート
S_P_list = sorted(S_P_list,key = lambda x:x[0],reverse = False)    
#ACが存在するPの集合
AC_list = list(set([i[0] for i in S_P_list if i[1] == 'AC']))
WA = 0
AC = 0
for i in range(M):
    if (S_P_list[i][0] in AC_list):
        if S_P_list[i][1] == 'AC':
            AC += 1
            AC_list.remove(S_P_list[i][0])
        else:
            WA += 1
print(AC,WA)

Submission status: Accepted

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

pena=[0]*(n+1)
seitou=[0]*(n+1)

for i in range(m):
    p,s = map(str,input().split()) 
    p=int(p)
    if s=="WA" and seitou[p]==0:
        pena[p]+=1
    if s=="AC":
        seitou[p]=1

pena_kazu=0

for i in range(1,n+1):
    if seitou[i]==1:
        pena_kazu+=pena[i]

seitou_kazu=sum(seitou)

print(str(seitou_kazu)+" "+str(pena_kazu))

Submission status: Accepted

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

print(str(ac) + ' ' + str(wa))