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=(int(i) for i in input().split())
P=[[int(j)-1  if i==0 else j for i, j in enumerate(input().split())] for  _ in range(M)]
ac="AC"
wa="WA"
flag=[0]*N
ans=0
pe=0

for i in range(M):
    if flag[P[i][0]]!=-1 and P[i][1]==ac:
        ans+=1
        pe+=flag[P[i][0]]
        flag[P[i][0]]=-1
    elif flag[P[i][0]]!=-1 and P[i][1]==wa:
        flag[P[i][0]]+=1
        
print(ans,pe)

Submission status: Accepted

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

check = [[] for i in range(n)]

for i in range(m):
    s = int(li[i][0])
    check[s-1].append(li[i][1])
    
for i in range(n):
    if len(check[i]) > 0:
        for j in range(len(check[i])):
            if check[i][j] == "WA":
                ans[1] += 1
            elif check[i][j] == "AC":
                ans[0] += 1
                break
        else:
            ans[1] -= len(check[i])

print(*ans)

Submission status: Accepted

Solution code:

N, M = map(int, input().split())
P = [ [] for i in range(N+1) ]

wa = 0
ac = 0

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

for i in range(1, N+1):
  tmp_ac = 0
  tmp_wa = 0

  for s in P[i]:
    if s == "WA" and not tmp_ac > 0:
      tmp_wa += 1
    elif s == "AC" and not tmp_ac > 0:
      tmp_ac += 1

  if tmp_ac > 0:
    wa += tmp_wa
    ac += tmp_ac

print(ac, wa)

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
ps = []
for i in range(m):
    ppss = [i for i in input().split()]
    ps.append(ppss)
ac = [0 for i in range(n)]
wa = [0 for i in range(n)]
for i in range(m):
    if ps[i][1] == 'AC':
        ac[int(ps[i][0])-1] = 1
    else:
        if ac[int(ps[i][0])-1] != 1:
            wa[int(ps[i][0])-1] += 1
for i in range(n):
    if ac[i] != 1:
        wa[i] = 0
print(sum(ac),sum(wa))

Submission status: Accepted

Solution code:
n_m = list(map(lambda x: int(x), input().split(" ")))
N = n_m[0]
M = n_m[1]

result_dict = {}

for i in range(M):
    p_s = input().split(" ")
    P = int(p_s[0])
    S = p_s[1]
    if P in result_dict:
        if result_dict[P][0] == 1:
            continue
        elif S == "AC":
            result_dict[P][0] = 1
        else:
            result_dict[P][1] += 1
    else:
        if S == "AC":
            result_dict[P] = [1, 0]
        else:
            result_dict[P] = [0, 1]

ac_count = 0
wa_count = 0
for v in result_dict.values():
    if v[0] == 0:
        continue
    ac_count += 1
    wa_count += v[1]

result = "{} {}".format(ac_count, wa_count)
print(result)

Submission status: Accepted

Solution code:
n1,m1 = map(int,input().split())
dic = [0 for i in range(n1)]
se = set()
for i in range(m1):
    n,m = input().split()
    if n not in se and m == "WA":
        dic[int(n)-1] += 1
    else:
        se.add(n)
print(len(se),sum([dic[int(i)-1] for i in se]))

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
P = []
S = []
T = [0 for i in range(N)]
U = [0 for i in range(N)]
ACs = 0
WAs = 0
for i in range(M):
  p, s = input().split()
  p = int(p)
  P.append(p)
  S.append(s)
for i in range(M):
  if S[i] == "AC":
    if U[P[i]-1] != 1:
      U[P[i]-1] += 1
      ACs += 1
      WAs += T[P[i]-1]
  else:
    T[P[i]-1] += 1
print(ACs, WAs)

Submission status: Accepted

Solution code:
import numpy as np
N, M =[int(i) for i in input().split()]
isfinish=[0]*N
isfail=[0]*N
for i in range(M):
    p, S = input().split()
    p=int(p)
    if isfinish[p-1]==1:
        continue
    elif S=="AC" and isfinish[p-1]==0:
        isfinish[p-1] = 1
    elif S=="WA" and isfinish[p-1]==0:
        isfail[p-1] +=1

