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: Wrong Answer

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

for i in range(M):
    if aclst[int(p[i][0])] == 0:
        if p[i][1] == 'AC':
            cnta += 1
            aclst[int(p[i][0])] = 1
            print(aclst)
        else:
            cntw += 1

print(cnta, cntw)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
TF=[0]*n
p=[0]*n
for _ in range(m):
    i,s =map(str,input().split())
    i=int(i)-1
    if (s=="WA") and (TF[i]==0):
        p[i]+=1
    if (s=="WA") and (TF[i]==1):
        pass
    if (s=="AC") and (TF[i]==0):
        TF[i]=1
    if (s=="WA") and (TF[i]==1):
        pass
ac=sum(TF)
pe=sum(p)
print(ac,pe)

Submission status: Wrong Answer

Solution code:
n , m = map(int,input().split())
r = 0
w = 0
a = []
b = []
tem = []
man = [0]
for i in range(m):
    ta,tb = map(str,input().split())
    a.append(ta)
    b.append(tb)
for i in range(m):
    if len(man) > 1:
        for k in range(len(man) - 1):
            z = man[k + 1]
            if b[i] == "AC" and int(a[i]) != int(z):
                r += 1
                tem.append(i)
                man.append(a[i])
    else:
        if b[i] == "AC":
                r += 1
                tem.append(i)
                man.append(a[i])
for j in range(len(tem) - 1):
    for i in range(tem[j] + 1):
        #print(i)
        #print(j)
        if a[j] == a[i] and b[j] == "WA":
            w += 1
ans = (str(r) + " " + str(w))
print(ans)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
p_list = []
s_list = []
ac_list = [0] * (n + 1)
ac, wa = 0, 0
if m == 0:
    print(0, 0)
else:
    for i in range(m):
        p, s = map(str, input().split())
        p = int(p)
        p_list.append(p)
        s_list.append(s)
        if s == "WA":
            if ac_list[p] == 0:
                wa += 1
            else:
                continue
        elif s == "AC":
            if ac_list[p] == 0:
                ac += 1
                ac_list[p] = 1
            else:
                continue
    for i in reversed(s_list):
        if i == "AC":
            break
        else:
            wa -= 1
    print(ac, wa)

Submission status: Wrong Answer

Solution code:
a,b=map(int,input().split())
wa={i:0 for i in range(1,a+1)}
ac={i:0 for i in range(1,a+1)}
g=0
if b==0:
    print("0 0")
    g=1
for i in range(b):
    c,d=input().split()
    #print(wa)
    if d=="WA" and ac[int(c)]==0:
        wa[int(c)]+=1
        #print(wa)
    else:
        #print(wa)
        ac[int(c)]=1
        #print(wa)
if g==0:
    #print(wa,ac)
    print(str(sum(wa.values()))+" "+str(sum(ac.values())))

Submission status: Wrong Answer

Solution code:
import sys

n, m = map(int, input().split())
ckn = set()
flag = 0
swa = 0
ac = 0

for i in sys.stdin:
  pm, c = i.split()
  if not(int(pm) in ckn):
    if c == 'WA':
      swa += 1

    elif c == 'AC':
      ckn.add(int(pm))
      ac += 1
      if flag == 0:
        flag = 1
  
print(ac, swa)

Submission status: Wrong Answer

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

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

#print(N, M, p, S)
ac = 0
wa = 0

if M != 0:
    p_pre = p[0]
    flag = False
    for i in range(M):#回答数
        print("P,S:",p[i],S[i],ac,wa)
    
        if flag == False:
            if S[i] == "WA":
                wa += 1
            else:
                ac += 1
                flag = True
        else:
            if p[i] == p_pre:
                p_pre = p[i]
                break
            else:
                if S[i] == "WA":
                    wa += 1
                    flag = False
                if S[i] == "AC":
                    ac += 1
        p_pre = p[i]

print(ac, wa)

