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: Time Limit Exceeded

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

def f(s):
  lst = s.split()
  return int(lst[0]),lst[1]



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

correct = 0
penalty = 0
q = []
relate = []

for i, j in enumerate(S):
  if 'AC' in j:
    if P[i] not in q:
      q.append(P[i])
      relate.append(P[i])
      correct += 1
    else:
      relate.append(P[i])
      continue
  if 'WA' in j:
    if P[i] not in q:
        penalty += 1
    else:
      continue

for i, j in enumerate(S):
  if 'WA' in j:
    if P[i] not in relate:
      penalty -= 1

print(correct, penalty)

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int, input().split())
A = [input().split() for i in range(M)]
#import numpy as np
wa = 0
ans = 0
A_ = sum(A, [])
#print(A)
A_len = len(A_)
for j in range(1,N+1):
  tmp = [A_[i+1] for i in range(A_len) if A_[i] == str(j)]
  #print(tmp)
  for i in range(len(tmp)):
    if A[i][1] == 'WA':
      wa +=1
    if A[i][1] == 'AC':
      ans += 1
      break
print(ans,wa)

Submission status: Time Limit Exceeded

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

cor = pen = temp_pen = 0
temp_p = "0"
pen_dic={}
ac=[]

for _ in range(m):
  temp=input().split()
  if temp[0] in ac:
    continue
  if temp[1] == "AC":
    ac.append(temp[0])
    t = 0
    try:
      t = pen_dic[temp[0]]
    except:
      pass
    
    pen += t
  else:
    if not temp[0] in ac:
      t = 0
      try:
        t = pen_dic[temp[0]]
      except:
        pass
      pen_dic.update({temp[0]:t + 1})
print(len(set(ac)), pen)

Submission status: Time Limit Exceeded

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

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

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

AC = [0] * M
WA = 0

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

print(len(AC) - AC.count(0), WA)

Submission status: Time Limit Exceeded

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


ACs=[]
WAs={}

AC=0
pena=0
for i in range(M):
  num, jud=input().split()
  if num in ACs:
    continue
  elif jud=="WA":
    if num not in WAs.keys():
      WAs[num]=1
    else:
      WAs[num]+=1
  else:
    ACs.append(num)
    AC+=1
    if num in WAs.keys():
      pena+=WAs[num]

print(AC, pena)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

x = list(map(int, input().split()))

N, M = x[0], x[1]

AC, WA = 0, 0

if M == 0:
    AC, WA = 0, 0
else:
    input_line = np.array([input() for i in range(M)])
    save_data = np.array([[0, "x"] for j in range(M)])

    for i in range(M):
        save_data[i] = input_line[i].split()

    data = np.array([["x" for i in range(M)] for j in range(M)])
    num = 0
    for i in range(M):
        data[num][i] = save_data[i][1]
        if i + 1 < M:
            if save_data[i][0] != save_data[i + 1][0]:
                num += 1

    for i in range(M):
        for j in range(M):
            if data[i][j] == "W":
                WA += 1
            elif data[i][j] == "A":
                AC += 1
                break

print(AC, WA)

Submission status: Time Limit Exceeded

Solution code:
N, M = input().split()
pS = [input().split() for i in range(int(M))]
ans = {}
ac = 0
wa = 0
for i in pS:
    if i[0] not in ans.keys():
        ans[i[0]] = [0, 0] 
        """
        if i[1] == "AC":
            ans[i[0]][0] += 1
            ac += 1
        elif i[1] == "WA":
            ans[i[0]][1] += 1
        """
    if i[1] == "AC":
        if ans[i[0]][0] == 0:
                ans[i[0]][0] += 1
                ac += 1
                wa += ans[i[0]][1]
    elif i[1] == "WA":
        if ans[i[0]][0] == 0:
            ans[i[0]][1] += 1

"""
for i in ans.values():
    ac += i[0]
    if i[0] >= 1:
        wa += i[1]
"""
print(ac, wa)

