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: Accepted

Solution code:
N,M=map(int,input().split())
PS = [input().split() for i in range(M)]
Flag = [0 for i in range(N)]
WA_count = [0 for i in range(N)]

for i in range(M):
  p = int(PS[i][0])-1
  s = PS[i][1]
  
  if s =="AC":
    Flag[p]=1
  else:
    if Flag[p]==0:
      WA_count[p]+=1
a=0
for i in range(N):
  if Flag[i]==1:
    a+=WA_count[i]

print(sum(Flag),a)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
a = [0 for i in range(n)]
ac = 0
wa = [0 for i in range(n)]
ww = 0
for i in range(m):
	p,s = map(str, input().split())
	if a[int(p)-1] == 0 and s == "WA":
		wa[int(p)-1] += 1
	if a[int(p)-1] == 0 and s == "AC":
		a[int(p)-1] =1
		ac += 1
		ww += wa[int(p)-1]
print (ac,ww)

Submission status: Accepted

Solution code:
def main():
    N, M = map(int, input().split())
    cnt = 0
    answer_list = [[] for _ in range(N)]
    for i in range(M):
        p, S = input().split()
        p = int(p) - 1
        answer_list[p].append(S)

    ac = 0
    wa = 0
    for answers in answer_list:
        tmp_wa = 0
        for a in answers:
            if a == 'AC':
                ac += 1
                wa += tmp_wa
                break
            else:
                tmp_wa += 1
    
    print(ac, wa)

    

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
Nstate = {str(i):0 for i in range(1,N+1)}
WAstate = {str(i):0 for i in range(1,N+1)}
AC = 0
for _ in range(M):
    n,m = map(str,input().split())
    if Nstate[n] == 0:
        if m == 'AC':
            Nstate[n] = 1
            AC += 1
        elif m == 'WA':
            WAstate[n] += 1
WA = 0
for i in range(1,N+1):
    if Nstate[str(i)] == 1:
        WA += WAstate[str(i)]
print(AC,WA)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
pen = [0] * N
AC = [False] * N
for _ in range(M):
    p, s = input().split()
    if s == "AC": AC[int(p) - 1] = True
    else:
        if AC[int(p) - 1] == False : pen[int(p) - 1] += 1
ACcount = AC.count(True)
Pcount = 0
for i in range(N):
    if AC[i]: Pcount += pen[i]
print(ACcount, Pcount)

Submission status: Accepted

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

AC = 0
WA = 0

list_AC = [-1] * N

P = []
S = []

for m in range(M):
    p, s = input().split()
    p    = int(p) - 1
    P.append(p)
    S.append(s)
    if s == 'AC':
        if list_AC[p] == -1:
            AC += 1
            list_AC[p] = m

for m in range(M):
    p = P[m]
    s = S[m]
    if s == 'WA':
        if list_AC[p] != -1:
            if m < list_AC[p]:
                WA += 1
print(AC, WA)

Submission status: Accepted

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

ac_check = [0 for _ in range(n)]
wa_check = [0 for _ in range(n)]

for i in range(m):
    i, judge = input().split()
    i = int(i)-1
    if judge == 'AC':
        if ac_check[i] == 0:
            ac_check[i] = 1

    elif judge == 'WA':
        if ac_check[i] == 0:
            wa_check[i] += 1
wa = 0
for i in range(n):
    if ac_check[i] == 1 and wa_check != 0:
        wa += wa_check[i]

print(sum(ac_check), wa)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
cleared = [False] * N
penalties = [0] * N
n_ac, penalty = 0, 0
for i in range(M):
    p, s = input().split()
    p = int(p)
    if not cleared[p - 1]:
        if s == "AC":
            cleared[p - 1] = True
            n_ac += 1
        else:
            penalties[p - 1] += 1

for i in range(N):
    if not cleared[i]:
        penalties[i] = 0

print(n_ac, sum(penalties))

Submission status: Accepted

Solution code:
#  --*-coding:utf-8-*--

def main():
    N,M = map(int, input().split())

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

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

        if S == 'AC':
            if ac[p] == 0:
                ac[p] = 1
        elif ac[p] == 0:
            wa[p] += 1

    sumOfWa = sum(w if a == 1 else 0 for (a,w) in zip(ac, wa))
    print(sum(ac), sumOfWa)
        


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
P, S = [], []
AC = [0 for n in range(N)]
WA = [0 for n in range(N)]
for m in range(M):
    p, s = input().split()
    p = int(p) - 1
    if AC[p] == 0 and s == 'WA':
        WA[p] += 1
    if s == 'AC':
        AC[p] = 1
