Problem:


Score : 300 points

Problem Statement

Takahashi participated in a contest on AtCoder.

The contest had N problems.

Takahashi made M submissions during the contest.

The i-th submission was made for the p_i-th problem and received the verdict S_i (AC or WA).

The number of Takahashi's correct answers is the number of problems on which he received an AC once or more.

The number of Takahashi's penalties is the sum of the following count for the problems on which he received an AC once or more: the number of WAs received before receiving an AC for the first time on that problem.

Find the numbers of Takahashi's correct answers and penalties.

Constraints

N, M, and p_i are integers.

1 \leq N \leq 10^5

0 \leq M \leq 10^5

1 \leq p_i \leq N

S_i is AC or WA.

Input

Input is given from Standard Input in the following format:

N M
p_1 S_1
:
p_M S_M

Output

Print the number of Takahashi's correct answers and the number of Takahashi's penalties.

Sample Input 1

2 5
1 WA
1 AC
2 WA
2 AC
2 WA

Sample Output 1

2 2

In his second submission, he received an AC on the first problem for the first time. Before this, he received one WA on this problem.

In his fourth submission, he received an AC on the second problem for the first time. Before this, he received one WA on this problem.

Thus, he has two correct answers and two penalties.

Sample Input 2

100000 3
7777 AC
7777 AC
7777 AC

Sample Output 2

1 0

Note that it is pointless to get an AC more than once on the same problem.

Sample Input 3

6 0

Sample Output 3

0 0



Sample input:
2 5
1 WA
1 AC
2 WA
2 AC
2 WA


Sample output:
2 2

Submission status: Time Limit Exceeded

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

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

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

print(a_cnt, w_cnt)

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

nums=[]
jud=[]
WAs={}
for i in range(M):
  A=input().split()
  nums.append(A[0])
  jud.append(A[1])
  WAs[nums[i]]=0

ACs=[]


AC=0
pena=0

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

Submission status: Time Limit Exceeded

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


def solve(N: int, M: int, p: "List[int]", S: "List[str]"):
    ac_list = []
    for (pi, si) in zip(p, S):
        if si=="AC":
            ac_list.append(pi)
    ac_list = list(set(ac_list))
    num_ans = len(ac_list)

    num_penalty = 0
    for (pi, si) in zip(p, S):
        # check ac
        if pi in ac_list:
            if si == "WA":
                num_penalty += 1
            else:
                tmp = ac_list.remove(pi)
        if len(ac_list) == 0:
            break

    print(num_ans, num_penalty)
# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    p = [int()] * (M)  # type: "List[int]"
    S = [str()] * (M)  # type: "List[str]"
    for i in range(M):
        p[i] = int(next(tokens))
        S[i] = next(tokens)
    solve(N, M, p, S)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

p = []
s = []
for _ in range(nm[1]):
    ps = input().split()
    p.append(int(ps[0]))
    s.append(ps[1])

ac = []
wa = {}
pc = 0

for i in range(nm[1]):
    if p[i] in ac:
        continue
    elif s[i] == 'WA':
        if p[i] in wa:
            wa[p[i]] += 1
        else:
            wa[p[i]] = 1
    else:
        if p[i] in wa:
            pc += wa[p[i]]
            ac.append(p[i])
        else:
            ac.append(p[i])

print(len(ac), pc)

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
ps = [input().split() for _ in range(m)]
 
a = []
wa = {}
AC_count = 0
WA_count = 0
for i in range(m):
    if ps[i][0] not in a:
        if ps[i][1] == 'AC':
            AC_count += 1
            if ps[i][0] in wa.keys():
                WA_count += wa[ps[i][0]]
            a.append(ps[i][0])
        else:
            if ps[i][0] in wa.keys():
                wa[ps[i][0]] += 1
            else:
                wa[ps[i][0]] = 1
print(AC_count, WA_count)

Submission status: Time Limit Exceeded

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

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

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

print(ac_count,wa_count)

Submission status: Time Limit Exceeded

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

