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:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
#input = sys.stdin.readline


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

    p_list, s_list = [], []
    for i in range(m):
        p, s = input().split()
        p_list.append(int(p))
        s_list.append(s)

    sum_wa = 0
    ac_num = 0
    ac_list = []
    wa_dic = {}
    for i in range(m):
        if p_list[i] in ac_list:
            continue

        if s_list[i] == "AC":
            ac_num += 1
            ac_list.append(p_list[i])
            if p_list[i] in wa_dic.keys():
                sum_wa += wa_dic[p_list[i]]
        else:
            if p_list[i] in wa_dic.keys():
                wa_dic[p_list[i]] += 1
            else:
                wa_dic[p_list[i]] = 1

    print(ac_num, sum_wa)

if __name__ == "__main__":
    resolve()

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int, input().split())
Counted = []
num1 = 0
num2 = 0
subnum2 = [0 for l in range(N)]
for j in range(M):
  p, S = input().split()
  p_ = int(p)
  if S == "AC" and not p_ in Counted:
    num1 += 1
    num2 += subnum2[p_ - 1]
    Counted.append(p_)
  elif S == "WA" and not p_ in Counted:
    subnum2[p_ - 1] += 1
print("{} {}".format(num1, num2))

Submission status: Time Limit Exceeded

Solution code:
def solve():

    N,M=map(int,input().split())
    A_list=[]#正解問題番号を入れる
    W_list=[0]*N
    WA=0
    PS=[list(map(str,input().split())) for i in range(M) ]
    ans=0
    pena=0
    for x in range(M):
        #if PS[x][0] not in A_list:
            if PS[x][0] in A_list:
                continue
            if PS[x][1]=='AC':
                A_list.append(PS[x][0])
                ans+=1
                WA+=W_list[int(PS[x][0])-1]
            else:
                #pena+=1
                W_list[int(PS[x][0])-1]+=1
    
    #print(ans,pena)
    print(ans,WA)
solve()

Submission status: Time Limit Exceeded

Solution code:
def solve():

    N,M=map(int,input().split()) #N個の問題,M回の提出
    A_list=[]#正解問題番号を入れる
    W_list=[0]*N
    WA=0
    PS=[list(map(str,input().split())) for i in range(M) ]
    ans=0
    pena=0
    for x in range(M):
        if PS[x][0] not in A_list:
            if PS[x][1]=='AC':
                A_list.append(PS[x][0])
                ans+=1
                WA+=W_list[int(PS[x][0])-1]
            else:
                #pena+=1
                W_list[int(PS[x][0])-1]+=1
    
    #print(ans,pena)
    print(ans,WA)
solve()

Submission status: Time Limit Exceeded

Solution code:
N,M=map(int,input().split()) #N個の問題,M回の提出
A_list=[]#正解問題番号を入れる
W_list=[0]*N
WA=0
PS=[list(map(str,input().split())) for i in range(M) ]
ans=0
pena=0
for x in range(M):
    if PS[x][0] not in A_list:
        if PS[x][1]=='AC':
            A_list.append(PS[x][0])
            ans+=1
            WA+=W_list[int(PS[x][0])-1]
        else:
            pena+=1
            W_list[int(PS[x][0])-1]+=1

#print(ans,pena)
print(ans,WA)

Submission status: Time Limit Exceeded

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

temp=0
wa=0
ac=0
for i in range(n):
    for j in range(m):
        if l[j][0] == str(i+1):
            #print(l[j][0], str(i+1))
            if l[j][1]=='WA':
                temp+=1
            else:
                ac+=1
                wa+=temp
                temp=0
                break

    
print(ac,wa)

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([int(p),s])

ac = 0 
wa = 0
    
for i in range(m):
    if l[i][1] == "WA":
        flag = True
        for j in range(0,i):
            if l[j][1] == "AC" and l[j][0] == l[i][0]:
                flag = False
                break
        if flag:
            wa += 1
        
    if l[i][1] == "AC":
        flag = True
        for j in range(0,i):
            if l[j][1] == "AC" and l[j][0] == l[i][0]:
                flag = False
                break
        if flag:
            ac += 1

print(ac,wa)

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([int(p),s])

ac = 0 
wa = 0
    
