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())
was = [0 for _ in range(n)]
counting = [-1 for _ in range(n)] #-1 未提出　0 間違い中 1 正解済み
for _ in range(m):
  result = input().split()
  p = int(result[0])
  s = result[1]
  if s == "WA" and counting[p-1] <= 0:
    was[p-1] += 1
  elif s == "AC" and counting[p-1] <= 0:
    counting[p-1] = 1

ac_count = 0
wa_count = 0
for i in range(n):
  if counting[i] == 1:
    ac_count += 1
    wa_count += was[i]

ret = str(ac_count) + " " + str(wa_count)
print(ret)

Submission status: Accepted

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

memo = [[0] * 2 for _ in range(N)]
memo_WA = [0] * N

answer_AC = 0
answer_WA = 0

for i in range(M):
    if memo[int(pS[i][0]) - 1][0] == 1:
        continue
    elif pS[i][1] == "AC":
        answer_AC += 1
        memo[int(pS[i][0]) - 1][0] = 1
    else:
        memo_WA[int(pS[i][0]) - 1] += 1

for i in range(N):
    if memo[i][0] == 1:
        answer_WA += memo_WA[i]

print(answer_AC)
print(answer_WA)

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
	else:
		if(ac[int(p)-1]==0):
			wa[int(p)-1]+=1
x=sum(ac)
y=0
for i in range(n):
	y+=ac[i]*wa[i]
print(x,y)

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
result = ["mada"]*n
wac = [0]*n
AC = 0
WA = 0
p = []
s = []
for i in range(m):
    pi,si = map(str,input().split())
    p.append(int(pi))
    s.append(si)

for i in range(m):
    pp = p[i]
    ss = s[i]
    if ss == "WA":
        if result[pp-1] == "mada":
            wac[pp-1] += 1
        elif result[pp-1] == "AC":
            continue
    elif ss == "AC":
        if result[pp-1] == "mada":
            result[pp-1] = "AC"
        elif result[pp-1] == "AC":
            continue

for i in range(n):
    if result[i] == "AC":
        AC += 1
        WA += wac[i]

print(AC,WA)

Submission status: Accepted

Solution code:
N , M = map(int,input().split())
lst = []
AC_list = [False] * N
WA_cnt_list = [0] * N
for _ in range(M):
    r , judge = input().split()
    question_num = int(r) - 1
    if AC_list[question_num]:
        continue
    elif judge == "WA":
        WA_cnt_list[question_num] += 1
    elif judge == "AC":
        AC_list[question_num] = True
wa_cnt = 0
for i in range(N):
    if AC_list[i]:
        wa_cnt += WA_cnt_list[i]
print(sum(AC_list) , wa_cnt)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
ls = tuple([] for i in range(N))
for _ in range(M):
    p, S = input().split()
    p = int(p)
    ls[p - 1].append(S)
    
cnt_crr = 0
cnt_pnt = 0

for e in ls:
    if "AC" in e:
        for _e in e:
            if _e == "AC":
                cnt_crr += 1
                break
            cnt_pnt += 1

print(cnt_crr, cnt_pnt)

Submission status: Accepted

Solution code:
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n,m=INTM()
    ct=[0  for i in range(100001)]
    li=[]
    check=[0  for i in range(100001)]
    for i in range(m):
        p,s=STRM()
        p=int(p)
        li.append([p,s])
    for i in range(len(li)):
        if check[li[i][0]]==0:
            if li[i][1]=='WA':
                ct[li[i][0]]+=1
            else:
                check[li[i][0]]=1
        else:
            pass
    for i in range(100001):
        if check[i]==0:
            ct[i]=0
        else:
            pass
    
    ct_s=sum(ct)
    ck_s=sum(check)
    print(ck_s,ct_s)
if __name__ == '__main__':
    do()

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
ans = [0]*2
tmp = [0]*n
false = [0]*n
for _ in range(m):
    p,s = map(str,input().split())
    p = int(p)
    if tmp[p-1] == 0:
        if s == 'AC':
            ans[0] += 1
            tmp[p-1] += 1
            ans[1] += false[p-1]
        elif s == 'WA':
            false[p-1] += 1
print(*ans)

Submission status: Accepted

