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:
#ABC 151 
N,M = map(int,input().split())
p = []
for i in range(M):
    p.append([str(j) for j in input().split()])
    
pena = 0
acc = 0
acc_list =[]
for m in range(M):
    for i in set([i[0] for i in p]):
        if i not in acc_list:
            if p[m][1]=='AC':
                acc_list.append(i)
                acc+=1
            else:
                pena+=1
print(str(acc) +" "+str(pena))

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
L = []
AC = []
cnt = 0
for _ in range(m):
    p, s = input().split()
    if p in AC:
        continue
    else:
        if s == 'AC':
            AC.append(p)
            cnt += L.count(p)
        else:
            L.append(p)
print(len(AC), cnt)

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int, input().split())
A = {}
ac = []
total=0
count = 0
for i in range(M):
    p, s = map(str, input().split())
    if int(p) not in ac:
        if int(p) not in A.keys(): 
            if int(p) >0 and int(p) <=N :
                if s == "WA":
                    A[int(p)] =1
                elif s =="AC":
                    A[int(p)] =0
                    ac.append(int(p))
                    count += 1
        elif int(p) in A.keys():
            if s == "WA":
                    A[int(p)] +=1
            elif s =="AC":
                    A[int(p)] +=0
                    ac.append(int(p))
                    count += 1
                    total += A[int(p)]

print(count,total)

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int, input().split())
A = {}
ac = []
for i in range(M):
    p, s = map(str, input().split())
    if int(p) not in ac:
        if int(p) not in A.keys(): 
            if int(p) >0 and int(p) <=N :
                if s == "WA":
                    A[int(p)] =1
                elif s =="AC":
                    A[int(p)] =0
                    ac.append(int(p))
        elif int(p) in A.keys():
            if s == "WA":
                    A[int(p)] +=1
            elif s =="AC":
                    A[int(p)] +=0
                    ac.append(int(p))
        
total=0
count = 0
for k,v in A.items():
    if k in ac:
        count += 1
        total += v
print(count,total)

Submission status: Time Limit Exceeded

Solution code:
n,m=map(int, input().split())
h = [list(map(str,input().split())) for _ in range(m)]
# print(h)
for i in range(m):
    h[i][0] = int(h[i][0])
l=[]
penalty = 0
import numpy as np
p = np.zeros(n)
for i in range(m):
    if h[i][0] not in l:
        if h[i][1] == 'AC':
            l.append(h[i][0])
            penalty += p[h[i][0]-1]
        else:
            p[h[i][0]-1] += 1
ansnum = len(l)

# for i in l:
#     penalty += p[i-1]

print(ansnum,int(penalty))

Submission status: Time Limit Exceeded

Solution code:
n,m=map(int, input().split())
h = [list(map(str,input().split())) for _ in range(m)]
# print(h)
for i in range(m):
    h[i][0] = int(h[i][0])
l=[]
import numpy as np
p = np.zeros(n)
for i in range(m):
    if h[i][0] not in l:
        if h[i][1] == 'AC':
            l.append(h[i][0])
        else:
            p[h[i][0]-1] += 1
ansnum = len(l)
penalty = 0
for i in l:
    penalty += p[i-1]

print(ansnum,int(penalty))

Submission status: Time Limit Exceeded

Solution code:
il1 = [int(k) for k in input().split()]
N = il1[0]
M = il1[1]
answered = []
result = [0, 0]
was = [0]
was = was * (N+1)

for i in range(M):
    il = input().split()
    p = int(il[0])
    s = il[1]
    if (p in answered):
        pass
    else:
        if (s == 'AC'):
            result[0] = result[0]+1
            answered.append(p)
            result[1] = result[1]+was[p]
        else:
            was[p] = was[p] + 1

print(str(result[0])+" "+str(result[1]))

Submission status: Time Limit Exceeded

Solution code:
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n,m=map(int, input().split())
    if m==0:
        print(0,0)
    else:
        ansl=[[] for i in range(n)]
        for i in range(m):
            p,s=input().split()
            p=int(p)
            if 'AC' not in ansl[p-1]:
                ansl[p-1].append(s)
        wacnt=0
        accnt=0
        for i in range(n):
            if 'AC' in ansl[i]:
                accnt+=1
                wacnt+=len(ansl[i])-1
        print(accnt,wacnt)
