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: Runtime Error

Solution code:
"""
author : halo2halo
date : 4, Feb, 2020
"""

import sys

# import itertools
# import math

import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
INF = 10 ** 9

N, M = map(int, readline().split())
AC = 0
WA = 0
li = []
for i in range(M):
    p, s = map(str, readline().decode('utf8').split())
    if p not in li:
        if s != 'AC':
            WA += 1
        else:
            AC += 1
            li.append(p)

print(AC, WA)

Submission status: Runtime Error

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

c = [0]*N
w = [0]*M

ac = 0
wa = 0

for i, v in A:
    if c[int(i)-1] == 0:
        if v == 'WA':
            w[int(i)-1] += 1
        elif v == 'AC':
            ac += 1
            wa += w[int(i)-1]
            c[int(i)-1] = 1

print(ac, wa)

Submission status: Runtime Error

Solution code:
def main(n,m,r):
    ac = [0]*n
    wa = [0]*n
    for i in range(len(r)):
        if r[i][1] == "WA":
            if ac[int(r[i][0])] != 0:
                wa[int(r[i][0])] += 1
        elif r[i][1] == "AC":
            ac[int(r[i][0])] = 1
    acsum = sum(ac)
    wasum = sum(wa)
    return "{0} {1}".format(acsum, wasum)

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

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
l=[[0][0] for _ in range(n+1)]
p=0
for _ in range(m):
  a,b=list(input().split())
  if str(b)=="AC" and l[int(a)][0]==0:
    l[int(a)][0]=1
    p+=l[int(a)][1]
  elif str(b)=="WA" and l[int(a)]==0:
    l[int(a)][1]+=1
print(l.count(1),p)

Submission status: Runtime Error

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

ls = [0 for _ in range(n+1)]

pen = 0

for _ in range(m):
  p,s = input().split()
  p = int(p)
  
  if ls[p] == None:
    pass
  elif s == "WA":
    ls[p] += 1
  else:
    pen += ls[p]
    ls[p] = None
print(sum(ls),pen)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
N, M = map(int, input().split(" "))
count = [0 for i in range(N)]
flag = [0 for i in range(N)]
correct = 0
for i in range(M):
    tmp = input().split(" ")
    p, S = int(tmp[0]), tmp[1]
    if S == "WA" and flag[p-1] == 0:
        count[p-1] += 1
    elif S == "AC" and flag[p-1] == 0:
        correct += 1
        flag[p-1] = 1
print(sum(correct), sum(count))

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
p_S = []
for i in range(0,M):
    a, b = input().split()
    a = int(a)
    p_S.append([a,b])
s, t = 0, 0
res = []
for i in range(0,N):
    res.append([i,0])
for i in range(0,M):
    if p_S[i][1] == "WA":
        res[p_S[i][0]][1] = res[p_S[i][0]][1]+1
    elif res[p_S[i][0]][1] >= 0:
        s, t = s+1, t+res[p_S[i][0]][1]
        res[p_S[i][0]][1] = -1
print(s, t)

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
if m ==0:
    print(0,0)
    exit()
p = [0] * (m+2)
s = [0] * (m+2)
w_count = 0
a_count = 0
flag = 0
for i in range(m+1):
    p[i],s[i] = input().split()
    if p[i] != p[i-1]:
        flag = 0
    if s[i] == 'AC' and flag == 0:
        flag = 1
        a_count += 1
    elif s[i] == 'WA':
        w_count += 1 and flag == 0
    


print(a_count,w_count)

Submission status: Runtime Error

Solution code:
import copy

N,M=map(int,input().split())
L=[list(map(int,input().split())) for i in range(M)]

