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())

submit = []
results = [0] * n

for i in range(m):
  p, s = input().split()
  p = int(p)
  if type(results[p-1]) is int:
    results[p-1]=[s]
  else:
    results[p-1].append(s)

ok = 0
penalty = 0
for result in results:
  if type(result) == int:
    pass
  elif 'AC' in result: 
    for r in result:
      if r == 'AC':
        ok = ok + 1
        break
      else:
        penalty = penalty + 1
      
print(ok, penalty)

Submission status: Accepted

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

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

for i in range(m):
    pi,si = input().split( )
    if si == "AC":
        AC[int(pi)] = 1
    elif not AC[int(pi)]:
        WA[int(pi)] += 1
print(sum(AC),end = " ")

ANS = [AC[i]*WA[i] for i in range(n+1)]
print(sum(ANS))

Submission status: Accepted

Solution code:
N, M = [int(i) for i in input().split()]
corrects = [0 for _ in range(N)]
wrongs = [0 for _ in range(N)]
for m in range(M):
  p, s = input().split()
  p = int(p)
  if corrects[p-1] == 0:
    if s == "WA":
      wrongs[p-1] += 1
    elif s == "AC":
      corrects[p-1] = 1
      corrects.append(p)
  
total_wrongs = 0
total_correct = 0
for i in range(N):
  if corrects[i] > 0:
      total_wrongs += wrongs[i]
      total_correct += 1
  
print(total_correct, total_wrongs)

Submission status: Accepted

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] * n

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


print('{} {}'.format(sum(pas),sum([pas[i]*pena[i] for i in range(n)])))

Submission status: Accepted

Solution code:
import sys

scan = sys.stdin.readline
n, m = map(int, scan().split(' '))
ans = [0] * n
ac = 0
for i in range(m):
    q, r = map(str, scan().strip('\n').split(' '))
    if r == 'AC':
        if ans[int(q) - 1] >= 0:
            ans[int(q) - 1] = -ans[int(q) - 1] - 1
            ac += 1
    else:
        if ans[int(q) - 1] >= 0:
            ans[int(q) - 1] += 1

wa = -sum(filter(lambda x: x < 0, ans)) - ac
print(ac, wa, sep=' ')

Submission status: Accepted

Solution code:
N, M = map(int, input().split(' '))
wa_count = [0] * N
ac = [False] * N
ac_count = 0

WA = 'WA'
AC = 'AC'
for i in range(M):
    #print()
    #print('wa_count', wa_count)
    #print('ac', ac)
    #print('ac_count', ac_count)
    #print()

    _p, S = input().split(' ')
    p = int(_p) - 1

    if ac[p]:
        continue

    if S == WA:
        wa_count[p] += 1
    elif S == AC:
        ac[p] = True
        ac_count += 1

    #if ac_count == N:
    #    break

wa_total = 0
for i, c in enumerate(wa_count):
    if ac[i]:
        wa_total += c

print(ac_count, wa_total)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

############### TESTCASE ###############
test = ""
#test = \
"""
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
ans 2 2
"""

"""
100000 3
7777 WA
7777 WA
7777 WA
ans 0 0
"""

"""
6 0
ans 0 0
"""

"""
2 10
1 WA
1 AC
2 WA
2 AC
2 WA
1 WA
1 AC
2 WA
2 AC
2 WA
ans 2 2
"""
########################################
test = list(reversed(test.strip().splitlines()))
if test:
    def input2():
        return test.pop()
else:
    def input2():
        return input()
################# MAIN ################# 

n, m = map(int, input2().split())
ps = [None] * m
for i in range(m):
    tmp = input2().split()
    ps[i] = int(tmp[0]), tmp[1]

aced = [0] * (n + 1)
wabfac = [0] * (n + 1)

for item in ps:
    if item[1] == "AC":
        aced[item[0]] = 1
    if item[1] == "WA":
        if aced[item[0]] == 0:
            wabfac[item[0]] += 1

penaans = 0
for j in range(1, n+1):
    if aced[j] == 1:
        penaans += wabfac[j]

print(aced.count(1), penaans)

Submission status: Accepted

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

list = [input().split() for _ in range(M)]

ac_list = [0] * N
wa_list = [0] * N

