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())
sub = [[0, 0] for _ in range(N)]  # 0: WC_num, 1: AC
ac, penalty = 0, 0
for _ in range(M):
    p, s = input().split()
    p = int(p)
    if s == 'WA':
        sub[p-1][0] += 1
    elif s == 'AC' and sub[p-1][1] == 0:
        sub[p-1][1] = 1
        ac += 1
        penalty += sub[p-1][0]
print(ac, penalty)

Submission status: Accepted

Solution code:
n, m = list(map(int, input().split()))
p, s = [], []
for i in range(m):
    ps = list(input().split())
    p.append(int(ps[0]))
    s.append(ps[1])
ac_list = [0 for i in range(n)]
wa_list = [0 for i in range(n)]
for i in range(m):
    if s[i] == "AC":
        ac_list[p[i] - 1] = 1
    else:
        if ac_list[p[i] - 1] == 0:
            wa_list[p[i] - 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:
n,m=map(int,input().split())
p=[0]*m
temp=['a']*m
s=["qw"]*m
judge=[0]*n
wa=[0]*n
  
for i in range(0,m):
  temp[i],s[i]=input().split()
  p[i]=int(temp[i])
  
ac=0
wasum=0
for i in range(0,m):
  if s[i][0]=='W' and s[i][1]=='A':
    wa[p[i]-1]+=1
  elif s[i][0]=='A' and s[i][1]=='C' and judge[p[i]-1]==0:
    ac+=1
    judge[p[i]-1]=1
    wasum+=wa[p[i]-1]
print("%d %d"% (ac,wasum))

Submission status: Accepted

Solution code:
[N,M]=list(map(int, input().split()))
ac=[0 for i in range(N)]
wa=[0 for i in range(N)]
p=[]
S=[]
WA=0

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

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

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

AC=ac.count(1)
print(str(AC)+" "+str(WA))

Submission status: Accepted

Solution code:

a,b=map(int,input().split())

c=[]
for i in range(b):
    d,e=map(str,input().split())
    c.append([int(d),e])

acans=0
waans=0
ac=[0]*(a+1)
wa=[0]*(a+1)
for i in range(b):
    if c[i][1]=="AC":
        if ac[c[i][0]-1]==0:
            acans+=1
            ac[c[i][0]-1]+=1
            waans+=wa[c[i][0]-1]
    else:
        wa[c[i][0]-1]+=1
#print(ac)
#print(wa)
print(acans,waans)

Submission status: Accepted

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

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

a = 0
b = 0

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

print(*[a, b])

Submission status: Accepted

Solution code:
def solve(string):
    n, m, *ps = string.split()
    n = int(n)
    ac = [0] * n
    wa = [0] * n
    for p, s in zip(*[iter(ps)] * 2):
        p = int(p) - 1
        if s ==  "AC":
            ac[p] = 1
        elif not ac[p]:
            wa[p] += 1
    return "{} {}".format(sum(ac),sum([w * a for a,w in zip(ac, wa)]))
    
    
if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))

Submission status: Accepted

Solution code:
N,M = map(int, input().split())
ans = {}
AC = 0
WA = 0

for i in range(M):
  num,stu = map(str, input().split())
  if num in ans:
    if ans[num][0] == 0:
      if stu == "AC":
        ans[num][0] = 1
      else:
        ans[num][1] += 1
  else:
      if stu == "AC":
        ans[num] = [1,0]
      else:
        ans[num] = [0,1]

  
for j in ans.values():
  if j[0] == 1:
    AC += 1
    WA += j[1]
    
print(str(AC)+" " +str(WA))

Submission status: Accepted

Solution code:
n, m = [int(i) for i in input().split(' ')]
wa = [0] * n
ac = [0] * n
for _ in range(m):
    problem, status = input().split(' ')
    problem = int(problem) - 1
    if status == 'WA':
        if ac[problem] == 0:
            wa[problem] += 1
        continue
    ac[problem] = 1

no_ac = 0
no_wa = 0

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

print(str(no_ac) + ' ' + str(no_wa))

Submission status: Accepted

Solution code:
n , m = map(int,input().split())
#{num:[ac,WA]}
P = {}
AC = 0
WA = 0
for i in range(m):
    num ,jud = map(str,input().split())
    if num in P:
        if P[num][0] == 0:
            if jud == "AC":
                P[num][0] = 1
            else:
                P[num][1] += 1
    else:
        if jud == "AC":
            P[num] = [1,0]
        else:
            P[num] = [0,1]