AC = 0
WA = 0
for i in range(0, N + 1):
    wa = 0
    for submit in l:
        if submit[0] == i:
            if submit[1] == "WA":
                wa += 1
            else:
                AC += 1
                WA += wa
                break

print(AC, WA)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

ACsum = 0
ACList = []
for mykey, myvalue in D.items() :
  if myvalue == "AC" :
    ACsum += 1
    ACList += [mykey]
    
#print(ACList)
WAsum = 0
for k in range(len(ACList)) :
  for i in range(M) :
    #print(ACList[k])
    #print(L[i][0])
    #print(L[i][1])
    if ACList[k] == L[i][0] :
      if L[i][1] == "WA" :
        WAsum += 1
      else :
        break

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

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 == 'WA' and  p in pro and p not in c:
        pro[p] += 1
    elif S == 'WA' and p not in c:
        pro[p] = 1
    elif S == 'AC' and p not in c:
        if p in pro:
            f_sum += pro[p]
        c.append(p)
print("{} {}".format(len(c), f_sum))

Submission status: Time Limit Exceeded

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


def solve(N: int, M: int, p: "List[int]", S: "List[str]"):
    ac_list = []
    for (pi, si) in zip(p, S):
        if si=="AC":
            ac_list.append(pi)
    ac_list = sorted(list(set(ac_list)))
    num_ans = len(ac_list)

    num_penalty = 0
    for (pi, si) in zip(p, S):
        # check ac
        if pi in ac_list:
            if si == "WA":
                num_penalty += 1
            else:
                tmp = ac_list.remove(pi)
        if len(ac_list) == 0:
            break

    print(num_ans, num_penalty)
# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    p = [int()] * (M)  # type: "List[int]"
    S = [str()] * (M)  # type: "List[str]"
    for i in range(M):
        p[i] = int(next(tokens))
        S[i] = next(tokens)
    solve(N, M, p, S)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

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

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

print(a_cnt, w_cnt)

Submission status: Time Limit Exceeded

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

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

wa = 0
for key, value in wa_history.items():
    if key in solved:
        wa += value

print(len(solved), wa)

Submission status: Time Limit Exceeded

Solution code:
n,m = map(int,input().split())
d = {}
a = []
b = 0
c = 0
for _ in range(m):
    p, s = input().split()
    a.append([p, s])
for i in range(m):
    if a[i][0] in d:
        continue
    else:
        if a[i][1] == 'WA':
            if [a[i][0], 'AC'] in a:
                b += 1
        else:
            d[a[i][0]] = 'AC'
            c += 1
print(c, b)

Submission status: Time Limit Exceeded

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

        sumi.append(a[0])
        ac += 1
        try:
            wa += b[a[0]]
        except KeyError:
            continue
print(ac, wa)

Submission status: Time Limit Exceeded

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

num = []
for i in range(n):
  num.append(i+1)

WA = 0
AC = 0

import numpy as np

ar = np.zeros((n, 2), dtype=np.int64)

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

Submission status: Time Limit Exceeded

Solution code:
N, M = list(map(int, input().split(' ')))
result_list = [input().split(' ') for i in range(M)]
AC_total = 0
WA_total = 0
ac_list = []
wa_dict = {}
for p, s in result_list:
    if p not in ac_list:
        if s == 'WA':
            if p in wa_dict:
                wa_dict[p] += 1
            else:
                wa_dict[p] = 1
        else:
            AC_total += 1
            if p in wa_dict:
                WA_total += wa_dict[p]
            ac_list.append(p)
print('{} {}'.format(AC_total, WA_total))

Submission status: Time Limit Exceeded

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

if __name__ == "__main__":
  main()

Submission status: Time Limit Exceeded

Solution code:
import math
import queue
import bisect
import heapq
import time
import itertools

mod = int(1e9+7)

def swap(a,b):
    return (b,a)

def my_round(a,dig=0):
    p = 10 ** dig
    return (a * p * 2 + 1) // 2 / p

def gcd(a,b): #最大公約数
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

def lcm(a,b): #最小公倍数
    return a/gcd(a,b)*b