Submission status: Wrong Answer

Solution code:
tmp = input().split()
N = int(tmp[0])
M = int(tmp[1])
 
quiz_dict = {}
wa_dict = {}
 
for i in range(M):
  tmp = input().split()
  
  quiz = tmp[0]
  res = tmp[1]
  
  quiz_dict[quiz] = 0
  
  if quiz not in wa_dict: 
    wa_dict[quiz] = 0
  
  if res == "AC":
    quiz_dict[quiz] = 1
  if res == "WA":
    if quiz_dict[quiz] == 0:
      wa_dict[quiz] += 1
wa_n = sum(wa_dict.values()) 
print(len(quiz_dict), wa_n)

Submission status: Wrong Answer

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

idxw = {}
idxa = {}

for i in range(int(M)):
  p, s = input().split(" ")
  if not ('{}{}'.format(p,s) in idxa):
    if s == 'AC':
      idxa['{}{}'.format(p, s)] = True
  if not ('{}{}'.format(p,s) in idxw):
    if not ('{}{}'.format(p,'AC') in idxa):
      if s == 'WA':
        idxw['{}{}'.format(p, s)] = True
#print(idxw)
#print(idxa)

print('{} {}'.format(len(idxa), len(idxw)))

Submission status: Wrong Answer

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

N, M = map(int, input().split())
a = [input().split() for _ in range(M)]
p = [int(x[0]) for x in a]
s = [x[1] for x in a]

sl = []
ans = 0
pen = 0
for i in range(M):
    if p[i] in sl or p[i] > N:
        continue

    if s[i] == 'WA':
        pen += 1
    else:
        ans += 1
        sl.append(p[i])

print(ans, pen)

Submission status: Wrong Answer

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


r = ['WA']*(N+1)
o = []
c = 0
ac_c = 0
p_c =0
li.sort()

for ps in li:
    index = int(ps[0])
    if ps[1] == 'WA':
        if r[index] == 'WA':
            
            c+=1

    else: # AC
        if r[index] == 'WA':
            r[index] = 'AC'
            p_c += c
            ac_c += 1
        else:
            pass
        c=0

print(ac_c, p_c)

Submission status: Wrong Answer

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

wa_num = 0
ac_q = []
for i in range(m):
    if int(score_list[i][0]) > n:
        continue 
    if score_list[i][1] == "WA" and score_list[i][0] not in ac_q:
        wa_num = wa_num + 1
    elif score_list[i][1] == "AC":
        if score_list[i][0] not in ac_q:
            ac_q.append(score_list[i][0])

ac_num = len(ac_q)

print(ac_num,wa_num)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
q = [0]*n
wa = 0
for _ in range(m):
    pp,s = input().split()
    p = int(pp)

    if q[p-1] == 0:
        if s == "WA":
            wa += 1
        else:
            q[p-1] = 1
qq = 0
for i in range(n):
    qq += q[i]
print(qq,wa)

Submission status: Wrong Answer

Solution code:
N,M = list(map(int,input().split()))
AC_list = [0] * N
WA_count = 0
AC_count = 0
for i in range(M):
    A = list(input().split())
    if AC_list[int(A[0])-1] == 1:
        continue
    else:
        if A[1] == "AC":
            AC_count += 1
            AC_list[int(A[0])-1] = 1
        elif A[1] == "WA":
            WA_count += 1
print(AC_count,WA_count)

Submission status: Wrong Answer

Solution code:
#import pysnooper
#import numpy
#import os,re,sys,operator
from collections import Counter,deque
#from operator import itemgetter,mul
#from itertools import accumulate,combinations,groupby,combinations_with_replacement,permutations
from sys import stdin,setrecursionlimit
#from bisect import bisect_left,bisect_right
#from copy import deepcopy
#import heapq
#import math
#import string
#from time import time
#from functools import lru_cache,reduce
#from math import factorial
#import sys
#from fractions import gcd
setrecursionlimit(10**6)
input=stdin.readline