for j in P.values():
    if j[0] == 1:
        AC += 1
        WA += j[1]
    
print("{} {}".format(AC,WA))

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
f = [False] * (N+1)
ac = wa = 0
c = [0] * (N+1)

for i in range(M):
    p, s = input().split()
    p = int(p)
    if f[p]: continue
    
    if s == 'AC':
        f[p] = True
        ac += 1
        wa += c[p]
    else: c[p] += 1
    
print(ac, wa)

Submission status: Accepted

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

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

for p, s in ps:
    if f[p]:
        if s == "AC":
            ac[p] += 1
            f[p] = False
        else:
            wa[p] += 1

ans = [0, 0]
for _f, _ac, _wa in zip(f, ac, wa):
    if not _f:
        ans[0] += _ac
        ans[1] += _wa

print(*ans)

Submission status: Accepted

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

# AC数を数える
countAC = 0
# 複数ACしている問題を1つにまとめる
pS_set = set(pS)
# AC数をfor文で計算
for i in pS_set:
    if i[1] == 'AC':
        countAC += 1

# WA数を保存する辞書を作る
countWA_dict = {}
# 始めてACするまでのWA数を保存する辞書を作る
countWA_final = {}
# WA数を数える
countWA = 0

for i in pS:
    # WAだったら
    if i[1] == 'WA':
        # ある問題で始めてWAを見つけた時
        if i[0] not in countWA_dict.keys():
            countWA_dict[i[0]] = 1
        # ある問題で2回目以上WAを見つけた時
        else:
            countWA_dict[i[0]] += 1
    # ACだったら
    else:
        # countWA_finalにまだ保存されていない(=始めてAC)かつcountWA_dictに保存されている(=ACする前にWAした)時
        if i[0] not in countWA_final.keys():
            countWA_final[i[0]] = 0
            if i[0] in countWA_dict.keys():
                # countWA_finalに保存
                countWA_final[i[0]] = countWA_dict[i[0]]
                # countWAにその数を足す
                countWA += countWA_dict[i[0]]

print(str(countAC) + ' ' + str(countWA))

Submission status: Accepted

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

INDEX_ANS_NUM = 0
INDEX_ANS_RES = 1

data_list = [[False, 0] for _ in range(N)]
IDX_IS_AC_DONE = 0
IDX_COUNT_WA = 1

for submit_index, submit in enumerate(submit_list):
  submit_prob_num = submit[INDEX_ANS_NUM]
  submit_result = submit[INDEX_ANS_RES]
  data_index = submit_prob_num - 1
  if (data_list[data_index][IDX_IS_AC_DONE] == True):
    continue
  else:
    if (submit_result == 'AC'):
      data_list[data_index][IDX_IS_AC_DONE] = True
    else:
      data_list[data_index][IDX_COUNT_WA] += 1

count_AC = 0
sum_WA = 0
for _, data in enumerate(data_list):
  if (data[IDX_IS_AC_DONE] == True):
    count_AC += 1
    sum_WA += data[IDX_COUNT_WA]

print(count_AC, sum_WA)

Submission status: Accepted

Solution code:
import sys
N, M, *PS = sys.stdin.read().strip().split()
N = int(N)
ac = [0] * N
wa = [0] * N
for p, s in zip(*[iter(PS)] * 2):
  p = int(p) -1
  if s == "AC":
    ac[p] = 1
  elif ac[p] == 0:
    wa[p] += 1
penalties = sum([w if a > 0 else 0 for a, w in zip(ac, wa)])
print("{} {}".format(sum(ac), penalties))

Submission status: Accepted

Solution code:
import sys
N, M, *PS = sys.stdin.read().strip().split()
N = int(N)
ac = [0] * N
wa = [0] * N
for p, s in zip(*[iter(PS)] * 2):
  p = int(p) -1
  if s == "AC":
    ac[p] = 1
  elif ac[p] == 0:
    wa[p] += 1
penalties = sum([w * a for a, w in zip(ac, wa)])
print("{} {}".format(sum(ac), penalties))

Submission status: Accepted

Solution code:
N,M = map(int, input().split())
# List to store grades
apb = [[] for i in range(10 ** 5)]

# num and apb convert to type dict
for i in range(M):
    n, a = input().split()
    apb[int(n)] += [a]
    if a == 'AC':
      continue