def divisors(a): # 約数列挙
    divisors = []
    for i in range(1,int(a**0.5)+1):
        if a%i==0:
            divisors.append(i)
            if i!=a//i:
                divisors.append(a//i)
    return divisors

def is_prime(a): #素数判定
    if a<2:
        return False
    elif a==2:
        return True
    elif a%2==0:
        return False
    sqrt_num = int(a**0.5)
    for i in range(3,sqrt_num+1,2):
        if a%i==0:
            return False
    return True

def prime_num(a): #素数列挙
    pn = [2]
    for i in range(3,int(a**0.5),2):
        prime = True
        for j in pn:
            if i%j==0:
                prime = False
                break
        if prime:
            pn.append(i)
    return pn

def prime_fact(a): #素因数分解
    sqrt = math.sqrt(a)
    res = []
    i = 2
    if is_prime(a):
        res.append(a)
    else:
        while a!=1:
            while a%i==0:
                res.append(i)
                a //= i
            i += 1
    return res

def main():
    n,m = map(int,input().split())
    mp = {}
    for i in range(m):
        p,s = input().split()
        if p in mp.keys():
            if mp[p][1]:
                continue
            elif s == 'AC':
                mp[p][1] = True
            else:
                mp[p][0] += 1
        else:
            if s == 'WA':
                mp[p] = [1,False]
            else:
                mp[p] = [0,True]
    ans = 0
    pena = 0
    for key in mp.keys():
        if mp[key][1]:
            ans += 1
            pena += mp[key][0]
    print(ans,pena)
    return

if __name__=='__main__':
    main()

Submission status: Time Limit Exceeded

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

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

for i in range(M):
  if li[i][1] == "AC":
    if li[i][0] in done:
      pass
    else:
      ans[0] += 1
      done.append(li[i][0])
      if li[i][0] in miss.keys():
        ans[1] += miss[li[i][0]]
  else:
    if li[i][0] in done:
      pass
    else:
      if li[i][0] in miss.keys():
        miss[li[i][0]] += 1
      else:
        miss[li[i][0]] = 1
print(ans[0],ans[1])

Submission status: Time Limit Exceeded

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

p = []
s = []
for _ in range(nm[1]):
    ps = input().split()
    p.append(int(ps[0]))
    s.append(ps[1])

ac = []
wa = {}
pc = 0

for i in range(nm[1]):
    if s[i] == 'WA':
        if s[i] not in ac:
            if p[i] in wa:
                wa[p[i]] += 1
            else:
                wa[p[i]] = 1
    else:
        if p[i] in ac:
            continue
        elif p[i] in wa:
            pc += wa[p[i]]
            ac.append(p[i])
        else:
            ac.append(p[i])

print(len(ac), pc)

Submission status: Time Limit Exceeded

Solution code:
line1 = input().split()
N, M = int(line1[0]), int(line1[1])
AC, WA = [], []
allWA = 0

for i in range(M):
  res = input().split()
  p = int(res[0])  #問題番号
  s = res[1]  #結果

  if not p in AC:
    if s == 'AC':
      AC.append(p)
      allWA += WA.count(p)
    else:
      WA.append(p)
    
print(str(len(AC)) + ' ' + str(allWA))

Submission status: Time Limit Exceeded

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

a = []
wa = {}
AC_count = 0
WA_count = 0
for i in range(m):
    if ps[i][0] not in a:
        if ps[i][1] == 'AC':
            AC_count += 1
            if ps[i][0] in wa.keys():
                WA_count += wa[ps[i][0]]
            a.append(ps[i][0])
        else:
            if ps[i][0] in wa.keys():
                wa[ps[i][0]] += 1
            else:
                wa[ps[i][0]] = 1
print(AC_count, WA_count)

Submission status: Time Limit Exceeded

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


def solve(N: int, M: int, p: "List[int]", S: "List[str]"):
    ac_list = []
    for (pi, si) in zip(p, S):
        if si=="AC":
            ac_list.append(pi)
    ac_list = sorted(list(set(ac_list)))
    num_ans = len(ac_list)

    num_penalty = 0
    for i, (pi, si) in enumerate(zip(p, S)):
        # check ac
        if pi in ac_list:
            if si == "WA":
                num_penalty += 1
            else:
                tmp = ac_list.remove(pi)

    print(num_ans, num_penalty)
# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    p = [int()] * (M)  # type: "List[int]"
    S = [str()] * (M)  # type: "List[str]"
    for i in range(M):
        p[i] = int(next(tokens))
        S[i] = next(tokens)
    solve(N, M, p, S)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

ac=0
wa=0
ll=[] #正答リスト
lll=[] #誤答リスト
for i in range(n):
    lll.append(0)
for i in range(m):
    if l[i][1]=="WA":
        lll[int(l[i][0])-1]+=1
    if l[i][1]=="AC" and int(l[i][0]) not in ll:
        ac+=1
        ll.append(int(l[i][0]))
        wa+=lll[int(l[i][0])-1]
print(ac,wa)

Submission status: Time Limit Exceeded

Solution code:
N, M = list(map(int, input().split(' ')))
result_list = [input().split(' ') for i in range(M)]
AC_total = 0
WA_total = 0
ac_list = []
wa_dict = {}
for p, s in result_list:
    if p not in ac_list:
        if s == 'WA':
            if p in wa_dict:
                wa_dict[p] += 1
            else:
                wa_dict[p] = 1
        else:
            AC_total += 1
            ac_list.append(p)
for p in wa_dict:
    if p in ac_list:
        WA_total += wa_dict[p]
print('{} {}'.format(AC_total, WA_total))

Submission status: Time Limit Exceeded

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

def qa(s):
    qa_dict = {}
    target_q = []
    WAs=0
    ACs=0
    for t in s:
        if t[1] == 'AC':
            target_q.append(t[0])
    target_q = sorted(list(set(target_q)))
    for q in target_q:
        qa_dict[q] = []
        for a in s:
            if a[0] == q:
                qa_dict[q].append(a[1])
                if a[1] == 'AC':
                    break
                else:
                    continue
    for v in qa_dict.values():
        WAs += (len(v) - 1)
        ACs += 1
    return ACs, WAs

if m == 0:
    ac, wa = 0, 0
else:
    ac, wa = qa(s)
print('{} {}'.format(ac, wa))

Submission status: Time Limit Exceeded

Solution code:
line1 = input().split()
N, M = int(line1[0]), int(line1[1])
AC, WA = [], []
allWA = 0

for i in range(M):
  res = input().split()
  p = int(res[0])  #問題番号
  s = res[1]  #結果

  if s == 'AC':
    if not p in AC:
      AC.append(p)
      allWA += WA.count(p)
  else:
    WA.append(p)
    
print(str(len(AC)) + ' ' + str(allWA))

Submission status: Time Limit Exceeded

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


import numpy as np
P=np.array(P)
S=np.array(S)

if M>0:
    ans=np.unique(P[S=="AC"])

    wa=0
    for j in ans:
        for i in S[P==j]:
            if i=="WA":
                wa+=1
            else:
                break

    print(len(ans),wa)
else:
    print(0,0)

Submission status: Time Limit Exceeded

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

result=[list(input().split()) for i in range(M)]
nums=[]
jud=[]
for i in range(M):
  nums.append(result[i][0])
  jud.append(result[i][1])
  
WAs={nums[i]: 0 for i in range(M)}
ACs=[]

AC=0
pena=0

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

Submission status: Time Limit Exceeded

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

WA_nums = dict()
AC = []
penalty = 0
for i in range(m):
    p, s = input().split()
    if p in AC:
        continue
    if s == 'AC':
        if p in WA_nums:
            penalty += WA_nums[p]
        AC.append(p)
    else:
        if p in WA_nums:
            WA_nums[p] += 1
        else:
            WA_nums[p] = 1

print(len(AC), penalty)

Submission status: Time Limit Exceeded

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

ansAC=0
ansP=0

n=[0]*N
AC=[]

for i in range(M):
    p,s =map(str,input().split())
    p=int(p)-1
    if p in AC:continue

    if s=="AC":
        ansP+=n[p]
        ansAC+=1
        AC.append(p)
    else:
        n[p]+=1

print(ansAC,ansP)

Submission status: Time Limit Exceeded

Solution code:
import collections

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

ac=0
wa=0
ll=[] #正答リスト
for i in range(m):
    if l[i][1]=="AC" and l[i][0] not in ll:
        ac+=1
        ll.append(l[i][0])
        wa+=l[:i].count([l[i][0],"WA"])
print(ac,wa)

Submission status: Time Limit Exceeded

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

P = []
S = []

clear = 0

q = {}
c = []

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

    if p not in c:
        if s == "AC":
            clear += 1
            c.append(p)

        if s == "WA":
            q[p] = q.get(p, 0) + 1

warng = 0
for k, v in q.items():
    if k in c:
        warng += v

print("{} {}".format(clear, warng))

Submission status: Time Limit Exceeded

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

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

print(len(AC), penalty)

Submission status: Time Limit Exceeded

Solution code:
def main():
    n, m = map(int, input().split())
    ac = 0
    wa = 0
    a = []
    b = {}
    for _ in range(m):
        q, j = input().split()
        if q in a:
            continue
        if q not in a and j == 'AC':
            ac += 1
            a.append(q)
            if q in b:
                wa += b[q]
        else:
            if q not in b:
                b[q] = 0
            b[q] += 1
    print(ac, wa)

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
n,m = list(map(int, input().split()))
aclist=[]
ac=0
wa=[0 for i in range(n)]
for i in range(m):
    j = list(input().split())
    if int(j[0]) not in aclist:
        if j[1]=='AC':
            ac+=1
            aclist.append(int(j[0]))
        elif j[1]=='WA':
            wa[int(j[0])-1]+=1
ans=0
for i in aclist:
    ans+=wa[i-1]
print(ac,ans)

Submission status: Time Limit Exceeded

Solution code:
from collections import defaultdict

n, m = map(int, input().split())
ac = 0
wa = 0
a = []
b = defaultdict(int)
for _ in range(m):
    q, j = input().split()
    if q in a:
        continue
    if q not in a and j == 'AC':
        ac += 1
        a.append(q)
        if q in b:
            wa += b[q]
    else:
        b[q] += 1
print(ac, wa)

Submission status: Time Limit Exceeded

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

p_list = []
S_list = []
ac_list = []
wa_list = [0 for i in range(N)]
for i in range(M):
    p, S = map(str, input().split())
    p = int(p)
    if p not in ac_list:
        if S == "AC":
            ac_list.append(p)
        else:
            wa_list[p - 1] += 1

wa_num = 0
for i in range(len(ac_list)):
    wa_num += wa_list[ac_list[i] - 1]
print("{} {}".format(len(ac_list), wa_num))

Submission status: Time Limit Exceeded

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

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

print(len(AC), penalty)

Submission status: Time Limit Exceeded

Solution code:
from collections import defaultdict

n, m = map(int, input().split())
ac = 0
wa = 0
a = []
b = defaultdict(int)
for _ in range(m):
    q, j = input().split()
    if q not in a and j == 'AC':
        ac += 1
        a.append(q)
        if q in b:
            wa += b[q]
    else:
        b[q] += 1
print(ac, wa)

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int, input().split())
S = [[]] * N
for i in range(M):
	p, s = input().split()
	S[int(p)-1] = S[int(p)-1] + [s]