for i in range(m):
    if l[i][1] == "WA":
        flag = True
        for j in range(0,i):
            if l[j][1] == "AC" and l[j][0] == l[i][0]:
                flag = False
        if flag:
            wa += 1
        
    if l[i][1] == "AC":
        flag = True
        for j in range(0,i):
            if l[j][1] == "AC" and l[j][0] == l[i][0]:
                flag = False
        if flag:
            ac += 1

print(ac,wa)

Submission status: Time Limit Exceeded

Solution code:
N,M=map(int,input().split())
ac=0
wa=0
mydict={}
w=[]
p=[]
for i in range(M):
    P,S=input().split()
    if S=="WA":
        if w.count(P)==0:
            mydict[P]=1
            w.append(P) 
        else:
            mydict[P]=mydict[P]+1
    else:
        if p.count(P)==0:
            ac=ac+1
            p.append(P)
            if w.count(P)!=0:
                wa=wa+mydict[P]
        else:
            pass
print(ac,wa)

Submission status: Time Limit Exceeded

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

ac = 0
wa = 0
end = []

wa_candidate = [0 for i in range(N)]
for _ in range(M):
    p_i, s_i = input().split()
    if p_i not in end:
        if s_i == "AC":
            ac += 1
            wa += wa_candidate[int(p_i) - 1]
            end.append(p_i)
        if s_i == "WA":
            wa_candidate[int(p_i) - 1] += 1

print(ac, wa)

Submission status: Time Limit Exceeded

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

ac = []
wa = [0 for i in range(N)]

for _ in range(M):
    p_i, s_i = input().split()
    if s_i == "AC" and int(p_i) not in ac:
        ac.append(int(p_i))
    if s_i == "WA" and int(p_i) not in ac:
        wa[int(p_i) - 1] += 1
        
ac = set(ac)
wa_num = 0
for i in range(N):
    if i + 1 not in ac:
        continue
    else:
        wa_num += wa[i]

print(len(ac), wa_num)

Submission status: Time Limit Exceeded

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

ac_num = 0
ac = []
wa = {str(i): 0 for i in range(1, N + 1)}

for _ in range(M):
    p_i, s_i = input().split()
    if s_i == "AC" and p_i not in ac:
        ac_num += 1
        ac.append(p_i)
    if s_i == "WA" and p_i not in ac:
        wa[p_i] += 1
                
wa = [count for p_i, count in wa.items() if p_i in ac]

print(len(ac), sum(wa))

Submission status: Time Limit Exceeded

Solution code:
"""
注意点：ACしていないWAはペナルティ数とはカウントされない
      また、ACの後にペナルティしたものはカウントされない
データ構造：
  WA:dict形式でカウントアップ
  AC:配列で末尾に挿入
一通り舐めた後AD配列をforで回してペナルティ数合計するか？
"""

N,M = list(map(lambda x: int(x), input().split()))
l = [(str(n + 1) , 0) for n in range(N)]
wa_count = dict(l)
ac_list = []
answer = 0

for _ in range(M):
  p,s = input().split()
  if s == 'WA':
    wa_count[p] += 1
  else:
    if p not in ac_list:
      answer += wa_count[p]
      ac_list.append(p)
    

print(len(ac_list), answer)

Submission status: Time Limit Exceeded

Solution code:
"""
注意点：ACしていないWAはペナルティ数とはカウントされない
      また、ACの後にペナルティしたものはカウントされない
データ構造：
  WA:dict形式でカウントアップ
  AC:配列で末尾に挿入
一通り舐めた後AD配列をforで回してペナルティ数合計するか？
"""

N,M = list(map(lambda x: int(x), input().split()))
results = []
for n in range(M):
  results.append(input().split())


l = [(str(n + 1) , 0) for n in range(N)]
wa_count = dict(l)
ac_list = []
answer = 0

for p, s in results:
  if s == 'WA':
    wa_count[p] += 1
  else:
    if p not in ac_list:
      answer += wa_count[p]
      ac_list.append(p)
    

print(len(ac_list), answer)

Submission status: Time Limit Exceeded

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

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

for _ in range(M):
    p_i, s_i = input().split()
    if s_i == "AC":
        ac.append(p_i)
    elif s_i == "WA" and p_i not in ac:
        wa[p_i] += 1
                
ac = set(ac)
wa = [count for p_i, count in wa.items() if p_i in ac]

print(len(ac), sum(wa))

Submission status: Time Limit Exceeded

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

ac = []
wa = {}