S=[]
component=[0,0]
for j in range(N):
    S.append(copy.deepcopy(component)

for k in range(1,M+1):
    if L[k-1][1]=='AC':
        if S[L[k-1][0]][0]==0:
            S[L[k-1][0]][0]=1
    else:
        if S[L[k-1][0]][0]==0:
            S[L[k-1][0]][1]+=1

ansAC=0
ansWA=0

for l in range(N):
    ansAC+=S[l][0]
    ansWA+=S[l][1]

print(ansAC,ansWA)

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
if m ==0:
    print(0,0)
    exit()
p = [0] * m 
s = [0] * m
w_count = 0
a_count = 0

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

p = sorted(set(p))
i = int(p[0])
j = 0

while i != int(p[-1]) + 1:
    if p[j] == i and s[j] == 'WA':
        w_count += 1
    elif p[j] == i and s[j] == 'AC':
        a_count += 1
        i += 1
    j += 1

print(a_count,w_count)

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
if m ==0:
    print(0,0)
    exit()
p = [0] * m 
s = [0] * m
w_count = 0
a_count = 0

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

p = sorted(set(p))
i = int(p[0])
j = 0

while i != int(p[-1]) + 1:
    if s[j] == 'WA':
        w_count += 1
    elif s[j] == 'AC':
        a_count += 1
        i += 1
    j += 1

print(a_count,w_count)

Submission status: Runtime Error

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

for p, S in results:
    if p in solved:
        continue

    if S == 'AC':
        solved.add(p)
        penalty += missed[p]
    elif p not in missed:
        missed[p] = 1
    else:
        missed[p] += 1

print(len(solved), penalty)

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
submits = []
for i in range(m):
  submit = input().split()
  submits.append(submit)
wa = 0
ac = 0
l = [submits[0]]
for i in range(1, m):
  if submits[i] == submits[i-1]:
    l.append(submits[i])
  else:
    l = []
    l.append(submits[i])
  if i != m-1 and submits[i] != submits[i+1]:
    for j in range(len(l)):
      if l[j][1] == "WA":
        wa += 1
      else:
        ac += 1
        break
  elif i == m-1:
    for j in range(len(l)):
      if l[j][1] == "WA":
        wa += 1
      else:
        ac += 1
        break
print(ac, wa)

Submission status: Runtime Error

Solution code:
rom sys import stdin

def main():
    n,m = map(int,stdin.readline().split())
    arr= [0 for _ in range(n+1)]
    p=0;a= 0
    for _ in range(m):
        x,y = stdin.readline().split()
        x = int(x)
        if  arr[x] != -1:
            if y == "WA":
                p+=1
            else:
                a+=1
                arr[x] = -1
    print(a,p)
main()

Submission status: Runtime Error

Solution code:
import numpy as np

def main():
    # N, M = map(int, input().split())
    # PS = {}
    # for i in range(M):
    #     row = input().split()
    #     row[0] = int(row[0])
    #     if row[0] not in PS:
    #         PS[row[0]] = [row[1]]
    #     else:
    #         PS[row[0]].append(row[1])

    # n_correct = 0
    # n_penalty = 0
    # for p in PS:
    #     if 'AC' in PS[p]:
    #         n_correct += 1
    #         for result in PS[p]:
    #             if result == 'AC':
    #                 break
    #             if result == 'WA':
    #                 n_penalty += 1
    
    # print('{} {}'.format(n_correct, n_penalty))

    
    N, M = map(int, input().split())
    acc = [False] * (N+1)
    pen = [0] * (N+1)
    for _ in range(M):
        p, S = input().split()
        p = int(p)
        if S[0] == 'A':
            acc[p] = True
        else:
            pen[p] += 1
    pen = 0
    for i in range(1, N+1):
        if not acc[p]:
            pen += pen[p]
    print('{} {}'.format(sum(acc), pen))

    

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
acc = [False] * N
pen = 0
for _ in range(M):
	p, S = input().split()
	p = int(p) - 1
	if S[0] == 'A':
		acc[p] = True
	else:
		if not acc[p]:
            pen += 1
print('{} {}'.format(sum(acc), pen))

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
acc = [False] * N
pen = 0
for _ in range(M):
  p, S = input().split()
  p = int(p) - 1
  if S[0] == 'A':
    acc[p] = True
  else:
  	if not acc[p]:
      pen += 1
print('{} {}'.format(sum(acc), pen))

Submission status: Runtime Error

Solution code:
import numpy as np
n,m = map(int,input().split())

p = []
s = []
ans_a = np.zeros(n+1)
ans_p = np.zeros(n+1)

for i in range(m):
    pi ,si = map(str,input().split())
    p.append(int(pi))
    s.append(si)

for i in range(m):
    if s[i] == "AC":
        ans_a[p[i]] = 1
    if s[i] == "WA" and ans_a[p[i]] == 0:
        ans_p[p[i]] += 1

print(int(np.sum(ans_a)), int(np.sum(ans_p))s)

Submission status: Runtime Error

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

wa_score = [0]*N
ac_flg = [0]*N

for p,s in p_s:
    p = int(p)
    if s == 'AC':
        ac_flg[p-1] = 1
    else:
        if ac_flg[p-1] == 0:
            wa_score[p-1] += 1

ac_count = sum(ac_flg)
wa_count = 0
for i in ac_flg:
    if i == 1:
        wa_count += wa_score[i]

print(ac_count,wa_count)

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
P = []
S = []
flag = [False for i in range(0, N)]
for i in range(0, M):
    x, y = map(str, input().split())
    P.append(int(x-1))
    S.append(y)
ans = [0, 0]
for i in range(0, M):
    if flag[P[i]]:
        continue
    else:
        if S[i] == 'AC':
            flag[P[i]] = True
            ans[0] += 1
        else:
            ans[1] += 1
print(*ans)

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
ac=[False]*(n+1)
wa=[0]*(n+1)
pena=0
for i in range(m):
    p,s=input().split()
    p=int(p)
    if s == "AC":
        ac[p] = True
    else:
        if False:
            wa[p] += 1
        else:
            continue
for i in ac:
    if i == True:
        pena += wa[index(i)]

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
ac=[0 for _ in range(n)]
wt=[0 for _ in range(n)]
pen=0
for i in range(m):
    p,s=input().split()
    if s=="AC":
        ac.append(int(p))
        pen += wt[int(p)]
    else:
        if int(p) in ac:
            pass
        else:
            wt[int(p)] += 1
            
t_ac=set(ac))
print(len(t_ac),pen)

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
ac=[0 for _ in range(n)]
wt=[0 for _ in range(n)]
pen=0
for i in range(m):
    p,s=input().split()
    if s=="AC":
        ac.append(p)
        pen += wt[int(p)]
    else:
        if p in ac:
            pass
        else:
            wt[int(p)] += 1
            