for i in range(M):
  if list[i][1] == "AC":
    ac_list[int(list[i][0])-1] = 1
    #print(i, ac_list)
    #print(i, wa_list)
  else:
    #print(i, ac_list)
    #print(i, wa_list)
    if ac_list[int(list[i][0])-1] == 0:
      wa_list[int(list[i][0])-1] += 1

for i in range(N):
  if ac_list[i] == 0:
    wa_list[i] = 0

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

Submission status: Accepted

Solution code:
class Question:
    def __init__(self, num, result):
        self.num = int(num)
        self.result = result


n, m = map(int, input().split())
p_list = [input().split() for _ in range(m)]
questions = [Question(num, result) for num, result in p_list]

# 高速化のためにsetを使う
ac_list = set()
wa_dict = {}
wa_count = 0

for q in questions:
    if not(q.num in ac_list):
        if q.result == 'AC':
            ac_list.add(q.num)
            wa_count += wa_dict[q.num] if q.num in wa_dict else 0
        elif q.num in wa_dict:
            wa_dict[q.num] += 1
        else:
            wa_dict[q.num] = 1
print('{} {}'.format(len(ac_list), wa_count))

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
p=[]
s=[]
t=[]
crc=0
wrg=0
for i in range(m):
    li=input().split()
    p.append(int(li[0]))
    s.append(li[1])
    
for j in range(n):
    t.append(0)
for k in range(m):
    if s[k]=="AC":
        if t[p[k]-1]>=0:
            crc+=1
            wrg+=t[p[k]-1]
            t[p[k]-1]=-1
    else:
        if t[p[k]-1]>=0:
            t[p[k]-1]+=1
print(str(crc)+" "+str(wrg))

Submission status: Accepted

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

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

x = 0
for i in range(n):
    x += wa[i] * ac[i]
        
print ("%d %d" % (sum(ac),x))

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
li=[]
ac_li=[0]*n
wa_li=[0]*n
ac = 0
wa = 0
for _ in range(m):
    a,b = input().split()
    li.append([int(a),b])

for i in li:
    if i[1] == "AC":
        if ac_li[i[0]-1] == 0:
            ac_li[i[0]-1] = 1
            ac +=1
    else:
        if ac_li[i[0]-1] == 0:
            wa_li[i[0]-1] += 1

for j in range(n):
    if ac_li[j]==1:
        wa += wa_li[j]
print(ac,wa)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
Alist = [[]]*M
for i in range(M):
  Alist[i] = list(map(str, input().split()))
collect = [False]*N
NP = 0
NAC = 0
results = [False]*N
for k in range(M):
  if Alist[k][1] == 'AC':
    results[int(Alist[k][0])-1] = True

for j in range(M):
  if Alist[j][1] == 'WA' and results[int(Alist[j][0])-1] == True and collect[int(Alist[j][0])-1] == False:
    NP += 1
  elif collect[int(Alist[j][0])-1] == False and Alist[j][1] == 'AC':
    NAC += 1
    collect[int(Alist[j][0])-1] = True
print(NAC, " ", NP)

Submission status: Accepted

Solution code:
nm = input().split()
wa = 0
ac = 0
db = [[0 for i in range(2)] for j in range(int(nm[0]))]

for i in range(int(nm[1])):
 tmp = input().split()
 if db[int(tmp[0])-1][1] == 0:
  if tmp[1] == "AC":
   db[int(tmp[0])-1][1]=1
   ac+=1
   wa+=db[int(tmp[0])-1][0]
  elif tmp[1] == "WA":
   db[int(tmp[0])-1][0]+=1
print(ac,wa)

Submission status: Accepted

Solution code:
n = input()
m = n.split()
P = [int(i) for i in m]
if P[1] == 0:
    for i in range(P[1]): #因数注意！
        n = input()    
    print("0 0")
else:
    
    AC = [0] * P[0]
    WA = [0] * P[0]

    for i in range(P[1]): #因数注意！
        n = input()    
        m = n.split()
        p = [i for i in m] #1列の数列をリスト化
        if p[1] == "AC":
            AC[int(p[0])-1] = 1
        else:
            if AC[int(p[0])-1] == 0:
                WA[int(p[0])-1] = WA[int(p[0])-1] +1
            else:
                pass
    A1 = 0
    A2 = 0
    for i in range(P[0]):
        if AC[i] == 1:
            A1 = A1+1
            A2 = A2 + WA[i]
    print(str(A1)+" "+str(A2))

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
a=[]
for i in range(n):
    a.append([0,0])
