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: Wrong Answer

Solution code:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,M=MI()
    AC=set()
    WA=defaultdict(int)
    ans = 0
    for _ in range(M):
        p,s = ST().split()
        if s=="AC":
            ans += WA[p]
            AC.add(p)
        else:
            WA[p]+=1
    print(len(AC),ans)
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
ac = [0] * N
cnt = 0
pena = 0
for p, S in [tuple(input().split()) for _ in range(M)]:
    p = int(p) - 1
    if S == 'WA' and ac[p] != 1:
        pena += 1
        continue
    if S == 'AC' and ac[p] != 1:
        cnt += 1
        ac[p] = 1
print(cnt, pena)

Submission status: Wrong Answer

Solution code:
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

N, M = list(map(int, sys.stdin.buffer.readline().split()))
PS = [sys.stdin.buffer.readline().decode().rstrip().split() for _ in range(M)]

ac = np.zeros(N + 1, dtype=int)
wa = np.zeros(N + 1, dtype=int)

for p, s in PS:
    p = int(p)
    if s == 'AC':
        ac[p] = 1
    if s == 'WA':
        if ac[p]:
            continue
        wa[p] += 1
print(ac.sum() , wa.sum())

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n,m = LI()
    p = [0]*n
    f = [0]*n
    for i in range(m):
        a,b = input().split()
        a = int(a)-1
        if b == "WA" and not f[a]:
            p[a] += 1
        if b == "AC":
            f[a] = 1
    print(sum(f),sum(p))
    return

#Solve
if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
import sys

n, m = map(int, input().split())
ac = 0
wa = 0
already = set()
for line in sys.stdin:
    p, s = line.strip().split()
    p = int(p)
    if p in already:
        continue
    if s == 'AC':
        ac += 1
        already.add(p)
    else:
        wa += 1

print(ac, wa)

Submission status: Time Limit Exceeded

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

ans = {}
done = []
ac = 0
p = 0

for i in range(M):
    a,b = map(str, input().split())
    if not a in ans:
        ans[a] = 0
    if b == 'WA':
        ans[a] += 1
    if b == 'AC' and a not in done:
        ac += 1
        p += ans[a]
        ans[a] = 0
        done.append(a)

print(ac,p)

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int, input().split())
ac = []
pena = 0
walen = [0]*N

for i in range(M):
    p, S = map(str, input().split())
    p = int(p) - 1
    if p in ac:
        continue
    elif S == 'AC':
        ac.append(p)
        pena += walen[p]
    else:
        walen[p] += 1

print(len(set(ac)), pena)

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int, input().split())
ac = []
pena = 0
walen = [0]*N

for i in range(M):
    p, S = map(str, input().split())
    p = int(p) - 1
    if p in ac:
        pass
    elif S == 'AC':
        ac.append(p)
        pena += walen[p]
    else:
        walen[p] += 1

print(len(set(ac)), pena)

Submission status: Time Limit Exceeded

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

for i in range(1, N+1):
  list1 = []
  for j in range(M):
    if  A[j][0] == str(i):
      list1.append(A[j][1])

  
  for k in range(1, len(list1)):
    if list1[k]=='AC':
      cac += 1
      cwa += list1[:k].count('WA')
      break
print(cac, cwa)

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int, input().split())
A, W = [], []
num, j = 0, 0

for i in range(M):
    P, S = map(str, input().split())
    if P not in A:
        if S == "AC":
            A.append(P)
            num += W.count(A[j])
            j += 1
        else:
            W.append(P)

print(len(A), num)

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int, input().split())
A, W = [], []
num = 0

for i in range(M):
    P, S = map(str, input().split())
    if P not in A:
        if S == "AC":
            A.append(P)
        else:
            W.append(P)

for j in range(len(A)):
    num += W.count(A[j])

print(len(A), num)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
def main():
    n, m = map(int,input().split())
    tried = np.array([list(input().split()) for i in range(m)])
    try:
        where_ac = np.array(tried[:,1]=='AC')
        acs = list(set(tried[:,0][where_ac]))
        tried = tried[np.isin(tried[:,0],acs)]
        appeared = []
        missed = 0
        for t in tried:
            if(t[1] == 'AC') or (t[0] in appeared):
                appeared.append(t[0])
            else:
                missed += 1
        print(len(acs),missed)
    except:
        print(0,0)
if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

