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 = map(int, input().split())
p = [0] * M
S = [''] * M
for i in range(M):
    p_i, S[i] = input().split()
    p[i] = int(p_i)

penal_ct = 0
ac_count = 0
# prev_ac_num = -1

ac_list = [False] * N

for i in range(M):
    if (not ac_list[p[i] - 1]) and S[i] == 'AC': # ACかつ今までにACしてない
        ac_list[p[i] - 1] = True
        ac_count += 1
        if i == 0:
            continue
        for j in range(i)[::-1]:
            if S[j] == 'WA' and p[j] == p[i]:
                penal_ct += 1

    if all(ac_list):
        break



# for i in range(1, M)[::-1]:
#     if S[i] == 'AC' and p[i] != prev_ac_num:
#         prob_num = prev_ac_num = p[i]
#         ac_count += 1
#         for j in range(i)[::-1]:
#             if p[j] == prob_num and S[j] == 'WA':
#                 penal_ct += 1
print(ac_count, penal_ct)

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 jud=="WA":
    if num not in WAs.keys():
      WAs[num]=1
    else:
      WAs[num]+=1
  else:
    if num not in ACs:
      ACs.append(num)
      AC+=1
      if num in WAs.keys():
        pena+=WAs[num]




"""
for i in range(M):
  if nums[i] in ACs:
    continue
  else:
    if jud[i]=="WA":
      WAs[nums[i]]+=1
    else:
      AC+=1
      ACs.append(nums[i])
      pena+=WAs[nums[i]]
"""      
print(AC, pena)

Submission status: Time Limit Exceeded

Solution code:
from operator import itemgetter

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

good=0
bad=0
  
for j in range(1,n+1):
  index=[i for i, x in enumerate(q) if x == j]
  #print(index)
  qset=[]
  for k in index:
    qset.append(ac[k])
  #print(qset)
  try:
    firstac=qset.index("AC")
  except ValueError:
    continue
  #print(firstac)
  good+=1
  bad+=firstac
print(good,bad)

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
p = []
s = []
ac_list = []
wa_list = [0] * n
wa_count = 0
for i in range(m):
    input_p, input_s = input().split()
    if input_p not in ac_list:
        if input_s == 'AC':
            ac_list.append(input_p)
            wa_count += wa_list[int(input_p)-1]
        else:
            wa_list[int(input_p)-1] += 1

        
print(len(ac_list), wa_count)

Submission status: Time Limit Exceeded

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

ans = [0, 0]
done = []
miss = {}

for i in range(M):
  if li[i][0] in done:
    continue
  if li[i][1] == "AC":
    ans[0] += 1
    done.append(li[i][0])
    if li[i][0] in miss:
      ans[1] += 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(ans[0],ans[1])

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
x = []
y = []
ac = 0
wa = 0
for i in range(m):
   p, s = map(str, input().split())
   p = int(p)
   if (s == 'AC' and [p, s] not in y):
      y.append([p, s])
      x.append(s)
   elif (s == 'WA' and [p, 'AC'] not in y):
      y.append([p, s])
      x.append(s)
print(x.count('AC'), x.count('WA'))

Submission status: Time Limit Exceeded

Solution code:
toisuu, subsuu = [int(x) for x  in input().split()]
wa_subs = {}
ac_list = []

def check_inside(toi, res):
    if res == "AC":
        if toi in ac_list:
            return 
        else:
            ac_list.append(toi)
            return
    elif res == "WA":
        if toi in ac_list:
            return
        if toi not in ac_list:
            if toi not in wa_subs.keys():
                wa_subs[toi] = 1
            else:
                wa_subs[toi] += 1
            return 

if(subsuu == 0):
    print("0 0")
else:
    for i in range(subsuu):
        toi, res = input().split()
        check_inside(toi, res)
    all_ac = len(ac_list)
    all_wa = 0
    for key in ac_list:
        if key in wa_subs.keys():
            all_wa += wa_subs[key]

    print(str(all_ac) + " " + str(all_wa))

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 = {key[0]:0 for key in results }

for sub in results:
    if not(sub[0] in solved):
        if sub[1] == 'AC':
            solved.append(sub[0])
        else:
            pennalty[sub[0]] += 1

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

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split(' '))
ans = []
c = 0
p = {} 
p_ = 0
for i in range(m):
  arr = list( input().split(' '))
  if ans.count(arr[0]) == 0:
    if not arr[0] in p:
      p[arr[0]] = 0
    if arr[1] == 'WA':
      p[arr[0]] += 1
      
    if arr[1] == 'AC':
      c += 1
      ans.append(arr[0])
      p_ += p[arr[0]]
      
      