for _ in range(M):
    p_i, s_i = input().split()
    if s_i == "AC":
        ac.append(p_i)
    elif s_i == "WA":
        if p_i not in ac:
            if p_i not in wa.keys():
                wa[p_i] = 1
            else:
                wa[p_i] += 1
                
ac = set(ac)
wa = [count for p_i, count in wa.items() if p_i in ac]

print(len(ac), sum(wa))

Submission status: Time Limit Exceeded

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

ac = []
wa = {}

for _ in range(M):
    p_i, s_i = input().split()
    if s_i == "AC":
        ac.append(p_i)
        ac = list(set(ac))
    elif s_i == "WA":
        if p_i not in ac:
            if p_i not in wa.keys():
                wa[p_i] = 1
            else:
                wa[p_i] += 1
                
ac = set(ac)
wa = {p_i: count for p_i, count in wa.items() if p_i in ac}

print(len(ac), sum(wa.values()))

Submission status: Time Limit Exceeded

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

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

for _ in range(M):
    p_i, s_i = input().split()
    if s_i == "AC":
        ac.append(p_i)
    elif s_i == "WA":
        if p_i not in ac:
            wa[p_i] += 1

ac = set(ac)
wa = {p_i: count for p_i, count in wa.items() if p_i in ac}

print(len(ac), sum(wa.values()))

Submission status: Time Limit Exceeded

Solution code:
n,m = map(int,input().split())
dic = {}
correct = penalty = 0
for i in range(m):
    p,s = input().split()
    if p not in dic:
        a = []
        a.append(s)
        dic[p] = a
    else:
        if 'AC' not in dic[p]:
            dic[p].append(s)
for p in dic:
    if 'AC' in dic[p]:
        correct += 1
        penalty += (len(dic[p])-1)
print(correct, penalty)

Submission status: Time Limit Exceeded

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

ac_list = [0 for i in range(n)]
wa_list = [0 for i in range(n)]
num_wa = 0
num_ac = 0

for ps in ps_list:
    p = int(ps[0])
    s = ps[1]
    
    if s == 'AC' and not ac_list[p-1]:
        ac_list[p-1] = 1
        num_wa += wa_list[p-1]
        num_ac += 1
    elif p not in ac_list:
        wa_list[p-1] += 1
        
print(num_ac, num_wa)

Submission status: Time Limit Exceeded

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

ac_list = []
wa_list = [0 for i in range(n)]
num_wa = 0
num_ac = 0

for ps in ps_list:
    p = int(ps[0])
    s = ps[1]
    
    if s == 'AC' and p not in ac_list:
        ac_list.append(p)
        num_wa += wa_list[p-1]
        num_ac += 1
    elif p not in ac_list:
        wa_list[p-1] += 1
        
print(num_ac, num_wa)

Submission status: Time Limit Exceeded

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

ac_list = []
wa_list = [0 for i in range(n)]
num_wa = 0

for ps in ps_list:
    p = int(ps[0])
    s = ps[1]
    
    if s == 'AC' and p not in ac_list:
        ac_list.append(p)
        num_wa += wa_list[p-1]
    elif p not in ac_list:
        wa_list[p-1] += 1
            
num_ac = len(ac_list)
        
print(num_ac, num_wa)

Submission status: Time Limit Exceeded

Solution code:
from collections import defaultdict

n, m = map(int, input().split())
ps_list = [[i for i in input().split()] for j in range(m)]

ac_list = []
wa_dict = defaultdict(int)
num_wa = 0

for ps in ps_list:
    p = int(ps[0])
    s = ps[1]
    
    if s == 'AC' and p not in ac_list:
        ac_list.append(p)
        num_wa += wa_dict[p]
    elif p not in ac_list:
        wa_dict[p] += 1
            
num_ac = len(ac_list)
        
print(num_ac, num_wa)

Submission status: Time Limit Exceeded

Solution code:
from collections import defaultdict

n, m = map(int, input().split())
ps_list = [[i for i in input().split()] for j in range(m)]

ac_list = []
wa_dict = defaultdict(int)
num_wa = 0

for ps in ps_list:
    p = int(ps[0])
    s = ps[1]
    
    if s == 'AC' and p not in ac_list:
        ac_list.append(p)
        num_wa += wa_dict[p]
    elif p not in ac_list:
        wa_dict[p] += 1
            
num_ac = len(set(ac_list))
        
print(num_ac, num_wa)