r,w = 0,0
for i in S:
	if 'AC' in i:
		r += 1
		w += i.index('AC')

print(r,w)

Submission status: Time Limit Exceeded

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

ac=0
wa=0
ll=[] #正答リスト
for i in range(m):
    if l[i][1]=="AC" and l[i][0] not in ll:
        ac+=1
        ll.append(l[i][0])
        for j in range(i):
            if l[j][1]=="WA" and l[j][0]==l[i][0]:
                wa+=1

print(ac,wa)

Submission status: Accepted

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

ac = 0
wa = 0
acs = [0] * n
was = [0] * n
for _ in range(m):
    p, s = input().split()
    p = int(p) - 1
    if s == 'AC':
        if not acs[p]:
            ac += 1
            wa += was[p]
            acs[p] += 1
    else:
        if not acs[p]:
            was[p] += 1
print(ac, wa)

Submission status: Accepted

Solution code:
# coding: utf-8


def main():
    N, M = map(int, input().split())
    ans = [0, 0]
    A = [[0, 0] for _ in range(N)]

    for i in range(M):
        p, s = input().split()
        p = int(p)
        if s == 'AC':
            A[p - 1][1] = 1
        elif A[p - 1][1] == 0:
            A[p - 1][0] += 1
    
    for i, j in A:
        if j == 1:
            ans[0] += 1
            ans[1] += i

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

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def resolve():
    n,m = map(int,input().split())
    ac_list = [0]*n
    wa_count = [0]*n
    ac = 0
    wa = 0
    for _ in range(m):
        p,s = input().split()
        if s == 'WA' and (ac_list[int(p)-1]==0):
            wa_count[int(p)-1] += 1
        elif s == 'AC' and (ac_list[int(p)-1]==0):
            ac += 1
            ac_list[int(p)-1] = 1
    for (i,j) in zip(wa_count,ac_list):
        if j: wa+=i
    print(f'{ac} {wa}')