def main():
    n, m = map(int,input().split())
    tried = np.array([list(input().split()) for i in range(m)])
    try:
        where_ac = np.array(tried[:,1]=='AC')
        acs = set(tried[:,0][where_ac])
        times = 0
        template = np.array([i for i in range(m)])
        for j in acs:
            first_ac = template[np.array(tried[:,0]==j)*where_ac][0]
            part = tried[:first_ac]
            times += len(part[part[:,0]==j])
        print(len(acs), times)
    except:
        print(0,0)
if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

def main():
    n, m = map(int,input().split())
    tried = np.array([list(input().split()) for i in range(m)])
    try:
        where_ac = np.array(tried[:,1]=='AC')
        acs = set(tried[:,0][where_ac])
        times = 0
        for j in acs:
            first_ac = np.array([i for i in range(m)])[np.array(tried[:,0]==j)*where_ac][0]
            part = tried[:first_ac]
            times += len(part[part[:,0]==j])
        print(len(acs), times)
    except:
        print(0,0)
if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

def main():
    n, m = map(int,input().split())
    tried = np.array([list(input().split()) for i in range(m)])
    try:
        where_ac = np.array(tried[:,1]=='AC')
        acs = set(tried[:,0][where_ac])
        times = 0
        for j in acs:
            first_ac = np.array([i for i in range(m)])[np.array(tried[:,0]==j)*where_ac][0]
            times += len(tried[:first_ac][tried[:,0][:first_ac]==j])
        print(len(acs), times)
    except:
        print(0,0)
if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

def main():
    n, m = map(int,input().split())
    problem = []
    ac = []
    for i in range(m):
        temp = list(input().split())
        problem.append(int(temp[0]))
        ac.append(temp[1])
    problem = np.array(problem)
    ac = np.array(ac)
    where_ac = np.array(ac=='AC')
    acs = set(problem[where_ac])
    tried = 0
    for j in acs:
        first_ac = np.array([i for i in range(m)])[np.array(problem==j)*where_ac][0]
        tried += len(problem[:first_ac][problem[:first_ac]==j])
    print(len(acs), tried)
if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

l=[0]*n
w=0
c=0
ac=[]

for i in range(m):
  p,s=map(str,input().split())
  p=int(p)
  if s=='WA':
    l[p-1]+=1
  else:
    if p not in ac:
      c+=1
      w+=l[p-1]
      ac.append(p)

print(c,w)

Submission status: Time Limit Exceeded

Solution code:
import collections

N, M = map(int, input().split())
WA_CNT = []
CLEAR = []
for i in range(M):
    P, S = input().split()
    P = int(P)
    if P in CLEAR:
        continue
    if S == "AC":
        CLEAR.append(P)
        continue

    WA_CNT.append(P)


cs = collections.Counter(WA_CNT)
num = len(CLEAR)
try_num = 0

for i in CLEAR:
    try_num += cs[i]
print("{} {}".format(num, try_num))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter

N, M = map(int, input().split())
ans = [[] for _ in range(N)]
for _ in range(M):
    p, s = input().split()
    if 'AC' not in ans[int(p)-1]:
        ans[int(p)-1].append(s)

cnt = Counter(sum(ans, []))

print(cnt['AC'], cnt['WA'])

Submission status: Time Limit Exceeded

Solution code:
n,m = map(int, input().split())
l = [0] * n

ac = 0
wa = 0
ac_done = []

for _ in range(m):
    p, s = input().split()
    p = int(p)
    if p in ac_done:
        continue
    else:
        if s == 'AC':
            ac += 1
            wa += l[p-1]
            ac_done.append(p)
        else:
            l[p-1] = 1 + l[p-1]

print(ac,wa)

Submission status: Time Limit Exceeded

Solution code:
n,m = map(int, input().split())
l = [0] * n

ac = 0
wa = 0
ac_done = []

for _ in range(m):
    p, s = input().split()
    p = int(p)
    if p not in ac_done:
        if s == 'AC':
            ac += 1
            wa += l[p-1]
            ac_done.append(p)
        else:
            l[p-1] = 1 + l[p-1]

print(ac,wa)

Submission status: Time Limit Exceeded

Solution code:
n,m = map(int, input().split())
l = [0] * n

ac = 0
wa = 0
ac_done = []

for _ in range(m):
    p, s = input().split()
    p = int(p)
    if s == 'AC' and p not in ac_done:
        ac += 1
        wa += l[p-1]
        ac_done.append(p)
    else:
        l[p-1] = 1 + l[p-1]