AC_count = sum(AC)
WA_count = 0
for n in range(N):
    if AC[n] == 1:
        WA_count += WA[n]
print(AC_count, WA_count)

Submission status: Accepted

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

ans_wa = 0
for _ in range(M):
  p, S = input().split()
  p = int(p) - 1
  if S == "AC":
    if ac[p] == False:
      ac[p] = True
      ans_wa += wa[p]
  else:
    wa[p] += 1

ans_ac = ac.count(True)
print("{} {}".format(ans_ac, ans_wa))

Submission status: Accepted

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

WAs = [0]*(N+1)
alreadyACed = set()
AC_num = 0

for i in range(M):
    p,S = list(input().split())
    if p in alreadyACed:
        continue
    else:
        if S == "WA":
            WAs[int(p)] += 1
        elif S == "AC":
            AC_num += 1
            alreadyACed.add(p)
WA_num = 0
for i in range(N+1):
    if str(i) in alreadyACed:
        WA_num += WAs[i]

print(AC_num,WA_num)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#solve
def solve():
    n, m = LI()
    d = [0] * n
    wa = [0] * n
    for _ in range(m):
        p, s = input().rstrip().split()
        p = int(p) - 1
        if d[p]:
            continue
        if s == "AC":
            d[p] = 1
        else:
            wa[p] += 1
    ans = 0
    for i in range(n):
        if d[i]:
            ans += wa[i]
    print(sum(d), ans)

    return


#main
if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
result = []
ans = dict((s, False) for s in range(1, N+1))
pen = dict((s, 0) for s in range(1, N+1))

for _ in range(M):
    s, d = input().split()
    if d == "AC":
        ans[int(s)] = True
        continue

    if d == "WA" and not ans[int(s)]:
        pen[int(s)] += 1

ans_result = 0
for _, v in ans.items():
    if v:
        ans_result += 1

pen_result = 0
for k, v in pen.items():
    if ans[k]:
        pen_result += v

print(ans_result, pen_result)

Submission status: Accepted

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

ok = [0 for _ in range(n)]
ng = [0 for _ in range(n)]
for _ in range(m):
    p, s = input().split()
    index = int(p) - 1
    if s == "AC":
        ok[index] += 1
    else:
        if ok[index] == 0:
            ng[index] += 1

count_ok = 0
count_ng = 0
for i in range(n):
    if ok[i] > 0:
        count_ok += 1
        if ng[i] > 0:
            count_ng += ng[i]
print("{} {}".format(count_ok, count_ng))

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
#from itertools import permutations

def gcd(a: int, b: int):
    """ https://cocodrips.hateblo.jp/entry/2014/03/05/143623
    """
    while b: a, b = b, a%b
    return a

def lcm(a: int, b: int):
    return a * b // gcd(a, b)


def main():
    #N = int(input())
    N,M = map(int, input().split())
    #vP = tuple(map(int, input().split()))
    #vA = list(map(int, input().split()))
    #vA = list(range(1,N+1))
    vS = [input().split() for _ in [0,]*M]
    vN = [False,]*(N+1)
    vW = [0,]*(N+1)

    x,p = 0,0
    for a,s in vS:
        i = int(a)
        v = s=="AC"
        if vN[i]==False:
            if v:
                x += 1
                vN[i] = True
                p += vW[i]
            else:
                vW[i] += 1

    print(x,p)

    #print(l, file=sys.stderr)
    #l //= 2
    #S = input().rstrip()
    #print(S)
    #print(chr(ord(S)+1))
    #print(lcm(N, M))
    #print("Yes" if N<=500*M else "No")
    #print(S.count("ABC"))


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from collections import defaultdict


def solve():
    N, M = map(int, input().split())
    ac_dict = defaultdict(int)
    wa_dict = defaultdict(int)
    ac_p, wa_p = set(), set()
    for _ in range(M):
        p, s = map(str, input().split())
        p = int(p)
        if s == 'AC':
            ac_p.add(p)
            ac_dict[p] = 1
        else:
            if ac_dict[p] != 1:
                wa_p.add(p)
                wa_dict[p] += 1
    
    wa = 0
    for pi in ac_p:
        if pi in wa_p:
            wa += wa_dict[pi]
    
    print(sum(ac_dict.values()), wa)