print(c,p_)

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
ps = [input().split() for _ in range(m)]
all_ac = set(int(p) for p,s in ps if s=='AC')
ac = []
pena_cnt = 0
ac_cnt = 0
for p,s in ps:
  p = int(p)
  if p in all_ac:
    if p not in ac:
      if s == 'WA':
        pena_cnt += 1
      else:
        ac_cnt += 1
        ac.append(p)
print(ac_cnt, pena_cnt)

Submission status: Time Limit Exceeded

Solution code:
N,M = map(int, input().split())
p = [0]*M
S = [0]*M
for i in range(M):
    p[i],S[i] = input().split()
import numpy as np
p = [int(s) for s in p]
p1 = np.array(p)
S1 = [1 if i=="AC" else 0 for i in S]
N1 = list(set(p1 * S1))


A = 0
B = 0
for i in range(M):
    if p1[i] in N1:
        A += S1[i]
        B += (1-S1[i])
        if S1[i] ==1:
            N1.remove(p1[i])
print(str(A)+" "+str(B))

Submission status: Time Limit Exceeded

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

WAs = [0] * n
ACs = []
penalty = 0
for submit in submits:
    p, s = submit
    p = int(p) - 1
    if p in ACs:
        continue
    if s == 'AC':
        penalty += WAs[p]
        ACs.append(p)
    else:
        WAs[p] += 1

print(len(ACs), penalty)

Submission status: Time Limit Exceeded

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

ans_list = []

for i in range(M):
    ans_list.append(input().split())

wa = 0
wa_tmp = 0
ac = 0
ac_tmp = 0
flag = 0
counter = 0

for n in range(1,N+1):
    if M == 0:
        break
    
    else:
        for t in range(counter, M):
            if ans_list[t][0] == str(n) and ans_list[t][1] == "AC":
                ac_tmp += 1
                counter += 1
                break

            elif ans_list[t][0] == str(n) and ans_list[t][1] == "WA":
                wa_tmp += 1
                counter += 1

            elif ans_list[t][0] == str(n+1):
                break
            

        if ac_tmp == 0:
            wa_tmp = 0
        
        wa += wa_tmp
        ac += ac_tmp

        wa_tmp = 0
        ac_tmp = 0


print(ac, wa)

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.keys():
            cnt_ac += 1
            ac[res[0]] = "AC"
            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 = list(map(int, input().split()))

x = []
for i in range(m):
  x.append(list(map(str,input().split())))
  
qu,ju = [],[]
AC,WA = 0,0
for i in x:
  qu.append(i[0])
  ju.append(i[1])

qu = list(set(qu))
for i in qu:
  x_target = [j for j in x if j[0] == i]
  
  #ACがあるかどうか、あった場合そのインデックス
  if [i,"AC"] in x_target:
    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())

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

def ans(dp, n, m) -> list:
    if m == 0:
        return [0, 0]

    answerd = []
    ac = 0
    wa = 0
    i = 0
    while i < m:
        q, r = input().split()
        q = int(q)

        if q in answerd:
            pass
        elif r == 'WA':
            dp[q] += 1
        elif r == 'AC':
            ac += 1
            wa += dp[q]
            answerd.append(q)

        i += 1

    return [ac, wa]

a = ans(dp, n, m)

print(*a)

Submission status: Time Limit Exceeded

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


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

    try:
        hist.index(p+'AC')
    except:
        hist.append(p+s)

ans = ''.join(hist)
ans_ac = ans.count('AC')
ans_wa = ans.count('WA')
print(ans_ac, ans_wa)

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)
  elif f=="WA" and d not in B:
    A.append(d)
for i in A:
  if i in B:
    wa+=1
print(ac,wa)

Submission status: Time Limit Exceeded

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

cor = pen = temp_pen = 0
temp_p = "0"
aclist=[]
res=[]
for _ in range(m):
  res.append(input().split())

for x in range(1, n+1):
  for result in res:
    if x == int(result[0]):
      if result[1] == "AC":
        cor += 1
        pen += temp_pen
        temp_pen = 0
        break
      else:
        temp_pen += 1