isfinish=np.array(isfinish)
isfail=np.array(isfail)
print(str(sum(isfinish)) + " "+ str(sum(isfail[isfinish==1])))

Submission status: Accepted

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

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

for i in range(m):
    if que[p[i]] == False:
        if s[i] == "WA":
            wan[p[i]] += 1
        else:
            que[p[i]] = True

for i in range(len(que)):
    if que[i] == True:
        ac += 1
        wa += wan[i]

print(ac,wa)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
p = []
s = []
for i in range(m):
    pp, ss = input().split()
    p.append(int(pp) - 1)
    s.append(ss)

acs = [0] * n
was = [0] * n
for i in range(m):
    if s[i] == 'AC':
        acs[p[i]] = 1
    else:
        if acs[p[i]] == 0:
            was[p[i]] += 1
for i in range(n):
    if acs[i] == 0:
        was[i] = 0
print("{} {}".format(sum(acs), sum(was)))

Submission status: Accepted

Solution code:
# C
n, m = map(int,input().split())
plst = []
result = []
for _ in range(m):
    p, s = input().split()
    p = int(p)
    plst.append(p)
    result.append(s)
rui = list(set(plst))
tmps = [[] for _ in range(len(rui))]
dic = dict(zip(rui, tmps))

for p, s in zip(plst, result):
    dic[p].append(s)

ac = 0
wa = 0

for item in dic.values():
    if 'AC' in item:
        ac += 1
        for l in item:
            if l == 'AC':
                break
            else:
                wa += 1
print(ac, wa)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
x=[list(input().split()) for i in range(m)]
a=0
p=0
x.sort(key=lambda x:x[0])
t='a'
for i in range(m):
  if t!=x[i][0]:
    w=0
    t=x[i][0]
    f=1
  if f:
    if x[i][1]=='AC':
      a+=1
      p+=w
      f=0
    else:
      w+=1
print(a,p)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
a=[]
for i in range(m):
    x,y=input().split()
    a.append([int(x),y])
check=[False]*n
ans=[0]*n
for i in a:
    if check[i[0]-1]==True:
        continue
    else:
        if i[1]=="AC":
            check[i[0]-1]=True
        else:
            if check[i[0]-1]!=True:
                ans[i[0]-1]+=1
total=0
for i in range(n):
    if check[i]==True:
        total+=ans[i]
print(check.count(True),total)

Submission status: Accepted

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

p = [0] * M
k = [""] * M

for i in range(M):
    p[i], k[i] = input().split()
    p[i] = int(p[i])-1
    

ans = [0]*N
pen = [0]*N
accept = 0
pena = 0
for i in range(M):
    if k[i] == "WA" and ans[p[i]] == 0:
        pen[p[i]] += 1
    elif k[i] == "AC" and ans[p[i]] == 0:
        pena += pen[p[i]]
        ans[p[i]] = 1
        accept += 1
        
print(str(accept) + " " + str(pena))

Submission status: Accepted

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

n_list=[0]*N
p_list=[0]*N

ac_cnt=0
wa_cnt=0


for i in range(M):
    p,S=input().split()
    p=int(p)
    if S=="WA":
        p_list[p-1]+=1
    else:
        if n_list[p-1]==0:
            n_list[p-1]=1
            ac_cnt+=1
            wa_cnt+=p_list[p-1]

print(ac_cnt,wa_cnt)

Submission status: Accepted

Solution code:
# coding: utf-8
import re
import math
#import numpy as np


#main
n,m=map(int,input().split())
MAP={}
PS=[]
for a in range(m):
    s,t=input().split()
    if(not s in MAP):MAP[s]=[]
    MAP[s].append(t)
ac=0
wa=0
for a,b in MAP.items():
    if(not "AC" in MAP[a]):continue
    for c in b:
        if(c=="WA"):
            wa+=1
        else:
            ac+=1
            break
print(ac,wa)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
isAC = [0]*N
ac = 0
WA = [0]*N
for _ in range(M):
    p, s = input().split()
    p = int(p)
    if not isAC[p-1]:
        if s == 'AC':
            isAC[p-1] = 1
            ac += 1
        else:
            WA[p-1] += 1
    
wa = sum([i*j for i, j in zip(isAC, WA)])
print(ac, wa)