resolve()

Submission status: Time Limit Exceeded

Solution code:
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n,m=map(int, input().split())
    if m==0:
        print(0,0)
    else:
        ansl=[[] for i in range(n)]
        for i in range(m):
            p,s=input().split()
            p=int(p)
            if 'AC' not in ansl[p-1]:
                ansl[p-1].append(s)
        wacnt=0
        accnt=0
        for i in range(n):
            if 'AC' in ansl[i]:
                accnt+=1
                wacnt+=len(ansl[i])-1
        print(accnt,wacnt)

resolve()

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N, M = map(int, input().split())
accepted = np.array([0] * N, dtype=np.int32)
penalties = np.array([0] * N, dtype=np.int32)
for _ in range(M):
    p, ac = [func(c) for func, c in zip([lambda n: int(n) - 1, lambda s: s == "AC"], input().split())]
    accepted[p] |= ac
    penalties[p] += not accepted[p]
print(sum(accepted), accepted.dot(penalties))

Submission status: Time Limit Exceeded

Solution code:
N, M = list(map(int, input().split()))
readline = []
ACs = []
ans1 = 0
ans2 = 0

for i in range (M):
    readline.append(input().split())
    x = readline[i][0]

    if (readline[i][1] == 'AC' and ACs.count(x) == 0):
        ACs.append(x)
        ans1 += 1
        for j in range (i):
            if (readline[j][0] == x):
                ans2 += 1

print(str(ans1) + ' ' + str(ans2))

Submission status: Time Limit Exceeded

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

for i in range(m):
    subs[int(l[i][0])-1].append(l[i][1])

ac, p = 0, 0

for j in range(n):
    for k in range(len(subs[j])):
        if subs[j][k] == 'AC':
            ac += 1
        
        if 'AC' in subs[j]:
            if subs[j][k] == 'WA':
                p += 1
            else:
                break

print(ac, p)

Submission status: Time Limit Exceeded

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

for i in range(m):
    subs[int(l[i][0])-1].append(l[i][1])

ac, p = 0, 0
for j in range(n):
    for k in range(len(subs[j])):
        if subs[j][k] == 'AC':
            ac += 1
        
        if 'AC' in subs[j]:
            if subs[j][k] == 'WA':
                p += 1
            else:
                break

print(ac, p)

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
s = list(tuple(input().split()) for _ in range(m))
t = [i for i in set(s) if i[1] == 'AC']
ac = 0
pe = 0
for i in t:
        for j in s:
            if  i == j:
                pe += s[: s.index(i)].count((i[0], 'WA'))
                ac += 1
                break
print(ac, pe)

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
s = list(tuple(input().split()) for _ in range(m))
t = [i for i in set(s) if i[1] == 'AC']
ac = len([k for k in t if k[1] == 'AC'])
pe = 0
for i in t:
        for j in s:
            if  i == j:
                pe += s[: s.index(i)].count((i[0], 'WA'))
                break
print(ac, pe)

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
s = list(tuple(input().split()) for _ in range(m))
t = set(s)
ac = len([k for k in t if k[1] == 'AC'])
pe = 0
for i in t:
    if i[1] == 'AC':
        for j in s:
            if  i == j:
                pe += s[: s.index(i)].count((i[0], 'WA'))
                break
    else:
        pass
print(ac, pe)

Submission status: Time Limit Exceeded

Solution code:
N,M=map(int,input().split())
words=[[] for _ in range(N)]
for _ in range(M):
    p,S=input().split()
    p=int(p)-1
    words[p].append(S)
AC=0
WA=0
for a in words:
    for b in a:
        if a.count('WA') != 0 and len(a) == a.count('WA'):
            break
        if b=='AC':
            AC+=1
            break
        elif b=='WA':
            WA+=1
print(AC,WA)

Submission status: Time Limit Exceeded

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

for i in range(m):
    if PS[i][1] == "AC":
        p = PS[i][0]
        if p not in AC:
            WA += PS[:i+1].count([p,"WA"])
            AC.append(p)

print(len(AC),WA)

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
n,m= map(int,input().split())

B = []
C = [0]*n
ans = 0
pna = 0
for i in range(m):
    a,b= input().split()
    if ans == n:
        break
    if b=="AC":
        if a not in B :
            B.append(a)
            ans += 1
            pna += C[int(a)-1]
    else:
        C[int(a)-1] += 1 