print(cor, pen)

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]

        #print(probs)
        #print(answs)
        ans_ac = 0
        ans_wa = 0

        probs_uniq = list(set(probs))
        #print(probs_uniq)
        for p in probs_uniq:
            #print(p)
            res = list(answs[probs == p])
            #print(res)
            if "AC\n" in res:
                ind_ac = res.index("AC\n")
                ans_ac += 1
                ans_wa += ind_ac
            else:
                pass
        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())

input_list = [input().split() for _ in range(m)]
total_count_wa, total_count_ac= 0, 0

for i in range(n):
    count_wa, count_ac, tmp_index= 0, 0, 0

    tmp_list = [ele[1] for ele in input_list if int(ele[0]) == i+1]
    if "AC" in tmp_list:
      tmp_index = tmp_list.index("AC")
      total_count_ac += 1
    total_count_wa += tmp_list[:tmp_index].count('WA')
    
print(total_count_ac, total_count_wa)

Submission status: Time Limit Exceeded

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

ac = 0
wa = 0

for n in range(N + 1):
  if n == 0:
    continue

  for index, i in enumerate(li):
    if int(i[0]) == n and i[1] == 'AC':
      ac += 1
      for indexs, x in enumerate(li):
        if indexs >= index:
          break
        if int(x[0]) == n and x[1] == 'WA':
          wa += 1
      break

print('{0} {1}'.format(ac, wa))

Submission status: Time Limit Exceeded

Solution code:
import sys
import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N, M = list(map(int, readline().split()))
p = []
S = []
for i in range(M):
    _p, s = readline().decode('utf-8').split()
    p.append(int(_p))
    S.append(s)
pset = list(set(p))

AC_cnt = 0
WA_cnt = 0

for i in pset:
    S_acc = [s for (s, p_) in zip(S, p) if p_ == i]
    if "AC" in S_acc:
        AC_cnt += 1
        idx = S_acc.index("AC")
        WA_cnt += idx

print(AC_cnt, WA_cnt)

Submission status: Time Limit Exceeded

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

ac_list = []
wa_list = [0] * n
wa_count = 0
for i in range(m):
    if p[i] not in ac_list:
        if s[i] == 'AC':
            ac_list.append(p[i])
            wa_count += wa_list[p[i]-1]
        else:
            wa_list[p[i]-1] += 1
        
print(len(ac_list), wa_count)

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 = []
for a in al:
  if a[1] == 'AC':
    al_a.append(a)
r1 = len(set(al_a))
al_a2 = [i[0] for i in al_a]
r2 = 0
for j in al:
  if j[1] == 'AC':
    al_a2 = [i for i in al_a2 if i != j[0]]
  elif j[1] == 'WA' and j[0] in al_a2:
    r2 += 1
  
  
print(int(r1) ,int(r2))

Submission status: Time Limit Exceeded

Solution code:
from operator import itemgetter
n,m=map(int,input().split())
wa=0
ac=0
ig=0
l=[(input().split()) for _ in range(m)]
l=sorted(l, key=itemgetter(0))

for t in l:
  c,r=t[0],t[1]
  if c == ig:
    continue
  
  if [c,'AC'] not in l:
    continue
  
  if r == 'WA':
    wa+=1
  elif r == 'AC':
    ac+=1
    ig=c
    
print(ac,wa)

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.keys():
            cnt_ac += 1
            ac[res[0]] = "AC"
            if res[0] in wa.keys():
                cnt_wa += wa[res[0]]
    elif not res[0] in ac.keys():
        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())
p = [0] * M
S = [''] * M
for i in range(M):
    p_i, S[i] = input().split()
    p[i] = int(p_i)

penal_ct = 0
ac_count = 0
# prev_ac_num = -1

ac_list = [False] * N

for i in range(M):
    if S[i] == 'AC' and (not ac_list[p[i] - 1]): # ACかつ今までにACしてない
        ac_list[p[i] - 1] = True
        ac_count += 1
        if i == 0:
            continue
        for j in range(i)[::-1]:
            if p[j] == p[i] and S[j] == 'WA':
                penal_ct += 1
    if all(ac_list):
        break



# for i in range(1, M)[::-1]:
#     if S[i] == 'AC' and p[i] != prev_ac_num:
#         prob_num = prev_ac_num = p[i]
#         ac_count += 1
#         for j in range(i)[::-1]:
#             if p[j] == prob_num and S[j] == 'WA':
#                 penal_ct += 1
print(ac_count, penal_ct)