if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
prob = [0]*N
WA = [0]*N
for _ in range(M):
    p,S = input().split()
    p = int(p)
    if S == "AC":
        prob[p-1] = 1
    elif prob[p-1] == 0:
        WA[p-1] += 1
sumWA = 0
for i in range(N):
    if prob[i] == 1:
        sumWA += WA[i]
print(sum(prob),sumWA)

Submission status: Accepted

Solution code:
if __name__ == "__main__":
	N, M = map(int, input().split())
	ac_list = [0] * (N+1)
	wa_list = [0] * (N + 1)
	for i in range(M):
		p, s = input().split()
		p = int(p)
		if s == "AC":
			ac_list[p] = 1
		else:
			if ac_list[p] == 0:
				wa_list[p] += 1
		# print(prob_list)
	ac = 0
	wa = 0
	for i in range(N+1):
		ac += ac_list[i]
		if ac_list[i] == 1:
			wa += wa_list[i]
	print("{0} {1}".format(ac, wa))

Submission status: Accepted

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

aclist = [0] * n
penaltylist = [0] * n

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

  if aclist[p-1] != 0:
    continue

  if s == 'AC':
    aclist[p-1] += 1
  else:
    penaltylist[p-1] += 1

ac = 0
penalty = 0
for i in range(n):
  if aclist[i] == 0:
    continue

  ac += 1
  penalty += penaltylist[i]

print(ac, penalty)

Submission status: Accepted

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

wa_counts = [0 for i in range(n)]
acs = [False for i in range(n)]

for i in range(m):
    if s[i] == 'AC':
        acs[p[i]-1] = True
    elif not acs[p[i]-1]:
        wa_counts[p[i]-1] += 1

wa_count = 0
ac_count = 0

for i in range(n):
    if acs[i] == True:
        ac_count += 1
        wa_count += wa_counts[i]

print(ac_count, wa_count, sep=' ')

Submission status: Accepted

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

ps = []
for i in range(M):
    ps.append(input().split())

penalties = [0] * N
corrects = [0] * N

for p, s in ps:
    if s == 'AC' and corrects[int(p) - 1] == 0:
        corrects[int(p) - 1] = 1
    elif s == 'WA' and corrects[int(p) - 1] == 0:
        penalties[int(p) - 1] += 1

for i in range(N):
    penalties[i] = penalties[i] * corrects[i]
print(sum(corrects), sum(penalties))

Submission status: Accepted

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

ans_flg = {}
wa_time = {}
wa = 0
ans = 0
for i in range(m):
    num, name = info[i]
    num = int(num)
    if num not in ans_flg:
        if name == "AC":
            ans_flg[num] = 1
            ans += 1
        else:
            if num not in wa_time:
                wa_time[num] = 1
            else:
                wa_time[num] += 1
wa = 0
for i in ans_flg:
    if i in wa_time:
        wa += wa_time[i]

print(ans, wa)

Submission status: Accepted

Solution code:
import numpy as np

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

aced = np.zeros(N, dtype="bool")
waed = np.zeros(N, dtype="int")

AC = "AC"
WA = "WA"

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

    if s == AC:
        aced[p] = True
    else:
        if not aced[p]:
            waed[p] += 1

ac_count = 0
wa_count = 0

for i in range(N):
    if aced[i]:
        ac_count += 1
        wa_count += waed[i]

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

Submission status: Accepted

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

ans = set()
pre_wa = [0]*(N+1)
wa = 0
for p, s in ps:
    p = int(p)
    if s == 'AC':
        ans.add(p)
        wa += pre_wa[p]
        pre_wa[p] = 0
    if s == 'WA' and p not in ans:
        pre_wa[p] += 1

print(len(ans), wa)

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
d = {}
f = {}
for i in range(1,n+1):
    d[i] = []
    f[i] = 0
    
correct = 0
wrong = 0
for i in range(m):
    p,s = input().split()
    p = int(p)
    
    if(s=="AC" and f[p]==0):
        correct += 1 
        wrong += len(d[p])
        f[p] = 1
        
    d[p].append(s)

print(correct,wrong)

Submission status: Accepted

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

ACcount=0
WAcount=0
for h in data:
    for i in range(len(h)):
        if h[i]=="WA":
            continue
        else:
            ACcount+=1
            WAcount+=i
            break
print(ACcount,WAcount)

Submission status: Accepted

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

wc = [0 for i in range(n)]
ac = [0 for i in range(n)]

n_wc = 0
n_ac = 0