print(ans,pna)

Submission status: Time Limit Exceeded

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

B = []
C = [0]*n
ans = 0
pna = 0
for i in range(m):
    A = list(map(str,input().split()))
    if ans == n:
        break
    if A[0] not in B:
        if A[1]=="AC" :
            B.append(A[0])
            ans += 1
            pna += C[int(A[0])-1]
        else:
      	  C[int(A[0])-1] += 1 
print(ans,pna)

Submission status: Time Limit Exceeded

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

B = []
C = [0]*n
ans = 0
pna = 0
for i in range(m):
    a,b= map(str,input().split())
    if ans == n:
        break
    if b=="AC":
        if a not in B :
            B.append(a)
            ans += 1
            pna += C[int(a)-1]
    else:
        C[int(a)-1] += 1 
print(ans,pna)

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
n,m= map(int,input().split())

B = []
C = [0]*n
ans = 0
pna = 0
for i in range(m):
    A = list(map(str,input().split()))
    if A[0] not in B:
        if A[1]=="AC" :
            B.append(A[0])
            ans += 1
            pna += C[int(A[0])-1]
        else:
      	  C[int(A[0])-1] += 1 
print(ans,pna)

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
n,m= map(int,input().split())

B = []
C = [0]*n
ans = 0
pna = 0
for i in range(m):
    A = list(map(str,input().split()))
    if A[1]=="AC":
        if A[0] not in B :
            B.append(A[0])
            ans += 1
            pna += C[int(A[0])-1]
    else:
        C[int(A[0])-1] += 1 
print(ans,pna)

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
n,m= map(int,input().split())

B = []
C = [0]*n
ans = 0
pna = 0
for i in range(m):
    A = list(map(str,input().split()))
    if ans == n:
        break
    if A[1]=="AC":
        if A[0] not in B :
            B.append(A[0])
            ans += 1
            pna += C[int(A[0])-1]
    if A[1]=="WA"  :
        C[int(A[0])-1] += 1 
print(ans,pna)

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
n,m= map(int,input().split())

B = []
C = [0]*n
ans = 0
pna = 0
for i in range(m):
    A = list(map(str,input().split()))
    if A[1]=="AC":
        if A[0] not in B :
            B.append(A[0])
            ans += 1
            pna += C[int(A[0])-1]
    if A[1]=="WA"  :
        C[int(A[0])-1] += 1 
print(ans,pna)

Submission status: Time Limit Exceeded

Solution code:
n,m= map(int,input().split())
B = []
C = []
ans = 0
pna = 0
for i in range(m):
    A = list(map(str,input().split()))
    if A[1]=="AC":
        if A[0] not in B :
            B.append(A[0])
            ans += 1
            pna += C.count(A[0])
    if A[1]=="WA"  :
        C.append(A[0])
print(ans,pna)

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
n,m= map(int,input().split())
B = []
C = []
ans = 0
pna = 0
for i in range(m):
    A = list(map(str,input().split()))
    if A[1]=="AC":
        if A[0] not in B :
            B.append(A[0])
            ans += 1
            pna += C.count(A[0])
    if A[1]=="WA"  :
        C.append(A[0])
print(ans,pna)

Submission status: Time Limit Exceeded

Solution code:
n,m= map(int,input().split())
A =[list(map(str,input().split())) for _ in range(m)]
B = []
C = []
ans = 0
pna = 0
for i in range(m):
    if A[i][1]=="AC":
        if A[i][0] not in B :
            B.append(A[i][0])
            ans += 1
            pna += C.count(A[i][0])
    if A[i][1]=="WA"  :
        C.append(A[i][0])
print(ans,pna)

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
n,m= map(int,input().split())
A =[list(map(str,input().split())) for _ in range(m)]
B = []
C = []
ans = 0
pna = 0
for i in range(m):
    if A[i][1]=="AC":
        if A[i][0] not in B :
            B.append(A[i][0])
            ans += 1
            pna += C.count(A[i][0])
    if A[i][1]=="WA"  :
        C.append(A[i][0])
print(ans,pna)

Submission status: Time Limit Exceeded

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

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