n,m=map(int,input().split())
s=[input().split() for _ in range(m)]
c=[False]*n
ac,pena=0,0
for i in s:
    p,b=int(i[0])-1,i[1]
    if b=="AC":
        c[p]=True
    elif b=="WA" and not c[p]:
        pena+=1
print(c.count(True),pena)

Submission status: Wrong Answer

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

ac = 0
wa = 0
wa_ = 0
ac_ = 0

if m > 0:
    p = 1
    for ps in psl:
        if p == int(ps[0]):
            if ps[1] == 'WA':
                wa_ += 1
            elif ps[1] == 'AC' and wa_ == 0:
                ac_ += 1
            elif ps[1] == 'AC' and wa_ > 0:
                ac_ += 1
                wa += wa_
                wa_ = 0
        else:
            if ac_ > 0:
                ac += 1
            wa_, ac_ = 0, 0
            p = int(ps[0])
            if ps[1] == 'WA':
                wa_ += 1
            if ps[1] == 'AC':
                ac_ += 1
if ac_ > 0:
    ac += 1

print(ac, wa)

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
dic = {}
for i in range(N):
  dic[i+1] = [0,0]

for _ in range(M):
  round,result = input().split()
  round = int(round)
  if result == 'AC' and dic[round][0] == 0:
    dic[round][0] = 1
  elif result == 'WA' and dic[round][0] == 0:
    dic[round][1] += 1

right = 0
wrong = 0

for item in dic.values():
  right += item[0]
  wrong += item[1]

print(right, wrong)

Submission status: Wrong Answer

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

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

sum_ok = 0
sum_miss = 0
former_ok = [0]*n

for i in range(m):
    if p[i] in former_ok or p[i] > n:
        continue
    elif s[i] == 'AC':  
        former_ok[sum_ok] = p[i]
        sum_ok += 1
        if sum_ok == n:
            break
    elif s[i] == 'WA':
        sum_miss += 1
    else:
        continue 
print(sum_ok, sum_miss)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
tmp,p,s = [],[],[]

for i in range(m):
  tmp = input().split()
  p.append(int(tmp[0])-1)
  s.append(tmp[1])

pas = [0] * n
pena = 0

for i in range(m):
  if pas[p[i]] == 0:
    if s[i] == 'WA':
      pena += 1
    elif s[i] == 'AC':
      pas[p[i]] = 1

print('{} {}'.format(sum(pas),pena))

Submission status: Wrong Answer

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

P = []
S = []

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

exs = list(set(P))

WAC_all = []
ACC_all = []
EX = []

for ex in exs:
    WAC = 0
    ACC = 0
    WAC_small = []
    ACC_small = []
    for i in range(M):
        if P[i] == ex:
            if S[i] == 'WA':
                WAC += 1
            else:
                WAC = 0
                ACC = 1
            EX.append(ex)
            WAC_small.append(WAC)
            ACC_small.append(ACC)
    WAC_all.append(WAC_small)
    ACC_all.append(ACC_small)

res_ac = 0
res_wa = 0

print(ACC_all)
print(WAC_all)
for i in range(len(ACC_all)):
    for j, ac in enumerate(ACC_all[i]):
        if ac == 0:
            res_wa += WAC_all[i][j]
        else:
            res_ac += 1
            break

print(res_ac, res_wa)

Submission status: Wrong Answer

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

tmp = [0 for i in range(N)]
p_list = tmp.copy()
ac_list = tmp.copy()

for i in range(M):
    L_ = list(input().split())
    p = int(L_[0]) - 1
    if ac_list[p] == 0:
        if L_[1] == 'AC':
            ac_list[p] = 1
        else:
            p_list[p] += 1

print("{} {}".format(sum(ac_list), sum(p_list)))

Submission status: Wrong Answer

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

if m == 0:
    print(0, 0)