Solution code:
n, m = map(int,input().split())
result = []
for _ in range(m):
    a, b = input().split()
    a = int(a)
    result.append([a, b])
problems = [0] * (n+1)
ac = 0
wa = 0
for i in range(m):
    if problems[result[i][0]-1] != -1:
        if result[i][1] == "AC":
            ac += 1
            wa += problems[result[i][0]-1]
            problems[result[i][0]-1] = -1
        else:
            problems[result[i][0]-1] += 1

print(ac, wa)

Submission status: Accepted

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

anslist = [0]*(N+1)
wanslist = [0]*(N+1)
AC = 0
WA = 0
for i in range(M):
    if anslist[int(data[i][0])] == 1:
        continue
    else:
        if data[i][1] == "AC":
            anslist[int(data[i][0])] = 1
            AC += 1
        else:
            wanslist[int(data[i][0])] += 1

for i in range(1, N+1):
    if anslist[i] == 1:
        WA += wanslist[i]

print(AC, WA)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
p = [0 for i in range(M)]
S = ["" for i in range(M)]
ACc = [False for i in range(N)]
firstans = [0 for i in range(N)]
errors = 0
answers = 0

for i in range(M):
    p[i], S[i] = input().split(" ")
    p[i] = int(p[i])

for i in range(M):
    if S[i] == "AC":
        ACc[p[i]-1] = True
        if firstans[p[i]-1] == 0:
            firstans[p[i]-1] = i


for i in range(M):
    if S[i] == "WA" and (ACc[p[i]-1]) and i <= firstans[p[i]-1]:
        errors +=1 
    

for i in range(N):
    if ACc[i]:
        answers +=1


print(answers, errors)

Submission status: Accepted

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

anss = [0 for i in range(n)]
all_wa = 0
for i in range(m):
    p, s = input().split()
    p = int(p)
    if anss[p-1] == "AC":
        continue
    elif s == "WA":
        anss[p-1] += 1
    else:
        all_wa += anss[p-1]
        anss[p-1] = "AC"

print(anss.count("AC"), all_wa)

Submission status: Accepted

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

Submission status: Accepted

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

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

ac_cnt = 0
wa_cnt = 0
ac_list = [0] * n
wa_list = [0] * n

for i in range(m):
    if ac_list[p[i] - 1] == 0:
        if s[i] == "WA":
            # wa_cnt += 1
            wa_list[p[i] - 1] += 1
        else:
            ac_list[p[i] - 1] = 1
            ac_cnt += 1
            wa_cnt += wa_list[p[i] - 1]


print(ac_cnt, wa_cnt)

Submission status: Accepted

Solution code:
from collections import defaultdict
n,m = list(map(int, input().split()))
wa = defaultdict(int)
ac = set()
for _ in range(m):
  p, s = input().split()
  if(s == "AC"):
    ac.add(p)
  if (p not in ac and s=="WA"): 
    wa[p] += 1
print(len(ac), sum([wa[i] for i in ac]))

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
if m == 0:
  print(0,0)
  exit()
A=[[0,0] for _ in range(n)]
for i in range(m):
  p,s=input().split()
  p=int(p)-1
  if A[p][0]==1:
    continue
  elif s=='AC':
    A[p][0]=1
  else:
  	A[p][1]+=1
ac=0
wa=0
for a in A:
  ac+=a[0]
  if a[0] == 1:wa+=a[1]
print(ac,wa)

Submission status: Accepted

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

dic = {x: [] for x in range(1, n+1)}
for p, s in arr:
    dic[int(p)].append(s)

ac = 0
wa = 0
for k, v in dic.items():
    tmp = 0
    for x in v:
        if x == 'AC':
            ac += 1
            wa += tmp
            break
        else:
            tmp += 1

print(ac, wa)

Submission status: Accepted

Solution code:

n,m = map(int,input().split())
nlis = [0] * n
ac = 0
wa = 0
for _ in range(m):
    p, s = input().split()
    p = int(p) -1
    if nlis[p] == -1:
        continue
    if s == "WA":
        nlis[p] += 1
    else:
        ac += 1
        wa += nlis[p]
        nlis[p] = -1