correct_ans_num = 0
penalty = 0
for i in range(1, N + 1):
  results = [result[1] for result in submit_list if int(result[0]) == i]
  
  if not 'AC' in results: continue
  
  first_AC_idx = results.index('AC')
  correct_ans_num += 1
  penalty += first_AC_idx
  
print('{} {}'.format(correct_ans_num, penalty))

Submission status: Time Limit Exceeded

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

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

correct_ans_num = 0
penalty = 0
for i in range(1, N + 1):
  results = [result[1] for result in submit_list if int(result[0]) == i]
  
  if not 'AC' in results: continue
  
  first_AC_idx = results.index('AC')
  correct_ans_num += 1
  penalty += results[:first_AC_idx].count('WA')
  
print('{} {}'.format(correct_ans_num, penalty))

Submission status: Time Limit Exceeded

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

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

correct_ans_num = 0
penalty = 0
for i in range(1, N + 1):
  results = [result[1] for result in submit_list if result[0] == i]
  
  if not 'AC' in results: continue
  
  first_AC_idx = results.index('AC')
  correct_ans_num += 1
  penalty += results[:first_AC_idx].count('WA')
  
print('{} {}'.format(correct_ans_num, penalty))

Submission status: Time Limit Exceeded

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

for i in range(1,N+1):
  count_wa = 0
  for j in range(M):
    if int(P[j]) == i:
      if S[j] == 'WA':
        count_wa += 1
      else:
        wa += count_wa
        ac += 1
        break
print(ac,wa)

Submission status: Time Limit Exceeded

Solution code:
N, M = (int(x) for x in input().split())
p = [0]*M
S = ["a"]*M
wa = 0
wapre = 0
ac = 0
index = []
for i in range(M):
  p[i], S[i] = (x for x in input().split())
  if S[i] == "AC" and p[i] not in index:
    ac = ac + 1
    index.append(p[i])
  elif S[i] == "WA" and p[i] not in index:
    wa = wa + 1
for i in range(M):
  if p[i] not in index:
    wa = wa-1
print(ac, wa)

Submission status: Time Limit Exceeded

Solution code:
N, M = (int(x) for x in input().split())
p = [0]*M
S = ["a"]*M
wa = 0
wapre = 0
ac = 0
index = []
for i in range(M):
  p[i], S[i] = (x for x in input().split())
for i in range(M):
  if S[i] == "AC" and p[i] not in index:
    ac = ac + 1
    index.append(p[i])
  elif S[i] == "WA" and p[i] not in index:
    wa = wa + 1
for i in range(M):
  if p[i] not in index:
    wa = wa-1
print(ac, wa)

Submission status: Time Limit Exceeded

Solution code:
n,m=map(int,input().split())
collect=[]
pen=[]
sum=0
for i in range(m):
  p,s=input().split()
  if p not in collect:
    if s=='WA':
      pen.append(p)
    else:
      collect.append(p)
      sum=sum+pen.count(p)
print(len(collect),sum)

Submission status: Time Limit Exceeded

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

# print(p_list)

AC_count = 0
WA_count = 0

AC_question = []
WA_question = {}

for p_list in p_lists:
    if p_list[0] in AC_question:
        continue

    if p_list[1] == 'AC':
        AC_count += 1

        if p_list[0] in WA_question:
            WA_count += WA_question[p_list[0]]

        AC_question.append(p_list[0])

    if p_list[1] == 'WA':
        if p_list[0] in WA_question:
            WA_question[p_list[0]] = WA_question[p_list[0]] + 1
        else:
            WA_question[p_list[0]] = 1

print(AC_count, WA_count)

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int, input().split())
solve_problem = []
d = {i: 0 for i in range(1, N+1)}
ans = 0
penalty = 0
for i in range(M):
    p, S = input().split()
    if S == 'AC' and p not in solve_problem:
        solve_problem.append(p)
        ans += 1
        penalty += d[int(p)]
    if S == 'WA':
        d[int(p)] += 1

print('{} {}'.format(ans, penalty))

Submission status: Time Limit Exceeded

Solution code:
import sys
from collections import deque
input = sys.stdin.readline

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

sl = deque()
ans = 0
pen = 0
WA = [0 for _ in range(N)]
for i in range(M):
    p, S = input().split()
    if p in sl:
        continue

    if S == 'AC':
        ans += 1
        sl.append(p)
        pen += WA[int(p) - 1]
    else:
        WA[int(p) - 1] += 1