Submission status: Time Limit Exceeded

Solution code:
N,M=map(int,input().split())
PS=[input().split() for i in range(M)]
ACzumi=[]
WA_count=[]
for i in range(M):
    if not PS[i][0] in ACzumi:
        if PS[i][1]=="AC":
            ACzumi.append(PS[i][0])
        else:
            WA_count.append(PS[i][0])
yokei=0            
for i in range(len(WA_count)):
    if not WA_count[i] in ACzumi:
        yokei+=1
        
#print(ACzumi)
print(len(ACzumi),len(WA_count)-yokei)

Submission status: Time Limit Exceeded

Solution code:
n,m=map(int,input().split())
ll=[input().split() for _ in range(m)]
la=list({p for p,s in ll if s=='AC'})
a=len(la);lf=[1]*a;d={};w=0
for p,s in ll:
  if p in la and lf[la.index(p)]:
    if s=='WA': d[p]=d.get(p,0)+1
    else: w+=d.get(p,0); lf[la.index(p)]=0
print(a,w)

Submission status: Time Limit Exceeded

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

p = []
s = []
ps = []

uoo = []

ans2 = 0

for i in range(m):
    tmp = list(input().split())
    ps.append(tmp)

    pi = tmp[0]
    si = tmp[1]

    if si == 'AC' and not(pi in uoo):
        ans2 += ps.count([pi,'WA'])

        uoo.append(pi)

ans1 = len(uoo)

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

Submission status: Time Limit Exceeded

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

p = []
s = []
ps = []

uoo = []

ans2 = 0

for i in range(m):
    tmp = list(input().split())
    ps.append(tmp)

    pi = tmp[0]
    si = tmp[1]

    if si == 'AC' and not(pi in uoo):
        sliced_ps = ps[:i]
        ans2 += sliced_ps.count([pi,'WA'])

        uoo.append(pi)

ans1 = len(uoo)

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

Submission status: Time Limit Exceeded

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

p = []
s = []
ps = []

uoo = []
cnt = []

ans2 = 0

for i in range(m):
    tmp = list(input().split())
    ps.append(tmp)
    p.append(tmp[0])
    s.append(tmp[1])

    if s[i] == 'AC' and not(p[i] in uoo):
        sliced_ps = ps[:i]
        ans2 += sliced_ps.count([str(p[i]),'WA'])

        uoo.append(p[i])
        cnt.append(i)

ans1 = len(cnt)

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

Submission status: Time Limit Exceeded

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

if num[1] == 0:     
  count_ac_all = 0
  count_wa_all = 0 

else:  
  num_list = []
  for i in range(0,num[1]):
    num_list.append(list(input().split()))

  group=set()
  new_num = []

  for i in range(0,num[1]):
    group.add(num_list[i][0])

  set_list = list(group)

  for i in range(0,len(set_list)):
    for j in range(0,len(num_list)):
      if num_list[j][0] == set_list[i]:
        new_num.append(num_list[j])

  count_ac = 0
  count_wa = 0
  count_ac_all = 0
  count_wa_all = 0
  base = new_num[0][0]
  count = 0


  for i in range(0,len(new_num)):
    if not new_num[i][0] == base:
      base = new_num[i][0]
      count = 0
      count_ac = 0
      count_wa = 0

    if count == 0:
      if new_num[i][1] == 'WA':
        count_wa = count_wa+1
      elif new_num[i][1] == 'AC':
        count_ac = count_ac+1
        count = 1

    if count == 1:
      count_ac_all = count_ac_all + count_ac
      count_wa_all = count_wa_all + count_wa
      count = -1
    
print(count_ac_all,count_wa_all)

Submission status: Time Limit Exceeded

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

pAC=[]
pWA=[]
for i in range(m):
  p,s=input().split()
  if p not in pAC:
    if s=='AC':
      pAC+=[p]
    else:
      pWA+=[p]

cnt=0
for i in pWA:
  if i in pAC:
    cnt+=1

print(len(set(pAC)),cnt)

Submission status: Time Limit Exceeded

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

pAC=[]
pWA=[]
for i in range(m):
  if ps[i][1]==1 and ps[i][0] not in pAC:
    pAC+=[ps[i][0]]
  elif ps[i][1]==0 and ps[i][0] not in pAC:
    pWA+=[ps[i][0]]

cnt=0
for i in pWA:
  if i in pAC:
    cnt+=1