print(ac,wa)

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    n, m = map(int, input().split())
    ac = set()
    wa = [0] * (n+1)

    for _ in range(m):
        p, s = input().split()
        p = int(p)
        if p in ac:
            continue
        if s == 'AC':
            ac.add(p)
        elif s == 'WA':
            wa[p] += 1
    wa = [j for i, j in enumerate(wa) if i in ac]
    print(len(ac), sum(wa))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
plist = [0 for _ in range(n)]
acornot = [0]*n
ans = 0
for i in range(m):
    p,s = input().split()
    p = int(p)
    p -= 1
    if s == "AC" and acornot[p] != 1:
        
        ans += 1
        acornot[p] = 1
    elif s == "AC" and acornot[p] ==1:
        continue
    elif s == "WA" and acornot[p] == 1:
        continue
    else:
        plist[p]+=1
print(ans)
ansp = 0
for i in range(n):
    if acornot[i] == 0:
        continue
    else:
        ansp+=plist[i]
print(ansp)

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
AC=[0]*(N+1)
WA=[0]*(N+1)
for i in range(M):
    p,S=input().split()
    p=int(p)
    if S=='WA' and AC[p]==0:
        WA[p]+=1
    if S=='AC' and AC[p]==0:
        AC[p]+=1
        
#結局正解できなかった場合はWA=0になる
for j in range(N+1):
    WA[j] = WA[j]*AC[j]
    
print(sum(AC),sum(WA))

Submission status: Accepted

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

pena = [0 for i in range(n)]
acc = [0 for i in range(n)]

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

    if acc[p] == 0:
        if ss == 'WA':
            pena[p] += 1
        else:
            acc[p] = 1

for i in range(n):
    pena[i] = pena[i] * acc[i]

print(sum(acc), sum(pena))

Submission status: Accepted

Solution code:
import numpy as np
n,m = map(int, input().split())
a = [False]*n
b = [0]*n
for i in range(m):
  p,s = map(str,input().split())
  p = int(p)-1
  if s == "AC":
    a[p] = True
  else:
    if a[p] == False:
      b[p]=b[p]+1
print(np.array(a).sum(),np.array(b)[np.array(a)].sum())

Submission status: Accepted

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

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

for _ in range(M):
    p, s = list(input().split())
    p = int(p) - 1
    ps_list[p].append(s)

wa_c = 0
ac_c = 0
total_wa_c = 0

for i, ss in enumerate(ps_list):
    wa_c = 0
    for s in ss:
        if s == "WA":
            wa_c += 1
        else:
            ac_c += 1
            total_wa_c += wa_c
            break

ans = "{} {}".format(ac_c, total_wa_c)
print(ans)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
flags = [False for _ in range(N)]
WAs = [0 for _ in range(N)]
pen = 0
for i in range(M):
    p, S = input().split()
    p = int(p)-1
    if S == 'AC' and not flags[p]:
        flags[p]=True
        pen += WAs[p]
    if not flags[p]:
        WAs[p] += 1
acc = flags.count(True)
print(acc, pen)

Submission status: Accepted

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

ac_count = sum(acs)
# 正答してないWAはペナルティではない
for n in range(N):
    if acs[n] == 0:
        was[n] = 0
wa_count = sum(was)
print(ac_count, wa_count)
# print(acs)
# print(was)

Submission status: Accepted

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

p_list = []
S_list = []
ac_set = set([])
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_set:
        if S == "AC":
            ac_set.add(p)
        else:
            wa_list[p - 1] += 1

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

Submission status: Accepted

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

mis=[[0,0] for i in range(n)]

for i in range(m):
  if sub[i][1]=='AC':
    mis[sub[i][0]-1][0]=1
  elif sub[i][1]=='WA' and mis[sub[i][0]-1][0]!=1:
    mis[sub[i][0]-1][1]+=1
    
ans=[0,0]
for i in range(n):
  if mis[i][0]==1:
    ans[0]+=1
    ans[1]+=mis[i][1]
print(ans[0],ans[1])

Submission status: Accepted

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

ans = 0
pena = 0
for p, s in [input().split() for _ in range(M)]:
    p = int(p)
    if flags[p-1] is not False:
        if s == "WA":
            flags[p-1] += 1
        else:
            pena += flags[p-1]
            flags[p-1] = False
            ans += 1