print(ac,wa)

Submission status: Time Limit Exceeded

Solution code:
n,m = map(int, input().split())
l = [0] * n

ac = 0
wa = 0
ac_done = []
for _ in range(m):
    p, s = input().split()
    p = int(p)
    if s == 'AC' and p not in ac_done:
        ac += 1
        wa += l[p-1]
        ac_done.append(p)
    elif s =='WA' and p not in ac_done:
        l[p-1] = 1 + l[p-1]

print(ac,wa)

Submission status: Time Limit Exceeded

Solution code:
n,m = map(int, input().split())
l = [0] * n

ac = 0
wa = 0
ac_done = []
for _ in range(m):
    p, s = input().split()
    p = int(p)
    if s == 'AC' and p not in ac_done:
        ac += 1
        wa += l[p-1]
        ac_done.append(p)
    elif s =='WA':
        l[p-1] = 1 + l[p-1]

print(ac,wa)

Submission status: Time Limit Exceeded

Solution code:
from collections import defaultdict

def main():
    N, M = map(int, input().split())
    a = [input().split() for _ in range(M)]
    fin = []
    wa_count = defaultdict(lambda:0)
    ac, wa = 0, 0

    for q_no, ans in a:
        if ans == "AC":
            if q_no in fin:
                continue
            else:
                fin.append(q_no)
                ac += 1
                wa += wa_count.get(q_no, 0)
        else:
            wa_count[q_no] += 1
    
    print(ac, wa)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
from collections import defaultdict

def main():
    N, M = map(int, input().split())
    a = [input().split() for _ in range(M)]
    fin = []
    wa_count = defaultdict(lambda:0)
    ac, wa = 0, 0

    for q_no, ans in a:
        if ans == "AC":
            if q_no not in fin:
                fin.append(q_no)
                ac += 1
                wa += wa_count.get(q_no, 0)
        else:
            wa_count[q_no] += 1
    
    print(ac, wa)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
from collections import defaultdict

def main():
    N, M = map(int, input().split())
    a = [input().split() for _ in range(M)]
    fin = []
    wa_count = defaultdict(lambda:0)
    ac, wa = 0, 0

    for q_no, ans in a:
        if q_no not in fin:
            if ans == "AC":
                fin.append(q_no)
                ac += 1
                wa += wa_count.get(q_no, 0)
            else:
                wa_count[q_no] += 1
    
    print(ac, wa)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

p = [0]*M
s = [0]*M
b = [0]*N
pena = 0
corr = 0

for i in range(N):
    b[i] = []

for i in range(M):
    p[i], s[i] = input().split()
    p[i] = int(p[i])
    if not (set(b[p[i]-1]) & {"AC"}):
        if s[i] == "AC":
            pena += len(b[p[i]-1])
            corr += 1
    b[p[i]-1].append(s[i])

print(corr, pena)

Submission status: Time Limit Exceeded

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

if m==0:
    print(0,0)
    import sys
    sys.exit()

p=[list(input().split()) for _ in range(m)]
correct=set([p[i][0] for i in range(m) if p[i][1]=='AC'])

correct2=[]
data=[0]*n


for i in [p[j] for j in range(m) if p[j][0] in correct]:
    if i[0] in correct2:
        continue
    else:
        if i[1]=='WA':
            data[int(i[0])-1]+=1
        else:
            correct2.append(i[0])

print(len(correct),sum(data))

Submission status: Time Limit Exceeded

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

if m==0:
    print(0,0)
    import sys
    sys.exit()

p=[list(input().split()) for _ in range(m)]
correct=set([p[i][0] for i in range(m) if p[i][1]=='AC'])

correct2=[]
sum_wa=0

for i in [p[j] for j in range(m) if p[j][0] in correct]:
    if i[0] in correct2:
        continue
    else:
        if i[1]=='WA':
            sum_wa+=1
        else:
            correct2.append(i[0])

print(len(correct),sum_wa)

Submission status: Time Limit Exceeded

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

if m==0:
    print(0,0)
    import sys
    sys.exit()

p=[list(input().split()) for _ in range(m)]
correct=set([p[i][0] for i in range(m) if p[i][1]=='AC'])

correct2=[]
data={}