Submission status: Time Limit Exceeded

Solution code:
n, m = input().split()
n = int(n)
m = int(m)
 
result_list = []
true_flag = False
ac_list = []

for i in range(m):
    a,b=input().split()
    result_list.append((int(a), b))
    if b == "AC":
        true_flag = True
        if a in ac_list:
            pass
        else:
            ac_list.append(a)

# 正解した問題を入れるlist
done_list = []
pn_list = [0] * n
correct = 0
pn = 0
 
if true_flag == False:
    print(0, 0)
else: 
    for result in result_list:
        if result[0] in done_list:
            pass
        elif result[1] == "WA":
            pn_list[result[0] - 1] += 1

        elif result[1] == "AC":
            done_list.append(result[0])
            correct += 1
            pn += pn_list[result[0] - 1]
        if len(done_list) == len(ac_list):
            break
    
    print(correct, pn)

Submission status: Time Limit Exceeded

Solution code:
buf=input().split(" ")
 
N=int(buf[0])
M=int(buf[1])
clear=[0]*M
ac=0
wa=0
 
for i in range(M):
  buf=input().split(" ")
  if clear.count(int(buf[0])) == 0:
    if buf[1] == "AC":
      clear[i]=int(buf[0])
      ac=ac+1
    elif buf[1] == "WA":
      wa=wa+1
print(str(ac)+" "+str(wa))

Submission status: Time Limit Exceeded

Solution code:
n, m = list(map(int, input().split()))
results = []
if m:
    for _ in range(m):
        results.append(input().split())
ac = []
wa = {}
cnt_ac = 0
cnt_wa = 0
for res in results:
    if res[1] == "AC":
        if not res[0] in ac:
            cnt_ac += 1
            ac.append(res[0])
            if res[0] in wa.keys():
                cnt_wa += wa[res[0]]
    else:
        if res[0] in wa.keys():
            wa[res[0]] += 1
        else:
            wa[res[0]] = 1
print(cnt_ac, cnt_wa)

Submission status: Time Limit Exceeded

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

n, m = map(int, input().split())
ac = []
ac_append = ac.append
wa = {}
ok = 0
ng = 0

for _ in range(m):
    p, s = input().split()
    if p not in ac:
        if s == "AC":
            ac_append(p)
            ok += 1
            if p in wa.keys():
                ng += wa[p]
        else:
            if p in wa.keys():
                wa[p] += 1
            else:
                wa[p] = 1

print(ok, ng)

Submission status: Time Limit Exceeded

Solution code:
nm = list(map(int, input().split()))
 
p = []
s = []
for _ in range(nm[1]):
    ps = input().split()
    p.append(int(ps[0]))
    s.append(ps[1])
 
ac = []
wa = {}
pc = 0
 
for i, j in zip(p, s):
    if i not in ac:
        if j == 'WA':
            if i in wa:
                wa[i] += 1
            else:
                wa[i] = 1
        else:
            if i in wa:
                pc += wa[i]
            ac.append(i)
 
print(len(ac), pc)

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
li = []
for i in range(m):
  li.append(list(input().split()))
a = []
b = 0
for j in range(m):
  if li[j][1] == "AC":
    a.append(int(li[j][0]))
  elif li[j][1] == "WA" and int(li[j][0]) not in a:
    b += 1
for k in range(m):
  if int(li[k][0]) not in a:
    b -= 1
c = str(len(set(a)))
print(c + " " + str(b))

Submission status: Time Limit Exceeded

Solution code:
n,m = map(int,input().split())
count_ac = 0
count_wa = 0
l = []
memo_n = []
for i in range(m):
    t = tuple(input().split())
    l.append(t)
    if t[1] == 'AC' and t[0] not in memo_n:
        memo_n.append(t[0])
        count_ac += 1
        count_wa += l.count((t[0],'WA'))

print(str(count_ac) + " " + str(count_wa))

Submission status: Time Limit Exceeded