print(ans, pena)

Submission status: Accepted

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

WAs = [0] * (N + 1)
ACs = [0] * (N + 1)
for m in range(M):
  key, value = input().split()
  key = int(key)
  if value == 'WA' and ACs[key] == 0:
    WAs[key] += 1
  if value == 'AC':
    ACs[key] = 1

countWAs, countACs = 0, 0
for n in range(N + 1):
  if ACs[n] >= 1:
    countACs += ACs[n]
    countWAs += WAs[n]

#print(ACs)
#print(WAs)
print(str(countACs) + ' ' + str(countWAs))

Submission status: Accepted

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

ac_counts = [0 for i in range(N + 1)]
wa_counts = [0 for i in range(N + 1)]
is_AC = [False for i in range(N + 1)]

for i in range(M):
  p, S = input().split()
  p = int(p)
  if not is_AC[p]:
    if S == "AC":
      ac_counts[p] += 1
      is_AC[p] = True
    else:
      wa_counts[p] += 1

ac_cnt, wa_cnt = 0, 0
for flag, _ac_cnt, _wa_cnt in zip(is_AC, ac_counts, wa_counts):
  if flag:
    ac_cnt += _ac_cnt
    wa_cnt += _wa_cnt

print(ac_cnt, wa_cnt)

Submission status: Accepted

Solution code:
def resolve():
    N, M = map(int, input().split())
    a = [[] for _ in range(N)]
    for _ in range(M):
        p, s = input().split()
        a[int(p)-1].append(s)
    correct = 0
    pena = 0
    for q in a:
        if 'AC' in q:
            correct += 1
            for qq in q:
                if qq == 'WA':
                    pena += 1
                else:
                    break
    print(correct, pena)

resolve()

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
L = []
for i in range(m):
  L.append([i for i in input().split()])
Lcorr = [0 for i in range(n)]
Lflag = [0 for i in range(n)]
Lpena = [0 for i in range(n)]

for i in range(m):
  if Lflag[int(L[i][0])-1] == 0 and L[i][1] == "AC":
    Lcorr[int(L[i][0])-1] += 1
    Lflag[int(L[i][0])-1] = 1
  if int(Lflag[int(L[i][0])-1]) == 0 and L[i][1] == "WA":
    Lpena[int(L[i][0])-1] += 1
    
for j in range(n):
  if Lflag[j] == 0:
    Lpena[j] = 0

corr = sum(Lcorr)
pena = sum(Lpena)
print("{0} {1}".format(corr, pena))

Submission status: Accepted

Solution code:
n, m = map(int,input().split())
ans = [0]*n
WA_li = [0]*n
AC = 0
WA = 0
for i in range(m):
    temp = list(map(str, input().split()))
    if ans[int(temp[0])-1] == 0:
        if temp[1] == "AC":
            ans[int(temp[0])-1] = 1
            AC += 1 
        else:
            WA_li[int(temp[0])-1] += 1
for i in range(n):
    if ans[i] == 1:
        WA += WA_li[i]
print(AC, WA)

Submission status: Accepted

Solution code:
from collections import defaultdict
N, M = map(int, input().split())
a = defaultdict(list)
b = defaultdict(int)
for i in range(M):
    li = list(input().split())
    li[0] = int(li[0])
    a[li[0]].append(li[1])
    if li[1] == 'AC':
        b[li[0]] = 1
ac = len(b)
wa = 0
for i in range(1, N+1):
    if b[i] == 1:
        for x in a[i]:
            if x == 'AC':
                break
            wa += 1
            
print(ac, wa)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
from fractions import gcd
from string import ascii_uppercase as ABC
#input = sys.stdin.readline
def inpl(): return list(map(int, input().split()))

from itertools import permutations
N, M = inpl()
C = 0
P = 0
ac = [False]*N
pe = [0]*N

for _ in range(M):
    p, s = input().split()
    p = int(p) - 1
    if s == "AC":
        ac[p] = True
    else:
        if ac[p] == False:
            pe[p] += 1
C = sum(ac)
P = sum([ac[i]*pe[i] for i in range(N)])
print(C, P)

Submission status: Accepted

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