for i in range(m):
    num,j = input().split()
    num = int(num)

    if j == 'AC' and ac[num-1] == 0:
        n_ac += 1
        ac[num-1] = 1
        n_wc += wc[num-1]
    else:
        wc[num-1] += 1

print(n_ac,n_wc)

Submission status: Accepted

Solution code:
N,M = list(map(int,input().split()))
ac = [0]*N
wa = [0]*N
for i in range(M):
    p,s = list(map(str,input().split()))
    p = int(p)
    if s == 'AC':
        ac[p - 1] = 1
    elif s == 'WA':
        if ac[p - 1] == 0:
            wa[p - 1] += 1
for i in range(N):
    if ac[i] == 0:
        wa[i] = 0
print(sum(ac),sum(wa))

Submission status: Accepted

Solution code:
import sys
import collections


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, m = list(map(int, readline().split()))
    ps = [list(map(str, readline().rstrip().decode('utf-8').split())) for _ in range(m)]
    ac = collections.defaultdict(int)
    wa = collections.defaultdict(int)
    for p, s in ps:
        if s == "WA":
            if p not in ac:
                wa[p] += 1
        if s == "AC":
            ac[p] += 1
    wac = 0
    for k, v in wa.items():
        if k in ac:
            wac += v
    print(len(ac), wac)


if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
wa = [0]*n
ac = [False]*n
for i in range(m):
    p,s = map(str,input().split())
    if s == "AC":
        ac[int(p)-1] = True
    else:
        if not ac[int(p)-1]:
            wa[int(p)-1] += 1
ac_num = 0
wa_num = 0
for i in range(n):
    if ac[i]:
        ac_num += 1
        wa_num += wa[i]
print(ac_num, wa_num)

Submission status: Accepted

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

for _ in range(m):
    p, s = input().split()
    p = int(p)
    
    if l[p] == -1:
        continue

    if s == "AC":
        res1 += 1
        res2 += l[p]
        l[p] = -1
    else:
        l[p] += 1

print(res1, res2)

Submission status: Accepted

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

ac = 0
wa = 0
for i in range(N):
    clear = False
    tmpwa = 0
    for s in q[i]:
        if not clear and s == 'AC':
            clear = True
            ac += 1
            break
        else:
            tmpwa += 1
    if clear:
        wa += tmpwa

print(ac, wa)

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
li=[0]*n
ans=[0,0]
for i in range(m):
    p,s=input().split()
    p=int(p)
    if li[p-1]>=0:
        if s=="WA":
            li[p-1]+=1
        elif s=="AC":
            ans[0]+=1
            ans[1]+=li[p-1]
            li[p-1]=-1
print(*ans)

Submission status: Accepted

Solution code:

N, M = map(int, input().split())
ac = [0]*N
wa = [0]*N
for i in range(M):
    p, s = input().split()
    if s == 'AC':
        ac[int(p)-1] = 1
    elif s == 'WA' and ac[int(p)-1] == 0:
        wa[int(p)-1] += 1

nwa = sum([ wa[i] for i in range(N) if ac[i] == 1])
print(sum(ac), nwa)

Submission status: Accepted

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

accepts = [False] * n
penalties = [0] * n

for i in range(m):
    p, s = input().split()
    p = int(p) - 1

    if s == 'AC':
        accepts[p] = True
    elif not accepts[p]:
        penalties[p] += 1

num_accepts = 0
num_penalties = 0

for i in range(n):
    if accepts[i]:
        num_accepts += 1
        num_penalties += penalties[i]

print(num_accepts, num_penalties)

Submission status: Accepted

Solution code:
n, m = [ int(v) for v in input().split() ]
status = [ "WA" for i in range(n) ]
penarty = [0 for i in range(n)]
for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    if status[p] == "WA":
        if s == "WA":
            penarty[p] += 1
        elif s == "AC":
            status[p] = "AC"
total_penarty = sum([ penarty[i] for i in range(n) if status[i] == "AC" ])
print(status.count("AC"), total_penarty)

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
l = []
for i in range(m):
    p,s = input().split()
    p = int(p)
    l.append([p,s])
pl = [0 for i in range(n+1)]
b = 0
key = 0
count = 0
ans = 0
penalty = 0
for i in range(m):
    if l[i][1] == "AC":
        if pl[l[i][0]] >= 0:
            ans += 1
            penalty += pl[l[i][0]]
            pl[l[i][0]] = -1
    else:
        if pl[l[i][0]] >= 0:
            pl[l[i][0]] += 1
        else:
            continue   