t_ac=set(ac))
print(len(t_ac),pen)

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
ac=[]
wt=[0 for _ in range(n)]
pen=0
for i in range(m):
    p,s=input().split()
    if s=="AC":
        ac.append(p)
        pen += wt[p]
    else:
        if p in ac:
            pass
        else:
            wt[p] += 1
            
t_ac=set(ac)
print(len(t_ac),pen)

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
ac=[]
wt=[]
pen=0
for i in range(m):
    p,s=input().split()
    if s=="AC":
        ac.append(p)
        pen += wt[p]
    else:
        if p in ac:
            pass
        else:
            wt[p] += 1
            
t_ac=set(ac)
print(len(t_ac),pen)

Submission status: Runtime Error

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()

if M == 0:
	print(0, 0)
else:
	temp = [input().split() for _ in range(M)]
	temp = [list(x) for x in zip(*temp)]
	p, S = list(map(int, temp[0])), temp[1]

	a = [i for i, x in enumerate(S) if x == 'AC']
	a.append(a[len(a)-1])
	AC = 0
	WA = 0
	
	for i in range(len(p)):
		if p[i]>=AC+1:
			if S[i]=="AC":
				if i == len(p)-1:
					AC += 1
				else:
					if p[i]==p[i+1]:
						if S[i+1]=="WA":
							AC += 1
						else:
							continue
					else:
						AC += 1
			else:
 				WA += 1

	print(AC, WA)

Submission status: Runtime Error

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()

if M == 0:
	print(0, 0)
else:
	temp = [input().split() for _ in range(M)]
	temp = [list(x) for x in zip(*temp)]
	p, S = list(map(int, temp[0])), temp[1]

	a = [i for i, x in enumerate(S) if x == 'AC']
	a.append(a[len(a)-1])

	AC = 0
	WA = 0

	for i in range(len(p)):
		if S[i]=="AC":
			if i == len(p)-1:
				AC += 1
			else:
				if p[i]==p[i+1]:
					if S[i+1]=="WA":
						AC += 1
					else:
						continue
				else:
					AC += 1
		else:
			if i < a[AC]:
	 			WA += 1
	print(AC, WA)

Submission status: Runtime Error

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()

if M == 0:
	print(0, 0)