b=[]
c=0
d=0
for i in range(m):
    b.append(list(input().split()))
    b[i][0]=int(b[i][0])
a=sorted(a,key=lambda x:x[0])
for i in range(m):
    if b[i][1]=='WA':
        if a[b[i][0]-1][0]==0:
            a[b[i][0]-1][1]+=1
    else:
        if a[b[i][0]-1][0]==0:
            a[b[i][0]-1][0]=1
for i in range(n):
    c+=a[i][0]
    if a[i][0]==1:
        d+=a[i][1]
print(c,d)

Submission status: Accepted

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

tasks = []
for i in range(n):
    tasks.append([0, 0])

A = 0
P = 0

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

    if tasks[p-1][0] == 0:
        if s == "AC":
            A += 1
            tasks[p-1][0] = 1
            P += tasks[p-1][1]
        else:
            tasks[p-1][1] += 1
    else:
        continue

print(A, P)

Submission status: Accepted

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


ACd = [0] * N
whenACd = [0] * N

pena = 0
I,X=[],[]
for m in range(M):
    i, x = list(map(str, input().split()))
    I.append(i)
    X.append(x)

for m,(i,x) in enumerate(zip(I,X)):
    if x == 'AC' and ACd[int(i) - 1] == 0:
        ACd[int(i) - 1] = 1
        whenACd[int(i) - 1] = m

for m,(i,x) in enumerate(zip(I,X)):
    if x == 'WA' and whenACd[int(i) - 1] > m:
        pena += 1

print(sum(ACd), pena)

Submission status: Accepted

Solution code:
N, M = [int(i) for i in input().split()]
AC = [0] * (N + 1)
WA = [0] * (N + 1)
for i in range(M):
    p, S = input().split()
    if S == "AC":
        AC[int(p)] = 1
    else:
        if AC[int(p)] == 0:
            WA[int(p)] += 1
ans0 = 0
ans1 = 0
for i in range(N):
    ans0 += AC[i+1]
    if AC[i + 1] == 1:
        ans1 += WA[i+1]
print(ans0, ans1)

Submission status: Accepted

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

count_map = [0] * (n + 1)
miss_map = [0] * (n + 1)

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

    if count_map[p]:
        continue

    if s == 'AC':
        count_map[p] = True
        count += 1
        miss += miss_map[p]
    else:
        miss_map[p] += 1

print(count, miss)

Submission status: Accepted

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

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

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

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

for i in range(n):
    wa[i] = wa[i] * ac[i]

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

Submission status: Accepted

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

	num = []
	ans = []
	for i in range(m):
		na,a = input().split()
		num.append(na)
		ans.append(str(a))
	
	ac = 0
	wa = 0
	ans_l = []
	for i in range(1,n+1):
		ans_l.append([i,1,0])
	ac_temp = []
	wa_temp = 0

	for i in range(m):
		if ans[i] == "WA":
			ans_l[int(num[i])-1][2] += 1
		elif ans[i] == "AC" and ans_l[int(num[i])-1][1] == 1:
			ac += 1
			ans_l[int(num[i])-1][1] = 0
			wa += ans_l[int(num[i])-1][2]
			ans_l[int(num[i])-1][2] = 0
	print(ac,wa)

if __name__ == '__main__':
	main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
problem_right = {}
problem_pen = {}
score, penalty = 0, 0
for i in range(M):
	p_i, S_i = input().split()
	if S_i == 'WA' and p_i not in problem_right:
		if p_i not in problem_pen:
			problem_pen[p_i] = 1
		else:
			problem_pen[p_i] += 1
	elif S_i == 'AC' and p_i not in problem_right:
		score += 1
		problem_right[p_i] = True
		if p_i in problem_pen:
			penalty += problem_pen[p_i]
print(str(score)+' '+str(penalty))

Submission status: Accepted

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
            elif qa[1] == 'AC':
                if qa_dict[qa[0]] == 0:
                    qa_dict[qa[0]] += 0.001
                else:
                    qa_dict[qa[0]] *= -1
                ACs += 1
    for v in qa_dict.values():
        if v > 0:
            WAs += int(v)
    return ACs, WAs

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

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
lis = [list(input().split()) for _ in range(M)]
AC = [[0] * 2 for i in range(N)]
for i in range(M):
    if lis[i][1] == "AC":
        AC[int(lis[i][0])-1][1] = 1
    elif AC[int(lis[i][0])-1][1] == 0:
        AC[int(lis[i][0])-1][0] += 1
