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

points    = 0
penalties = 0

# 答えのリストの作成
input_lists = []
question_numbers = []
for i in range(m):
  qn, ans = input().split()
  input_list = [int(qn), ans]
  question_numbers.append(int(qn))
  input_lists.append(input_list)

# 問題番号の重複排除
question_numbers = list(set(question_numbers))

# カウント
for qn in question_numbers:
  # print(qn)
  # 問題番号毎に処理
  answers = []
  for input_list in input_lists:
    if(qn == input_list[0]):
      answers.append(input_list[1])
  # print(answers)
  # 配列にACが含まれていればpointsをインクリメント
  if('AC' in answers):
    points = points + 1
  	# ペナルティのカウント
    for answer in answers:
      if(answer == 'WA'):
        penalties = penalties + 1
      else:
        break

print(points, penalties)

Submission status: Time Limit Exceeded

Solution code:
N, M = [int(x) for x in input().split(" ")]
P = []
correct_set = set()
penalty = 0
for x in range(M):
    temp = [x for x in input().split(" ")]
    if temp == [temp[0], "WA"] and [temp[0], "AC"] in P:
        continue
    P.append(temp)
for x in P:
    penalty += 1 if x[1] == "WA" else 0
    if x[1] == "AC":
        correct_set.add(x[0])

print(len(correct_set), end=" ")
print(penalty)

Submission status: Time Limit Exceeded

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


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


a=[]

count_WA=0
for i in range(M):
    a.append(input().split())


AC=[]
for i in a:
    if i[1]=="AC" and not(i[0] in AC):
        AC.append(i[0])
count_AC=len(AC)

for i in a:
    if i[0] in AC:
        if i[1]=="AC":

            AC.remove(i[0])
        else:
            count_WA+=1




print(count_AC,count_WA,sep=" ")

Submission status: Time Limit Exceeded

Solution code:
import sys

N, M = map(int, sys.stdin.readline().split())
P = [None]*M
S = [None]*M
for i in range(M):
    P[i], S[i] = sys.stdin.readline().split()

AC = [0]*N
WA = 0
for i in range(M):
    if S[i] == "AC":
        if AC[int(P[i])-1] == 0:
            AC[int(P[i])-1] += 1
            for j in range(i):
                if P[j] == P[i] and S[j] == "WA":
                    WA += 1

print(sum(AC), WA)

Submission status: Time Limit Exceeded

Solution code:
n, m = input().split()
n = int(n)
m = int(m)
 
result_list = []
true_flag = False
for i in range(m):
    a,b=input().split()
    result_list.append((int(a), b))
    if b == "AC":
        true_flag = True
 
# 正解した問題を入れる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) == n:
            break
    
    print(correct, pn)

Submission status: Time Limit Exceeded

Solution code:
N,M=map(int,input().split())
m=[]
for i in range(M):
    m.append(list(input().split()))
cnt_ac=0
cnt_wa=0
num=1
while num <=N:
    for i in range(M):
        if int(m[i][0])==num:
            if m[i][1]=="AC":
                cnt_ac+=1
                num +=1
            else:
                cnt_wa+=1
        elif i <M-1:
            continue
        else:
            num +=1
print(cnt_ac,cnt_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
    else:
        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] >= 1:
                pass
            else:
                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:
toisuu, subsuu = [int(x) for x  in input().split()]
ac_list = []
wa_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:
            wa_list.append(toi)
            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:
        all_wa += wa_list.count(key)

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

n, m = map(int, input().split())
ac = []
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
        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 = [int(i) for i in input().split()]
corrects = []
wrongs = {}
for m in range(M):
  p, s = input().split()
  if p not in corrects:
    if s == "WA":
      if p not in wrongs:
        wrongs[p] = 0        
      wrongs[p] += 1
    elif s == "AC":
      corrects.append(p)
  
total_wrongs = 0
for p in corrects:
  if p in wrongs:
	  total_wrongs += wrongs[p]
      
print(len(corrects), total_wrongs)

Submission status: Time Limit Exceeded

Solution code:
import sys
sys.setrecursionlimit(1000000)
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
  
  if 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 sys
input = sys.stdin.readline

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

WAs = [0] * n
ACs = []
ac_append = ACs.append
penalty = 0
for i in range(m):
    p, s = input().strip().split(' ')
    p = int(p) - 1
    if p in ACs:
        continue
    if s == 'AC':
        penalty += WAs[p]
        ac_append(p)
    else:
        WAs[p] += 1