else:
    check_list = [0]*(n+1)
    wa = 0
    ac = 0
    for i in range(m):
        p, s = input().split()
        p = int(p)
        if check_list[p] == 1:
            continue
        elif s == 'AC':
            check_list[p] = 1
            ac += 1
        #elif check_list[p] == 0 and s == 'WA':                                          
        else:
            wa += 1
        print(check_list)
    print(ac, wa)

Submission status: Wrong Answer

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


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

Submission status: Wrong Answer

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

ac_answer=0
wa_answer=0
ac_list=[]
problem_num=1
tmp=0
for i in range(M):
    P, S = map(str, input().split())
    if not problem_num==int(P):
        tmp=0
        problem_num=int(P)
    if S=="WA":
        tmp+=1
    if S=="AC":
        if int(problem_num) not in ac_list:
            ac_answer+=1
            wa_answer=wa_answer+tmp
            ac_list.append(int(problem_num))
    # print(tmp)
    # print(ac_answer)
    # print(wa_answer)
    # print(ac_list)

print(str(ac_answer)+" "+str(wa_answer))

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
ac = 0
wa = 0
aclist = {}
for i in range(n):
    aclist[i + 1] = 0

for i in range(m):
    a,b = input().split()
    a = int(a)
    if aclist[a] == 1:
        continue
    elif b == 'WA':
        wa += 1
    else:
        aclist[a] += 1
        ac += 1
print(int(ac), int(wa), end="")

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
p = []
S = []
for i in range(M):
    pp, SS = map(str, input().split())
    p.append(pp)
    S.append(SS)

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

AC = 0
P = 0

Q = []
for i in range(N):
    Q.append(0)

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

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
ac,wa=0,0
aced=0
l=[0 for _ in range(m)]
for i in range(m):
  p,s=input().split()
  p=int(p)
  l[i]=[p,s,i+1]
l.sort(key=lambda x: (x[0],x[2]))
#print(l)
for i in range(m):
  s=l[i][1]
  q=l[i][0]
  if aced!=q:
    if s=='AC':
      ac+=1
      aced=q
    else:
      wa+=1

  #print(ac,wa,aced)

  
  

print(ac,wa)

Submission status: Wrong Answer

Solution code:
a,b=map(int,input().split())
wa={i:0 for i in range(1,a+1)}
ac={i:0 for i in range(1,a+1)}
g=0
print(wa)
if b==0:
    print("0 0")
    g=1
for i in range(b):
    c,d=input().split()
    if d=="WA" and ac[int(c)]==0:
        wa[int(c)]+=1
    else:
        ac[int(c)]=1
if g==0:
    print(str(sum(wa.values()))+" "+str(sum(ac.values())))

Submission status: Wrong Answer

Solution code:
def sum(arg):
  ans = 0
  for i in arg:
    ans += i
  return ans

N, M = map(int, input().split())
ac = [0]*N
wa = [0]*N
for i in range(M):
  pi, si = input().split()
  pi = int(pi)
  if si == "AC" and ac[pi-1] == 0:
    ac[pi-1] = 1
  if si == "WA" and ac[pi-1] == 0:
    wa[pi-1] += 1
print(sum(ac), sum(wa))

Submission status: Wrong Answer

Solution code:
def main(n, m, p_s: list):
    AC = set()
    WA = 0

    for p, s in p_s:
        if int(p) in AC:
            continue

        if s == "AC":
            AC.add(int(p))
        elif s == "WA":
            WA += 1

    print(len(AC), WA)


if __name__ == "__main__":
    n, m = map(int, input().split())
    p_s = [input().split() for _ in range(m)]

    main(n, m, p_s)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
if m == 0 :
  print('0 0')
  exit()
t = [0]*n
ansWA,ansAC = 0,0
for i in range(m):
  tmpN,tmpW = input().split()
  if t[int(tmpN)-1] == 0:
    if tmpW == 'WA':
      ansWA += 1
    if tmpW == 'AC':
      ansAC += 1
      t[int(tmpN)-1] = 1