a = 0
w = 0
for i in range(N):
    if AC[i][1] == 1:
        a += 1
        w += AC[i][0]
print(a, w)

Submission status: Accepted

Solution code:
import numpy as np
N,M = map(int, input().split())
P = [input().split() for i in range(M)]
dic = {}
ans = 0
pen = 0

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

for i in range(M):
  if dic[int(P[i][0])][0] == False:
    if P[i][1] == "WA":
      dic[int(P[i][0])][1] += 1
    else:
      dic[int(P[i][0])][0] = True
      pen += dic[int(P[i][0])][1]
      ans += 1

print(ans,pen)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
d = [0]*(N+1)
d2 = [0]*(N+1)
r1=r2=0
for _ in range(M):
    p, j = input().split()
    p = int(p)
    j = j.strip()
    if j == "AC":
        if not d[p]:
            d[p] = 1
            r1 += 1
            r2 += d2[p]
    else:
        if not d[p]:
            d2[p] += 1
print(r1,r2)

Submission status: Accepted

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

ok = 0
ng = 0
ng_tmp = [0] * n
flag = [True] * n

for i in range(m):
  tmp = input().split()
  p = int(tmp[0])
  s = tmp[1]
  if flag[p-1]:
    if s == 'AC':
      flag[p-1] = False
      ok += 1
      ng += ng_tmp[p-1]
    if s == 'WA':
      ng_tmp[p-1] += 1

  
print(ok, ng)

Submission status: Accepted

Solution code:
import numpy as np
 
N, M = map(int, input().split())
 
suc = [0 for i in range(N+1)]
pen = [0 for i in range(N+1)]
 
for i in range(M):
    p, s = input().split()
    p = int(p)
    if s == "WA" and suc[p] == 0:
        pen[p] += 1
    elif s == "AC":
        suc[p] = 1

for i in range(N+1):
    if suc[i] == 0:
        pen[i] = 0

print( sum(suc), sum(pen) )

Submission status: Accepted

Solution code:
N, M = map(int, input().rstrip().split())
AC = 0
WA = 0
data = {}
for _ in range(M):
    tmp = input().rstrip().split()
    p, S =  int(tmp[0]), tmp[1]
    if p not in data.keys():
        if S == 'AC':
            data[p] = {'AC': True, 'WA': 0}
            AC += 1
        elif S == 'WA':
            data[p] = {'AC': False, 'WA': 1}
    else:
        if S == 'AC':
            if data[p]['AC'] is True:
                continue
            elif data[p]['AC'] is False:
                data[p]['AC'] = True
                WA += data[p]['WA']
                AC += 1
        elif S == 'WA':
            if data[p]['AC'] is True:
                continue
            elif data[p]['AC'] is False:
                data[p]['WA'] += 1
print('{} {}'.format(AC, WA))

Submission status: Accepted

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

for p in failed:
    if not p in solved:
        failed[p] = 0

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

Submission status: Accepted

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

pen= [0] * (n+1)
result=[False] * (n+1)
cnt = 0
pen_sum = 0
for i in range(m):
    p1, s1 = input().split()
    p1 = int(p1)
    if s1 == "AC" and not result[p1]:
        result[p1] = True
        cnt += 1
        pen_sum += pen[p1]
    if s1 == "WA" and not result[p1]:
        pen[p1] += 1

print("{} {}".format(cnt, pen_sum))

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
if M > 0:
    S = [[i for i in input().split()] for _ in range(M)]
    w = [0] * (N+1)
    ac = set()
    for s in S:
        if int(s[0]) in ac:
            continue
        elif s[1] == "AC":
            ac.add(int(s[0]))
        else:
            w[int(s[0])] += 1
    wa = [w[i] for i in ac]
    print(len(ac), sum(wa))
else:
    print(0, 0)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
pi = []
si = []
for _ in range(m):
    p, s = input().split()
    pi.append(int(p))
    si.append(s)

ac = 0
wa = 0
c = {}
for i in range(m):
    if pi[i] in c.keys():
        if si[i] == 'AC' and c[pi[i]] != float("INF"):
            wa += c[pi[i]]
            ac += 1
            c[pi[i]] = float("INF")
        else:
            c[pi[i]] += 1
    else:
        if si[i] == 'AC':
            c[pi[i]] = float("INF")
            ac += 1
        else:
            c[pi[i]] = 1