Solution code:
n,m = list(map(int, input().split()))
x = []
for i in range(m):
  x.append(list(map(str,input().split())))
  
qu = []
count = 0
AC,WA = 0,0
for i in x:
  qu.append(i[0])
  

qu_set = list(set(qu))
for i in qu_set:
  x_target = [j for j in x if j[0] == i]
  
  #ACがあるかどうか、あった場合そのインデックス
  if [i,"AC"] in x:
    index = x_target.index([i,"AC"])
    WA += index
    AC += 1
  else:
    pass
  
print(AC, WA)

Submission status: Time Limit Exceeded

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


c = 0
a = 0

t = [0]*(n+1)

temp = []


for i in range(m):
    s = input().split()
    x = s[0]
    y = s[1]
    if y == 'AC' and x not in set(temp):
        a += 1
        c += t[int(x)]
        temp += [x]
    elif y == 'WA':
        t[int(x)] += 1

print(a, c)

Submission status: Time Limit Exceeded

Solution code:
N, M = (int(i) for i in input().split(' '))
lstP = []
lstS = []
lstC = []

for i in range(M):
  P, S = (j for j in input().split(' '))
  if P in lstP:
    idx = lstP.index(P)
    if lstS[idx] == 'WA' and S == 'WA':
      lstC[idx] += 1
    elif lstS[idx] == 'WA' and S == 'AC':
      lstS[idx] = 'AC'
  else:
    lstP.append(P)
    lstS.append(S)
    if S == 'AC':
      lstC.append(0)
    else:
      lstC.append(1)

cntC = 0
cntS = 0

for i in range(len(lstS)):
  if lstS[i] == 'AC':
    cntC += 1
    cntS += lstC[i]

print(str(cntC) + ' ' + str(cntS))

Submission status: Time Limit Exceeded

Solution code:
qus = list(map(int, input().split()))
data  = {}
ch = []
sum = 0
pe = 0
for i in range(0, qus[1]):
  int_data = list(map(str, input().split()))
  n = int_data[0]
  if n in  data:
    if int_data[1] == 'WA':
      data[n] += 1
    else:
        if n in ch:
            None
        else:
            sum += 1
            pe += data[n]
            ch.append(n)
  else:
    if int_data[1] == 'AC':
        if n in ch:
            None
        else:
            sum += 1
            ch.append(n)
    else:
      data[n] = 1
print(sum,' ',pe)

Submission status: Time Limit Exceeded

Solution code:
def main():
    from sys import stdin
    input = stdin.readline
    N, M = map(int, input().split())
    SP = [tuple(input().split()) for i in range(M)]
    wa_num = 0
    wa_num_temp = {}
    ac_num = 0
    ansed = []
    ansed_append = ansed.append
    for sp in SP:
        if sp[0] in ansed:
            continue
        if sp[0] not in wa_num_temp:
            wa_num_temp[sp[0]] = 0
        if sp[1] == "WA" and sp[0] not in ansed:
            wa_num_temp[sp[0]] += 1
        elif sp[1] == "AC" and sp[0] not in ansed:
            ac_num += 1
            wa_num += wa_num_temp[sp[0]]
            ansed_append(sp[0])

    print(ac_num, wa_num)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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


import numpy as np
P=np.array(P)
S=np.array(S)

if M>0:
    ans=np.unique(P[S=="AC"])

    wa=0
    for j in ans:
        for i in S[P==j]:
            if i=="WA":
                wa+=1
            else:
                break

    print(len(ans),wa)
else:
    print(0,0)

Submission status: Time Limit Exceeded

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


c = 0
a = 0

t = [0]*(n+1)

temp = []


for i in range(m):
    s = input().split()
    x = s[0]
    y = s[1]
    if y == 'AC' and x not in temp:
        a += 1
        c += t[int(x)]
        temp += [x]
    elif y == 'WA':
        t[int(x)] += 1

print(a, c)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

n, m = [int(i) for i in input().split()]
to_i = dict(AC=1, WA=0)
ps = list()
ss = list()
for i in range(m):
  p, s = input().split()
  ps.append(int(p))
  ss.append(to_i[s])