else:
	temp = [input().split() for _ in range(M)]
	temp = [list(x) for x in zip(*temp)]
	p, S = list(map(int, temp[0])), temp[1]

	a = [i for i, x in enumerate(S) if x == 'AC']
	a.append(a[len(a)-1])
	print(a)

	AC = 0
	WA = 0
	
	for i in range(len(p)):
		if S[i]=="AC":
			if i == len(p)-1:
				AC += 1
			else:
				if p[i]==p[i+1]:
					if S[i+1]=="WA":
						AC += 1
					else:
						continue
				else:
					AC += 1
		else:
			if i < a[AC]:
	 			WA += 1
	print(AC, WA)

Submission status: Runtime Error

Solution code:
import sys

lines = sys.readlines()[1:]

ac = []
w = 0

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

    if p in ac:
        continue

    if s == "WA":
        w += 1
    elif s == "AC":
        ac += [p]

print("%d %d" % (len(ac), w))

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
a_s = []
for i in range(m):
  a, s = map(str, input().split())
  a = int(a)
  a_s.append([a,s])
num_now = a_s[0][0]
ac_frag = False
sum_ac = 0
sum_pe = 0
for i in range(m):
  if num_now == a_s[i][0]:
    if a_s[i][1] == "AC" and not ac_frag:
      sum_ac += 1
      ac_frag = True
    else:
      if not ac_frag:
        sum_pe += 1
  else:
    num_now = a_s[i][0]
    ac_frag = False
    if a_s[i][1] == "AC":
      sum_ac += 1
      ac_frag = True
    else:
      sum_pe += 1
print(str(sum_ac) + " " + str(sum_pe))

Submission status: Runtime Error

Solution code:

from collection import defaultdict
N, M = map(int, input().split())

aced = [False]*N
D = defaultdict(int)
ac = 0
pena = 0
for _ in range(M):
    id, judge = input().split()
    id = int(id)-1
    if judge == "WA":
        D[id] += 1
    else:
        if not aced[id]:
            aced[id] = True
            ac += 1
            pena += D[id]
print(ac, pena)

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
cache = 0
ans = 0
ac = 0
cachedic = {}
plis = []
for i in range(m):
    p, s = input().split()
    p = int(p)
    if s == "WA":
        cachedic[s] += 1
    else:
        if p in plis:
            continue
        plis.append(p)
        ac += 1
        ans += cachedic[s]
        cache = 0
print("{} {}".format(ac, ans))

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
wa, ac = [0]*(N+1), [0]*(N+1)
wa_ac = 0
for i in range(1, M+1):
  pi, Si = input().split()
  pi = int(pi)
  if Si == 'WA' and ac[pi] == 0: 
    wa[pi] += 1
  elif Si == 'AC' and ac[pi] == 0:
    ac[pi] += 1

for i in range(1, M+1):
  if ac[i] == 1:
    wa_ac += wa[i]

print('{} {}'.format(sum(ac), wa_ac))

Submission status: Runtime Error

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

point = 0
pena = 0
ind = 0
for i in set(p):
    cnt = p.count(i)
    tmp = 0
    for c in range(cnt):
        score = S[ind]
        if score == "AC":
            if tmp == cnt:
                pass
            else:
                point += 1
                tmp = cnt
        if tmp != cnt and score == "WA":
            pena += 1

        ind += 1
    print("-----")

print(point, pena)

Submission status: Runtime Error

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

point = 0
pena = 0
ind = 0
for i in set(p):
    cnt = p.count(i)
    tmp = 0
    for c in range(cnt):
        score = S[ind]
        if score == "AC":
            if tmp == cnt:
                pass
            else:
                point += 1
                tmp = cnt
        if tmp != cnt and score == "WA":
            pena += 1

        ind += 1
    print("-----")

print(point, pena)

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
S = list(map(str,input().split()))
ac = 0
wa = 0
i = 0
j = 0
while j < n:
  while i < m:
    if S[i] == "AC":
      ac += 1
      i += 1
      j += 1
    else:
      wa += 1
      i += 1
print(ac)
print(wa)

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
S = list(map(str,input().split()))
ac = 0
wa = 0
i = 0
j = 0
for j in range(n):
  for i in range(m):
    if S[i] == "AC":
      ac += 1
      i += 1
      j += 1
    else:
      wa += 1
      i += 1