print(ac, wa)

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
pS = [list(input().split()) for _ in range(M)]
A = [0]*N
P = [0]*N
ans_A = 0
ans_P = 0
for p,S in pS:
    p = int(p)
    if S == 'AC':
        A[p-1] = 1
    else:
        if A[p-1] == 0:
            P[p-1] += 1
idx = 0
for a,p in zip(A,P):
    if a == 1:
        ans_A += 1
        ans_P += P[idx]
    idx += 1
print(ans_A,ans_P)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
ps = [input() for _ in range(m)]
p = [0] * m
s = [''] * m
for i in range(m):
  x, y = ps[i].split()
  p[i] = int(x)
  s[i] = y
ac_flag = [0]*n # AC出したかどうかのflag
ac_count = 0
wa_count = [0]*n
for j in range(m):
  if ac_flag[p[j]-1] == 1:
    continue
  if s[j] == 'AC':
    ac_flag[p[j]-1] = 1
    ac_count+=1
  if s[j] == 'WA':
    wa_count[p[j]-1] += 1
true_wa_count=0
for k in range(n):
  if ac_flag[k] == 1:
    true_wa_count+=wa_count[k]
print(ac_count,true_wa_count)

Submission status: Accepted

Solution code:
import numpy as np
N,M = map(int,input().split())
pena = np.zeros(N)
clear = np.zeros(N)
for i in range(M):
    p,S = input().split()
    p = int(p)-1
    if S == "WA" and clear[p] == 0:
        pena[p] += 1
    else:
        clear[p] = 1
clear_num = np.where(clear == 1)[0]
new_pena = pena[clear_num]
print(int(np.sum(clear)),int(np.sum(new_pena)))

Submission status: Accepted

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():
	if j[-2::] == 'AC':
		account += 1
		pena += j.count('WA')
print(account,pena)

Submission status: Accepted

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

lis = []

for _ in range(M):
    i, j = input().split()
    i = int(i)
    lis.append((i, j))


cntsAC = 0

inc = [i for i in range(1, N + 1)]
zeros = [0 for _ in range(N)]

flags = dict(zip(inc, zeros))
flags_forAC = dict(zip(inc, zeros))
flags_forWA = dict(zip(inc, zeros))

cntsWA = 0

for k, v in lis:
    if flags_forAC[k] == 0:
        if v == "AC":
            flags_forAC[k] = 1
            cntsAC += 1
            flags[k] = 1
        else:
            flags_forAC[k] = 1
    else:
        if v == "AC" and flags[k] == 0:
            cntsAC += 1
            flags[k] = 1


for k, v in lis:
    if flags[k] == 1 and v == "WA" and flags_forWA[k] == 0:
        cntsWA += 1
    elif v == "AC":
        flags_forWA[k] = 1

print(cntsAC, cntsWA, sep=" ")

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
# 正解数
SEIKAI = 0
# ペナルティ
PENALTI = 0

L = [0] * 100001

for i in range(M):
    _P,S = input().split()
    P = int(_P)
    if S == 'WA' and L[P] != -1:
        L[P] += 1
    elif S == 'AC' and L[P] != -1:
        SEIKAI += 1
        PENALTI += L[P]
        # -1は正解済みのフラグ
        L[P] = -1

print(SEIKAI,PENALTI)

Submission status: Accepted

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

num = [0]*n
nn = [-1]*n
WA = 0
AC = 0

for i in range(m):
  text = input().strip().split()
  p = int(text[0])
  s = text[1]
  
  if nn[p-1] == -1:
    if s == 'AC':
      AC += 1
      WA += num[p-1]
      nn[p-1] = 1
    elif s == 'WA':
      num[p-1] += 1
      
print(AC, WA)

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
ac = 0
wa = 0
p = []
s = []
flag = 0
ind_lists = [0]*(n)
for i in range(m):
    P,S = map(str,input().split())
    p.append(int(P))
    s.append(S)
mita = set()
for i in range(m):
    if p[i] in mita:
        pass
    elif s[i] == "AC":
        mita.add(p[i])
        ind_lists[p[i] - 1] = (i+1)
o_set = set()
for i in range(len(ind_lists)):
    if ind_lists[i]-1 < 0:
        o_set.add(i+1)