print(str(ansAC) + ' ' + str(ansWA))

Submission status: Wrong Answer

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

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

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

    if(s=='AC'):
        ac[p-1] = 1
    else:
        if(ac[p-1] == 0):
            wa[p-1] += 1

print('{} {}'.format(sum(ac), sum(wa)))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
ac_count = 0
penalty_count = 0
ac_number_list = set()

for i in range(M):
    temp_number, temp_result = map(str, input().split())
    if temp_number not in ac_number_list :
        if temp_result == 'AC' :
            ac_count += 1
            ac_number_list.add(temp_number)
        else :
            penalty_count += 1    

print('{} {}'.format(ac_count, penalty_count))

Submission status: Wrong Answer

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

A = [[0] * 2 for i in range(M)]

for i in range(M):
    A[i][0], A[i][1] = input().split()


AC = []
WA = []

for j in range(M)[::-1]:
    if A[j][1] == 'AC' and (A[j][0] in AC) is False:
        AC.append(A[j][0])
    elif A[j][1] == 'WA' and (A[j][0] in AC) is True:
        WA.append(A[j][0])

print(len(AC), len(WA))

Submission status: Wrong Answer

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

aclist = []
wacount = 0

for i in range(M):
  if in2[i][0] in aclist:
    continue
  elif in2[i][1] == "WA":
    wacount += 1
  elif in2[i][1] == "AC":
    aclist.append(in2[i][0])
  elif len(aclist) == N:
    break

print(len(aclist), wacount)

Submission status: Wrong Answer

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

result = {}
c_cnt = 0
w_cnt = 0
for i in range(m):
    p, s = input().split()
    if (p in result):
        continue
    else:
        if (s == 'AC'):
            result[p] = 1
            c_cnt = c_cnt + 1
        else:
            w_cnt = w_cnt + 1

print('{} {}'.format(c_cnt, w_cnt))

Submission status: Wrong Answer

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

idxw = {}
idxa = {}

for i in range(int(M)):
  p, s = input().split(" ")
  if not ('{}{}'.format(p,s) in idxa):
    if s == 'AC':
      idxa['{}{}'.format(p, s)] = True
  if not ('{}{}'.format(p,s) in idxw):
    if not ('{}{}'.format(p,'AC') in idxa):
      if s == 'WA':
        idxw['{}{}'.format(p, s)] = True
print(idxw)
print(idxa)

print('{} {}'.format(len(idxa), len(idxw)))

Submission status: Wrong Answer

Solution code:
n, m = map(int,input().split())
ok, ng = 0, 0
qestion_no = 0
end_flag = False
for _ in range(m):
  p,s = map(str,input().split())
  if qestion_no == p:
    if end_flag:
      continue
  else:
    qestion_no = p
    end_flag = False
  if 'WA' == s:
    ng += 1
  else:
    ok += 1
    end_flag = True
print(ok, ng)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
t = dict()
account,pena = 0,0
for i in range(m):
	s = input().split()
	if not s[0] in t.keys():
		t[s[0]] = s[1]
	else:
		if t[s[0]][-2::] == 'WA':
			t[s[0]] += s[1]
for j in t.values():
	print(j)
	if j[-2::] == 'AC':
		account += 1
		pena += j.count('WA')
print(account,pena)

Submission status: Wrong Answer

Solution code:
N, M = [int(i) for i in input().split()]
d = {}
for i in range(M):
    ps = tuple(input().split())
    if ps in d:
        d[ps] += 1
        if ps[1] == "WA" and (ps[0], "AC") in d:
            d[ps] -= 1
    else:
        d[ps] = 1
ans1 = 0
ans2 = 0
for i in range(N):
    if (str(i), "AC") in d:
        ans1 += 1
    if (str(i), "WA") in d:
        ans2 += d[(str(i), "WA")]