Submission status: Time Limit Exceeded

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

n,m = map(int,input().split())

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

ac_list = []
wa_count_list = [0]*n
wa_count = 0
# ac_count = 0
for i in range(m):
    q = int(ps[i][0])
    if q in ac_list:
        pass
    else:
        if ps[i][1] == "AC":
            # ac_count += 1
            ac_list.append(int(ps[i][0]))
            wa_count += wa_count_list[q-1]
        else:
            wa_count_list[q-1] += 1

print(len(ac_list),wa_count)

Submission status: Time Limit Exceeded

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

ans_list = []

for i in range(M):
    ans_list.append(input().split())

wa = 0
wa_tmp = 0
ac = 0
ac_tmp = 0
flag = 0
conter = 0

for n in range(1,N+1):

    for t in range(M):
        if ans_list[t][0] == str(n) and ans_list[t][1] == "AC":
            ac_tmp += 1
            break

        elif ans_list[t][0] == str(n) and ans_list[t][1] == "WA":
            wa_tmp += 1

        elif ans_list[t][0] == str(n+1):
            break
        
    if ac_tmp == 0:
        wa_tmp = 0
    
    wa += wa_tmp
    ac += ac_tmp

    wa_tmp = 0
    ac_tmp = 0


print(ac, wa)

Submission status: Time Limit Exceeded

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

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

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

print (ac_total, wa_total)

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
cnt = 0
wa = 0
ac = 0
sumi = []
b = {}
table = [input().split() for x in range(m)]
for x in range(m):
    if table[x][1] == 'WA':
        try:
            b[table[x][0]] += 1
        except KeyError:
            b[table[x][0]] = 1
    if table[x][1] == 'AC' and not table[x][0] in sumi:
        sumi.append(table[x][0])
        ac += 1
        try:
            wa += b[table[x][0]]
        except KeyError:
            continue
print(ac, wa)

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 in ac:
        continue
    elif j == 'WA':
        if i in wa:
            wa[i] += 1
        else:
            wa[i] = 1
    else:
        if i in wa:
            pc += wa[i]
            ac.append(i)
        else:
            ac.append(i)

print(len(ac), pc)

Submission status: Time Limit Exceeded

Solution code:
def main():
    N, M = map(int, input().split())
    SP = [input().split() for i in range(M)]
    wa_num = 0
    wa_num_temp = {}
    ac_num = 0
    ansed = []
    for sp in SP:
        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())
l=[input().split() for _ in range(m)]
arr=[]
ac,wa=0,0

for r in l:
  p,s=int(r[0]),r[1]
  if s=='AC' and not ([p,'AC'] in arr):
    arr.append([p,s])
  elif s=='WA' and not ([p,'AC'] in arr):
    arr.append([p,s])
for r in arr:
  p,s=r
  if s=='WA' and [p,'AC'] in arr:
    wa+=1
  if s=='AC':
    ac+=1
    
print(ac,wa)

Submission status: Time Limit Exceeded

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

  for i in range(M) :
    tmp = input().split()
    p.append(int(tmp[0]))
    S.append(tmp[1])

  s = set(p)
  dict = {}
  for i in s :
    dict[i] = 0
  # print(dict)
  w_cnt = 0
  a_cnt = 0
  skip = []
  for i in range(M) :
    if p[i] not in skip :
      if S[i] == 'WA' :
        dict[p[i]] += 1
        continue
      else :
        a_cnt += 1
        w_cnt += dict[p[i]]
        skip.append(p[i])
        continue

  print(a_cnt, w_cnt)

if __name__ == '__main__' :
  main()

Submission status: Time Limit Exceeded

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

ac_list = []
p_set = set(p)
wa_list = [0] * n
wa_count = 0
for i in range(m):
    if p[i] not in ac_list:
        if s[i] == 'AC':
            ac_list.append(p[i])
            wa_count += wa_list[p[i]-1]
        else:
            wa_list[p[i]-1] += 1
    if len(ac_list) == len(p_set):
        break
        
print(len(ac_list), wa_count)

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
solved = []
wa_history = {}

for i in range(m):
    t1, t2 = input().split()
    if t1 in solved:
        pass
    elif t2 == 'WA':
        if t1 in wa_history:
            wa_history[t1] += 1
        else:
            wa_history[t1] = 1
    else: # t2 == AC
        solved.append(t1)