print(ac)
print(wa)

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
S = list(map(int,input().split()))
ac = 0
wa = 0
i = 0
j = 0
for j in range(n):
  for i in range(m):
    if S[i] == "AC":
      ac += 1
      i += 1
      j += 1
    else:
      wa += 1
      i += 1
print(ac)
print(wa)

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
S = list(map(int,input().split()))
ac = 0
wa = 0
for j in range(n):
  for i in range(m):
    if S[i] == "AC":
      ac += 1
      i += 1
      j += 1
    else:
      wa += 1
      i += 1
print(ac)
print(wa)

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
p,S = list(map(int,input().split()))
ac = 0
wa = 0
for j in range(n):
  for i in range(m):
    if S[i] == "AC":
      ac += 1
      i += 1
      j += 1
    else:
      wa = 0
      i += 1

Submission status: Runtime Error

Solution code:
N, M = [int(i) for i in input().split()]
pS = {}

for _ in range(M):
    a, s = [i for i in input().split()]
    if a not in pS:
        pS[a] = {}
        if s == 'AC':
            pS[a]['AC'] = True
        else:
            pS[a]['count'] = 1
    else:
        if s == 'AC':
            pS[a]['AC'] = True
        elif 'AC' not in pS[a]:
            pS[a]['count'] += 1

s = 0
a = 0
for v in pS.values():
    s += v['count']
    if 'AC' in v:
        a += 1
    
print(a, s)

Submission status: Runtime Error

Solution code:
def resolve_c():
    n, m = map(int, input().split())
    ac_list = [0] * m
    wa_list = [0] * m
    wa_tmp_list = [0] * m
    for i in range(m):
        p, s = input().split()
        if ac_list[int(p)] == 0:
            if s == "AC":
                ac_list[int(p)] = 1
                wa_list[int(p)] = wa_tmp_list[int(p)]
            elif s == "WA":
                wa_tmp_list[int(p)] += 1
    print(str(sum(ac_list)) + " " + str(sum(wa_list)))
resolve_c()

Submission status: Runtime Error

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

if M == 0 or N == 0:
    print("{} {}".format(0, 0))
else:

    p = [0]*M
    S = [0]*M

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

    penalty = 0


    correct_set = set()
    for i in range(M):
        if S[i] == 'AC':
            correct_set.add(p[i])

    correct = len(correct_set)

    for i in range(M):
        if S[i] == 'AC':
            correct_set.remove(p[i])
        elif S[i] == 'WA' and p[i] in correct_set:
            penalty += 1


            

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

Submission status: Runtime Error

Solution code:
def solve():
    N, M = map(int, input().split())
    WAnum = 0
    ACnum = 0
    WA = [0]*max(N, M)
    AC = [False]*max(N, M)

    if N==0:
        print(0, 0)
        exit()

    for _ in range(M):
        p, S = map(str, input().split())
        p = int(p)
        if AC[p]:
            continue
        if S == 'AC':
            AC[p] = True
            ACnum += 1
            WAnum += WA[p]
        elif S == 'WA':
            WA[p] += 1
        #print(AC, WA)
    #print(AC,WA)
    print(ACnum, WAnum)

solve()

Submission status: Runtime Error

Solution code:
def solve():
    N, M = map(int, input().split())
    WAnum = 0
    ACnum = 0
    WA = [0]*max(N, M)
    AC = [False]*max(N, M)

    for _ in range(M):
        p, S = map(str, input().split())
        p = int(p)
        if AC[p]:
            continue
        if S == 'AC':
            AC[p] = True
            ACnum += 1
            WAnum += WA[p]
        elif S == 'WA':
            WA[p] += 1
        #print(AC, WA)
    #print(AC,WA)
    print(ACnum, WAnum)

solve()

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
da = [map(str,input().split()) for i in range(m)]
penalty = [0 for i in range(n)]
accepted = [False for i in range(n)]
for i in range(m):
  now = int(da[i][0]) - 1
  if da[i][1] == 'AC':
    accepted[now] = True
  elif not accepted[now]:
    penalty[now] += 1
AC,WA = 0,0
for i in range(n):
  if accepted[i]:
    AC += 1
    WA += penalty[i]