print(len(set(pAC)),cnt)

Submission status: Time Limit Exceeded

Solution code:
n,m=map(int,input().split())
ps=[list(map(int, input().replace('AC','1').replace('WA','-1').split())) for i in range(m)]

pAC=[]
pWA=[]
for i in range(m):
  if ps[i][1]==1 and ps[i][0] not in pAC:
    pAC+=[ps[i][0]]
  elif ps[i][1]==-1 and ps[i][0] not in pAC:
    pWA+=[ps[i][0]]

cnt=0
for i in pWA:
  if i in pAC:
    cnt+=1

print(len(set(pAC)),cnt)

Submission status: Time Limit Exceeded

Solution code:
n,m=map(int,input().split())
ps=[list(map(int, input().replace('AC','1').replace('WA','-1').split())) for i in range(m)]

pAC=[]
pWA=[]
for i in range(m):
  if ps[i][1]==1 and ps[i][0] not in pAC:
    pAC+=[ps[i][0]]
  elif ps[i][1]==-1 and ps[i][0] not in pAC:
    pWA+=[ps[i][0]]

pWA2=[]
for i in pWA:
  if i in pAC:
    pWA2+=[i]
pWA=pWA2
print(len(set(pAC)),len(pWA))

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
ac = []
sb = []
for i in range(m):
    p, s = input().split()
    p = int(p)
    sb.append([p, s])
    if s == "AC" and p not in ac:
        ac.append(p)
a = 0
w = 0
for q, st in sb:
    if q in ac:
        if st == "AC":
            a += 1
            ac.remove(q)
        else:
            w += 1
print(str(a) + " " + str(w))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

AC=[]
WA=0
for i in range(m):
    if p[i][1]=="AC" and p[i][0] not in AC:
        AC.append(p[i][0])
    elif p[i][1]=="WA" and p[i][0] not in AC and [p[i][0],"AC"] in p:
        WA=WA+1
print(len(AC),WA)

Submission status: Time Limit Exceeded

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

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()
for i in range(m):
    p[i]=int(p[i])
AC=[]
AC1=[]
WA=0
for i in range(m):
    if s[i]=="AC" and p[i] not in AC:
        AC.append(p[i])
        AC1.append(i)
for i in range(m):
    if s[i]=="WA" and p[i] in AC:
        if AC1[AC.index(p[i])]>i:
            WA=WA+1
print(len(AC),WA)

Submission status: Time Limit Exceeded

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

Counted = []
num1 = 0
num2 = 0
subnum2 = [0 for l in range(N)]
for j in range(M):
  if S[j] == "AC" and not p[j] in Counted:
    num1 += 1
    num2 += subnum2[p[j] - 1]
    Counted.append(p[j])
  elif S[j] == "WA" and not p[j] in Counted:
    subnum2[p[j] - 1] += 1
print("{} {}".format(num1, num2))

Submission status: Time Limit Exceeded

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

for _ in range(M):
    p, s = input().split()
    p = int(p)

    if s == "AC" and p not in correct:
        correct.append(p)
        penalty += missed[p - 1]
    elif s == "WA" and p not in correct:
        missed[p - 1] += 1

print(len(correct), penalty)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding:utf-8 -*-
n,m = map(int, input().split())

res = []
for i in range(m):
  res.append(input().split())

que = []
for a1,a2 in res:
  if a2 == 'AC':
    que.append(a1)
  
num = set(que)

ac = 0
wa = 0
c = ''
for b in num:
  for c1,c2 in res:
    if c1 == b and c2 == 'AC':
      #print(b,c1,c2)
      ac += 1
      break
    elif c1 == b and c2 =='WA':
      #print(b,c1,c2)
      wa += 1

print(ac,wa)

Submission status: Time Limit Exceeded

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

ac_prolst = []
for i in range(len(ps_lst)):
    number = ps_lst[i][0]
    answer = ps_lst[i][1]
    if answer=='AC':
        ac_prolst.append(number)
ac_lst = list(set(ac_prolst))

ps_dic = {}
for i in range(m):
    number = ps_lst[i][0]
    if number in ac_lst:
        tmp_dic = {number: 'WA'}
        ps_dic.update(tmp_dic)