ps = np.array(ps)
ss = np.array(ss)

sub_ps = np.unique(ps)

cnt_c, cnt_w = 0, 0
for sp in sub_ps:
  indices = np.where(ps==sp)[0]
  s_sp = ss[indices]
  if s_sp.sum() == 0:
    continue
  num_ws = np.where(s_sp == 1)[0][0]
  cnt_w += num_ws
  cnt_c += 1

print(cnt_c, cnt_w)

Submission status: Time Limit Exceeded

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

ans = [0 for i in range(n)]
pena = [0 for i in range(n)]

end = [0 for i in range(n)]
for i in range(m):
    if [l[i][0], "AC"] in l:
        end[int(l[i][0])-1] += 1

for i in range(m):

    if l[i][1] == "AC" and ans[int(l[i][0])-1] != 1:
        ans[int(l[i][0])-1] += 1

    elif ans[int(l[i][0])-1] != 1 and end[int(l[i][0])-1] >= 1:
        pena[int(l[i][0])-1] += 1
    

print(sum(ans), sum(pena))

Submission status: Time Limit Exceeded

Solution code:
# AC を 1回以上出した各問題において、初めて AC を出すまでに出した WA の数
n,m = map(int, input().split())
p = []
s = []
wacounter = 0
walist = []
for i in range(0, n):
  walist.append(0)
point = 0
point_to_num = [] #acをとった問題
for i in range(0, m):
  list = input().split()
  p.append(int(list[0]))
  s.append(list[1])
 
for i in range(0, m):
  if s[i] == "AC" and not p[i] in point_to_num: #もし正解で、今までにその問題に正解していなかったら
    point_to_num.append(p[i]) #正解リストにその問題を追加
    point = point + 1 #正解ポイントをあげる
  elif s[i] == "WA" and not p[i] in point_to_num: #不正解かつ今まで正解を出したことがない
      wacounter += 1
      walist[p[i]-1] += 1
for i in range(0, n):
  if not i + 1 in point_to_num:#もし正解してない番号があったら、walistからwacounterをとってきてひく
    wacounter = wacounter - walist[i]
print(point, wacounter)

Submission status: Time Limit Exceeded

Solution code:
a,s=input().split()
a=int(a) 
s=int(s)
A=[]
B=[]
ac=0
wa=0
for i in range(s):
  d,f=input().split()
  if f=="AC" and d not in B:
    ac+=1
    B.append(d)
    wa+=A.count(d)
  elif f=="WA" and d not in B:
    A.append(d)
print(ac,wa)

Submission status: Time Limit Exceeded

Solution code:
import sys
n, m = map(int, input().split())
wa, ac = 0, 0
memo = []
hi = n
if n < m:
    hi = m
b = [0] * hi
table = [sys.stdin.readline().split() for x in range(m)]
for x in range(m):
    if table[x][1] == 'AC' and not table[x][0] in memo:
        memo.append(table[x][0])
        ac += 1
        wa += b[int(table[x][0])]
    elif table[x][1] == 'WA':
        b[int(table[x][0])] += 1
print(ac, wa)

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
count = 0
ans = []
pen = []
penal = 0
p = [0]*m
x = [0]*m
for i in range(m):
    p[i], x[i] = map(str, input().split())
    if x[i] == "AC":
        ans.append(p[i])
    elif x[i] == "WA":
        for j in range(len(ans)):
            if p[i] == ans[j]:
                penal -= 1
                break
        penal += 1
        pen.append((p[i], x[i]))
    if len(ans) == n:
        break


ans = list(set(ans))

for i in range(len(pen)):
    if pen[i][0] not in ans:
        penal -= 1

if penal < 0:
    penal = 0

print("{}".format(len(ans)) + " {}".format(penal))

Submission status: Time Limit Exceeded

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

n, m = map(int, input().split())
ac = []
ac_append = ac.append
wa = {}
ok = 0
ng = 0