print(len(ACs), penalty)

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

for i in range(m):
    if l[i][1] == "WA" and ans[int(l[i][0])-1] != 1 and [l[i][0], "AC"] in l:
        pena[int(l[i][0])-1] += 1

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

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

Submission status: Time Limit Exceeded

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

lis = []

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


cnt_AC = []
cntsAC = 0

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

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

cntsWA = 0

for k, v in lis:
    if k not in cnt_AC:
        if v == "AC":
            cnt_AC.append(k)
            cntsAC += 1
            flags[k] = 1
        else:
            cnt_AC.append(k)
    else:
        if v == "AC" and flags[k] == 0:
            cntsAC += 1
            flags[k] = 1


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

print(cntsAC, cntsWA, sep=" ")

Submission status: 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] 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:
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 = [input().split(" ") for j in range(NM[1])]
        pss_t = list(zip(*pss))
        probs = list(pss_t[0])
        answs = list(pss_t[1])

        probs_uniq = list(set(probs))

        #print(probs_uniq)
        ans_ac = 0
        ans_wa = 0
        for p in probs_uniq:
            #print(p)
            res = [answs[r] for r in range(NM[1]) if probs[r] == 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 = [int(item) for item in input().split()]
ans_list = [input().split() for _ in range(M)]
# print(ans_list)

temp_ans_list = [[]]*(N+1)  

# print(temp_ans_list)

for q, ans in ans_list:
    q_index = int(q)
    temp = temp_ans_list[q_index]
    temp = temp + [ans]
    temp_ans_list[q_index] = temp
# print(temp_ans_list)  

res_ac = 0

res_pena = 0

for ans_list in temp_ans_list:
    if 'AC' in ans_list:
        res_ac += 1
    
        temp_pena = 0
        index_WA = ans_list.index('AC')

        res_pena += index_WA

print(res_ac, res_pena)

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 = []
    for lst in resultlist:
        if lst.num in AClist:continue
        if lst.result == 'AC':
            AClist.append(lst.num)
        else:
            WAcountlist[lst.num] += 1

    WAcount = 0
    for i in AClist:
        WAcount += WAcountlist[i]

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


WelcomeTo()

Submission status: Time Limit Exceeded

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

p = []
tmp_p = [0]*N
S = []

wa = 0
ac = 0

for i in range(M):
    P, s = list(map(str, input().split()))

    if s == 'WA':
        if P in p:
            pass
        else:
            tmp_p[int(P)-1] += 1

    else:
        if P in p:
            pass
        else:
            ac += 1
            p.append(P)
            wa += tmp_p[int(P)-1]


print(ac, wa)

Submission status: Time Limit Exceeded

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

ok = 0
ng = 0
ng_tmp = [0] * n
ok_l = []

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

  
print(ok, ng)

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
  
  if 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:
# -*- 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 ac)):
        ans2 += 1
for i in range(m):
    if (not(a[i][0] in 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 = map(int,input().split())
count_ac = 0
count_wa = 0
l = []
for i in range(m):
    t = tuple(input().split())
    l.append(t)
set_l = list(set(l))
for i in range(len(set_l)):
    if set_l[i][1] == 'AC':
        count_ac += 1
for i in range(1,n+1):
    if (str(i), 'AC') in l:
        idx = l.index((str(i), 'AC'))
        count_wa += l[:idx].count((str(i),'WA'))

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

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

ans1, ans2 = 0, 0
done = []
miss = {}

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

print(ans1,ans2)

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
import sys

N, M = map(int, sys.stdin.readline().split())
P = [None]*M
S = [None]*M
for i in range(M):
    string = sys.stdin.readline().split()
    P[i] = int(string[0])
    S[i] = string[1]


ac = [0]*N
AC = 0
WA = 0
for i in range(M):
    if S[i] == "AC":
        if ac[P[i]-1] == 0:
            ac[P[i]-1] += 1
            for j in range(i):
                if P[j] == P[i] and S[j] == "WA":
                    WA += 1

AC = sum(i > 0 for i in ac)
print(AC, 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)
wa+=len(A)
for i in A:
  if i not in B:
    wa-=A.count(i)

print(ac,wa)

Submission status: Time Limit Exceeded

Solution code:
n, m = input().split()
n = int(n)
m = int(m)
 
result_list = []
for i in range(m):
    a,b=input().split()
    result_list.append((int(a), b))
 
# 正解した問題を入れるlist
done_list = []
pn_list = [0] * n
correct = 0
pn = 0
 
 
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) == n:
        break
 
print(correct, pn)

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

    if 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:
n,m = list(map(int, input().split()))
x = []
for i in range(m):
  x.append(list(map(str,input().split())))
  
qu = []
AC,WA = 0,0
for i in x:
  qu.append(i[0])

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:
    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())
A = [list(map(str, input().split())) for _ in range(m)]

ans = 0
pen = 0

def get_dup(seq):
    seen = []
    return [x for x in seq
            if not seen.append(x) and seen.count(x) == 0
            or not seen.append(x) and seen.count(x) == 2]

A=get_dup(A)

for a in A:
    if a[1]=='AC':
        ans += 1
    if a[1] == 'WA':
        pen += 1

print(ans, pen)

Submission status: Time Limit Exceeded

Solution code:
import sys
n,m = map(int,input().split())
d = []
a = 0
w = 0

if m == 0:
    print(0,0)
    sys.exit()
for i in range(m):
    p,s = input().split()
    if (p,"AC") not in d:
        d.append((p,s))
        if s == "AC":
            a +=1
        elif s == "WA":
            w += 1
print(a,w)

Submission status: Time Limit Exceeded

Solution code:
N, M = input().split()
pS = [input().split() for i in range(int(M))]
ans = {}
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
        elif i[1] == "WA":
            ans[i[0]][1] += 1
    else:
        if i[1] == "AC":
            if ans[i[0]][0] == 0:
                    ans[i[0]][0] += 1
        elif i[1] == "WA":
            if ans[i[0]][0] >= 1:
                pass
            else:
                ans[i[0]][1] += 1
ac = 0
wa = 0
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 = map(int, input().split(' '))
submits = [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:
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))
ll=sorted(l, key=itemgetter(0))

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

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