resolve()

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
ac_cnt = set()
wa_cnt = 0
penalty = [0]*n
for i in range(m):
    p,s = input().split()
    num = int(p) - 1
    if num not in ac_cnt:
        if s == "AC":
            ac_cnt.add(num)
            wa_cnt += penalty[num]
        else:
            penalty[num] += 1
print(len(set(ac_cnt)),wa_cnt)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
def main():
    N, M = map(int, input().split())
    pS = [list(input().split()) for _ in range(M)]

    score = [0] * (N + 1)
    ac = [False] * (N + 1)
    for p, S in pS:
        res = int(p)
        if S == 'AC':
            ac[res] = True
        if ac[res]:
            continue
        score[res] += 1
    penalty = 0
    for i in range(N + 1):
        if ac[i]:
            penalty += score[i]
    print(sum(ac), penalty)
    # print(ac)
    # print(score)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

for i in range(m):
    no = p[i]
    if correct[no-1] == 1:
        continue
    elif s[i] == 'WA':
        penalty[no-1] += 1
    elif s[i] == 'AC':
        correct[no-1] = 1

pen = 0
for i in range(n):
    if correct[i] == 1:
        pen += penalty[i]
print(sum(correct), pen)

Submission status: Accepted

Solution code:
N, M = map(int, input().split(' '))
ac_set = set()
wa_cnt, wa_cnt_ls = 0, [ 0 for i in range(N) ]
for i in range(M):
    p, s = input().split(' ')
    idx = int(p) - 1
    if not idx in ac_set:
        if s == 'AC':
            ac_set.add(idx)
            wa_cnt += wa_cnt_ls[idx]
        else:
            wa_cnt_ls[idx] += 1
print(len(ac_set), wa_cnt)

Submission status: Accepted

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

submit = []
for i in range(m):
    temp = [x for x in input().split()]
    submit.append(temp)

ac = [0] * (n + 1)
wa = [0] * (n + 1)

for i in range(m):
    result = submit[i][1]
    question = int(submit[i][0])

    if result == 'AC' and ac[question] == 0:
        ac[question] = 1
    elif result == 'WA' and ac[question] == 0:
        wa[question] += 1

for i in range(n + 1):
    if ac[i] != 1:
        wa[i] = 0

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

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
AC = [0]*n
WA = [0]*n
ac = 0
wa = 0

for i in range(m):
  c,s = input().split()
  c = int(c)
  c -= 1
  if AC[c]: continue
  if s == 'AC':
    AC[c] = 1
  else:
    WA[c] +=  1

for i in range(n):
  ac += AC[i]
  if AC[i]: 
    wa += WA[i]

print(ac, wa)

Submission status: Accepted

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

for m in range(M):
    a,b = map(str, input().split())
    a = int(a) - 1

    if ans[a] != -1 and b == 'WA':
        ans[a] += 1
    if ans[a] != -1 and b == 'AC':
        ac += 1
        p += ans[a]
        ans[a] = -1

print(ac,p)