inp = [input().split() for _ in range(m)]
for p, s in inp:
    if p not in ac:
        if s == "AC":
            ac_append(p)
            ok += 1
        else:
            if p in wa.keys():
                wa[p] += 1
            else:
                wa[p] = 1

for i in ac:
    if i in wa.keys():
        ng += wa[i]

print(ok, ng)

Submission status: Time Limit Exceeded

Solution code:
# N問出題, M回提出
N, M = map(int, input().split())

p_S_list = []

WA = 'WA'
AC = 'AC'

first_AC_index_list = []
AC_set = set([])

for j in range(M):
    p, S = input().split()
    int_p = int(p)
    p_S_list.append([int_p, S])

    if S == AC and (int_p not in AC_set):
        first_AC_index_list.append([j, int_p])
        AC_set.add(int_p)

count_AC = len(first_AC_index_list)
count_WA = 0


for i_list in first_AC_index_list:
    count_WA += p_S_list[:i_list[0]].count([i_list[1], WA])

ans = str(count_AC) + ' ' + str(count_WA)

print(ans)

Submission status: Time Limit Exceeded

Solution code:
mondai, kaitou = map(int, input().split())

# 問題ごとの
clearNo = []
# 問題ごとのWrong
wrong = {}
cleard = 0
pena = 0
# 解答数分繰り返す
kaitous = [input().split() for _ in range(kaitou)]
for i in kaitous:
    if i[0] in clearNo:
        continue
    else:
        if i[1] == 'WA':
            if i[0] in wrong:
                wrong[i[0]] += 1
            else:
                wrong[i[0]] = 1
        else:
            cleard += 1
            if i[0] in wrong:
                pena += wrong[i[0]]
            clearNo.append(i[0])

print(str(cleard) + ' ' + str(pena))

Submission status: Time Limit Exceeded

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


c = 0
a = 0

t = [0]*(n+1)

temp = []


for i in range(m):
    s = input().split()
    x = s[0]
    y = s[1]
    if x not in temp:
        if y == 'AC':
            a += 1
            c += t[int(x)]
            temp += [x]
        elif y == 'WA':
            t[int(x)] += 1
    elif len(temp) == n:
        break

print(a, c)

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
n,m = map(int,input().split())
p_s = [input().split() for i in range(m)]
dic = {}
penalty = 0
acc = 0
num_list=[]
for i in range(m):
  num = p_s[i][0]
  if num in num_list:
    continue
  if p_s[i][1] == "WA":
    if num in dic:
      dic[num]+=1
    else:
      dic[num]=1
  else:
    if num not in num_list:
      num_list.append(num)
      acc += 1
    if num in dic:
      penalty += dic[num]

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import sys
input = sys.stdin.readline
 
def main():
    NM = [int(i) for i in input().split(" ")]
    if NM[1] == 0:
        ans = "0 0"
    else:
        pss = np.array([np.array(input().split(" ")) for j in range(NM[1])])
 
        probs = pss[:,0]
        answs = pss[:,1]

        ans_ac = 0
        ans_wa = 0
 
        probs_uniq = list(set(probs))
        for p in probs_uniq:
            res = answs[probs == p]
            ind_ac = np.where(res == "AC\n")[0]
            if ind_ac.shape[0] == 0:
                pass
            else:
                ans_ac += 1
                ans_wa += ind_ac[0]

        ans = str(ans_ac) + " " + str(ans_wa)
    print(ans)
 
if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

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

print(len(AC) - AC.count(0), len(WA) - WA.count(0))

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline

n, m = map(int,input().split())
a = []
for i in range(m):
    a.append([str(i) for i in input().split()])

ac = []
ans2 = 0
for i in range(m):
    if a[i][1] == "AC":
        ac.append(a[i][0])
    if (a[i][1] == "WA") and (not (a[i][0] in set(ac))):
        ans2 += 1