wa = 0
for key in wa_history.keys():
    if key in solved:
        wa += wa_history[key]

print(len(solved), wa)

Submission status: Time Limit Exceeded

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

ans = [0, 0]
done = []
miss = {}

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

print(ans[0],ans[1])

Submission status: Time Limit Exceeded

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

ansewered_question = set([l[i][0] for i in range(len(l))])

AC = 0
WA = 0
for i in ansewered_question:
    wa = 0
    for submit in l:
        if submit[0] == i:
            if submit[1] == "WA":
                wa += 1
            else:
                AC += 1
                WA += wa
                break

print(AC, WA)

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int, input().split())
p = [0] * M
S = [''] * M
for i in range(M):
    p_i, S[i] = input().split()
    p[i] = int(p_i)

penal_ct = 0
ac_count = 0
# prev_ac_num = -1

ac_list = [False] * N

for i in range(M):
    if S[i] == 'AC' and (not ac_list[p[i] - 1]): # ACかつ今までにACしてない
        ac_list[p[i] - 1] = True
        ac_count += 1
        if i == 0:
            continue
        for j in range(i)[::-1]:
            if p[j] == p[i] and S[j] == 'WA':
                penal_ct += 1



# for i in range(1, M)[::-1]:
#     if S[i] == 'AC' and p[i] != prev_ac_num:
#         prob_num = prev_ac_num = p[i]
#         ac_count += 1
#         for j in range(i)[::-1]:
#             if p[j] == prob_num and S[j] == 'WA':
#                 penal_ct += 1
print(ac_count, penal_ct)

Submission status: Time Limit Exceeded

Solution code:
n,m=map(int,input().split())
sl=[]
pl=[]
pena=0
ac=0
ac_p=[]
wa={}
for i in range(m):
    #p,s=map(str,input().split())
    li = input().split()
    p=int(li[0])
    s=li[1]
    #p=int(p)
    if s=="WA":
        wa[p]=wa.get(p,0)+1
    else:#もしACなら
        if not p in ac_p:
            ac+=1
            ac_p.append(p)
            pena+=wa.get(p,0)

print("{0} {1}".format(ac,pena))

Submission status: Time Limit Exceeded

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

n,m = map(int,input().split())

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

ac_list = []
wa_count_list = [0]*n
wa_count = 0
ac_count = 0
for i in range(m):
    q = int(ps[i][0])
    if q in ac_list:
        pass
    else:
        if ps[i][1] == "AC":
            ac_count += 1
            ac_list.append(int(ps[i][0]))
            wa_count += wa_count_list[q-1]
        else:
            wa_count_list[q-1] += 1

print(ac_count,wa_count)

Submission status: Time Limit Exceeded

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

AC =0
WA =0
dic = {}
for m in range(M):
    id, res = map(str,input().split())
    if id not in dic.keys():
        dic[id] = [res]
        if res == 'AC':
            AC += 1
    elif 'AC' not in dic[id]:
        dic[id].append(res)
        if res == 'AC':
            AC += 1
            if 'WA' in dic[id]:
                WA += dic[id].count('WA')


print(str(AC)+ ' '+str(WA))

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
#N = int(input())
N, M = map(int, input().split())
L = []
for _ in range(M) :
  L.append(list(map(str, input().split())))
#print(L)
  
D = {}
for i in range(M) :
  if L[i][0] not in D :
    D[L[i][0]] = L[i][1]
  else :
    if L[i][1] == "AC" :
      D[L[i][0]] = L[i][1]

ACsum = 0
ACList = []
for mykey, myvalue in D.items() :
  if myvalue == "AC" :
    ACsum += 1
    ACList += [mykey]
    
#print(ACList)
ACEnd = []
WAsum = 0
for i in range(M) :
  if L[i][0] in ACList and L[i][0] not in ACEnd :
    if L[i][1] != "AC" :
      WAsum += 1
    else :
      ACEnd.append(L[i][0])

print(str(ACsum) + " " + str(WAsum))

Submission status: Time Limit Exceeded

Solution code:
import sys
import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N, M = list(map(int, readline().split()))
p = []
S = []
for i in range(M):
    _p, s = readline().decode('utf-8').split()
    p.append(int(_p))
    S.append(s)
p = np.array(p)

AC_list = []
AC_cnt = 0
WA_cnt = 0