print(ans, pen)

Submission status: Time Limit Exceeded

Solution code:

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

data = {}
ps = []
ACs = []

num_ac = 0
num_wa = 0

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

    if not (p in ps):
        ps.append(p)
        data[p] = {'AC':0, 'WA':0}

    if S == 'AC' and data[p]['AC'] == 0:
        ACs.append(p)
        data[p]['AC'] += 1
        num_ac += 1
        num_wa += data[p]['WA']

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

print(num_ac, num_wa)

Submission status: Time Limit Exceeded

Solution code:

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

data = {}
ps = []
ACs = []
for i in range(M):
    p, S = input().split()
    p = int(p)

    if not (p in ps):
        ps.append(p)
        data[p] = {'AC':0, 'WA':0}

    if S == 'AC' and data[p]['AC'] ==0:
        ACs.append(p)
        data[p]['AC'] += 1

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

ans = 0
for p in ACs:
    ans += data[p]['WA']

print(len(ACs), ans)

Submission status: Time Limit Exceeded

Solution code:
p,q= input().split()
a,b =(int(p), int(q))
wa_count =0
ac_count = 0
pro_num = 0
input_list = [input().split() for i in range(b)]

for i in range(a+1):
    wa_count_f=0
    
    for j in range(b):
        if int(input_list[j][0]) == i:
            if input_list[j][1] == 'WA':
                wa_count_f += 1
            elif input_list[j][1] == 'AC':
                ac_count+= 1
                wa_count += wa_count_f
                break
            
print(ac_count, wa_count)

Submission status: Time Limit Exceeded

Solution code:
n,m=map(int,input().split())
if m==0:
  print(0,0)
else:
  p=[list(map(str,input().split())) for i in range(m)]
  q=[]
  s=[0]*n
  t=0
  for i in range(m):
    if p[i][1]=='AC' and  not p[i][0] in q:
      q.append(p[i][0])
      
      t+=s[int(p[i][0])-1]
      
      
    elif p[i][1]=="WA":
      if not p[i][0] in q:
        s[int(p[i][0])-1]+=1
        
  
  
  
  
  print(len(q),t)

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int,input().split())
pS = [tuple(input().split()) for _ in range(m)]
pena = 0
correct = 0
d = {}
for p, s in pS:
    if p in d.keys():
        d[p].append(s)
    else:
        d[p] = [s]
for key, values in d.items():
    cnt = 0
    for i in values:
        if i == "WA":
            cnt += 1
        else:
            correct += 1
            pena += cnt
            break
print(correct, pena)

Submission status: Time Limit Exceeded

Solution code:
def main():
    _, m = map(int, input().split())
    l = []
    w = a = 0
    D = {}
    for _ in range(m):
        n, j = input().split()
        if n not in D:
            D[n] = 0
        if n not in l:
            if j == "WA":
                D[n] += 1
            else:
                a += 1
                l += [n]
                w += D[n]
    print(a, w)

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
_, m = map(int, input().split())
if m == 0:
    print(0,0)
    exit()
l = []
w = a = 0
D = {}
for _ in range(m):
    n, j = input().split()
    if n not in D:
        D[n] = 0
    if n not in l:
        if j == "WA":
            D[n] += 1
        else:
            a += 1
            l += [n]
            w += D[n]
print(a, w)

Submission status: Time Limit Exceeded

Solution code:
_, m = map(int, input().split())
l = []
w = a = 0
D = {}
for _ in range(m):
    n, j = input().split()
    if n not in D:
        D[n] = 0
    if n not in l:
        if j == "WA":
            D[n] += 1
        else:
            a += 1
            l += [n]
            w += D[n]
print(a, w)

Submission status: Time Limit Exceeded

Solution code:
n,m = map(int,input().split())
from collections import defaultdict
wa_d = defaultdict(int)
wa = [0 for _ in range(n)]
ac = []
for x in [list(input().split()) for _ in range(m)]:
    if x[0] in ac:
        continue
    if x[1]=="AC":
        ac.append(x[0])
        wa[int(x[0])-1] = wa_d[int(x[0])-1]
    else:
        wa_d[int(x[0])-1] += 1
    
print(len(ac),sum(wa))

Submission status: Time Limit Exceeded