for i in range(m):
    if (not(a[i][0] in set(ac))) and a[i][1] == "WA":
        ans2 -= 1
ans1 = len(set(ac))

print(ans1,end = " ")
print(ans2)

Submission status: Time Limit Exceeded

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

ACnumber=[]
for i in range(M):
    if pS[i][1]=='AC':
        ACnumber.append(pS[i][0])
ACnumber=list(set(ACnumber))
ACnumber.sort()
ansAC=len(ACnumber)

ansWA=0
for i in range(ansAC):
    for j in range(M):
        if pS[j]==[ACnumber[i],'WA']:
            ansWA+=1
        if pS[j]==[ACnumber[i],'AC']:
            break
    else:
        continue

ans=[ansAC,ansWA]
print(*ans)

Submission status: Time Limit Exceeded

Solution code:
# AC を 1回以上出した各問題において、初めて AC を出すまでに出した WA の数
n,m = map(int, input().split())
p = []
s = []
wacounter = 0
walist = []
for i in range(0, n):
  walist.append(0)
point = 0
point_to_num = [] #acをとった問題
for i in range(0, m):
  list = input().split()
  p.append(int(list[0]))
  s.append(list[1])
 
for i in range(0, m):
  if s[i] == "AC" and not p[i] in point_to_num: #もし正解で、今までにその問題に正解していなかったら
    point_to_num.append(p[i]) #正解リストにその問題を追加
    #point = point + 1 正解ポイントをあげる
  elif s[i] == "WA" and not p[i] in point_to_num: #不正解かつ今まで正解を出したことがない
      wacounter += 1
      walist[p[i]-1] += 1
for i in range(0, n):
  if not i + 1 in point_to_num:#もし正解してない番号があったら、walistからwacounterをとってきてひく
    wacounter = wacounter - walist[i]
print(len(point_to_num), wacounter)

Submission status: Time Limit Exceeded

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


def main():
    N, M = map(int, input().split())
    SP = [tuple(input().split()) for i in range(M)]
    wa_num = 0
    wa_num_temp = {}
    ac_num = 0
    ansed = []
    ansed_append = ansed.append
    for sp in SP:
        if sp[0] in ansed:
            continue
        if sp[0] not in wa_num_temp:
            wa_num_temp[sp[0]] = 0
        if sp[1] == "WA" and sp[0] not in ansed:
            wa_num_temp[sp[0]] += 1
        elif sp[1] == "AC" and sp[0] not in ansed:
            ac_num += 1
            wa_num += wa_num_temp[sp[0]]
            ansed_append(sp[0])

    print(ac_num, wa_num)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

def get_unique_list(seq):
    seen = []
    return [x for x in seq if x not in seen and not seen.append(x)]
wa_sum = 0
ac_uq_list = []

ac_uq_list = get_unique_list([P[i] for i in range(M) if P[i][1] == "AC"])


for ac in ac_uq_list:
    c_list = [P[i] for i in range(len(P)) if P[i][0] == ac[0]]
    wa_sum += len(c_list[:c_list.index(ac)])

print(str(len(ac_uq_list)) + " " + str(wa_sum))

Submission status: Time Limit Exceeded

Solution code:
n, m = list(map(int, input().split()))
results = []
if m:
    results = [input().split() for _ in range(m)]
ac = []
wa = {}
cnt_ac = 0
cnt_wa = 0
for res in results:
    if res[1] == "AC":
        if not res[0] in ac:
            cnt_ac += 1
            ac.append(res[0])
            if res[0] in wa.keys():
                cnt_wa += wa[res[0]]
    else:
        if res[0] in wa.keys():
            wa[res[0]] += 1
        else:
            wa[res[0]] = 1
print(cnt_ac, cnt_wa)

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
wa, ac = 0, 0
memo = []
hi = n
if n < m:
    hi = m
b = [0] * hi
table = [input().split() for x in range(m)]
for x in range(m):
    if table[x][1] == 'AC' and not table[x][0] in memo:
        memo.append(table[x][0])
        ac += 1
        wa += b[int(table[x][0])]
    elif table[x][1] == 'WA':
        b[int(table[x][0])] += 1