apb_new = list(filter(lambda a: a != [], apb))

# count
penalty = 0
correct_answer = 0
for words in apb_new:
  if 'AC' in words:
    correct_answer += 1
    for word in words:
      if word == 'WA':
        penalty += 1
      else:
        break


print(correct_answer, penalty)

Submission status: Accepted

Solution code:
def ACWA(p,j,p_list):
    if j=="AC":
        p_list[p][0]=1
    else:
        p_list[p][1]+=1
    return p_list
    
N,M = map(int,input().split(" "))
p_list = {}
wa_count = 0

for _ in range(M):
    In = input().split()
    if (In[0] in p_list) == False:
        p_list[In[0]]=[0,0]
        p_list = ACWA(In[0],In[1],p_list)
    else:
        if p_list[In[0]][0]==1:
            continue
        else:
            p_list = ACWA(In[0],In[1],p_list)
                
List = list(p_list.values())
a = 0
b = 0

for i in range(len(List)):
    if List[i][0]==1:
        a+=List[i][0]
        b+=List[i][1]

print("{} {}".format(a,b))

Submission status: Accepted

Solution code:
import sys
N, M, *PS = sys.stdin.read().strip().split()
N = int(N)
ac = [0] * N
wa = [0] * N
for p, s in zip(*[iter(PS)] * 2):
  p = int(p) - 1
  if s == "AC":
    ac[p] = 1
  elif ac[p] == 0:
    wa[p] += 1
penalties = sum([w * a for a, w in zip(ac, wa)])
print("{} {}".format(sum(ac), penalties))

Submission status: Accepted

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

question = [0]*(N+1)
wrong = [0]*(N+1)

for i in range(M):
    if PS[i][1] == 'AC':
        if question[int(PS[i][0])] == 0:
            question[int(PS[i][0])] = 1
    else:
        if question[int(PS[i][0])] == 0:
            wrong[int(PS[i][0])] += 1

WA = 0
for i in range(N+1):
    if question[i] == 1:
        WA += wrong[i]

print(sum(question), WA)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
AC=[0]*n
WA=[0]*n
ACs=set()
for _ in range(m):
    p,c=input().split(); p=int(p)
    if p in ACs:continue
    if c=='AC':
        AC[p-1]+=1
        ACs.add(p)
    else:
        WA[p-1]+=1
for i in range(n):
    if i+1 not in ACs:
        WA[i]=0
print(sum(AC),sum(WA))

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
AC = [0 for _ in range(n)]
PENA = [0 for _ in range(n)]
ac = 0
pena = 0
for _ in range(m):
    p, s = input().split()
    p = int(p)-1
    if(AC[p]):
        continue
    if(s == "AC"):
        AC[p] = 1
    else:
        PENA[p] += 1

for i in range(n):
    ac += AC[i]
    if(AC[i]):
        pena += PENA[i]
print(ac, pena)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
AC = [0 for _ in range(n+1)]
PENA = [0 for _ in range(n+1)]
ac = 0
pena = 0
for _ in range(m):
    p, s = input().split()
    p = int(p)
    if(AC[p]):
        continue
    if(s == "AC"):
        AC[p] = 1
    else:
        PENA[p] += 1

for i in range(n+1):
    ac += AC[i]
    if(AC[i]):
        pena += PENA[i]
print(ac, pena)

Submission status: Accepted

Solution code:
n, m = map(int,input().split())
cor, war = 0,0
c = [[0,0] for k in range(n)] #[ACしたか,WA数]
for i in range(m):
  p,s = list(input().split())
  p = int(p)-1
  if s == "AC" and c[p][0] == 0: #初めてのACなら正答数を増やしてフラグを立て、ペナルティを誤答数分増やす
    cor += 1
    c[p][0] = 1
    war += c[p][1]
  if s == "WA" and c[p][0] == 0: #ACしていない状態でのWA数を記録
    c[p][1] += 1
print(cor,war)

Submission status: Accepted

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

ans_list = [[False, 0] for _ in range(N)]
for i, p in enumerate(P):
  current_prob_index = p[0] - 1
  if (ans_list[current_prob_index][0] == True):
    continue
  else:
    if (p[1] == 'WA'):
      ans_list[current_prob_index][1] += 1
    else:
      ans_list[current_prob_index][0] = True

AC_count = 0
WA_count = 0
for i, a in enumerate(ans_list):
  if (a[0] == True):
    AC_count += 1
    WA_count += a[1]