print(ans1, ans2)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
dic = {}
for i in range(10**5+1):
    dic[str(i)] = "0"
ac_dic = {}
wa_c = 0

for i in range(m):
    p,s = map(str,input().split())
    if s =="AC":
        dic[p] = "AC"
        ac_dic[p] = "AC"

    if s == "WA" and dic[p] != "AC":
        wa_c += 1


#print(ac_dic)
print(len(ac_dic),wa_c)

Submission status: Wrong Answer

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

if m == 0:
    print(0, 0)
else:
    check_list = [0]*(n+1)
    wa = 0
    ac = 0
    for i in range(m):
        p, s = input().split()
        p = int(p)
        if check_list[p] == 1:
            continue
        if check_list[p] == 0 and s == 'AC':
            check_list[p] = 1
            ac += 1
        #elif check_list[p] == 0 and s == 'WA':                                          
        else:
            wa += 1
        print(check_list)
    print(ac, wa)

Submission status: Wrong Answer

Solution code:
N,M=input().split()
answer=0
penalty=0
PS=[]
check=[]
for _ in range(int(M)):
    PS.append(input().split())
for i in PS:
    if ((str(i[0])+' AC') in check)==False:
        if i[1]=="WA":
            penalty+=1
        elif i[1]=="AC":
            answer+=1
            check.append(str(i[0])+" AC")
print(str(answer)+" "+str(penalty))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
N, M = map(int, input().split())
#problems = [[] for i in range(N)]

c = p = 0
prev_ac_num = None
prev_wa_num = None
prev_num = None

wa_count = 0

for i in range(M):
    num, state = map(str, input().split())

    # 問題が変わった
    if prev_num != num:
        wa_count = 0

    if state == 'WA':
        wa_count += 1

    # penaltyのカウント
    if state == 'AC' and prev_ac_num != num:
        p += wa_count
        wa_count = 0

    # acceptのカウント
    if state == 'AC' and prev_ac_num != num:
        c += 1

    if state == 'AC':
        prev_ac_num = num
        wa_count = 0

    if state == 'WA':
        prev_wa_num = num

    prev_num = num

print(c, p)

Submission status: Wrong Answer

Solution code:
n, m = input().split(" ")
n, m = int(n), int(m)
p_s = []
for i in range(m):
    inp = input().split(" ")
    p_s.append(list(inp))

ans_list = [0]*n
failure_list = [0]*n
if m == 0:
    pass
else:
    for p, s in p_s:
        p = int(p)
        if s == "AC":
            if ans_list[p-1] == 0:
                ans_list[p-1] = 1
            elif ans_list[p-1] == 1:
                pass
            else:
                print("error")
        elif s == "WA":
            if ans_list[p-1] == 0:
                failure_list[p-1] += 1
            elif ans_list[p-1] == 1:
                pass
            else:
                print("error")
print(sum(ans_list), sum(failure_list))

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
AC_flag = [False]*N
WA_count = [0]*N
for m in range(M):
    P,S = map(str,input().split())
    p = int(P)
    if AC_flag[p-1] == False and S == "AC":
        AC_flag[p-1] = True
    elif AC_flag[p-1] == False and S == "WA":
        WA_count[p-1] += 1
print(*[sum(AC_flag),sum(WA_count)])

Submission status: Wrong Answer

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

correct = 0
penalty = 0

corrected = []

for i in range(m):
  pi, si = input().split()
  if (si == 'AC' and pi not in corrected):
    corrected.append(pi)
    correct += 1
  elif (si == 'WA' and pi not in corrected):
    penalty += 1
      
print("{} {}".format(correct, penalty))

Submission status: Wrong Answer

Solution code:
import sys
N,M = map(int,input().split())
if M == 0:
    print('%d %d' % (0,0))
    sys.exit(0)
Liste = dict()
Question = [0] * M
ACorWE = [0] * M
Z = 0
correct = 0
pena = 0
for i in range(M):
    Question[i], ACorWE[i]= map(str, input().split())