qlist=list(set(q))
for j in qlist:
  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:
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))
ll=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
  del ll[0]
print(ac,wa)

Submission status: Time Limit Exceeded

Solution code:
import collections
n,m = map(int,input().split())
alist = []
wlist = []
ac_counter = 0
wa_counter = 0
for _ in range(m):
  t = tuple(input().split())
  checkac = (t[0],"AC")
  if t[1] == "WA" and not checkac in alist:
    alist.append(t)
    wa_counter += 1
  elif t[1] == "AC" and not checkac in alist:
    alist.append(t)
    ac_counter += 1
print(ac_counter,wa_counter)

Submission status: Time Limit Exceeded

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

temp_ans_list = [[]]*(N+1)  

# print(temp_ans_list)

for q, ans in ans_list:
    q_index = int(q)
    temp = temp_ans_list[q_index]
    temp = temp + [ans]
    temp_ans_list[q_index] = temp
# print(temp_ans_list)  

res_ac = 0

res_pena = 0

for ans_list in temp_ans_list:
    if 'AC' in ans_list:
        res_ac += 1
    
        temp_pena = 0
        for ans in ans_list:
            if ans == 'WA':
                temp_pena += 1
            else:
                break
        res_pena += temp_pena

print(res_ac, res_pena)

Submission status: Time Limit Exceeded

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


a=[]
count_AC=0
count_WA=0
for i in range(M):
    a.append(input().split())


AC=[]
for i in a:
    if i[1]=="AC" and not(i[0] in AC):
        AC.append(i[0])
for i in a:
    if i[0] in AC:
        if i[1]=="AC":
            count_AC+=1
            AC.remove(i[0])
        else:
            count_WA+=1




print(count_AC,count_WA,sep=" ")

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

N,M = map(int,input().split())
P = np.zeros(M, dtype=int)
S = np.zeros(M, dtype=int)
for i in range(M):
    p,s = map(str,input().split())
    P[i] = int(p)
    if s == 'AC':
        S[i] = 1
    
cOK = 0
cNG = 0
for q in range(1,N+1):
    Q = list(S[P==q])
    if 1 in Q:
        cOK += 1
        cNG += Q.index(1)

print(cOK, cNG)

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:
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] in ansed:
            continue
        if sp[0] not in wa_num_temp:
            wa_num_temp[sp[0]] = 0
        if sp[1] == "WA":
            wa_num_temp[sp[0]] += 1
        elif sp[1] == "AC":
            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:
import sys
n,m = map(int,input().split())
d = []
a = 0
w = 0

if m == 0:
    print(0,0)
    sys.exit()
for i in range(m):
    p,s = input().split()
    if (p,"AC") not in d:
        d.append((p,s))
for j in d:
    if j[1] == "AC":
        a += 1
    elif j[1] == "WA":
        w += 1
print(a,w)

Submission status: Time Limit Exceeded

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

    if 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:
N, M = list(map(int, input().split()))

p = []
p_ = []
S = []

wa = 0
ac = 0

for i in range(M):
    P, s = list(map(str, input().split()))
    p_.append(P)
    S.append(s)

    if s == 'WA':
        if P in p:
            pass
        else:
            wa += 1
    else:
        if P in p:
            pass
        else:
            ac += 1
            p.append(P)

for i in range(M):
    if S[i] == 'WA':
        if p_[i] in p:
            pass
        else:
            wa -= 1

print(ac, wa)

Submission status: Time Limit Exceeded

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

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()
  if t[0] not in AC:
    if t[1]=="AC":
      w+=WA.count(t[0])
      AC.append(t[0])
    else:
      WA.append(t[0])
print(str(len(AC))+" "+str(w))

Submission status: Time Limit Exceeded

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

if M == 0:
    print(0,0)
else:
    countA = 0
    countW = 0
    for i in range(M):
        if A[i][1] == 'AC':
            x = 0
            for j in range(i):
                if int(A[j][0]) == int(A[i][0]) and A[j][1] == 'AC':
                    x = x+1
                else:
                    x = x
            if x == 0:
                countA = countA +1
            else:
                countA = countA
        else:
            y = 0
            for j in range(i):
                if int(A[j][0]) == int(A[i][0]) and A[j][1] == 'AC':
                    y = y+1
                else:
                    y = y
            if y == 0:
                countW = countW +1
            else:
                countW = countW
        
    print(countA,countW)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
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 ac)):
        ans2 += 1
for i in range(m):
    if (not(a[i][0] in ac)) and a[i][1] == "WA":
        ans2 -= 1
ans1 = len(set(ac))

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

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)
A=tuple(A)
B=tuple(B)
for i in A:
  if i in B:
    wa+=1

print(ac,wa)

Submission status: Time Limit Exceeded

Solution code:
def main():
  AC = 0
  WA = 0
  
  solving = {}
  solved = []
  
  N,M = map(int, input().split())
  
  Q = [] 
  
  P = [0] * M
  S = [0] * M
  
  for i in range(M):
    p, s = input().split()
    if p in solved:
      continue
    elif s == 'WA':
      if p not in solved:
        if p in solving:
          _wa = solving[p]
          solving[p] = _wa + 1
        else:
          solving[p] = 1
    else:
      AC += 1
      if p in solving:
      	WA += solving[p]
      solved.append(p)
  
  print(AC, WA)
  return 0

if __name__ == "__main__":
  main()

Submission status: Time Limit Exceeded

Solution code:
N, M = [int(num) for num in input().split()]
pro = {}
c_sum = 0
c = []
f_sum = 0
for i in range(M):
    p, S = input().split()
    if S == 'AC':
        if p not in c:
            if p in pro:
                f_sum += pro[p]
            c.append(p)
    else:
        if p in c:
            continue
        elif p not in pro:
            pro[p] = 1
        else:
            pro[p] += 1
print("{} {}".format(len(c), f_sum))

Submission status: Time Limit Exceeded

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

if m == 0:
  print(0,0)

else:  
  for j in range(m):
    if (taka[j][1] == 'AC') and (int(taka[j][0]) not in ac):
      ac.append(int(taka[j][0]))
    if (taka[j][1] == 'WA') and (int(taka[j][0]) not in ac):
      wa[int(taka[j][0])-1] += 1
    
  for k in range(1,n+1):
    if k not in ac:
      wa[k-1] = 0
  
  print(len(ac),sum(wa))

Submission status: Time Limit Exceeded

Solution code:
n,m=map(int,input().split())
ans = 0
wa = 0
li = [[i] for i in range(n)]
for i in range(m):
  p,s=map(str,input().split())
  p=int(p)
  if "AC" not in li[p-1]:
    li[p-1].append(s)
#print(li)
for i in li:
  if "AC" in i:
    ans += 1
    wa += i.count("WA")

print(ans,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:
        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)