print(ans,penalty)

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
PS=[list(input().split()) for i in range(M)]
chk=[0]*N
Pena=[0]*N
seito=0
pena=0
for p,s in PS:
  p=int(p)
  if chk[p-1]==0:
    if s=='WA':
      Pena[p-1]+=1
    elif s=='AC':
      seito+=1
      chk[p-1]=1
      pena+=Pena[p-1]
  else:
    pass
print(seito,pena)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
dic = {i: False for i in range(1,n+1)}
was = [0 for i in range(n+1)]
ac = 0
wa = 0
for i in range(m):
  p, s = input().split()
  p = int(p)
  if dic[p]==False:
    if s == 'AC':
      dic[p] = True
      ac += 1
    else:
      was[p] += 1
for i in range(1,n+1):
  if dic[i]:
    wa += was[i]
print('{} {}'.format(ac, wa))

Submission status: Accepted

Solution code:
import sys
input=sys.stdin.readline
n,m=map(int,input().split())
ac=[0]*n
c=0
w=0
ps=[]
for _ in range(m):
    p,s=input().split()
    p=int(p)
    s=s.rstrip()
    ps.append((p,s))
    if s=='AC':
        if ac[p-1]==0:
            c+=1
            ac[p-1]=1
        else:
            pass
nac=[0]*n
for _ in range(m):
    p=ps[_][0]
    s=ps[_][1]
    if s=='AC':
        if nac[p-1]==0:
            nac[p-1]=1
        else:
            pass
    else:
        if nac[p-1]==0 and ac[p-1]==1:
            w+=1
print(c,w)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
s=[0]*n
t=[0]*n
for i in range(m):
    a,b=map(str,input().split())
    a,
    a=int(a)-1
    if not s[a]:
        if b=="WA":
            t[a]+=1
        else:
            s[a]=1
print(sum(s),sum(t[i] for i in range(n)if s[i]))

Submission status: Accepted

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

PM.sort(key=lambda x:x[0])
# print(PM)


aw = []
for i in range(N+10):
    aw.append([0,0])

a_cnt = 0
w_cnt = 0
for p, m in PM:
    if aw[p][0] == 1:
        pass
    elif m == 'WA':
        aw[p][1] += 1
    elif m == 'AC':
        aw[p][0] = 1

for a, w in aw:
    if a == 1:
        a_cnt += 1
        w_cnt += w
print(a_cnt, w_cnt)

Submission status: Accepted

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

acs = [False] * (N + 1)
was = [0] * (N + 1)

for p, s in X:
    if s == "AC":
        acs[int(p)] = True
    elif not acs[int(p)]:
        was[int(p)] += 1

was_cnt = 0
for a, w in zip(acs, was):
    if a:
        was_cnt += w

print(sum(acs), was_cnt)

Submission status: Accepted

Solution code:
from collections import defaultdict

n, m = map(int, input().strip().split())
data = [input().strip().split() for _ in range(m)]

ac = defaultdict(int)
wa = defaultdict(int)

for p, s in data:
    if s == 'AC':
        ac[p] += 1
    else:
        if ac[p] == 0:
            wa[p] += 1

correct = 0
penalty = 0
for i in range(n + 1):
    p = str(i)
    if ac[p] > 0:
        correct += 1
        penalty += wa[p]

print(correct, penalty)

Submission status: Accepted

Solution code:
#!python3

iim = lambda: map(int, input().rstrip().split())
liim = lambda: list(map(int, input().rstrip().split()))

def resolve():
    N, M = iim()
    wa = dict()
    ac = set()
    for i in range(M):
        p, s = input().split()

        if not p in wa:
            wa[p] = 0

        if s == "AC":
            ac.add(p)
        elif not p in ac:
            wa[p] += 1

    x = 0
    for p in ac:
        x += wa[p]
    print(len(ac), x)


if __name__ == "__main__":
    resolve()

Submission status: Accepted

Solution code:
import sys
from collections import defaultdict

N,M=map(int, sys.stdin.readline().split())

ac=set()
wa=defaultdict(lambda: 0) 

wa_cnt=0

for _ in range(M):
    p,s=sys.stdin.readline().split()
    if s=="AC":
        ac.add(p)
        if wa[p] != "Done":
            wa_cnt+=wa[p]
        wa[p]="Done"
    elif s=="WA":
        if wa[p] != "Done":
            wa[p]+=1