for i in [p[j] for j in range(m) if p[j][0] in correct]:
    if i[0] in correct2:
        continue
    else:
        if i[0] in data.keys():
            if i[1]=='WA': 
                data[i[0]]+=1
            else:
                correct2.append(i[0])
        else:
            if i[1]=='WA':
                data[i[0]]=1
            else:
                data[i[0]]=0
                correct2.append(i[0])
                
print(len(correct),sum([data[i] for i in correct]))

Submission status: Time Limit Exceeded

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

if m==0:
    print(0,0)
    import sys
    sys.exit()

correct=[]
data={}

for i in [list(input().split()) for _ in range(m)]:
    if i[0] in correct:
        continue
    else:
        if i[0] in data.keys():
            if i[1]=='WA': 
                data[i[0]]+=1
            else:
                correct.append(i[0])
        else:
            if i[1]=='WA':
                data[i[0]]=1
            else:
                data[i[0]]=0
                correct.append(i[0])
                
print(len(correct),sum([data[i] for i in correct]))

Submission status: Time Limit Exceeded

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

correct=[]
data={}

"""
for j in range(m):
    if p[j][0] in correct:
        continue
    if p[j][0] in data.keys():
        if p[j][1]=='WA': 
            data[p[j][0]]+=1
        else:
            correct.append(p[j][0])
    else:
        if p[j][1]=='WA':
            data[p[j][0]]=1
        else:
            correct.append(p[j][0])
"""

for i in [list(input().split()) for _ in range(m)]:
    if i[0] in correct:
        continue
    else:
        if i[0] in data.keys():
            if i[1]=='WA': 
                data[i[0]]+=1
            else:
                correct.append(i[0])
        else:
            if i[1]=='WA':
                data[i[0]]=1
            else:
                correct.append(i[0])


#print(correct,data)
#print(len(correct),sum(data.values()))

print(len(correct),sum([data[i] for i in correct if i in data.keys()]))

Submission status: Time Limit Exceeded

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

correct=[]
data={}

for j in range(m):
    if p[j][0] in correct:
        continue
    if p[j][0] in data.keys():
        if p[j][1]=='WA': 
            data[p[j][0]]+=1
        else:
            correct.append(p[j][0])
    else:
        if p[j][1]=='WA':
            data[p[j][0]]=1
        else:
            correct.append(p[j][0])

#print(correct,data)
#print(len(correct),sum(data.values()))
sum_wa=0
for i in correct:
    if i in data.keys():
        sum_wa+=data[i]
#print(sum_wa)
print(len(correct),sum_wa)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def main():
    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 = [int(s) for s in p]
    # 問題によってカウントしたい
    WA = [0] * (n+1)
    # 全体として何個かがわかればいい
    AC = [False] * (n+1)
    for i in range(m):
        # AC出ててなくて、WAでたらカウント、AC出たらフラグ変更        
        if not AC[p[i]]:
            if S[i] == 'WA':
                WA[p[i]] += 1
            else:
                AC[p[i]] = True
        # AC出てるから次へ
        else:
            continue
    wa = sum(WA)
    ac = sum(AC)
    print(ac, wa)
        
if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int, input().split())
judge_lis = [[] for i in range(N)]
for i in range(M):
  problem, result = input().split()
  judge_lis[int(problem)-1].append(result)

ans_lis = [0 for i in range(N)]
ans_num = 0
for i in range(N):
  j = 0
  while j < len(judge_lis[i]):
    if not "AC" in judge_lis[i]:
      break
    if judge_lis[i][j] == "WA":
      ans_lis[i] += 1
    if judge_lis[i][j] == "AC":
      ans_num += 1
      break
    j += 1
      
print(ans_num, sum(ans_lis))

Submission status: Time Limit Exceeded

Solution code:
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N,M = map(int,readline().split())
WA_cnt = [0]*(N+1)
A = []
cnt = 0
for _ in range(M):
    p,S = readline().decode().split()
    p = int(p)
    if S == 'AC' and (p in A) == False:
        A.append(p) 
        cnt += WA_cnt[p]
    else:
        WA_cnt[p] += 1
        
print(len(set(A)),cnt)

Submission status: Time Limit Exceeded

Solution code:
N,M = map(int, input().split())
answer_p = set()
submit_p= set()
L=[]
count_pena=0

for _ in range(M):
  p,S= input().split()
  answer_p.add(p)
  if (p, 'AC') in L:
    continue
  L.append((p,S))

for l in L:
  if l[0] not in answer_p:
    continue
  else:
    if l[1]=='WA':
      count_pena+=1