for i in range(m):
    number = ps_lst[i][0]
    answer = ps_lst[i][1]

    if number in ac_lst:
        if answer == 'AC' and ps_dic[number] == 'WA':
            ac_count += 1
            tmp_dic = {number: 'AC'}
            ps_dic.update(tmp_dic)
        elif answer == 'WA' and ps_dic[number] == 'WA':
            wa_count += 1

print('{} {}'.format(ac_count, wa_count))

Submission status: Time Limit Exceeded

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


ps_dic = {}
for i in range(m):
    number = ps_lst[i][0]
    tmp_dic = {number:'WA'}
    ps_dic.update(tmp_dic)

wa_dic = {}
for i in range(m):
    number = ps_lst[i][0]
    tmp_dic = {number:0}
    wa_dic.update(tmp_dic)

for i in range(m):
    number = ps_lst[i][0]
    answer = ps_lst[i][1]

    if answer=='AC' and ps_dic[number]=='WA':
        ac_count += 1
        tmp_dic = {number:'AC'}
        ps_dic.update(tmp_dic)
    elif answer=='WA' and ps_dic[number]=='WA':
        wa_dic[number] += 1

for i in range(len(ps_dic)):
    pslst = list(ps_dic.items())
    walst = list(wa_dic.items())
    if pslst[i][1]=='AC':
        wa_count += walst[i][1]

print('{} {}'.format(ac_count, wa_count))

Submission status: Time Limit Exceeded

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

pc_dic = {}
for i in range(m):
    number = ps_lst[i][0]
    tmp_dic = {number:'WA'}
    pc_dic.update(tmp_dic)

for i in range(m):
    number = ps_lst[i][0]
    answer = ps_lst[i][1]

    if answer=='AC' and pc_dic[number]=='WA':
        ac_count += 1
        tmp_dic = {number:'AC'}
        pc_dic.update(tmp_dic)
    elif answer=='WA' and pc_dic[number]=='WA':
        tmp = 0
        for j in range(m):
            if ps_lst[j][0]==number and ps_lst[j][1]=='AC':
                tmp = 1
                break
        if tmp==1:
            wa_count += 1

print('{} {}'.format(ac_count, wa_count))

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] = map(str,input().split())
    p[i] = int(p[i])

ac = []
for i in range(m):
    if s[i] == 'AC':
        ac.append(p[i])

ac = list(set(ac))

first_sub = []
for i in ac:
    for j in range(m):
        if p[j] == i:
            first_sub.append(j)
            break

ans_ng = 0
for i in range(len(ac)):
    ng = 0
    for j in range(first_sub[i],m):
        if p[j] == ac[i] and s[j] == 'WA':
            ng += 1
        elif p[j] == ac[i] and s[j] == 'AC':
            break
    ans_ng += ng
            


print(len(ac),ans_ng)

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] = map(str,input().split())
    p[i] = int(p[i])

ac = []
for i in range(m):
    if s[i] == 'AC':
        ac.append(p[i])

ac = list(set(ac))

ans_ng = 0
for id in ac:
    ng = 0
    for j in range(m):
        if p[j] == id and s[j] == 'WA':
            ng += 1
        elif p[j] == id and s[j] == 'AC':
            break
    ans_ng += ng
            


print(len(ac),ans_ng)

Submission status: Time Limit Exceeded

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

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

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

        if q not in ac_list:
            if r == 'WA':
                wa_counts[q-1] += 1

            else:
                ac_list.append(q)
                penalties += wa_counts[q-1]

    print(len(ac_list), penalties)

resolve()

Submission status: Time Limit Exceeded

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

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

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

        if q not in ac_list:
            if r == 'WA':
                wa_counts[q-1] += 1

            else:
                ac_list.append(q)
                penalties += wa_counts[q-1]

    print(len(ac_list), penalties)

resolve()

Submission status: Time Limit Exceeded

Solution code:
def main(n,m,r):
    c_ac = 0
    c_wa = 0
    for i in range(n):
        wa = 0
        for j in range(len(r)):
            if int(r[j][0]) != i+1:
                continue
            if r[j][1] == "WA":
                wa += 1
            elif r[j][1] == "AC":
                c_ac += 1
                c_wa += wa
                break
    return "{0} {1}".format(c_ac, c_wa)


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

Submission status: Time Limit Exceeded

Solution code:

# -*- coding: utf-8 -*-
N,M = map(int, input().split())

# 2次元配列
ans_list = []
for i in range(M):
    a = list(map(str, input().split()))
    ans_list.extend([a])