Solution code:
n,m = map(int,input().split())
from collections import defaultdict
wa_d = defaultdict(int)
wa = []
ac = []
for x in [list(input().split()) for _ in range(m)]:
    if x[1]=="AC":
        if x[0] not in ac:
            ac.append(x[0])
            wa.append(wa_d[x[0]])
    else:
        wa_d[x[0]] += 1
print(len(ac),sum(wa))

Submission status: Time Limit Exceeded

Solution code:
n,m = map(int,input().split())
p_li = [list(input().split()) for _ in range(m)]
from collections import defaultdict
wa_d = defaultdict(int)
wa = 0
ac = []
for x in p_li:
    if x[0] not in ac:
        if x[1]=="AC":
            ac.append(x[0])
            wa+=wa_d[x[0]]
        else:
            wa_d[x[0]] += 1
    if len(ac)==n:
        break        
print(len(ac),wa)

Submission status: Time Limit Exceeded

Solution code:
n,m = map(int,input().split())
p_li = [list(input().split()) for _ in range(m)]
from collections import defaultdict
wa_d = defaultdict(int)
wa = 0
ac = []
for x in p_li:
    if x[0] not in ac:
        if x[1]=="AC":
            ac.append(x[0])
            wa+=wa_d[x[0]]
        else:
            wa_d[x[0]] += 1
        
print(len(ac),wa)

Submission status: Time Limit Exceeded

Solution code:
n,m = map(int,input().split())
p_li = [list(input().split()) for _ in range(m)]
from collections import defaultdict
wa_d = defaultdict(int)
wa = []
ac = []
for x in p_li:
    if x[1]=="AC":
        if x[0] not in ac:
            ac.append(x[0])
            wa.append(wa_d[x[0]])
    else:
        wa_d[x[0]] += 1
        
print(len(ac),sum(wa))

Submission status: Time Limit Exceeded

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

AC = 0
WA = 0
WA_dict = {i: 0 for i in range(1, N+1)}
exc = []

for _ in range(M):
    p, s = input().split()
    if p in exc:
        continue
    elif s=='WA':
        WA_dict[int(p)] += 1
    else:
        AC += 1
        WA += WA_dict[int(p)]
        exc.append(p)

print(AC, WA)

Submission status: Time Limit Exceeded

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

AC = 0
WA = 0
WA_dict = {i: 0 for i in range(1, N+1)}
exc = []

for p, s in P_S:
    if p in exc:
        continue
    elif s=='WA':
        WA_dict[int(p)] += 1
    else:
        AC += 1
        WA += WA_dict[int(p)]
        exc.append(p)

print(AC, WA)

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int, input().split())
L = [list(input().split()) for i in range(M)]
P = []
S = [0] * (N + 1)
for i in L:
  s, p = int(i[0]), i[1]
  if s not in P:
    if p == 'AC':
      P.append(s)
    else:
      S[s] += 1
A = sum([S[i] for i in P])
print(len(P), A)

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int, input().split())
P = []
S = [0] * (N + 1)
for i in range(M):
  s, p = input().split()
  s = int(s)
  if s not in P:
    if p == 'AC':
      P.append(s)
    else:
      S[s] += 1
A = sum([S[i] for i in P])
print(len(P), A)

Submission status: Time Limit Exceeded

Solution code:
N,M = map(int, input().split())
L = []
C = 0
P = 0
for i in range(M):
    p,S = map(str, input().split())
    if S == 'AC' and [p,S] not in L:
        L.append([p,S])
        C += 1
    elif S == 'WA' and [p,'AC'] not in L:
        L.append([p,S])
        P += 1
print(C,P)

Submission status: Time Limit Exceeded

Solution code:
N,M = map(int, input().split())
L = []
for i in range(M):
    p,S = map(str, input().split())
    L.append([p,S])
C = 0
P = 0
A = []
for k in range(M):
    if L[k][1] == 'AC' and L[k] not in A:
        A.append(L[k])
        C += 1
    elif L[k][1] == 'WA' and [L[k][0],'AC'] not in A:
        A.append(L[k])
        P += 1
print(C,P)

Submission status: Time Limit Exceeded

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

A = []
for k in range(M):
    if L[k][1] == 'AC' and L[k] not in A:
        A.append(L[k])
    elif L[k][1] == 'WA' and [L[k][0],'AC'] not in A:
        A.append(L[k])