print(len(answer_p), count_pena)

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int, input().split())
AC = []
WA = []
wa = 0
for i in range(M):
  p, S = input().split()
  p = int(p)
  if S == 'AC':
    if p in set(AC):
      continue
    else:
      AC.append(p)
      if p in set(WA):
        wa += WA.count(p)
  else:
    if p in set(AC):
      continue
    else:
      WA.append(p)
c = len(AC)
print(c, wa, sep=' ')

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int, input().split())
AC = []
WA = []
for i in range(M):
  p, S = input().split()
  p = int(p)
  if S == 'AC':
    AC.append(p)
  else:
    if p in set(AC):
      continue
    else:
      WA.append(p)
AC = list(set(AC))
c = len(AC)
wa = 0
for w in WA:
  if w in set(AC):
    wa += 1
print(c, wa, sep=' ')

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter
n,m = map(int, input().split())

pen = 0
ac = 0
ques = []
ac_ques = set()

for _ in range(m):
    p,s = map(str, input().split())
    if p not in ac_ques:
        if s == "WA":
            ques.append(p)
        else:
            c = Counter(ques)
            pen += c[p]
            ac_ques.add(p)

print(len(ac_ques),pen)

Submission status: Time Limit Exceeded

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

arr = []
for i in range(m):
    c = input().split()
    arr.append([(int)(c[0]), c[1]])
#print("{}".format(arr))

penalty_log = {}    # まだACでないWAはここに溜める
success_log = []    # 一度でも成功したACはここに溜める

for elem in arr:
    if elem[1] == 'WA':
        if elem[0] not in success_log:
            if elem[0] not in penalty_log:
                penalty_log[elem[0]] = 1
            else:
                penalty_log[elem[0]] += 1

    elif elem[1] == 'AC':
        if elem[0] not in success_log:
            success_log.append(elem[0])

#print("success_log = {}".format(success_log))
#print("penalty_log = {}".format(penalty_log))

success = len(success_log) # ACの個数
penalty = 0 # WAの個数
for k, v in penalty_log.items():
    if k in success_log:
        penalty += v
print("{} {}".format(success, penalty))

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
ac = set()
pn = 0
l = []
for i in range(m):
  p, s = map(str, input().split())
  if s == 'AC':
    ac.add(p)
  l.append([p, s])


for a in ac:
  for p in l:
    if p[0] == a and p[1] == 'WA':
      pn += 1
    elif p[0] == a and p[1] == 'AC':
      break
print(len(list(ac)), pn)

Submission status: Time Limit Exceeded

Solution code:
L=list()
R=list()
a,b=map(int,input().split())
for i in range(b):
  c,d=input().split()
  c=int(c)
  if d=="AC":
    L.append(c)
  elif d=="WA":
    if c not in L:
      R.append(c)
L=set(L)
t=len(L)
P=[1 for i in R if i in L]
s=sum(P)
print(t,s)

Submission status: Time Limit Exceeded

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

p = [0]*(M+1)
s = [0]*(M+1)

for i in range(1,M+1):
  p[i],s[i] = input().split()
p = list(map(lambda pi:int(pi),p))


wa = 0
ac = 0
for i in range(1,N+1):
  if not i in p:
    continue
  for m in range(1,M+1):
    if p[m]==i:
      if s[m]=='AC':
      	ac += 1
      	break
      elif s[m] == 'WA':
      	wa += 1
if M==wa:
  wa = 0
print(str(ac)+' '+str(wa))

Submission status: Time Limit Exceeded

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

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

for i in range(M):
  p,s = map(str,input().split())
  p = int(p)
  if s == "AC" and p not in ac_count:
    ac += 1
    wa += wa_count[p]
    ac_count.append(p)
  else:
    wa_count[p] += 1

print(ac, wa)

Submission status: Time Limit Exceeded

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

if m == "0":
    print("0", "0")
    exit()
else:
    p=[list(map(str,list(input().split()))) for i in range(int(m))]

acs = []
was = {}

ans1 = 0
ans2 = 0

for i in p:
    if i[1] == "AC" and i[0] not in acs:
        ans1 += 1
        acs.append(i[0])
        if i[0] in was.keys():
            ans2 += was[i[0]]
    elif i[1] == "WA" and i[0] not in was.keys():
        if i[0] not in acs:
            was[i[0]] = 1
    elif i[1] == "WA" and i[0] in was.keys():
        if i[0] not in acs:
            was[i[0]] += 1