ACWAList = []
for i in range(N):
    ACWAList.append([0, 0])

for i in range(M):
    P = int(PSList[i][0])

    if ACWAList[P-1][0] == 1:
        continue

    if PSList[i][1] == "AC":
        ACWAList[P-1][0] = 1
    else:
        ACWAList[P-1][1] += 1

ACSum = 0
WASum = 0
for i in range(N):
    if ACWAList[i][0] != 1:
        continue
    ACSum += ACWAList[i][0]
    WASum += ACWAList[i][1]

print(str(ACSum) + " " + str(WASum))

Submission status: Accepted

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

Submission status: Accepted

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

WA = [0] * (10 ** 5 + 1)
AC = [False] * (10 ** 5 + 1)
for i in range(M):
    _no , re = input().split()
    no = int(_no)
    if re == 'AC':
        AC[no] = True
    if not AC[no]:
        if re == 'WA':
            WA[no] += 1
pena = 0
for i in range(10 ** 5 + 1):
    if AC[i]:
        pena += WA[i]

print(AC.count(True), pena)

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
hist = {}
hist_wa = {}
count_ac = count_wa = 0
for i in range(m):
  p,s = input().split()
  if p in hist:
    continue
  if s == 'AC':
    hist[p] = True
    count_ac += 1
    if p in hist_wa:
      count_wa += hist_wa[p]
  else:
    if p in hist_wa:
      hist_wa[p] += 1
    else:
      hist_wa[p] = 1
print('{} {}'.format(count_ac, count_wa))

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
ps = []
P = []
S = []
for i in range(m):
  a = list(input().split())
  d = int(a[0])
  t = [d, a[1]]
  ps.append(t)
  P.append(d)
  S.append(t[1])
ac = 0
penalty = 0
ans = [0]*100000
for j in range(m):
  if ans[P[j]] <= 0:
    ans[P[j]] -= 1
  if S[j] == 'AC' and ans[P[j]]<0:
    ans[P[j]] *= -1
    ac += 1
for a in ans:
  if a >0:
    penalty += a-1
print(ac, penalty)

Submission status: Accepted

Solution code:
n, m = list(map(int, input().split()))
ac = [0] * n
wa = [0] * n
numac = 0
numwa = 0
p = 0
for i in range(m):
    _a, _s = list(input().split())
    _a = int(_a)
    if _s == "AC":
        if ac[_a - 1] == 0:
            numac += 1
            ac[_a - 1] = 1
            numwa += wa[_a - 1]
    elif _s == "WA":
        if ac[_a - 1] == 0:
            wa[_a - 1] += 1
print("{} {}".format(numac, numwa))

Submission status: Accepted

Solution code:
import collections
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]

n, m = ril()
ls = rsls(m)

ac = set()
wa = collections.defaultdict(int)
done = set()
for p, s in ls:
    if p not in ac:
        if s == 'AC':
            ac.add(p)
        else:
            wa[p] += 1
print(len(ac), sum(wa[p] for p in ac))

Submission status: Accepted

Solution code:
n, m = map(int, input().split(" "))
s = []
for i in range(m):
    s.append(tuple(input().split()))
tmp_ac = [0 for _ in range(n+1)]
tmp_pn = [0 for _ in range(n+1)]
end = set()
for i, x in s:
    if x == 'AC':
        if i in end:
            continue
        else:
            tmp_ac[int(i)] += 1
            end.add(i)
    else:
        if i not in end:
            tmp_pn[int(i)] += 1
        else:
            continue
for i in range(n+1):
    if tmp_ac[i] == 0:
        tmp_pn[i] = 0
ac = sum(tmp_ac)
pn = sum(tmp_pn)
print(str(ac) + " " + str(pn))

Submission status: Accepted

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

re = [[] for _ in range(n)]

for p, s in ps:
  p = int(p) - 1
  re[p].append(s)

po = 0
pe = 0

for r in re:
  temp_pe = 0
  for x in r:
    if x == 'AC':
      po += 1
      pe += temp_pe
      break
    else:
      temp_pe += 1

print(po, pe)

Submission status: Accepted

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