print(AC_count, WA_count)

Submission status: Accepted

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

right = 0
wrong = 0
question = [0 for i in range(N+1)]
wrong_count = [0 for i in range(N+1)]

for i in range(M):
    if list[i][1] == "AC" :
        if question[int(list[i][0])] != 1 :
            right += 1
            wrong += wrong_count[int(list[i][0])]
            question[int(list[i][0])] = 1
    else :
        if question[int(list[i][0])] != 1:
            wrong_count[int(list[i][0])] += 1

print("{} {}".format(right, wrong))

Submission status: Accepted

Solution code:
from numpy import *

N, M = map(int, input().split())
p = zeros(M, dtype=int)
S = []
for i in range(M):
    x, y = input().split()
    p[i] = int(x) - 1
    S.append(y)

ac = zeros(N, dtype=int)
wa = zeros(N, dtype=int)
s_ac = 0
s_wa = 0
for i in range(M):
    if ac[p[i]] == 0:
        if S[i] == 'AC':
            ac[p[i]] += 1
            s_ac += 1
            s_wa += wa[p[i]]
        elif S[i] == 'WA':
            wa[p[i]] += 1
    else:
        pass

print('{} {}'.format(s_ac, s_wa))

Submission status: Accepted

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

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

Submission status: Accepted

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

answer_list = {}
for i in range(N):
    answer_list[str(i+1)] = 0

for i in range(M):
    p, S = input().split()
    if answer_list[p] == "AC":
        pass
    else:
        if S == "AC":
            AC += 1
            WA += answer_list[p]
            answer_list[p] = "AC"
        else:
            answer_list[p] += 1

print(AC, WA)

Submission status: Accepted

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

acCount = 0
waCount = 0

for i in range(m):
    p, s = input().split()
    p = int(p)
    if(ac[p] == False):
        if (s == "AC"):
            ac[p] = True
        else:
            wa[p] += 1

for i in range(n+1):
    if(ac[i] == True):
        acCount += 1
        waCount += wa[i]

print(acCount, waCount)

Submission status: Accepted

Solution code:
def main():
    N,M=map(int,input().split())
    pS=[list(input().split()) for i in range(0,M)]
    atcoderresult=[[0,0] for i in range(0,N+1)]
    for i in range(0,M):
        if pS[i][1]=='WA' and atcoderresult[int(pS[i][0])][0]==0:
            atcoderresult[int(pS[i][0])][1]=atcoderresult[int(pS[i][0])][1]+1
        if pS[i][1]=='AC':
            atcoderresult[int(pS[i][0])][0]=1
    ac=0
    penalty=0
    for i in range(1,N+1):
        if atcoderresult[i][0]==1:
            ac=ac+1
            penalty=penalty+atcoderresult[i][1]
    print(ac,penalty)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import numpy as np

N,M = map(int,input().split())

Q = np.zeros((N,2),dtype=int)
for i in range(M):
  p,S = input().split()
  p = int(p)-1
  if Q[p,0] == 0 and S == "AC":
    Q[p,0] = 1
  elif Q[p,0] == 0 and S == "WA":
    Q[p,1] += 1
  else:
    pass

Q[:,1] *= Q[:,0]
ret = Q.sum(axis=0)
print(ret[0],ret[1])

Submission status: Accepted

Solution code:
from sys import stdin
input = stdin.readline
N, M = map(int, input().split())
ac = [False] * N
wa = [0] * N
wa_cnt = 0
for i in range(M):
  p, s = input().split()
  p = int(p) - 1
  if ac[p] is False and s == "AC":
    wa_cnt += wa[p]
    ac[p] = True
  elif s == "WA":
    wa[p] += 1