#print(grid)
#正答数とペナルティ数

ac_list=[0 for _ in range(N)]
wa_list=[0 for _ in range(N)]
ac_cnt=0
pnl_cnt=0
for i in range(M):
	if ans_list[i][0] not in ac_list and ans_list[i][1]=='AC':
		#ac_cnt+=1
		ac_list[int(ans_list[i][0])-1]=1
	elif ac_list[int(ans_list[i][0])-1]==0 and ans_list[i][1]=='WA':
		wa_list[int(ans_list[i][0])-1]+=1
	else:
		pass
for i in range(N):
	if ac_list[i]==0:
		wa_list[i]=0

print('{} {}'.format(sum(ac_list),sum(wa_list)))

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    n, m = map(int, input().split())
    ac = []
    wa = []
    wa_count = 0
    for i in range(m):
        p, s = input().split()
        if p in ac:
            continue
        else:
            if s == 'AC':
                ac.append(p)
                wa_count += wa.count(p)
            else:
                wa.append(p)
    print(len(ac), wa_count)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    n, m = map(int, input().split())
    ac = []
    wa = []
    wa_count = 0
    for i in range(m):
        p, s = input().split()
        if p in ac:
            continue
        else:
            if s == 'AC':
                ac.append(p)
            else:
                wa.append(p)
    for a in ac:
        wa_count += wa.count(a)
    print(len(ac),wa_count)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
import sys

lines = [l.rstrip() for l in sys.stdin.readlines()[1:]]

ac = []
wa = {}

for l in lines:
    p_raw, s = l.split(" ")
    p = int(p_raw)

    if p in ac:
        continue

    if s == "WA":
        if p not in wa.keys():
            wa[p] = 0
        wa[p] += 1

    elif s == "AC":
        ac += [p]

ac_count = len(ac)
wa_count = 0
for p in ac:
    wa_count += (wa[p] if p in wa.keys() else 0)

print("%d %d" % (ac_count, wa_count))

Submission status: Time Limit Exceeded

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

if M == 0:
  print(0,0)
  exit();

x = {}  
for _ in range(M):
  a,w = map(str,input().split())
  x.setdefault(int(a),[]).append(w)  
  
ac = wa = 0  
for k in x.keys():
  for j in x[k]:
    if 'AC' not in x[k]:
      break
    elif j == 'AC':
      ac += 1
      break
    elif j =='WA':
      wa += 1
      
print(ac,wa)

Submission status: Time Limit Exceeded

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

if M == 0:
  print(0,0)
  exit();

x = {}  
for _ in range(M):
  a,w = map(str,input().split())
  x.setdefault(int(a),[]).append(w) 

ac = wa = 0  
for k,v in x.items():
  for j in x[k]:
    if 'AC' not in v:
      break
    elif j == 'AC':
      ac += 1
      break
    elif j =='WA':
      wa += 1
  
print(ac,wa)

Submission status: Time Limit Exceeded

Solution code:
a = input().split()
n = int(a[0])
m = int(a[1])
ps = []
for i in range(m):
    psi = input().split()
    pi = int(psi[0])
    ps.append([pi,psi[1]])
ac = 0
pn = 0
q = []
for i in range(n):
    q.append([0,0])
for i in range(n):
    if ([i+1,'AC'] in ps):
        q[i][0]=ps.index([i+1,'AC'])
        ac = ac + 1
        q[i][1]=ps[0:q[i][0]].count([i+1,'WA'])
        pn = pn + q[i][1]
print(ac,pn)

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3

N, M = map(lambda x: int(x), input().split())

Pdict = {}
for i in range(M):
    p_i, S_i = input().split()
    Pdict[p_i] = Pdict.get(p_i, []) + [S_i]

ACNum = 0
PenaltyNum = 0
for i in Pdict.values():
    temp = 0
    for j in i:
        if j == "AC":
            ACNum += 1
            PenaltyNum += temp
            break
        else:
            temp += 1

print(ACNum, PenaltyNum)

Submission status: Time Limit Exceeded

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

accurate = []
correct = 0
wrong = [0] * n
penalty = 0

for i in range(m):
    p,s = input().split()
    num = int(p) - 1 
    if s == 'AC' and num not in accurate:
        accurate.append(num)
        correct += 1
        penalty += wrong[num]
    elif s == 'WA' and num not in accurate:
        wrong[num] += 1 
    else:
        continue

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