for i in range(1, N + 1):
    if i in p:
        S_acc = [s for (s, p_) in zip(S, p) if p_ == i]
        if "AC" in S_acc:
            AC_cnt += 1
            for s in S_acc:
                if s == "WA":
                    WA_cnt += 1
                else:
                    break
print(AC_cnt, WA_cnt)

Submission status: Time Limit Exceeded

Solution code:
toisuu, subsuu = [int(x) for x  in input().split()]
ac_subs = {}
wa_subs = {}
stoplist = []
if(subsuu == 0):
    print("0 0")
else:
    for i in range(subsuu):
        toi, res = input().split()
        if res == "AC":
            if toi not in ac_subs.keys():
                ac_subs[toi] = 1
            else:
                ac_subs[toi] += 1
            stoplist.append(toi)
        elif res == "WA":
            if toi not in stoplist:
                if toi not in wa_subs.keys():
                    wa_subs[toi] = 1
                else:
                    wa_subs[toi] += 1

    all_ac = 0
    all_wa = 0
    for key in ac_subs:
        all_ac += 1
        if key in wa_subs.keys():
            all_wa += wa_subs[key]

    print(str(all_ac) + " " + str(all_wa))

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split(' '))
submits = [list(input().split(' ')) for i in range(m)]
acs = set([submit[0] for submit in submits if submit[1]=='AC'])

WA_nums = dict()
ACs = []
penalty = 0
for submit in submits:
    p, s = submit
    if not p in acs:
        continue
    elif p in ACs:
        continue
    if s == 'AC':
        if p in WA_nums:
            penalty += WA_nums[p]
        ACs.append(p)
    else:
        if p in WA_nums:
            WA_nums[p] += 1
        else:
            WA_nums[p] = 1

print(len(acs), penalty)

Submission status: Time Limit Exceeded

Solution code:
def main():
  AC = 0
  WA = 0
  
  N,M = map(int, input().split())
  
  Q = [] 
  
  P = [0] * M
  S = [0] * M
  
  for i in range(M):
    _p, _s = input().split()
    P[i] = int(_p)
    S[i] = _s
    
  for i,s in enumerate(S):
    if s == 'AC' and P[i] not in Q:
      AC += 1
      for j in range(i):
        if P[j] == P[i] and S[j] == 'WA':
          WA += 1
      Q.append(P[i])
  
  print(AC, WA)
  return 0

if __name__ == "__main__":
  main()

Submission status: Time Limit Exceeded

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

ac_list = []
wa_list = [0] * n
wa_count = 0
for i in range(m):
    if p[i] not in ac_list:
        if s[i] == 'AC':
            ac_list.append(p[i])
            wa_count += wa_list[p[i]-1]
        else:
            wa_list[p[i]-1] += 1
print(len(ac_list), wa_count)

Submission status: Time Limit Exceeded

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

y = []
ac = 0
wa = 0
for p, s in x:
   if (s == 'AC' and [p, s] not in y):
      y.append([p, s])
      ac += 1
   elif (s == 'WA' and [p, 'AC'] not in y):
      y.append([p, s])
      wa += 1
print(ac, wa)

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" and not res[0] in ac.keys():
        cnt_ac += 1
        ac[res[0]] = "AC"
        if res[0] in wa.keys():
            cnt_wa += wa[res[0]]
    elif not res[0] in ac.keys():
        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回提出
N, M = map(int, input().split())

p_S_list = []

WA = 'WA'
AC = 'AC'

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

count_AC = 0
count_WA = 0
for i in range(1, N + 1):
    # i問目の問題について考える
    if [i, AC] in p_S_list:
        count_AC += 1

        first_AC_index = p_S_list.index([i, AC])

        count_WA += p_S_list[:first_AC_index].count([i, WA])

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

print(ans)

Submission status: Time Limit Exceeded

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

ps = []
for _ in range(m):
    p, s = input().split(" ")
    ps.append([int(p), s])


def is_ok(num, ps_list):
    for p,s in ps_list:
        if p == num and s == "AC":
            return True
    return False


ans_num = 0
p_num = 0
for num in range(1, n + 1):
    if is_ok(num, ps):
        ans_num += 1
        wrong_list = list(filter(lambda x: x[0] == num, ps))
        for _, s in wrong_list:
            if s == "WA":
                p_num += 1
            else:
                break
print(ans_num, p_num)