mita = set()
for i in range(m):
    if p[i] in o_set or p[i] in mita:
        pass
    elif s[i] == "AC":
        ac += 1
        mita.add(p[i])
    else:
        wa += 1

print(ac,wa)

Submission status: Accepted

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

ans1, ans2 = 0, 0
done = set([0])
miss = {}

for i in range(M):
  if li[i][0] in done:
    continue
  if li[i][1] == "AC":
    ans1 += 1
    done.add(li[i][0])
    if li[i][0] in miss:
      ans2 += miss[li[i][0]]
      del miss[li[i][0]]
  else: # "WA"
    if li[i][0] in miss:
      miss[li[i][0]] += 1
    else:
      miss[li[i][0]] = 1

print(ans1,ans2)

Submission status: Accepted

Solution code:
n,m = map(lambda x: int(x),input().split())
err = 0
ans_count = 0

dict = {}
dict_err = {}
for _ in range(m):
    p,s = input().split()
    p = int(p)
    if not (p in dict.keys()) :
        dict[p] = s
        if s == 'WA' :
            dict_err[p] = 1
        elif s == 'AC' :
            ans_count += 1

    elif (p, 'WA') in dict.items() and s == 'WA':
        err = dict_err[p] + 1
        dict_err[p] = err
    elif (p, 'WA') in dict.items() and s == 'AC':
        dict[p] = s
        ans_count += 1

for i,j in dict.items() :
    if j == 'WA' :
        dict_err.pop(i)
print(ans_count,sum(dict_err.values()))

Submission status: Accepted

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

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

fin=[0]*(N+1)
count_AC=0
count_WA=[0]*(N+1)

if(M!=0):
    for i in range(0,M):
        if(S[i]=="AC"):
            if(fin[int(p[i])]!=-1):
                count_AC+=1
                fin[int(p[i])]=-1
        else:
            if(fin[int(p[i])]!=-1):
                count_WA[int(p[i])]+=1
    
    for i in range(1,N+1):
        if(fin[i]!=-1):
            count_WA[i]=0
    
    print(count_AC,sum(count_WA))

else:
    print(count_AC,sum(count_WA))

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
pi = []
Si = []
for i in range(M):
    p, S = map(str, input().split())
    pi.append(p)
    Si.append(S)
score = 0
penalty = 0
now_num = 1
AC_problem = [True] * N
WA_problem = [True] * N
penalty_num = [0] * N
for i in range(M):
    if Si[i] == 'AC' and AC_problem[int(pi[i]) - 1]:
        score += 1
        AC_problem[int(pi[i]) - 1] = False
        WA_problem[int(pi[i]) - 1] = False
    elif WA_problem[int(pi[i]) - 1]:
        penalty += 1
        penalty_num[int(pi[i]) - 1] += 1

for i in range(N):
    if AC_problem[i]:
        penalty -= penalty_num[i]
        
print(str(score) + ' ' + str(penalty))

Submission status: Accepted

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

ac = 0
wa = 0
ans = [{'AC': False, 'cnt': 0} for _ in range(n)]

if m == 0:
    print('0 0')
else:

    for _ in range(m):
        p,s = list(input().split())
        p = int(p)
        if s == 'AC':
            ans[p-1]['AC'] = True
        elif ans[p-1]['AC'] == False:
            ans[p-1]['cnt'] += 1

    for a in ans:

        if a['AC']:
            ac += 1
            wa += a['cnt']
    print('{} {}'.format(ac, wa))

Submission status: Accepted

Solution code:
import sys
from math import factorial
from fractions import Fraction
import heapq, bisect, fractions
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
MOD = 10**9 + 7

n, m = MAP()
submits = [[] for i in range(n)]
for i in range(m):
    p, S = input().split()
    p = int(p)
    submits[p-1].append(S)

ac = 0
wa = 0

for i in range(n):
    for j in range(len(submits[i])):
        if submits[i][j] == 'AC':
            ac += 1
            wa += len(submits[i][:j])
            break

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

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
q = [input().split() for _ in range(m)]
ac = [False for _ in range(n+1)]
wa = [0 for _ in range(n+1)]
for p, s in q:
	p = int(p)
	if s == "WA" and not ac[p]:
		wa[p] += 1
	if s == "AC":
		ac[p] = True
print(sum(ac), sum([wa[i] for i in range(n+1) if ac[i]]))

Submission status: Accepted

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