print(ac, wa)

Submission status: Time Limit Exceeded

Solution code:
# N問出題, M回提出
N, M = map(int, input().split())

p_S_list = []

WA = 'WA'
AC = 'AC'

first_AC_index_list = []
AC_set = set([])

for j in range(M):
    p, S = input().split()
    int_p = int(p)
    p_S_list.append([int_p, S])

    if S == AC and (int_p not in AC_set):
        first_AC_index_list.append([j, int_p])
    
    if S == AC:
        AC_set.add(int_p)

count_AC = len(first_AC_index_list)
count_WA = 0


for i_list in first_AC_index_list:
    count_WA += p_S_list[:i_list[0]].count([i_list[1], WA])

ans = str(count_AC) + ' ' + str(count_WA)

print(ans)

Submission status: Time Limit Exceeded

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


c = 0
a = 0

t = [0]*(n+1)

temp = []


for i in range(m):
    s = input().split()
    if s[0] not in temp:
        if s[1] == 'AC':
            a += 1
            c += t[int(s[0])]
            temp += [s[0]]
        elif s[1] == 'WA':
            t[int(s[0])] += 1
    elif len(temp) == n:
        break

print(a, c)

Submission status: Time Limit Exceeded

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


def main():
    N, M = map(int, input().split())
    SP = [tuple(input().split()) for i in range(M)]
    wa_num = 0
    wa_num_temp = {}
    ac_num = 0
    ansed = []
    for sp in SP:
        if sp[0] in ansed:
            continue
        if sp[0] not in wa_num_temp:
            wa_num_temp[sp[0]] = 0
        if sp[1] == "WA" and sp[0] not in ansed:
            wa_num_temp[sp[0]] += 1
        elif sp[1] == "AC" and sp[0] not in ansed:
            ac_num += 1
            wa_num += wa_num_temp[sp[0]]
            ansed.append(sp[0])

    print(ac_num, wa_num)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int, input().split())
al = []
for i in range(M):
  al.append(tuple(input().split()))
al_a = [i[0] for i in al if i[1] == 'AC']
al_a = list(set(al_a))
r1 = len(al_a)
r2 = 0
for j in al:
  if j[0] in al_a and j[1] == 'AC':
    al_a.remove(j[0])
  elif j[1] == 'WA' and j[0] in al_a:
    r2 += 1
    
print(r1 ,r2)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
# Your code here!
inf = [ int(a) for a in input().rstrip().split(' ')]
# results = [[a for a in input().rstrip().split(' ')] for i in range(inf[1])]

solved = []
pennalty = {}

for i in range(inf[1]):
    sub = [a for a in input().rstrip().split(' ')]
    if not(sub[0] in solved):
        if sub[1] == 'AC':
            solved.append(sub[0])
        else:
            if (sub[0] in pennalty):
                pennalty[sub[0]] += 1
            else:
                pennalty[sub[0]] = 1

pena = 0
for key in solved:
    if key in pennalty:
        pena += pennalty[key]
            
print('{} {}'.format(len(solved), pena))

Submission status: Time Limit Exceeded

Solution code:
s=list(map(int,input().split()))
AC=[]
WA={}
w=0
for b in range(s[1]):
  t=input().split()
  a=t[0]
  if a not in AC:
    if t[1]=="AC":
      w+=WA.get(a,0)
      AC.append(a)
    else:
      if a in WA:
        WA[a]=WA[a]+1
      else:
        WA[a]=1
print(str(len(AC))+" "+str(w))

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
cnt = 0
wa = 0
ac = 0
sumi = []
hi = n
if n < m:
    hi = m
b = [0] * hi
table = [input().split() for x in range(m)]
for x in range(m):
    if ac == n:
        break
    if table[x][1] == 'WA':
        b[int(table[x][0])] += 1
    elif table[x][1] == 'AC' and not table[x][0] in sumi:
        sumi.append(table[x][0])
        ac += 1
        wa += b[int(table[x][0])]