def solve(N: int, M: int, p: "List[int]", S: "List[str]"):
    pe=[0]*N
    ac=[False]*N
    for i in range(M):
        if S[i]=="AC":
            ac[p[i]-1]=True
        if S[i]=="WA" and ac[p[i]-1]==False:
            pe[p[i]-1]+=1

    a=0
    for i in range(N):
        if ac[i]==False: pe[i]=0
        else: a+=1

    print(a, sum(pe))

    return


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

Solution code:
n,m = map(int,input().split())
d = {}
for _ in range(m):
    p,s = input().split()
    try:
        d[int(p)].append(s)
    except:
        d[int(p)] = [s]
T = 0
pe = 0
for key in d:
    if "AC" in d[key]:
        T += 1
        pe += d[key].index("AC")

print(T,pe)

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
pS = [[i for i in map(str,input().split())] for j in range(m)]
acd = [False for i in range(n)]
WA = [0 for i in range(n)]

for i in range(m):
  if pS[i][1]=="AC":
    acd[int(pS[i][0])-1]=True
  if acd[int(pS[i][0])-1]==False and pS[i][1]=="WA":
    WA[int(pS[i][0])-1] += 1

acds = sum(acd)
WAs = sum([WA[i] for i in range(n) if acd[i]==True])
print(str(acds) + ' ' + str(WAs))

Submission status: Accepted

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

p, s = [], []
result = [0] * (n + 1)
wa = [0] * (n + 1)

for _ in range(m):
    tmpp, tmps = map(str, input().split())
    p.append(int(tmpp)), s.append(tmps)

for i in range(m):
    if result[p[i]] == 0:
        if s[i] == "AC":
            result[p[i]] = 1

        else:
            wa[p[i]] += 1

ac = sum(result)
wa = sum(wa[i] for i in range(n + 1) if result[i] == 1)

print(ac, wa)

Submission status: Accepted

Solution code:
import collections


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

    count = collections.defaultdict(int)
    count_sccess = collections.defaultdict(bool)

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

        if S == "WA" and not count_sccess[p]:
            count[p] += 1
        if S == "AC" and not count_sccess[p]:
            count[p] += 0
            count_sccess[p] = True

    ans1 = 0
    ans2 = 0
    for a, b in zip(count, count_sccess):
        if count_sccess[b]:
            ans1 += 1
            ans2 += count[a]

    print(ans1, ans2)


main()

Submission status: Accepted

Solution code:
# /usr/bin/python3
# -*- coding: utf-8 -*-
from queue import Queue
from queue import LifoQueue as Stack
from math import sqrt
from fractions import gcd

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

def intinput():
    return int(input())

def mulinputs():
    return map(int,input().split())

def lineinputs(func=intinput):
    datas = []
    while True:
        try:
            datas.append(func())
        except EOFError:
            break
    return datas



N, M = mulinputs()
datas = dict()
for i in range(1,N+1):
    datas[i] = []

while True:
    try:
        pi, Si = input().split()
        datas[int(pi)].append(Si)
    except EOFError:
        break

ac_cnt = 0
wa_cnt = 0
for v in datas.values():
    if 'AC' in v:
        ac_cnt += 1
        for judge in v:
            if judge == 'AC':
                break
            wa_cnt += 1

print(ac_cnt, wa_cnt)

Submission status: Accepted

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

ls.sort(key=lambda x:int(x[0]))

idx = 1
w=0
a=0
wp=0
for i in range(m):
    if idx<int(ls[i][0]):
        wp = 0
        idx = int(ls[i][0])
    if idx==int(ls[i][0]):
        if ls[i][1]=='WA':
            wp += 1
        else:
            w += wp
            wp = 0
            a += 1
            idx += 1

print(a,w)

Submission status: Accepted

Solution code:
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import bisect

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))

N, M = LI()
ps = [0 for i in range(M)]
for i in range(M):
    p,s = input().split()
    p = int(p)
    p -= 1
    s = str(s)
    ps[i] = [p,s]

# ACs = [0 for i in range(N)]
tmp = 0
ans = [[0,0] for i in range(N)] # AC, WA
for i in range(M):
    p, s = ps[i]
    if ans[p][0]:
        pass
    else:
        if s == "AC":
            ans[p][0] = 1
        else:
            ans[p][1] += 1