print(AC,WA)

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
da = [map(str,input().split()) for i in range(m)]
penalty = [0 for i in range(n)]
accepted = [False for i in range(n)]
for i in range(m):
  now = int(da[i][0])
  if da[i][1] == 'AC':
    accepted[now] = True
  elif not accepted[now]:
    penalty[now] += 1
AC,WA = 0,0
for i in range(n):
  if accepted[i]:
    AC += 1
    WA += penalty[i]
print(AC,WA)

Submission status: Runtime Error

Solution code:
import sys

N, M = input().split(' ')
p_acwa_dict = {}
cnt_ac = 0
cnt_wa = 0
pre_p = 0
for line in sys.stdin:
  p, s = line.rstrip().split()
  p = int(p)
  
  if pre_p > 0 and pre_p != p:
    pre_acwa_cnt_dict = p_acwa_dict[pre_p]
    if pre_acwa_cnt_dict['AC'] > 0:
      cnt_ac += pre_acwa_cnt_dict['AC']
      cnt_wa += pre_acwa_cnt_dict['WA']
      
  pre_p = p
  acwa_cnt_dict = p_acwa_dict.setdefault(p, {'AC': 0, 'WA': 0})
  if acwa_cnt_dict['AC'] > 0:
    continue
  acwa_cnt_dict[s] += 1

pre_acwa_cnt_dict = p_acwa_dict[pre_p]
if pre_acwa_cnt_dict['AC'] > 0:
  cnt_ac += pre_acwa_cnt_dict['AC']
  cnt_wa += pre_acwa_cnt_dict['WA']
print("{} {}".format(cnt_ac, cnt_wa))

Submission status: Runtime Error

Solution code:
def get_next_ints(delim=" "):
    return tuple([int(float(x)) for x in input().split(delim)])
def solve(maze, start_r, start_c):
    
    distances = {}
    offsets = [(-1,0),(1,0),(0,-1),(0,1)]
    
    distances[start_r, start_c] = 0
    candidates = [(start_r, start_c)]
    
    while candidates:
        r, c= candidates.pop(0)
        
        for offset_r, offset_c in offsets:
            move_r, move_c = r + offset_r, c + offset_c
            if not (move_r, move_c) in distances and maze[move_r, move_c] == ".":
                distances[move_r, move_c] = distances[r, c] + 1
                candidates.append((move_r, move_c))
    
    return max(distances.values())
    

def main():
    h, w = get_next_ints()
    from collections import defaultdict
    maze = defaultdict(str)
    for r in range(h):
        line = get_next_str()
        for c in range(w):
            maze[r,c] = line[c]
    
    results = []
    for r in range(h):
        for c in range(w):
            result = solve(maze, r, c)
            results.append(result)
    
    print(max(results))
    
if __name__ == '__main__':
    main()
if __name__ == '__jupyter__':
    import doctest
    print(doctest.testmod())

Submission status: Runtime Error

Solution code:
import numpy as np

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

AC = np.array([0]*N) # 正解を入れる箱
WA = np.array([0]*N) # 不正解を入れる箱

for _ in range(M):
    p, S = input().split()
    
    if AC[int(p)-1] ==0 and S == "WA": # まだ「正解が出てない & 不正解」
        WA[int(p)-1] += 1              # なら不正解の箱に＋１
    else:
        AC[int(p)-1] = 1               # それ以外は正解の箱に１
    
print(sum(AC), sum(WA*AC)) # ただし不正解の箱は最後まで正解が出なかった問題はペナルティ無しにする必要があるので、正解の箱の中身と掛け合わせて消しておく。

Submission status: Runtime Error

Solution code:
def get_next_ints(delim=" "):
    return tuple([int(float(x)) for x in input().split(delim)])

def get_next_by_types(*value_types,delim=" "):
    """標準入力をスペースで分割し、それぞれを任意のタイプにcastします
    row, col, text = get_next_by_types(int, int ,str)
    """
    return tuple([t(x) for t, x in zip(value_types,input().rstrip("\n").split(delim))])