list_n = list(range(n))

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

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

ac = 0
wa = 0
for i in l:
    if 'AC' in i:
        ac += 1
        wa_l = i[0:(i.index('AC'))]
        wa += wa_l.count('WA')
        
print(ac,wa)

Submission status: Accepted

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

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

hantei = []
for j in range(0,N):
    hantei.append([0,0])


for i in range(0,M):
    num = listA[i][0]-1
    if listA[i][1]=='AC':

        hantei[num][0]=1

    elif listA[i][1]=='WA' and hantei[num][0]==0:

        hantei[num][1] += 1


pena = 0
corr=0
for y in range(0, N):
    if hantei[y][0]==1:
        corr += 1
        pena += hantei[y][1]

print(corr,pena)

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
AC=[False]*N
P=[0]*N
pena=0
for i in range(M):
  p,s=map(str,input().split())
  p=int(p)-1
  if s=='WA' and AC[p]==False:
    P[p] +=1
  elif s=='AC' and AC[p]==False:
    AC[p]=True
    pena += P[p]
answer=0
for i in range(N):
  if AC[i]==True:
    answer +=1
print(answer,pena)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
dic = dict()
li = list()
for i in range(m):
    x1, y1 = input().split()
    if x1 not in dic.keys():
        dic[x1] = [0,0]
    if dic[x1][0] == 0:
        if y1 == "AC":
            dic[x1][0] = 1
        else:
            dic[x1][1] += 1
ac = 0
wa = 0
for key in dic.keys():
    if dic[key][0] == 1:
        ac += 1
        wa += dic[key][1]
print(ac, wa)

Submission status: Accepted

Solution code:
import numpy as np

N_M = input()
N = int(N_M.split(" ")[0])
M = int(N_M.split(" ")[1])

input_list = []
for i in range(M):
	input_list.append(tuple(input().split(" ")))

AC_list = np.zeros(N, dtype=bool)
WA_list = np.zeros(N, dtype=int)

for data in input_list:

	if data[1] == 'AC':
		AC_list[int(data[0]) - 1] = True
		if WA_list[int(data[0]) - 1] > 0:
			WA_list[int(data[0]) - 1] = -1 * WA_list[int(data[0]) - 1]

	if data[1] == 'WA':
		if not AC_list[int(data[0]) - 1]:
			WA_list[int(data[0]) - 1] += 1

print(np.count_nonzero(AC_list), np.sum((WA_list < 0) * WA_list) * -1)

Submission status: Accepted

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

for i in range(m):
    if not Bool[p[i]-1]:
        if s[i] == "WA":
            count[p[i]-1] += 1
        else:
            Bool[p[i]-1] = 1
ans = 0
for i in range(n):
    if Bool[i]:
        ans += count[i]

print(sum(Bool),ans)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
l=[[0 for i in range(2)]for j in range(n+1)]
wa,ac=0,0
for i in range(m):
  p,s=input().split()
  p=int(p)
  if s=="WA" and l[p][1]==0:
    l[p][0]+=1
  elif s=="AC" and l[p][1]==0:
    l[p][1]+=1
    ac+=1
    wa+=l[p][0]
print(ac,wa)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
from itertools import groupby
from operator import itemgetter
def print_ans(N, M, ar):
    """Test Case
    >>> print_ans(2, 5, [['1', 'WA'], ['2', 'WA'], ['2', 'AC'], ['2', 'WA'], ['1', 'AC']])
    2 2
    >>> print_ans(100000, 3, [['7777', 'AC'], ['7777', 'AC'], ['7777', 'AC']])
    1 0
    >>> print_ans(6, 0, [])
    0 0
    """
    correct = 0
    wrong = 0
    ar = sorted(ar, key=itemgetter(0))
    if M == 0:
        print(0, 0)
    else:
        for (k, g) in groupby(ar, key=itemgetter(0)):
            tmp_wrong = 0
            ac_flg = False
            for item in g:
                if item[1] == "AC":
                    correct += 1
                    ac_flg = True
                    break
                else:
                    tmp_wrong += 1
            if ac_flg == True:
                wrong += tmp_wrong
        print("{} {}".format(correct, wrong))
if __name__ == '__main__':
    N, M = map(int, input().rstrip().split())
    if M == 0:
        ar = []
    else:
        ar = [list(map(str, input().rstrip().split())) for i in range(M)]
    print_ans(N, M, ar)