for i in range(len(A)):
    if A[i][1] == 'AC':
        C += 1
    else:
        P += 1
print(C,P)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N, M = map(int, input().split())
L = [list(input().split()) for i in range(M)]
AC = np.array([L[j] for j in range(M) if [L[j][0], 'AC'] not in L[:j]])
print(np.count_nonzero(AC == 'AC', axis = 1), np.count_nonzero(AC == 'WA', axis = 1))

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int, input().split())
L = [list(input().split()) for i in range(M)]
AC = list(set([L[j][0] for j in range(M) if L[j][1] == 'AC']))
P = [L[:L.index([k, 'AC'])].count([k, 'WA']) for k in AC]
print(len(AC), sum(P))

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int, input().split())
L = [list(input().split()) for i in range(M)]
AC = list(set([L[j][0] for j in range(M) if L[j][1] == 'AC']))
P = 0
for k in AC:
  P += L[:L.index([k, 'AC'])].count([k, 'WA'])
print(len(AC), P)

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int, input().split())
L = [list(input().split()) for i in range(M)]
AC = list(set([L[j][0] for j in range(M) if L[j][1] == 'AC']))
P = 0
for k in AC:
  n = L.index([k, 'AC'])
  P += L[:n].count([k, 'WA'])
print(len(AC), P)

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int, input().split())
L = [list(input().split()) for i in range(M)]
ac = [L[j][0] for j in range(M) if L[j][1] == 'AC']
AC = list(set(ac))
P = 0
for k in AC:
  n = L.index([k, 'AC'])
  P += L[:n].count([k, 'WA'])
print(len(AC), P)

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int,input().split())
sp = [input().split() for i in range(m)]
#print(sp)
x = [] #正解記録リスト
y = []
z = 0 #ペナルティ数カウンター

for i in range(m):
  if sp[i][1] == "AC" and int(sp[i][0]) not in x: #初正解の場合
    x.append(int(sp[i][0]))
    y.append(i)
    #print(x)

for i in range(m):
  if sp[i][1] == "WA": #不正解の場合
    if int(sp[i][0]) in x: #正解していたら
      a = x.index(int(sp[i][0]))
      if i < y[a]: #正解前だったら
        z = z + 1 #ペナルティとしてカウント

print(len(x), z)

Submission status: Time Limit Exceeded

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

#print(N, M, lst)
#count AC
AC_count = 0
WA_count = 0
AC_check={}
for i in range(M-1,-1,-1):
    #print(i)
    if lst[i][1]=='AC':
        AC_check[lst[i][0]-1]=i
#print(AC_check)

AC_count=len(AC_check)

for k, v in AC_check.items():
        #AC_count += 1
        WA_count+=lst[:v].count((k+1, 'WA'))

print(AC_count, WA_count)

Submission status: Time Limit Exceeded

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

#print(N, M, lst)
#count AC
AC_count = 0
WA_count = 0
AC_check=[None]*N
for i in range(M-1,-1,-1):
    #print(i)
    if lst[i][1]=='AC':
        AC_check[lst[i][0]-1]=i
#print(AC_check)

AC_count=N-AC_check.count(None)

for i in range(1, N+1):
    if AC_check[i-1]!=None:
        #AC_count += 1
        WA_count+=lst[:AC_check[i-1]].count((i, 'WA'))

print(AC_count, WA_count)

Submission status: Time Limit Exceeded

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

#print(N, M, lst)
#count AC
AC_count = 0
WA_count = 0
AC_check=[None]*N
for i in range(M-1,-1,-1):
    #print(i)
    if lst[i][1]=='AC':
        AC_check[lst[i][0]-1]=i
#print(AC_check)


for i in range(1, N+1):
    if AC_check[i-1]!=None:
        AC_count += 1
        WA_count+=lst[:AC_check[i-1]].count((i, 'WA'))

print(AC_count, WA_count)

Submission status: Time Limit Exceeded

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

#print(N, M, lst)
#count AC
AC_count = 0
WA_count = 0
for i in range(1, N+1):
    if (i, 'AC') in lst:
        AC_count += 1
        success = lst.index((i, 'AC'))
        WA_count+=lst[:success].count((i, 'WA'))

print(AC_count, WA_count)