print(ac.count(True), wa_cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
k, n = list(map(int, input().split()))
AC, WA = [0] * k, [0] * k
for i in range(n):
  x = input().split()
  number = int(x[0]) - 1
  if x[1] == "AC":
    AC[number] = 1
  elif x[1] == "WA" and AC[number] == 0:
    WA[number] += 1
print(sum(AC), sum([w for i, w in enumerate(WA) if AC[i]]))

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
A = []
for _ in range(m):
    a,b = input().split()
    tmp = [int(a),b]
    A.append(tmp)
dict = {}
for a in A:
    dict.update({a[0]:[False,0]})
for a in A:
    if dict[a[0]][0] == False:
        if a[1] == "WA":
            dict[a[0]][1] += 1
        else:
            dict[a[0]][0] = True
wa = 0
ac = 0
for i in dict:
    if dict[i][0]:
        ac += 1
        wa += dict[i][1]
print("{} {}".format(ac,wa))

Submission status: Accepted

Solution code:
"""
author : halo2halo
date : 4, Feb, 2020
"""

import sys

# import itertools
# import math

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
INF = 10 ** 9

N, M = map(int, readline().split())
PS = [line.split() for line in readlines()]
AC = [False] * (N + 1)
WA = [0] * (N + 1)

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

ac = sum(AC)
print(ac, penal)

Submission status: Accepted

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

wa_stock = [0] * N
ac = 0
wa = 0
stat = ['NA'] * N

for _ in range(M):
    p, S = input().split()
    key = int(p) - 1
    if S == 'WA':
        wa_stock[key] += 1
    elif stat[key] != 'AC' and S == 'AC':
        stat[key] = 'AC'
        ac += 1
        wa += wa_stock[key]

print(ac, wa)

Submission status: Accepted

Solution code:
from collections import defaultdict
wa_dict = defaultdict(lambda: 0)
n, m = map(int, input().split())
ac_set = set([])
ac = 0
wa = 0
for _ in range(m):
    p, s = input().split()
    if s == 'AC':
        if p not in ac_set:
            wa += wa_dict[p]
            ac_set.add(p)
    else:
        if p not in ac_set:
            wa_dict[p] += 1
print(len(ac_set), wa)

Submission status: Accepted

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

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

for i in range(n):
    if ac[i] == 1:
        continue
    elif ac[i] == 0:
        wa[i] = 0
        
print(sum(ac),sum(wa))

Submission status: Accepted

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

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

ac_num = 0
for i in range(len(ac)):
    if ac[i] != 0:
        ac_num += 1
ng = 0
for i in range(len(wa)):
    if ac[i] != 0:
        ng += wa[i]
            
print(ac_num,ng)

Submission status: Accepted

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

c = [0]*N
w = [0]*N

ac = 0
wa = 0

for i, v in A:
    if c[int(i)-1] == 0:
        if v == 'WA':
            w[int(i)-1] += 1
        elif v == 'AC':
            ac += 1
            wa += w[int(i)-1]
            c[int(i)-1] = 1

print(ac, wa)

Submission status: Accepted

Solution code:
n, m = (int(x) for x in input().split())
ps = []
for _ in range(m):
    p, s = (x for x in input().split())
    ps.append([int(p), s])
ans = [0] * n
pen = 0
tmp = [0] * n
for p, s in ps:
    if ans[p - 1] == 1:
        continue
    if s == 'WA':
        tmp[p - 1] += 1
    else:
        ans[p - 1] = 1
        pen += tmp[p - 1]
print(sum(ans), pen)

Submission status: Accepted

Solution code:
n, m = (int(x) for x in input().split())
ps = []
for _ in range(m):
    p, s = (x for x in input().split())
    ps.append([int(p), s])
ans = [0] * n
pen = 0
tmp = [0] * n
for p, s in ps:
    if s == 'WA' and ans[p - 1] == 0:
        tmp[p - 1] += 1
        continue
    else:
        ans[p - 1] = 1
        pen += tmp[p - 1]
        tmp[p - 1] = 0 
print(sum(ans), pen)

Submission status: Accepted

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

    penalties = 0
    wa_counts = [0] * n
    ac_flags = [0] * n

    for _ in range(m):
        line = input().split()
        q = int(line[0])
        r = line[1]

        if ac_flags[q-1] == 0:
            if r == 'WA':
                wa_counts[q-1] += 1

            else:
                ac_flags[q-1] = 1
                penalties += wa_counts[q-1]

    print(sum(ac_flags), penalties)
    
resolve()

Submission status: Accepted

Solution code:
def main(n,m,r):
    ac = [0]*n
    wa = [0]*n
    for i in range(len(r)):
        seq = int(r[i][0])
        judge = r[i][1]
        if ac[seq-1] == 1:
            continue
        if judge == "WA":
            wa[seq-1] += 1
        else:
            ac[seq-1] = 1
    for i in range(len(ac)):
        if ac[i] == 0:
            wa[i] = 0
    return "{0} {1}".format(sum(ac), sum(wa))

n,m = map(int, input().split())
r = list(input().split() for _ in range(m))
print(main(n,m,r))

Submission status: Accepted

Solution code:
import numpy as np
N, M = map(int, raw_input().split())
Trial = np.zeros(N, int)
Penalty = 0
Accept  = 0
Finish = np.zeros(N, bool)
for i in xrange(M):
    a, b = raw_input().split()
    A = int(a) - 1
    if not Finish[A]:
        if b == 'AC':
            Penalty += Trial[A]
            Finish[A] = True
            Accept += 1
        else:
            Trial[A] += 1
    else:
        pass
    
print Accept, Penalty

Submission status: Accepted

Solution code:
import numpy as np
N, M = map(int, raw_input().split())
Trial = np.zeros(N, int)
Penalty = 0
Finish = np.zeros(N, bool)
for i in xrange(M):
    a, b = raw_input().split()
    A = int(a) - 1
    if not Finish[A]:
        if b == 'AC':
            Penalty += Trial[A]
            Finish[A] = True
        else:
            Trial[A] += 1
    else:
        pass
    
Accept = Finish.sum()
print Accept, Penalty

Submission status: Accepted

Solution code:
def main():
    N, M = map(int, input().split(' '))
    wc_cnt = [0 for _ in range(N + 1)]
    ac, wc = 0, 0
    for i in range(M):
        num, result = input().split(' ')
        num = int(num)
        if wc_cnt[num] is None:
            continue
        if result == 'AC':
            wc += wc_cnt[num]
            wc_cnt[num] = None
            ac += 1
        else:
            wc_cnt[num] += 1
    print(ac, wc)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

is_solved = [0]*N
penalties = [0] * N
solutions = 0

for i in range(M):
    p_idx, verdict = input().split()
    p_idx = int(p_idx)

    if verdict == "WA" and (not is_solved[p_idx-1]):
        penalties[p_idx - 1] += 1
    elif verdict == "AC" and (not is_solved[p_idx-1]):
        is_solved[p_idx-1] = 1
        solutions += 1
penalty = 0

for i in range(N):
    if is_solved[i]:
        penalty += penalties[i]

print(solutions, penalty)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
l=[0]*(n+1)
p=0
for _ in range(m):
  a,b=list(input().split())
  if str(b)=="AC" and l[int(a)]!=-1:
    p+=l[int(a)]
    l[int(a)]=-1
  elif str(b)=="WA" and l[int(a)]!=-1:
    l[int(a)]+=1
print(l.count(-1),p)

Submission status: Accepted

Solution code:
import sys
import socket

hostname = socket.gethostname()

if hostname == 'F451C':
    sys.stdin = open('c1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    N, M = read_int_list()
    p = [0] * M
    S = [''] * M
    for i in range(M):
      l = read_str_list()
      p[i] = int(l[0])
      S[i] = l[1]
      
    r = set()
    for i in range(M):
      if S[i] == 'AC':
        if p[i] not in r:
          r.add(p[i])

    correct, penalties = 0, 0
    f = set()  
    for i in range(M):
      if S[i] == 'AC':
        if p[i] not in f:
          f.add(p[i])
          correct += 1
      # print(p[i], S[i], f, r)
      
      if S[i] == 'WA':
        if p[i] not in f and p[i] in r:
          penalties += 1

    print(correct, penalties)


def main0():
    N, M = read_int_list()
    p = [0] * M
    S = [''] * M
    for i in range(M):
      l = read_str_list()
      p[i] = int(l[0])
      S[i] = l[1]
      
    r = set()
    for i in range(M):
      if S[i] == 'AC':
        if p[i] not in r:
          r.add(p[i])

    correct = len(r)
    penalties = 0
    f = set()  
    for i in range(M):
      if S[i] == 'AC':
        if p[i] not in f:
          f.add(p[i])
      
      if S[i] == 'WA':
        if p[i] not in f and p[i] in r:
          penalties += 1

    print(correct, penalties)


def main1():
    N, M = read_int_list()
    correct = 0
    penalties = 0
    WA = [0] * (N + 1)
    AC = [0] * (N + 1)
    for i in range(M):
      l = read_str_list()
      p = int(l[0])
      S = l[1]

      if S == 'AC':
        AC[p] += 1
      if S == 'WA':
        WA[p] += 1

      if S == 'AC' and AC[p] == 1:
        correct += 1
        penalties += WA[p]
      
      # print(AC[1:], WA[1:])

    print(correct, penalties)

main1()

Submission status: Accepted

Solution code:
import sys
import socket

hostname = socket.gethostname()

if hostname == 'F451C':
    sys.stdin = open('c1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    N, M = read_int_list()
    p = [0] * M
    S = [''] * M
    for i in range(M):
      l = read_str_list()
      p[i] = int(l[0])
      S[i] = l[1]
      
    r = set()
    for i in range(M):
      if S[i] == 'AC':
        if p[i] not in r:
          r.add(p[i])

    correct, penalties = 0, 0
    f = set()  
    for i in range(M):
      if S[i] == 'AC':
        if p[i] not in f:
          f.add(p[i])
          correct += 1
      # print(p[i], S[i], f, r)
      
      if S[i] == 'WA':
        if p[i] not in f and p[i] in r:
          penalties += 1

    print(correct, penalties)


def main0():
    N, M = read_int_list()
    p = [0] * M
    S = [''] * M
    for i in range(M):
      l = read_str_list()
      p[i] = int(l[0])
      S[i] = l[1]
      
    r = set()
    for i in range(M):
      if S[i] == 'AC':
        if p[i] not in r:
          r.add(p[i])

    correct = len(r)
    penalties = 0
    f = set()  
    for i in range(M):
      if S[i] == 'AC':
        if p[i] not in f:
          f.add(p[i])
      
      if S[i] == 'WA':
        if p[i] not in f and p[i] in r:
          penalties += 1

    print(correct, penalties)

main0()

Submission status: Accepted

Solution code:
import sys
import socket

hostname = socket.gethostname()

if hostname == 'F451C':
    sys.stdin = open('c1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    N, M = read_int_list()
    p = [0] * M
    S = [''] * M
    for i in range(M):
      l = read_str_list()
      p[i] = int(l[0])
      S[i] = l[1]
      
    r = set()
    for i in range(M):
      if S[i] == 'AC':
        if p[i] not in r:
          r.add(p[i])

    correct, penalties = 0, 0
    f = set()  
    for i in range(M):
      if S[i] == 'AC':
        if p[i] not in f:
          f.add(p[i])
          correct += 1
      # print(p[i], S[i], f, r)
      
      if S[i] == 'WA':
        if p[i] not in f and p[i] in r:
          penalties += 1

    print(correct, penalties)

main()

Submission status: Accepted

Solution code:
def InS(): return input()


def InL(): return list(map(int, input().split()))


def InI(): return int(input())


N, M = (int(x) for x in input().split(" "))

i = 0
WAcnt = [0] * N
stack = [False] * N
WAcnt
# stack = []

data_list = [list(map(str, input().split(" "))) for i in range(M)]

if M == 0:
    print(0, 0)
else:
    while M > i:
        if stack[int(data_list[i][0]) - 1] == False:
            if data_list[i][1] == "AC":
                stack[int(data_list[i][0]) - 1] = True
            else:
                WAcnt[int(data_list[i][0]) - 1] += 1
        i += 1
    res = 0
    for i in range(N):
        if stack[i]:
            res += WAcnt[i]

    print(sum(stack), res)

Submission status: Accepted

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

ls = [0 for _ in range(n+1)]

ans = 0
pen = 0

for _ in range(m):
  p,s = input().split()
  p = int(p)
  
  if ls[p] == None:
    pass
  elif s == "WA":
    ls[p] += 1
  else:
    pen += ls[p]
    ls[p] = None
    ans +=1
print(ans,pen)

Submission status: Accepted

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

lac = [0]*(N+1)
lpcnt = [0]*(N+1)

for i in range(M):
  s = input().split()
  n = int(s[0])
  if s[1] == "AC":
    lac[n] =1
    continue
  if s[1] == "WA" and lac[n] == 0:
    lpcnt[n] += 1

cnt = 0
for i in range(N+1):
  if lac[i] == 1:
    cnt += lpcnt[i]
  
print(sum(lac), end=" ")
print(cnt)

Submission status: Accepted

Solution code:
from sys import stdin
n,m = map(int,stdin.readline().split())
prob = dict()
AC,WA = 0,0
for _ in range(m):
	p,s = stdin.readline().split()
	p = int(p)
	if p in prob:
		if s == "AC":
			if prob[p] > 0:
				AC += 1
				WA += prob[p]
				prob[p] = 0
		else:
			if prob[p] > 0: prob[p] += 1
	else:
		if s == "AC":
			prob[p] = 0
			AC += 1
		else:
			prob[p] = 1
print(AC,WA)