Question = [int(element) for element in Question]
for _ in range(max((max(Question)+1),len(ACorWE))): #range(max(Question)+1) before
    Liste[_] = [0] 
#Liste[4].append(0) 
#print(Liste)
#print(Question) #[1, 1, 2, 2, 2]
#print(ACorWE) #['WA', 'AC', 'WA', 'AC', 'WA']
for i in range(M): ###for i in range(M) before 
    Liste[Question[i]].append(ACorWE[i])
    #print(Liste)
    Liste[i].remove(0)
#print(Liste)
#{0: [], 1: ['WA', 'AC'], 2: ['WA', 'AC', 'WA'], 3: [], 4: []}

for i in range(1,max(Question)+1):
    if 'AC' in Liste[i] and Z == 0:
        correct += 1
        Z = 1
    Z = 0
for i in range(1,max(Question)+1):
    for j in range(len(Liste[i])):
        if j <= len(Liste[i]) -2:
            if Liste[i][j] == 'WA' and Liste[i][j+1] == 'AC':
                pena += 1
        
print('%d %d' % (correct,pena))

Submission status: Wrong Answer

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

print(sum(ac), sum(wa))

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
p_s=[list(map(str,input().split())) for _ in range(M)]
ac_wa = [0,0]
ac_list = []
wa_list = []

for p,s in p_s:
    if s == "AC" and p not in ac_list:
        ac_wa[0] += 1
        ac_list.append(p)
    elif s == "WA" and p not in wa_list:
        ac_wa[1] += 1
        wa_list.append(p)
print(*ac_wa)

Submission status: Wrong Answer

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


p = [0]*M#問題の番号
s = [0]*M#結果 AC,WA

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

cor_count = 0
pen_count = 0
AC_list = []


if s[0] == 'AC':
	AC_list.append(p[0])
	cor_count += 1
else:
	pen_count += 1

for i in range(M-1):
	if p[i] == p[i+1]:
		if not p[i+1] in AC_list:
			if s[i+1] =='AC':
				cor_count += 1
				AC_list.append(p[i+1])
			else:
				pen_count += 1
	else:
		if s[i+1] =='AC':
			cor_count += 1
			AC_list.append(p[i+1])
		else:
			pen_count += 1

if M != 0:
	print(cor_count,pen_count)

Submission status: Wrong Answer

Solution code:
n , m = map(int,input().split())
p = []
s = []
for i in range(m):
    a, b = input().split()
    p.append(int(a))
    s.append(0 if b=='WA' else 1)

ac = 0
pena = 0


for i in set(p):
    for j in range(m):
        if s[j] == 0:
            pena +=1 
        elif s[j] == 1:
            ac +=1
            break
print(ac,pena)

Submission status: Wrong Answer

Solution code:
mondaisu , teisyutukaisu = map(int,input().split())

flag = []
penalog = []

for i in range(mondaisu):
  flag.append(0)
  penalog.append(0)



for i in range(teisyutukaisu):
  bango , kekka = input().split()
  bango = int(bango)
  if flag[bango-1] == 1:
    continue
  if kekka == 'WA':
    penalog[bango-1] = penalog[bango-1] + 1
  if kekka == 'AC':
    flag[bango-1] = 1
  
print(sum(flag),sum(penalog))

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
p = []
s = []
end = []

ac = 0
wa = 0
acflag = False
pre = -1

if m == 0:
    print("0 0")
    exit()

for i in range(m):
    a,b = input().split()
    p.append(a)
    s.append(b)

pre = p[0]
for i in range(m):
    if not(p[i] in end):
        acflag = False
    
    if acflag == False:
        if s[i] == "WA":
            wa += 1
        elif s[i] == "AC":
            ac += 1
            acflag = True
            end.append(p[i])

    pre = p[i]

print(str(ac) + " " + str(wa))

Submission status: Wrong Answer