print len(ac),wa_cnt

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
AC = [False]*N
wa_cnt = [0]*N
ac_ans = 0
wa_ans = 0
for _ in range(M):
    ps,s = input().split()
    p = int(ps)
    if s == 'WA':
        wa_cnt[p-1] += 1
    if s == 'AC' and AC[p-1] == False:
        wa_ans += wa_cnt[p-1]
        AC[p-1] = True
ac_ans = sum(AC)
print(ac_ans,wa_ans)

Submission status: Accepted

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

SC = [[0 for _ in range(2)] for _ in range(N)]
for p,s in PS:
  if s == 'AC':
    SC[p][0] = 1
  else:
    if SC[p][0] == 0:
      SC[p][1] += 1

sc = 0
pe = 0
for s,p in SC:
  sc += s
  if s != 0:
    pe += p
print(sc,pe)

Submission status: Accepted

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

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

for i in range(N+1):
    if prob[i] > 0:
        WA -= prob[i]

print(AC, WA)

Submission status: Accepted

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


def solve(N: int, M: int, p: "List[int]", S: "List[str]"):
    ok = 0
    penalty = 0

    problem_dict = {}
    for i in range(M):
        if problem_dict.get(p[i]) == None:
            problem_dict[p[i]] = [S[i]]
        else:
            problem_dict[p[i]].append(S[i])


    for key,value in problem_dict.items():
        if "AC" not in value:
            continue

        for result in value:
            if result == "WA":
                penalty += 1
            else:
                ok += 1
                break
    
    print(ok,penalty)
    return


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: Accepted

Solution code:
N,M=map(int,input().split())
acs=[0]*N
was=[0]*N
for i in range(M):
    p,s=input().split()
    if s=='AC':
        acs[int(p)-1]=1
    else:
        was[int(p)-1]+=(acs[int(p)-1]!=1)
was=[was[i] for i in range(N) if acs[i]==1]
print(sum(acs),sum(was))

Submission status: Accepted

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

pena_prob = [0]*(10**5 + 10)
ac_prob = [0]*(10**5 + 10)
for i in range(M):
  p,S = input().split()
  p = int(p)
  if(S == 'AC'):
    ac_prob[p] = 1
  elif(S == 'WA'):
    if(ac_prob[p] == 0):
      pena_prob[p] += 1

pena = 0
for i in range(len(ac_prob)):
  if(ac_prob[i] == 1):
   pena += pena_prob[i]    
  
ac = sum(ac_prob)
print(ac, pena)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
ps_lis = []
for i in range(m):
    p, s = input().split()
    ps_lis.append([int(p), s])
ac_lis = [0] * (n + 1)
pe_lis = [0] * (n + 1)
for p, s in ps_lis:
    if s == 'WA' and ac_lis[p] == 0:
        pe_lis[p] += 1
    elif s == 'AC':
        ac_lis[p] = 1
for i, ac in enumerate(ac_lis):
    if ac == 0:
        pe_lis[i] = 0
print(sum(ac_lis), sum(pe_lis))

Submission status: Accepted

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

p = [0] * (n+1)
p_wa = [0] * (n+1)

num_ac = 0
num_wa = 0

for i in range(m):
    mondai = int(ps[i][0])
    if p[mondai] == 0:
        if ps[i][1] == 'WA':
            p_wa[mondai] += 1
        else:
            num_ac += 1
            num_wa += p_wa[mondai]
            p[mondai] = 1

print(num_ac,num_wa)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, M, P, S):
    ac = set()
    wa = Counter()
    for i in range(M):
        if S[i] == 'AC':
            ac.add(P[i])
        elif P[i] not in ac:
            wa[P[i]] += 1
    return '%d %d' % (len(ac), sum([wa[i] for i in range(1, N+1) if i in ac]))


def main():
    N, M = read_int_n()
    P, S = [], []
    for _ in range(M):
        p, s = read_str_n()
        p = int(p)
        P.append(p)
        S.append(s)
    print(slv(N, M, P, S))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import numpy as np

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

_ac = np.array([0 for i in range(n)])
_wa = np.array([0 for i in range(n)])

for i in range(m):
  _p, s = input().split()
  p = int(_p)
  
  if s == "AC":
    _ac[p - 1] = 1
  elif s == "WA" and _ac[p - 1] == 0:
    _wa[p - 1] += 1

ac = _ac
wa = _ac * _wa

print(str(ac.sum()) + " " + str(wa.sum()))