def main():
    n, m = get_next_ints()
    ac_count = 0
    wa_count = 0
    
    ac_found = False
    wa = 0
    prev_p = -1
    for i in range(m):
        
        p, result = get_next_by_types()
        if p != prev_p:
            prev_p = p
            if ac_found:
                ac_count += 1
                wa_count += wa
            ac_found = False
            wa = 0
        if not ac_found:
            if result == 'AC':
                ac_found = True
            else:
                wa += 1
    if ac_found:
        ac_count += 1
        wa_count += wa
    print(ac_count, wa_count)
    
if __name__ == '__main__':
    main()
if __name__ == '__jupyter__':
    import doctest
    print(doctest.testmod())

Submission status: Runtime Error

Solution code:
def main():
    n, m = get_next_ints()
    ac_count = 0
    wa_count = 0
    
    ac_found = False
    wa = 0
    prev_p = -1
    for i in range(m):
        
        p, result = input().rstrip("\n").split(" ")
        if p != prev_p:
            prev_p = p
            if ac_found:
                ac_count += 1
                wa_count += wa
            ac_found = False
            wa = 0
        if not ac_found:
            if result == 'AC':
                ac_found = True
            else:
                wa += 1
    if ac_found:
        ac_count += 1
        wa_count += wa
    print(ac_count, wa_count)
    
if __name__ == '__main__':
    main()
if __name__ == '__jupyter__':
    import doctest
    print(doctest.testmod())

Submission status: Runtime Error

Solution code:

def get_next_by_types(*value_types,delim=" "):
    """標準入力をスペースで分割し、それぞれを任意のタイプにcastします
    row, col, text = get_next_by_types(int, int ,str)
    """
    return tuple([t(x) for t, x in zip(value_types,input().rstrip("\n").split(delim))])

def main():
    n, m = get_next_ints()
    ac_count = 0
    wa_count = 0
    
    ac_found = False
    wa = 0
    prev_p = -1
    for i in range(m):
        
        p, result = get_next_by_types(int, str)
        if p != prev_p:
            prev_p = p
            if ac_found:
                ac_count += 1
                wa_count += wa
            ac_found = False
            wa = 0
        if not ac_found:
            if result == 'AC':
                ac_found = True
            else:
                wa += 1
    if ac_found:
        ac_count += 1
        wa_count += wa
    print(ac_count, wa_count)
    
if __name__ == '__main__':
    main()
if __name__ == '__jupyter__':
    import doctest
    print(doctest.testmod())

Submission status: Runtime Error

Solution code:


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


p = []
s = []
ans = [0]*N
c_wa = [0]*N
c_sum = 0

for i in range(M):
    temp1, temp2 = input().strip().split(" ")
    p.append(int(temp1))
    s.append(str(temp2))
  

for j in range(M):
    
    if s[j] == "WA":
        if ans[p[j]-1] == 0:
            c_wa[p[j]-1] += 1
        elif ans[p[j]-1] == 1:
            pass
        
                
            
    elif s[j] == "AC":
        if ans[p[j]-1] == 0:
            ans[p[j]-1] += 1
        elif ans[p[j]-1] == 1:
            pass
    
for j in range(N):
    if ans[p[j]-1] == 1:
        c_sum += c_wa[p[j]-1]
        
            
print(sum(ans), c_sum)

Submission status: Runtime Error

Solution code:


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


p = []
s = []
ans = [0]*N
c_wa = [0]*N
c_sum = 0

for i in range(M):
    temp1, temp2 = input().strip().split(" ")
    p.append(int(temp1))
    s.append(str(temp2))
  

for j in range(M):
    
    if s[j] == "WA":
        if ans[p[j]-1] == 0:
            c_wa[p[j]-1] += 1
        elif ans[p[j]-1] == 1:
            pass
        
                
            
    elif s[j] == "AC":
        if ans[p[j]-1] == 0:
            ans[p[j]-1] += 1
        elif ans[p[j]-1] == 1:
            pass
    
for i in range(N):
    if ans[p[j]-1] == 1:
        c_sum += c_wa[p[j]-1]
        
            
print(sum(ans), c_sum)

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
ans = 0
Q = [0] * N
wrong = [0] * N
for i in (M):
  p, S = map(str, input().split())
  p = int(p) - 1
  if Q[p] == 0 and S == "AC":
    ans += wrong[p]
    Q[p] = 1
  elif S == "WA":
    wrong[p] += 1
print(ans)