print(ans1, ans2)

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
apple = []
w = 0
cat = []
for _ in range(m):
    apple.append(list(map(str, input().split())))
r = 0
orange = [0]*(n)


for i in apple:
        if i[0] not in cat:
            if i[1] != "AC":
                orange[int(i[0]) -1] += 1
            else:
                cat.append(i[0])
                r += 1
                w += orange[int(i[0]) - 1]
                if r == n:
                    break
                else:
                    pass
        else:
            pass
print(r, w)

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
apple = []
w = 0
cat = []
for _ in range(m):
    apple.append(list(map(str, input().split())))
r = 0
orange = [0 for i in range(n)]


for i in apple:
    if r != n:
        if i[0] not in cat:
            if i[1] != "AC":
                orange[int(i[0]) -1] += 1
            else:
                cat.append(i[0])
                r += 1
                w += orange[int(i[0]) - 1]
        else:
            pass
    else:
        break
print(r, w)

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
apple = []
w = 0
cat = []
for _ in range(m):
    apple.append(list(map(str, input().split())))
r = 0
orange = [0 for i in range(n)]


for i in apple:
    if i[0] not in cat:
        if i[1] != "AC":
            orange[int(i[0]) -1] += 1
        else:
            cat.append(i[0])
            r += 1
            w += orange[int(i[0]) - 1]
    else:
        pass
print(r, w)

Submission status: Time Limit Exceeded

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

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def main():
    N, M = map(int, readline().split())
    submit = [line.split() for line in readlines()]
    submit = [[int(p), S.decode()] for p, S in submit]
    AC_submit = [p for p, S in submit if S == 'AC']
    correct_set = set(AC_submit)
    penalty = 0
    for n in correct_set:
        p_submit = [S for p, S in submit if p == n]
        try:
            penalty += p_submit.index('AC')
        except ValueError:
            pass
    print(len(correct_set), penalty)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
# C - Welcome to AtCoder
# https://atcoder.jp/contests/abc151/tasks/abc151_c

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

# 問題数分配列を作成 -> 正解判定用の関数
tmp=[0]*m
ac = 0
wa = 0

tmp_wa = 0

for i in range(m):
    if ps[i][1] == "AC":
        # 正解したことのある問題か確認
        if ps[i][0] not in list(set(tmp)):
            ac += 1          
            wa = tmp_wa
            # tmp_wa = 0
            tmp[i] = ps[i][0]


    else:
        if ps[i][0] not in tmp:
            tmp_wa += 1


print(ac,wa)


# ACのカウントを数える
# ACが出るまでにでたWAをカウントする

# すでに正解済みの問題であれば、ACはカウントアップしない。

# すでに正解済みの問題であれば、ACはカウントアップしない。

# おそらく辞書を使う

Submission status: Time Limit Exceeded

Solution code:
# C - Welcome to AtCoder
# https://atcoder.jp/contests/abc151/tasks/abc151_c

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

# 問題数分配列を作成 -> 正解判定用の関数
tmp=[0]*m
ac = 0
wa = 0

tmp_wa = 0

for i in range(m):
    if ps[i][1] == "AC":
        # 正解したことのある問題か確認
        if ps[i][0] not in tmp:
            ac += 1          
            wa = tmp_wa
            # tmp_wa = 0
            tmp[i] = ps[i][0]


    else:
        if ps[i][0] not in tmp:
            tmp_wa += 1


print(ac,wa)


# ACのカウントを数える
# ACが出るまでにでたWAをカウントする

# すでに正解済みの問題であれば、ACはカウントアップしない。

# すでに正解済みの問題であれば、ACはカウントアップしない。

# おそらく辞書を使う

Submission status: Time Limit Exceeded

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

sP = {}
WA =0
AC =0
number_list =[]
for _ in range(M):
    data = input()
    number, result = data.split()
    if number not in number_list:
        number_list.append(number)

    if data not in sP:
        if number + " AC" not in sP:
            if result == "WA":
                sP[data] = 1
                WA += 1

            elif result == "AC":
                sP[data] = 1
                AC += 1
        else:
            pass
    else:
        sP[data] += 1
        if number + " AC" not in sP:
            if result == "WA":
                WA += 1

            elif result == "AC":
                AC += 1
        else:
            pass

for num in number_list:
    num_res = str(num) + " AC"
    if num_res not in sP:
        WA -= sP[str(num) + " WA"]


print(AC, WA)