anss = [0, 0]
for i in range(N):
    if ans[i][0]:
        anss[0] += 1
        anss[1] += ans[i][1]

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

Submission status: Accepted

Solution code:
def main():
    n,m=map(int,input().split())
    L=[list(input().split()) for _ in range(m)]
    AC=[0]*n
    WA=[0]*n
    for l in L:
        i = int(l[0])-1
        if AC[i]<1:
            if l[1]=='WA':
                WA[i] += 1
            else:
                AC[i]=1
    print(AC.count(1),sum([i*j for i,j in zip(AC,WA)]))
main()

Submission status: Accepted

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

ac = 0
wa = 0

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

    if(l[p-1]):
        continue
    
    if(s=="AC"):
        l[p-1] = True
        ac += 1
        wa += res[p-1]
        continue

    res[p-1] += 1


print(ac, wa)

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),s])
ps.sort(key=lambda x:x[0])
d = {}
t = 0
ac = 0
wa = 0

for res in ps:
    if t != res[0]:
        if res[1] == "WA":
            d[res[0]] = d.get(res[0],0) + 1
        else:
            ac += 1
            wa += d.get(res[0],0)
            t = res[0]

print(ac,wa)

Submission status: Accepted

Solution code:
# 2020/01/12

n,m=map(int,input().split())
ps=[0]*(n+1)
ac=0
wa=0

for i in range(m):
    p,s=input().split()
    p=int(p)
    if ps[p]>0:continue
    if s=='WA':
        ps[p]-=1
    else:
        wa+=-ps[p]
        ps[p]=1
        ac+=1
print(*[ac,wa])

Submission status: Accepted

Solution code:
n, m = [int(i) for i in input().split()]
wrong_count = [0 for i in range(n)]
correct_count = [0 for i in range(n)]
for i in range(m):
    p, s = input().split()
    if s == 'AC':
        correct_count[int(p)-1] = 1
    elif correct_count[int(p)-1] == 0:
        wrong_count[int(p)-1] += 1
penalty_count = sum([wrong_count[i] for i in range(n) if correct_count[i] == 1])
print(sum(correct_count), penalty_count)

Submission status: Accepted

Solution code:
n,m = map(int, input().split())
#AC, WA
nn = [ [0, 0] for i in range(n)]
ps = []
for i in range(m):
    p, s = input().split()
    p = int(p)
    if s == "AC":
        if nn[p - 1][0] == 0:
            nn[p - 1][0] += 1
        else:
            pass
    else:
        if nn[p - 1][0] == 0:
            nn[p - 1][1] += 1
        else:
            pass

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

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

Submission status: Accepted

Solution code:
# coding: utf-8
n, m = map(int, input().split())
data = [input().split() for i in range(m)]
check = [False] * (n + 1)
tmp_wa = [0] * (n + 1)
ac = 0
wa = 0

for i in range(m):
    if data[i][1] == 'WA':
        if check[int(data[i][0])]:
            continue
        else:
            tmp_wa[int(data[i][0])] += 1
    else:
        if check[int(data[i][0])]:
            continue
        else:
            check[int(data[i][0])] = True
            wa += tmp_wa[int(data[i][0])]
            ac += 1

print('{} {}'.format(ac, wa))

Submission status: Accepted

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

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

AC, WA = 0, 0

for q in L:
    tmp_ac = 0
    tmp_wa = 0
    for a in q:
        if a == 'WA':
            tmp_wa += 1
        if a == 'AC':
            tmp_ac += 1
            break
    if tmp_ac == 1:
        AC += 1
        WA += tmp_wa

print(AC, WA)

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()
    p = int(p)
    if ac[p-1] == 0:
        if s == "AC":
            ac[p-1] = 1
        else:
            wa[p-1] += 1

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

print(ans1,ans2)

Submission status: Accepted

Solution code:
N, M=map(int, input().split())
lst=[input().split() for _ in range(M)]
AC=[False for _ in range(N)]
WA=[0 for _ in range(N)]
for p, S in lst:
  p=int(p)-1
  if S=="AC":
    AC[p]=True
  if S=="WA" and not AC[p]:
    WA[p]+=1
for i in range(N):
  if not AC[i]:
    WA[i]=0
print(sum(AC), sum(WA))