print(ac, wa)

Submission status: Time Limit Exceeded

Solution code:

import numpy as np
N,M=map(int, input().split())
A = np.array([input().split() for i in range(M)])


if M>0:
    P=A[:,0]
    S=A[:,1]
    wa={}
    ac=[]
    key=[]
    for i in range(M):
        if P[i] not in ac:
            if P[i] not in key:
                key.append(P[i])
                wa[P[i]]=0
                
            if S[i]=="WA":
                wa[P[i]]+=1
            else:
                ac.append(P[i])
    ans=0
    for i in key:
        if i in ac:
            ans+=wa[i]
    print(len(ac),ans)
else:
    print(0,0)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:

class Result:
    def __init__(self, num, result):
        self.num = num
        self.result = result


def WelcomeTo():
    N, M = map(int, input().split())
    resultlist = []
    WAcountlist = []
    for _ in range(M):
        templist = input().split()
        resultlist.append(Result(int(templist[0]), templist[1]))
    for _ in range(0, N + 1):
        WAcountlist.append(0)

    AClist = []
    WAcount = 0
    for lst in resultlist:
        if lst.num in AClist:continue

        if lst.result == 'AC':
            AClist.append(lst.num)
            WAcount += WAcountlist[lst.num]
        else:
            WAcountlist[lst.num] += 1


    print('{} {}'.format(len(AClist), WAcount))


WelcomeTo()

Submission status: Time Limit Exceeded

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

ACed = set()
for p, s in submit:
    if p in ACed:
        continue
    else:
        if s == "AC":
            ACed.add(p)

A = len(ACed)
P = 0

for i in range(1, n+1):
    if i in ACed:
        count = 0
        for p, s in submit:
            if p == i and s == "WA":
                count += 1
            elif p != i:
                continue
            else:
                break
        P += count

print(A, P)

Submission status: Time Limit Exceeded

Solution code:
mondai, kaitou = map(int, input().split())

# 問題ごとの
clearNo = []
# 問題ごとのWrong
wrong = {}
cleard = 0
pena = 0
# 解答数分繰り返す
for i in range(kaitou):
    qNo, kaitou = input().split()
    qNo = qNo
    if qNo in clearNo:
        continue
    else:
        if kaitou == 'WA':
            if qNo in wrong:
                wrong[qNo] += 1
            else:
                wrong[qNo] = 1
        else:
            cleard += 1
            if qNo in wrong:
                pena += wrong[qNo]
            clearNo.append(qNo)

print(str(cleard) + ' ' + str(pena))

Submission status: Time Limit Exceeded

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


c = 0
a = 0

t = [0]*(n+1)

temp = []


for i in range(m):
    s = input().split()
    if s[0] not in temp:
        if s[1] == 'AC':
            a += 1
            c += t[int(s[0])]
            temp += [s[0]]
        elif s[1] == 'WA':
            t[int(s[0])] += 1

# for i in range(m):
#     s = input().split()
#     if s[0] not in temp:
#         if s[1] == 'AC':
#             a += 1
#             c += t
#             t = 0
#             temp += [s[0]]
#         elif s[1] == 'WA':
#             t += 1

print(a, c)

Submission status: Time Limit Exceeded

Solution code:
n,m = map(int, input().split())
l=[]
for _ in range (0,m):
    l.append(input())
if m == 0:
    print ("0 0")
    exit (0)

wa_total=0
ac_total=0
ac_list=[]

for i in range(0,m):
    if str(l[i].split()[1]) == "AC":
        if not str(l[i].split()[0]) in ac_list:
            ac_list.append(str(l[i].split()[0]))
            ac_total+=1
            for j in range(0,i):
                if int(l[j].split()[0]) == int(l[i].split()[0]):
                    if str(l[j].split()[1]) == "WA":
                        wa_total+=1

print (ac_total, wa_total)