Submission status: Accepted

Solution code:
from math import factorial
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def MI(): return map(int, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


def MS(): return map(str, input().split())

YN = ['No', 'Yes']
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']


# show_flg = False
show_flg = True

p = None
XY = None
N = None


def main():
    N, M = MI()
    ans = 0
    p = [0] * M
    S = [0] * M
    dic = {}
    # x = LI()

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

    for i in range(M):
        if S[i] == 'WA' and dic[p[i]]['AC'] is False:
            dic[p[i]]['WA'] += 1
        elif S[i] == 'AC':
            dic[p[i]]['AC'] = True

    AC = 0
    WA = 0
    for key in dic.keys():
        if dic[key]['AC']:
            AC += 1
            WA += dic[key]['WA']

    print(AC, WA)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
p=[]
s=[]
for i in range(m):
	P,S=input().split()
	P=int(P)-1
	p.append(P)
	s.append(S)

wa=[0 for i in range(n)]
ac=[0 for i in range(n)]
for i in range(m):
	if s[i]=="AC":
		ac[p[i]]+=1
	else:
		if ac[p[i]]==0:
			wa[p[i]]+=1

sum_ac=0
pena=0
for i in range(n):
	if ac[i]!=0:
		sum_ac+=1
		pena+=wa[i]
print(sum_ac,end=' ')
print(pena)

Submission status: Accepted

Solution code:
n,m = map(int, input().split())
flag = [False] * (10**5 + 100)
wa = [0] * (10**5 + 100)
for i in range(m):
    p, s = map(str, input().split())
    p = int(p)

    if flag[p] == False:
        if s == "AC":
            flag[p] = True
        else:
            wa[p] += 1

ans = 0
for i in range(10**5+1):
    if flag[i]:
        ans += wa[i]
print(sum(flag), ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# abc151/abc151_c
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N, M = i2nn()
    wa_list = [0] * N
    penalty = 0
    ac = 0
    for _ in range(M):
        p, S = i2s().split(' ')
        p = int(p) - 1
        if wa_list[p] >= 0:
            if S == 'WA':
                wa_list[p] += 1
            else:
                penalty += wa_list[p]
                wa_list[p] = -1
                ac += 1
    print(ac, penalty)
    return

main()

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
seiseki=[[0]*N for _ in range(2)]
for i in range(M):
  p,S=input().split()
  p=int(p)
  if seiseki[1][p-1]==0:
    if S=='WA':
      seiseki[0][p-1]+=1
    else:
      seiseki[1][p-1]=1
AC=sum(seiseki[1])
WA=0
for i in range(N):
  if seiseki[1][i]==1:
    WA+=seiseki[0][i]
print(AC,WA)

Submission status: Accepted

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

no,prob=[0]*n,[-1]*n
for i in range(m):
  p,s=int(PS[i][0]),PS[i][1]
  if s=='AC': prob[p-1]=1
  if s=='WA' and prob[p-1]==-1: no[p-1]+=1
pena,ans=0,0
for i,p in enumerate(prob):
  if p==1:
    pena+=no[i]
    ans+=1
print(ans,pena)

Submission status: Accepted

Solution code:
n,m=input().strip().split(" ")
n,m=[int(n),int(m)]
f=[0 for _ in range(n+1)]
f1=[0 for _ in range(n+1)]
for i in range(m):
    a,b=input().strip().split(" ")
    a,b=[int(a),str(b)]
    if b=="AC":
        f[a]=1
    elif b=="WA":
        if f[a]==0:
            f1[a]+=1
su=0
for i in range(n+1):
    if f[i]==1:
        su+=f1[i]
print(sum(f),su)

Submission status: Accepted

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

lac = [0] * (n+1)
lwa = [0] * (n+1)

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

ans = 0
pnl = 0

for i in range(1, n+1):
    if lac[i] > 0:
        ans += 1
        pnl += lwa[i]

print("{} {}".format(ans, pnl))

Submission status: Accepted

Solution code:
def main():
  N, M = map(int, input().split())
  
  correct = [0] * N
  penalty = [0] * N
  pena = 0
  
  for _ in range(M):
    pi, si = input().split()
    pi = int(pi)
    
    if si == 'WA' and correct[pi-1] == 0:
      penalty[pi-1] += 1
    elif si =='AC' and correct[pi-1] == 0:
      correct[pi-1] = True
      pena += penalty[pi-1]

  print(sum(correct), pena)       

main()

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
PS = [list(input().split()) for _ in range(M)]
l = [False]*N
k = [False]*N
for p,s in PS:
  p=int(p)
  if s=='AC':
    k[p-1]=True
pena = 0
for p,s in PS:
  p = int(p)
  if s=='AC':
    if not l[p-1]:
      l[p-1]=True
  if s=='WA':
    if (not l[p-1])and(k[p-1]):
      pena+=1
      
ans = sum(l)
print(ans,pena)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
good = [0] * n
pena = [0] * n
for i in range(m):
	pi, si = map(str, input().split())
	pi = int(pi)
	if si == "AC":
		good[pi - 1] = 1
	elif si == "WA" and good[pi - 1] == 0:
		pena[pi - 1] += 1

sum_good = 0
sum_pena = 0
for i in range(n):
	if good[i] >= 1:
		sum_good += 1
		sum_pena += pena[i]

print(sum_good, sum_pena)

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
ps = [input().split() for i in range(M)]
from collections import defaultdict
acs = set()
penas = defaultdict(lambda: 0)
for p,s in ps:
    if p in acs: continue
    if s=='AC':
        acs.add(p)
    else:
        penas[p] += 1

pena = 0
for p in acs:
    pena += penas[p]
print(len(acs), pena)

Submission status: Accepted

Solution code:
#C
N, M = map(int, input().split())
flags = [0] * (N+1)
submit_count = [0] * (N+1)
true_answer = 0
penalty = 0

for _ in range(M):
    pi, Si = input().split()
    pi = int(pi)
    if Si == "AC":
        if flags[pi] == 0:
            flags[pi] = 1
            true_answer += 1
            penalty += submit_count[pi]
        else:#すでにAC済みの場合
            pass
    else:#Si == "WA"の場合
        if flags[pi] == 0:
            submit_count[pi] += 1
        else:#すでにAC済みの場合
            pass
        
print(true_answer, penalty)

Submission status: Accepted

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

result_AC = [False]*N # 正答したかどうかを保存する
correct_num = 0
penalty_num = 0
penalty_list = [0]*N

for _ in range(0, M):
  p, S = input().split(" ")
  p = int(p) - 1
  # pをみて，もしresult_ACがtrueならばnext
  if(result_AC[p]):
    continue
  # そうでない場合，
  else:
    ## ACならば，result_ACをtrueにして，correct_num += 1
    if S == 'AC':
      result_AC[p] = True
      correct_num += 1
      penalty_num += penalty_list[p]
    ## WAならば，penalty_num += 1
    else:
      penalty_list[p] += 1

print(correct_num, penalty_num)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(4100000)

import math

import logging

logging.basicConfig(level=logging.DEBUG)

logger = logging.getLogger(__name__)


def resolve():
    N, M = [int(x) for x in sys.stdin.readline().split()]
    pS_list = [[x for x in sys.stdin.readline().split()] for _ in range(M)]

    aced_list = [False for _ in range(N)]
    penal_list = [0 for _ in range(N)]
    for p, s in pS_list:
        p = int(p) - 1
        if s == 'AC':
            aced_list[p] = True
        else:
            if not aced_list[p]:
                penal_list[p] += 1

    for i in range(N):
        if not aced_list[i]:
            penal_list[i] = 0

    print(sum(aced_list), sum(penal_list))


if __name__ == "__main__":
    resolve()

# AtCoder Unit Test で自動生成できる, 最後のunittest.main は消す
# python -m unittest template/template.py で実行できる
# pypy3 -m unittest template/template.py で実行できる
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """2 5
1 WA
1 AC
2 WA
2 AC
2 WA"""
        output = """2 2"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """100000 3
7777 AC
7777 AC
7777 AC"""
        output = """1 0"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """6 0"""
        output = """0 0"""
        self.assertIO(input, output)

    def test_入力例_4(self):
        input = """2 5
1 WA
1 AC
2 WA
2 WA
2 WA"""
        output = """1 1"""
        self.assertIO(input, output)

Submission status: Accepted

Solution code:
#標準入力を高速に
import sys 
input = sys.stdin.readline

N,M = map(int,input().split())
p = [0]*M
S = [""]*M
for i in range(M):
    p[i],S[i] = input().split()
    p[i] = int(p[i])
    p[i] -= 1

penalties=[0]*N
penalty=0
flag=[True]*N
for i in range(M):
    if flag[p[i]]:
        if S[i] == "WA":
            penalties[p[i]] += 1
        else:
            flag[p[i]] = False

corrects = 0
for i in range(N):
    if not flag[i]:
        corrects += 1
        penalty += penalties[i]

print(corrects)
print(penalty)
#print(sum(penalties))

Submission status: Accepted

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


def solve(N: int, M: int, p: "List[int]", S: "List[str]"):
    x = [0] * N

    ac = 0
    wa = 0

    for i in range(M):
        if x[p[i]-1] >= 0:
            if S[i] == "AC":
                ac += 1
                wa += x[p[i]-1]
                x[p[i]-1] = -1
            else:
                x[p[i]-1] += 1
    print(ac, wa)


    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    p = [int()] * (M)  # type: "List[int]"
    S = [str()] * (M)  # type: "List[str]"
    for i in range(M):
        p[i] = int(next(tokens))
        S[i] = next(tokens)
    solve(N, M, p, S)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

myAC = [0 for n in range(N+1)]
myWA = [0 for n in range(N+1)]

ansAC = 0
ansWA = 0


for m in range(M):
    a,  b = map(str, input().split())
    a = int(a)
    if b == 'WA' and myAC[a] != 1:
        myWA[a] += 1
        
    if b == 'AC' and myAC[a] != 1:
        myAC[a] = 1
        ansWA += myWA[a]
        ansAC += 1

#print(myAC)
#print(myWA)
print(ansAC,ansWA)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline


def main():
    N, M = map(int, input().split())
    ps = []
    for i in range(M):
        p, s = input().split()
        ps.append((int(p), s))
    ac = [0]*(10**5)
    pena = [0]*(10**5)
    for p, s in ps:
        if s == "WA":
            if ac[p] == 0:
                pena[p] += 1
        if s == "AC":
            ac[p] = 1
    p = 0
    for i in range(len(ac)):
        if ac[i] == 1:
            p += pena[i]
    print(ac.count(1), p)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
ps = []
memo = [0 for i in range(n)]
pena = [0 for i in range(n)]
for i in range(m):
    p, s = input().split()
    p = int(p)
    if s == "AC":
        memo[p-1] = 1
    else:
        if memo[p-1] == 0:
            pena[p-1] += 1
ans = 0
for i, p in enumerate(pena):
    if memo[i]:
        ans += p
print(sum(memo), ans)

Submission status: Accepted

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

correct, penalty = 0, 0
last_c, is_solved = 1, False
tmp_pen = 0
for ps_i in ps:
  p, s = ps_i
  if (p != last_c):
    tmp_pen = 0
    is_solved = False
    last_c = p
    if (is_solved):
      continue
    elif (s == "WA"):
      tmp_pen += 1
    else:
      correct += 1
      penalty += tmp_pen
      is_solved = True
  else:
    if (is_solved):
      continue
    elif (s == "WA"):
      tmp_pen += 1
    else:
      correct += 1
      penalty += tmp_pen
      is_solved = True
print(correct, penalty)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n, m = map(int, input().split())

cnt_ac = 0
cnt_wa = 0
ac_set = set()
wa_dict = dict()

for i in range(m):
    str_list = input().split()
    p = int(str_list[0])
    s = str_list[1]
    if p not in ac_set:
        if s == 'AC':
            cnt_ac = cnt_ac + 1
            if p in wa_dict:
                cnt_wa = cnt_wa + wa_dict[p]
            ac_set.add(p)
        else:
            if p in wa_dict:
                wa_dict[p] = wa_dict[p] + 1
            else:
                wa_dict[p] = 1

print(str(cnt_ac) + ' ' + str(cnt_wa))

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
d={}
for i in range(m):
    p,s=map(str,input().split())
    if p not in d:
        d[p]=[s,1]
    elif d[p][0]=="WA":
        d[p][0]=s
        d[p][1]+=1
ans=[0,0]
for i in d:
    if d[i][0]=="AC":
        ans[0]+=1
        ans[1]+=d[i][1]-1
print(*ans)

Submission status: Accepted

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

ans_ac = 0
ans_wa = 0
flag = 0
number = 0
ok = ["n" for i in range(n)]
count_wa = [0 for i in range(n)]
count = 0
for i in range(m):
    if ok[int(ps[i][0])-1] == "n":
        if ps[i][1] == "WA":
            count_wa[int(ps[i][0])-1] += 1
        else:
            ans_ac += 1
            ans_wa += count_wa[int(ps[i][0])-1]
            ok[int(ps[i][0])-1] = "OK"
 #   print(ok)
 #   print(count_wa)
    
print(ans_ac,ans_wa)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
N, M = [int(x) for x in input().split()]
p = []
S = []
for _ in range(M):
    temp = input().rstrip().split()
    p.append(int(temp[0]))
    S.append(temp[1])
dic = {}
for i in range(N):
    dic[i + 1] = []
for i, j in zip(p, S):
    dic[i].append(j)
AC = 0
WA = 0
for k in dic.keys():
    temp = dic[k]
    WA_count = 0
    for j in temp:
        if j == "WA":
            WA_count += 1
        else:
            AC += 1
            WA += WA_count
            break
print(AC, WA)

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
pS = [list(input().split()) for _ in range(M)]
lis = [0]*N
pena = [0]*N
for p,S in pS:
    p = int(p)-1
    if S == "AC":
        lis[p] = 1
    else:
        if lis[p] == 0:
            pena[p] += 1
pe = 0
for i in range(N):
    if lis[i]:
        pe += pena[i]

print(sum(lis), pe)

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
done = [0]*(n+1)
wa = [0]*(n+1)
pen = 0
for i in range(m):
  p,q = input().split()
  p = int(p)
  if q == "WA":
    if done[p] == 0:
      wa[p] += 1
  else:
    if done[p] == 0:
      done[p] = 1
      pen += wa[p]
print(sum(done),pen)

Submission status: Accepted

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

for i in range(len(PSs)):
    PSs[i][0] = int(PSs[i][0])

is_ac = [False for i in range(n)]

ac = int()
wa = [0 for i in range(n)]
for i in range(len(PSs)):
    if PSs[i][1] == 'AC' and not is_ac[PSs[i][0]-1]:
        ac += 1
        is_ac[PSs[i][0]-1] = True
    
    if PSs[i][1] == 'WA' and is_ac[PSs[i][0]-1] == False:
        wa[PSs[i][0]-1] += 1

#print(ac)
#print(is_ac)
#print(wa)

pen = int()
for i in range(n):
    if is_ac[i] == True:
        pen += wa[i]
        #print(i, i, i)

print(ac, pen)

Submission status: Accepted

Solution code:
from collections import defaultdict
N, M = map(int, input().split())
done = set()
ac = defaultdict(int)
wa = defaultdict(int)
# ACを一回以上出した問題のみ
for _ in range(M):
    p, s = map(str, input().split())
    if s == "WA":
        if p not in done:
            wa[p] += 1
    elif s == "AC":
        if p not in done:
            ac[p] += 1
            done.add(p)

a = len(ac)
w = 0
for k, v in wa.items():
    if k in done:
        w += v

print(a, w)

Submission status: Accepted

Solution code:
n,m = [int(i) for i in input().split()]
a = [input().split() for i in range(m)]

WAcounter = [0]*(n+1)
ans = 0
p = 0
for c in a:
    i = int(c[0])
    s = c[1]
    if s=="WA":
        WAcounter[i]+=1
    else:
        p += max(0,WAcounter[i])
        ans += 1 if WAcounter[i]>=0 else 0
        WAcounter[i]=-1000000
print(ans,p)

Submission status: Accepted

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

for _ in range(M):
    p, S = [x for x in input().split(" ")]
    p = int(p)
    if p in submit:
        submit[p].append(S)
    else:
        submit[p] = [S]


cor = 0
fail = 0

for _, res in submit.items():
    fail_one = 0
    cor_one = 0
    for pat in res:
        if pat == "AC":
            cor_one = 1
            break
        else:
            fail_one += 1
    cor += cor_one
    if cor_one == 1:
        fail += fail_one

print(cor, fail)

Submission status: Accepted

Solution code:
import numpy as np

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

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

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

for p, s in zip(P, S):
  if s == 'AC':
    AC[p] = 1
    block[p] = 1
  if s == 'WA':
    if block[p] == 0:
      WA[p] += 1

print(sum(AC), sum(np.array(WA) * np.array(AC)))

Submission status: Accepted

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

d={}
for i in range(m):
    p,s=map(str,input().split())
    p=int(p)
    if p in d:
        d[p].append(s)
    else:
        d[p]=[s]

a,b=0,0
for i in d:
    x=d[i]
    temp=0
    flag=1
    for j in range(len(x)):
        if x[j]=="WA":
            b+=1
            temp+=1
        else:
            a+=1
            flag=0
            break

    if flag:
        b-=temp
        
print(a,b)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
n,m=map(int,input().split())
s=[]
for i in range(m):
    s.append(input().split())
    s[i][0]=int(s[i][0])
cnt=[0]*n
cnt1=[0]*n
#print(s)
for i in range(m):
    if s[i][1]=='WA':
        if cnt[s[i][0]-1]!=0:
            continue
        else:
            cnt1[s[i][0]-1]+=1
    if s[i][1]=='AC':
        if cnt[s[i][0]-1]!=0:
            continue
        else:
            cnt[s[i][0]-1]+=1
    #print(cnt)
    #print(cnt1)
ans=0
ans1=0
#print(cnt,cnt1)
for i in range(n):
    if cnt[i]==0:
        continue
    else:
        ans+=cnt[i]
        ans1+=cnt1[i]
print(ans,ans1)

Submission status: Accepted

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

Submission status: Accepted

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

d = {}
count_AC = 0
count_WA = 0
for m in range(M):
  p, S = input().split()
  if p in d:
    if d[p]['AC'] > 0:
      continue
    else:
      if S == 'AC':
        d[p]['AC'] = 1
        count_AC += 1
        count_WA += d[p]['WA']
      else:
        d[p]['WA'] += 1
  
  else:
    d[p] = {'AC' : 0, 'WA' : 0}
    if S == 'AC':
      d[p]['AC'] += 1
      count_AC += 1
    else:
      d[p]['WA'] += 1
    
print(count_AC, count_WA)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
ac = [False for _ in range(N)]
n_wa_list = [0 for _ in range(N)]
n_ac = 0
for _ in range(M):
    p, s = input().split()
    p = int(p) - 1
    if not ac[p]:
        if s == 'WA':
            n_wa_list[p] += 1
        else:
            n_ac += 1
            ac[p] = True

n_wa = 0
for c, n in zip(ac, n_wa_list):
    if c:
        n_wa += n
print(n_ac, n_wa)

Submission status: Accepted

Solution code:
from collections import defaultdict
N, M = map(int,input().split())
submit = defaultdict(list)
for i in range(M):
    problem_num, S = input().split()
    problem_num = int(problem_num)
    if S == "AC":
        S = 1
    else:
        S = 0
    submit[problem_num].append(S)
# print(submit)

ac = 0
penalty = 0
for l in submit.values():
    if 1 in l:
        ac += 1
        for i in range(len(l)):
            if l[i] == 0:
                penalty +=1
            elif l[i] == 1:
                break
print(str(ac)+" "+str(penalty))

Submission status: Accepted

Solution code:
[N,M] = list(map(int,input().split()))
P = []
S = []
for i in range(M):
    [ptmp,stmp] = list(input().split())
    P.append(ptmp)
    S.append(stmp)
ans1 = [0]*N
ans2 = [0]*N
for i in range(M):
    prob = int(P[i])
    resu = S[i]
    if resu=="AC":
        ans1[prob-1]=1
    elif resu=="WA" and ans1[prob-1]!=1:
        ans2[prob-1]+=1

cnt1=0
cnt2=0
for i in range(N):
    if ans1[i]==1:
        cnt1+=ans1[i]
        cnt2+=ans2[i]

output = str(cnt1) + " " + str(cnt2)

print(output)