Solution code:
input1 = input().split()
problem = int(input1[0])
num_sub = int(input1[1])
list_sub = []
for i in range(num_sub):
  check = True
  input2 = input().split()
  if(input2[1] == "AC"):
    for j in list_sub:
      if(input2[0] == j[0] and j[1] == "AC"):
        check = False
  if(check):
    list_sub.append((input2[0], input2[1]))
wrong = 0
right = 0
for i in list_sub:
  if(right == problem):
    break
  if(i[1] == "WA"):
    wrong = wrong + 1
  if(i[1] == "AC"):
    right = right + 1
print(str(right) + " " + str(wrong))

Submission status: Wrong Answer

Solution code:
N,M = list(map(int,input().split()))
AC_list = [0] * N
WA_count = 0
AC_count = 0
for i in range(M):
    A = list(input().split())
    if AC_list[int(A[0])-1] == 1:
        continue
    else:
        if A[1] == "AC":
            AC_count += 1
            AC_list[int(A[0])-1] = 1
        else:
            WA_count += 1
print(str(AC_list.count(1)) + " " + str(WA_count))

Submission status: Wrong Answer

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

def qa(s):
    qa_dict = {}
    WAs=0
    ACs=0
    for qa in s:
        qa_dict[qa[0]] = 0
    for qa in s:
        if qa_dict[qa[0]] <= 0:
            if qa[1] == 'WA':
                qa_dict[qa[0]] -= 1
                WAs += 1
            elif qa[1] == 'AC':
                if qa_dict[qa[0]] == 0:
                    qa_dict[qa[0]] += 1
                else:
                    qa_dict[qa[0]] *= -1
                ACs += 1
    return ACs, WAs

if m == 0:
    ac, wa = 0, 0
else:
    ac, wa = qa(s)
print('{} {}'.format(ac, wa))

Submission status: Wrong Answer

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

wa = 0
ac = 0
ac_list = []
for _ in range(M):
    p, s = input().split()
    if p not in ac_list:
        if s == "WA":
                wa += 1
        else:
                ac += 1
                ac_list.append(p)
print(ac, wa)

Submission status: Wrong Answer

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

solved = {}
failed = {}
for _ in range(M):
    p, S = input().split()
    p = int(p)
    if S == 'AC':
        if p in solved:
            pass
        else:
            solved[p] = 1
    else:
        if not (p in solved):
            if p in failed:
                failed[p] += 1
            else:
                failed[p] = 1

print(sum(solved.values()), sum(failed.values()))

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
N, M = map(int, input().split())
P = [input().split() for _ in range(M)]
X = defaultdict(int)
ac = 0
wa = 0
for pi in P:
    i = int(pi[0])
    s = pi[1]
    if X[i-1] == 0:
        if s == 'WA':
            wa += 1
        else:
            ac += 1
            X[i-1] = 1

print(ac, wa)

Submission status: Wrong Answer

Solution code:
N, M= map(int, input().split())
p = [0]*M
S = [0]*M
for i in range(M):
  p[i], S[i]= list(input().split())
correct_list = []
sum = 0
for i in range(M):
  if S[i] == "AC":
    if p[i] not in correct_list:
      correct_list.append(p[i])
  if S[i] == "WA":
    if p[i] not in correct_list:
      sum += 1
print(len(correct_list), sum)

Submission status: Wrong Answer

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

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

#print(N, M, p, S)
ac = 0
wa = 0

if M != 0:
    #print("P,S:",p[i],S[i])
    p_pre = p[0]
    flag = False
    for i in range(M):#回答数
        if flag == False:
            if S[i] == "WA":
                wa += 1
            else:
                ac += 1
                flag = True
        else:
            if p[i] == p_pre:
                break
            else:
                if S[i] == "WA":
                    wa += 1
                    flag = False
                if S[i] == "AC":
                    ac += 1
        p_pre = p[i]

print(ac, wa)