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_list = [[i for i in input().split()] for j in range(m)]

ac_list = []
wa_list = [0 for i in range(n)]
num_wa = 0
num_ac = 0

for ps in ps_list:
    p = int(ps[0])
    s = ps[1]
    
    if s == 'AC' and wa_list[p-1] != -1:
        ac_list.append(p)
        num_wa += wa_list[p-1]
        num_ac += 1
        wa_list[p-1] = -1
    elif wa_list[p-1] != -1:
        wa_list[p-1] += 1
        
print(num_ac, num_wa)

Submission status: Accepted

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip()
n,m=map(int,input().split())
wa=[0]*n
ac=[0]*n
for _ in range(m):
    x,y=map(str,input().split())
    x=int(x)
    if y=='WA':
        if ac[x-1]==0:
            wa[x-1]+=1
    if y=='AC':
        ac[x-1]=1
for i in range(n):
    if ac[i]==0: wa[i]=0
print(sum(ac),sum(wa))

Submission status: Accepted

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


ACflag=[0]*N
WAcount=[0]*N

for i in range(M):
    if ACflag[pS[i][0] -1] ==0:
        if pS[i][1]=="AC":
            ACflag[pS[i][0] -1] = 1
        else:
            WAcount[pS[i][0] -1] +=1

for j in range(N):
    WAcount[j] *= ACflag[j]

print(sum(ACflag), sum(WAcount))

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(m):
    x[i], y[i] = map(str, input().split())

#print(x)
#print(y)

ans_ac = [0]*n
ans_wa = [0]*n
ac = 0
wa = 0


for i in range(m):
    a = int(x[i])-1
    #print(a, y[i])
    if y[i] == "WA":
        ans_wa[a] += 1
    if y[i] == "AC" and ans_ac[a] == 0:
        ac += 1
        ans_ac[a] = 1
        wa += ans_wa[a]
#print(ans_wa)
print(ac, wa)

Submission status: Accepted

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

for i in range(m):
    p, s = input().split()
    p = int(p)
    p -= 1
    if cnt[p] == -1:
        continue
    elif s == 'AC':
        ac += 1
        wa += cnt[p]
        cnt[p] = -1
    else:
        cnt[p] += 1
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=map(str,input().split())
  p=int(p)-1
  if ac[p]==0:
    if s=='AC':
      ac[p]=1
    else:
      wa[p]+=1

w=0
for i in range (n):
  w+=ac[i]*wa[i]
print(sum(ac),w)

Submission status: Accepted

Solution code:
import numpy as np
n,m = map(int,input().split())
ac, wa = [0] * n, [0] * n
for i in range(m):
  p,s = input().split()
  p = int(p)-1
  if s == 'AC':
    ac[p] = 1
  if s == 'WA' and ac[p] == 0:
    wa[p] += 1
print('{} {}'.format(sum(ac), np.dot(ac, wa)))

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 7)
read = sys.stdin.buffer.read 
input = sys.stdin.buffer.readline
def inputS(): return input().rstrip().decode()
readlines = sys.stdin.buffer.readlines 

# ACが出ていない問題のWAは数えない
N, M = map(int, input().split())
flag = ["WA"]*(N+1)
WAcnt = [0]*(N+1)
ans = {"AC":0, "WA":0}

for _ in range(M):
  i, s = input().split()
  ind = int(i)
  s = s.decode()
  if flag[ind] == "AC":
    continue
  if s == "AC":
    ans[s] += 1
    ans["WA"] += WAcnt[ind]
    flag[ind] = s
  else:
    WAcnt[ind] += 1
    

print(ans["AC"], ans["WA"])

Submission status: Accepted

Solution code:
from collections import defaultdict

N, M = map(int, input().split())
submit = defaultdict(int)
ac = 0
penalty = 0
accepted = [False] * N

for _ in range(M):
    P, S = input().split()
    p = int(P) - 1
    if (S == "WA") and (not accepted[p]):
        submit[p] += 1
    elif (S == "AC") and (not accepted[p]):
        accepted[p] = True
        ac += 1

for i in range(N):
    if accepted[i]:
        penalty += submit[i]

print(" ".join(map(str, [ac, penalty])))

Submission status: Accepted

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

check = [0]*N
count_W = 0
count_A = 0
for i in range(M):
    p, S = input().split()
    p = int(p)
    if check[p-1] != -1:
        if S == "WA":
            check[p-1] = check[p-1] + 1
        else:
            count_A = count_A + 1
            count_W = count_W + check[p-1]
            check[p-1] = -1
print(count_A, count_W)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
a=[0]*n
b=[0]*n
ac=0
pe=0
for i in range(m):
    p,s=input().split()
    if a[int(p)-1]==0:
        if s=="AC":
            a[int(p)-1]=1
            ac+=1
            pe+=b[int(p)-1]
        else:
            b[int(p)-1]+=1
print(ac,pe)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
A=[[0,0] for i in range(n)] #ACしたか、WA数
AC=0
pen=0
for i in range(m):
    a,b=map(str,input().split())
    a=int(a)
    if b=="AC":
        A[a-1][0]=1
    elif b=="WA" and A[a-1][0]==0:
        A[a-1][1]+=1
for i in range(n):
    if A[i][0]==1:
        AC+=1
        pen+=A[i][1]
print(AC,pen)

Submission status: Accepted

Solution code:
f=lambda:input().split()
n,m=map(int,f())
sa,lw=set(),[0]*n
for _ in range(m):
  p,s=f()
  if p in sa: continue
  if s=='AC': sa.add(p)
  else: lw[int(p)-1]+=1
print(len(sa),sum(lw[int(p)-1] for p in sa))

Submission status: Accepted

Solution code:
import sys
input=sys.stdin.readline
n,m=map(int,input().split())
sa,lw=set(),[0]*n
for _ in range(m):
  p,s=input().split()
  if p in sa: continue
  if s=='AC': sa.add(p)
  else: lw[int(p)-1]+=1
print(len(sa),sum(lw[int(p)-1] for p in sa))

Submission status: Accepted

Solution code:
import sys
input=sys.stdin.readline
n,m=map(int,input().split())
lp,ls=[],[]
for _ in range(m):
  p,s=input().split()
  lp.append(int(p)-1)
  ls.append(s=='AC')
la,lw=[0]*n,[0]*n
for p,s in zip(lp,ls):
  if la[p]<1:
    if s: la[p]=1
    else: lw[p]+=1
print(sum(la),sum(w*a for a,w in zip(la,lw)))

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
PS=[input().split() for i in range(M)]
ACzumi=set()
WA_count=[]
for i in range(M):
    if not PS[i][0] in ACzumi:
        if PS[i][1]=="AC":
            ACzumi.add(PS[i][0])
        else:
            WA_count.append(PS[i][0])
yokei=0            
for i in range(len(WA_count)):
    if not WA_count[i] in ACzumi:
        yokei+=1
        
#print(ACzumi)
print(len(ACzumi),len(WA_count)-yokei)

Submission status: Accepted

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

WAlist = [0]*N
ACflag = [0]*N

for i in range(M):
    p, s = input().split()
    p=int(p)
    if ACflag[p-1] == 0:
        if   s == "WA":
            WAlist[p-1] += 1
        elif s == "AC":
            ACflag[p-1] = 1
            
WA = 0
for i in range(N):
    if ACflag[i]==1:
        WA += WAlist[i]
    
print(sum(ACflag), WA)

Submission status: Accepted

Solution code:
#ACしてないときはWAは加算されないようにする必要あり．
N, M = map(int, input().split())

AC = 0
WA = 0
A = [[0]*2 for _ in range(N)] #flag管理,n番目の問題がACになったらn-1番目の配列に1を入れる
for _ in range(M):
	p, S = input().split() #注意!ここのpはstrで入っている
	ip = int(p)
	if A[ip-1][1] == 0:
		if S == "WA":
			A[ip-1][0] += 1
		else:
			A[ip-1][1] = 1
			AC += 1
	else:
		continue

for i in range(N): #WAのカウント
	if A[i][1] == 1:
		WA += A[i][0]

print(AC,WA)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
hasAC = [False] * n #AC or WAの配列を用意
wa = [0] * n #waの回数を格納
a = 0
b = 0

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

    p = int(p) - 1
    if s == 'AC':    
        hasAC[p] = True
    else:
        if not hasAC[p]:
            wa[p] += 1

for i in range(n):
    if hasAC[i]:
        a += 1
        b += wa[i]

print(a, b)

Submission status: Accepted

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

AC = collections.defaultdict(bool)
WA = collections.defaultdict(int)

const = 0
score = 0
for p, s in result:
    if s == "AC" and not AC[p]:
        score += 1
        const += WA[p]
        AC[p] = True
    if s == "WA" and not AC[p]:
        WA[p] += 1
print(score, const)

Submission status: Accepted

Solution code:
from collections import defaultdict

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

sub_st = defaultdict(list)
for p, s in ps:
    sub_st[p].append(s)

solved = 0
error = 0
for k, v in sub_st.items():
    temp_error = 0
    for history in v:
        if 'AC' in history:
            error += temp_error
            solved += 1
            break
        temp_error += 1

print(solved, error)

Submission status: Accepted

Solution code:
#151c
n,w=map(int,input().split())
ac=0
wa=[0]*n
wa_cnt=[0]*n
ac_flg=[0]*n
for i in range(w):
	p,s=input().split()
	p=int(p)-1
	if ac_flg[p]==1:
		continue
	else:
		if s=='AC':
			ac_flg[p]=1
			ac+=1
			wa[p] =wa_cnt[p]
			#wa_cnt=0
		else:
			wa_cnt[p]+=1

wa_ans=0
for i in range(n):
	wa_ans+=wa[i]

print(ac,wa_ans)

Submission status: Accepted

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

n_flg = [False for _ in range(n)]
pena_tmp = [0 for _ in range(n)]

pena = 0

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

    p = int(p) - 1


    if n_flg[p]:
        pass
    elif s == 'WA':
        pena_tmp[p] += 1
    elif s == 'AC':
        pena += pena_tmp[p]
        n_flg[p] = True

print(n_flg.count(True), pena)

Submission status: Accepted

Solution code:
# ABC 151C
n, m = map(int, input().split())
ac = 0
wa = 0
cnt = [0]*n
for i in range(m):
    p, s = input().split()
    p = int(p)
    p -= 1
    if cnt[p] == -1:
        continue
    elif s == 'AC':
        ac += 1
        wa += cnt[p]
        cnt[p] = -1
    else:
        cnt[p] += 1
print(ac, wa)

Submission status: Accepted

Solution code:
# ABC 151C
n, m = map(int, input().split())
ac = 0
wa = 0
cnt = [0]*n
for i in range(m):
    p, s = input().split()
    p = int(p)
    p -= 1
    if cnt[p] == -1:
        continue
    if s == 'AC':
        ac += 1
        wa += cnt[p]
        cnt[p] = -1
    else:
        cnt[p] += 1
print(ac, wa)

Submission status: Accepted

Solution code:
d=dict()
wa=ans=0
N,M=map(int,input().split())
for i in range(M):
  p,s=input().split()
  if p not in d:
    d[p]=0
  if d[p]>=0 and s=="AC":
    ans+=1
    wa+=d[p]
    d[p]=-float("inf")
  else:
    d[p]+=1
print(ans,wa)

Submission status: Accepted

Solution code:
d=dict()
wa=ans=0
N,M=map(int,input().split())
for i in range(M):
  p,s=input().split()
  if p not in d:
    d[p]=0
  if d[p]>=0 and s=="AC":
    ans+=1
    wa+=d[p]
    d[p]=-1
  elif d[p]>=0:
    d[p]+=1
print(ans,wa)

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
AC=["false"]*N
WA=[0]*N
wa=0
ac=0
for i in range(M):
    p,s=input().split()
    p=int(p)
    if s=="AC":
        if AC[p-1]=="false":
            AC[p-1]="True"
            ac+=1
            wa+=WA[p-1]
    else:
        WA[p-1]+=1
print(ac,wa)

Submission status: Accepted

Solution code:
from collections import defaultdict

N, M = map(int, input().split())
WA = {i : 0 for i in range(1,N+1)}
AC = defaultdict(int)
boollist = [False]*N

for _ in range(M):
    p,s = input().split()
    p = int(p)
    if s == 'WA' and not boollist[p-1]:
        WA[p] += 1
    elif s == 'AC':
        boollist[p-1] = True
        AC[p] = 1
print(sum(AC.values()), sum([a for a,b in zip(WA.values(), boollist) if b==True]))

Submission status: Accepted

Solution code:
from collections import defaultdict

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

ac_set = set()
wa_count = defaultdict(int)
for p, s in PS:
    if s == 'AC':
        ac_set.add(p)
    else:
        if p not in ac_set:
            wa_count[p] += 1
print(len(ac_set), sum(wa_count[p] for p in ac_set))

Submission status: Accepted

Solution code:
def solve():
    N,M = map(int, input().split())
    accepted = [False]*(N+1)
    AC_num = [0]*(N+1)
    WA_num = [0]*(N+1)
    res = [0,0]
    for _ in range(M):
        p, submit_res = input().split()
        p = int(p)
        if not accepted[p]:
            if submit_res == 'WA':
                WA_num[p] += 1
                # res[1] += 1
            else:
                # res[0] += 1
                AC_num[p] += 1
                accepted[p] = True
                
    res = [sum(accepted[i]*n for i,n in enumerate(AC_num)), sum(accepted[i]*n for i,n in enumerate(WA_num))]
    print(' '.join(map(str, res)))
    
solve()

Submission status: Accepted

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():
    if 'AC' in v and 'count' in v:
        s += v['count']
    if 'AC' in v:
        a += 1
    
print(a, s)

Submission status: Accepted

Solution code:
from collections import defaultdict

n, m = map(int, input().split())
PS = [input().split() for _ in range(m)]
ac = defaultdict(bool)
wa = defaultdict(int)
cost = 0
score = 0
for p, s in PS:
  if s == 'AC' and not ac[p]:
    score += 1
    cost += wa[p]
    ac[p] = True
  if s == 'WA' and not ac[p]:
    wa[p] += 1
print(score, cost)

Submission status: Accepted

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


def solve(N: int, M: int, p: "List[int]", S: "List[str]"):
    A = [False] * (N+1)
    W = [0] * (N+1)
    wans = 0
    for _p, _s in zip(p, S):
        if A[_p]:
            continue
        if _s == 'WA':
            W[_p] += 1
        else:
            A[_p] = True
            wans += W[_p]
    ans = sum(A)
    print(ans, wans)


# 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())
ps=[list(map(int,input().replace('WA','0').replace('AC','1').split())) for i in range(m)]
ps.sort(key=lambda x:x[0])

tmp_p=0
ac_cnt=0
wa_cnt=0
wa=0
flg=0
for i in range(m):
  p=ps[i][0]
  s=ps[i][1]
  if tmp_p!=p:
    wa=0
    flg=0
  if s==1 and flg==0:
    flg=1
    ac_cnt+=1
    wa_cnt+=wa
  elif s==0 and flg==0:
    wa+=1
  tmp_p=p
print(ac_cnt, wa_cnt)

Submission status: Accepted

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

tempP = ""
ac = []
wa = []

for count in range(N):
    ac.append(0)
    wa.append(0)

for count in range(M):
    P,S = input().split()
    P = int(P)
    P -= 1
    
    if ac[P] == 0:
        if S == "AC":
            ac[P] = 1
        else:
            wa[P] +=1



a = 0
b = 0
 
for i in range(N):
    if ac[i] == 1:
        a += 1
        b += wa[i]
 
print(*[a, b])

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 7)
read = sys.stdin.buffer.read 
input = sys.stdin.buffer.readline
def inputS(): return input().rstrip().decode()
readlines = sys.stdin.buffer.readlines 

N, M = map(int, input().split())
AC = [False]*(N+1)
WA = [0]*(N+1)
WAsum = 0

for _ in range(M):
  p, s = input().split()
  p = int(p)  
  if AC[p]:
    continue
  if s == b"AC":
    AC[p] = True
    WAsum += WA[p]
  else:
    WA[p] += 1
print(sum(AC), WAsum)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
ss=set()
s3=set()
penality=0
l=[]
for _ in range(m):
  p,s=input().split()
  p=int(p)
  if s=="AC":
    s3.add(p)
  l.append([p,s])
for i in range(len(l)):
  p=l[i][0]
  s=l[i][1]
  if (p not in ss) and s=="WA" and (p in s3):
    penality+=1
  if s=="AC":
    ss.add(p)
print(len(ss),penality)

Submission status: Accepted

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

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

for i in lst:
    if status[i[0]-1]!="AC" and i[1]=="AC":
        ac += 1
        wa += status[i[0]-1]
        status[i[0]-1] = "AC"
    elif status[i[0]-1]!="AC" and i[1]=="WA":
        status[i[0]-1] += 1

print(ac,wa)

Submission status: Accepted

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

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

for i in lst:
    if status[i[0]-1]!="AC":
        if i[1]=="AC":
            ac += 1
            wa += status[i[0]-1]
            status[i[0]-1] = "AC"
        else:
            status[i[0]-1] += 1

print(ac,wa)

Submission status: Accepted

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

is_ac = [0] * (n+1)
wa = [0] * (n+1)
count_ac = count_penalty = 0
for pp, ss in zip(p, s):
    if not is_ac[pp]:
        if ss == 'WA':
            wa[pp] += 1
        else:
            count_ac += 1
            count_penalty += wa[pp]
            is_ac[pp] = 1

print(count_ac, count_penalty)

Submission status: Accepted

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

ac=[0]*n
ac_cnt=0
wa_cnt=[0]*n
for i in range(len(l)):
    num = int(l[i][0])-1
    acwa= l[i][1]
    if ac[num]==0:
        if acwa == "AC":
            ac_cnt+=1
            ac[num]=1
        elif acwa=="WA":
            wa_cnt[num]+=1

wa_ans=0
for i in range(n):
    if ac[i] == 1:
        wa_ans+=wa_cnt[i]
print(ac_cnt,wa_ans)

Submission status: Accepted

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

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

a = 0
b = 0

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

print(*[a, b])

Submission status: Accepted

Solution code:
n, m = [int(elem) for elem in input().split()]
ac = [0] * n
wa = [0] * n
 
for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    if s == 'AC':
        ac[p] = 1
    if not ac[p] and s == 'WA':
        wa[p] += 1

c = 0
for i in range(n):
    c += wa[i] * ac[i]
print(sum(ac), c)

Submission status: Accepted

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

aced_state = [False for i in range(N+1)]
wa_state = [0 for i in range(N+1)]

for i in range(M):
    p,s = map(str,input().split())
    p = int(p)
    if aced_state[p] == True:
        continue
    else:
        if s == "AC":
            cnt_ac += 1
            cnt_wa += wa_state[p]
            aced_state[p] = True
        else:
            wa_state[p] += 1

print(cnt_ac,cnt_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) - 1
    if s == 'AC':
        ac[p] = 1
    if not ac[p] and s == 'WA':
        wa[p] += 1

c = 0
for i in range(n):
    c += wa[i] * ac[i]
print(sum(ac), c)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
missed = {str(i): 0 for i in range(1, N + 1)}
answered = {}
for _ in range(M):
    idx_q, status = input().split()
    if status == 'AC':
        answered[idx_q] = 'AC'
    else:
        if idx_q not in answered:
            missed[idx_q] += 1
answered_num = len(answered)
missed_num = 0
for idx in answered.keys():
    missed_num += missed[str(idx)]
print(answered_num, missed_num)

Submission status: Accepted

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

ac_cnt=[False]*n
wa_cnt=[0]*n

for _ in range(m):
    a,b=input().split()
    a=int(a)-1
    if b == "AC":
        ac_cnt[a] = True
    else:
        if ac_cnt[a] == False:
            wa_cnt[a] += 1
c=0
d=0

for i in range(n):
    if ac_cnt[i]:
        c += 1
        d += wa_cnt[i]

print(c,d)

Submission status: Accepted

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

ans=dict()
AC=0
WA=0

for i in range(M):
    P,S= map(str,input().split())
    if((P in ans)==False):
        ans[P]=[S]
    else:
        ans[P].append(S)

for i in ans.values():
    tmp=0
    for value in i:
        if(value=='AC'):
            AC+=1
            WA+=tmp
            break
        else:
            tmp+=1
print(AC,WA)

Submission status: Accepted

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

x = [False]*n
y = [0]*n

for i in range(m):
  a,b = input().split()
  a = int(a) - 1
  if b =='AC' and x[a] == False:
    x[a] = True
  elif b == 'WA' and x[a] == False:
    y[a] += 1

ac = 0
wa = 0
for i in range(n):
  if x[i]:
    ac += 1
    wa += y[i]
print(ac,wa)

Submission status: Accepted

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

def main():
    n, m = map(int, input().split())
    li_answers = [[] for i in range(n + 1)]
    for i in range(m):
        p, s = input().split()
        li_answers[int(p)].append(s)
    acs = 0
    pens = 0
    for i in range(n + 1):
        for j, s in enumerate(li_answers[i]):
            if s == "AC":
                acs += 1
                pens += j
                break
    print(acs, pens)

main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n, m = map(int, input().split())
o = [[0] * 2 for i in range(n)]
acCount = 0
penalty = 0
for i in range(m):
    p, s = input().split()
    if o[int(p)-1][0] == 1:
        pass
    else:
        if s == 'AC':
            o[int(p)-1][0] = 1
        elif s == 'WA':
            o[int(p)-1][1] += 1

for j in range(n):
    if o[j][0] == 1:
        acCount += 1
        penalty += o[j][1]
    else:
        pass
# output
print(acCount, penalty)

Submission status: Accepted

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

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

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

print(ac_ans, wa_ans)

Submission status: Accepted

Solution code:
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

n,m = get_nums_l()
qqq = list(map(lambda s: s.strip().split(), sys.stdin.readlines()))
qqq = list(map(lambda q: (int(q[0]), q[1]), qqq))
qqq.sort(key=lambda q: q[0])

prev = None
wa = 0
accepted = set()
ans_wa = 0
for q in qqq:
    no = q[0]
    ju = q[1]
    if no != prev:
        wa = 0
    if ju == "AC":
        if no not in accepted:
            accepted.add(no)
            ans_wa += wa
    if ju == "WA":
        wa += 1
    prev = no

print(len(accepted), ans_wa)

Submission status: Accepted

Solution code:
import sys
N, M, *PS = sys.stdin.read().strip().split()
N = int(N)
ac = [0] * N
wa = [0] * N
for p, s in zip(*[iter(PS)] * 2):
  p = int(p) - 1
  if s == "AC":
    ac[p] = 1
  elif ac[p] == 0:
    wa[p] += 1
penalties = sum(w * a for a, w in zip(ac, wa))
print(sum(ac), penalties)

Submission status: Accepted

Solution code:
import sys
N, M, *PS = sys.stdin.read().strip().split()
N = int(N)
ac = [0] * N
wa = [0] * N
for p, s in zip(*[iter(PS)] * 2):
  p = int(p) - 1
  if s == "AC":
    ac[p] = 1
  elif ac[p] == 0:
    wa[p] += 1
penalties = sum(w if a > 0 else 0 for a, w in zip(ac, wa))
print(sum(ac), penalties)

Submission status: Accepted

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

N=[]

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

co=0
pe=0
for i in range(m):
    p,s=input().split()
    p=int(p)
    if s=='WA':
        N[p-1][0]+=1
    elif N[p-1][1]!=1:
        pe+=N[p-1][0]
        co+=1
        N[p-1][1]=1

print(str(co)+' '+str(pe))

Submission status: Accepted

Solution code:
N, M = list(map(int, input().split()))
pen_tot = 0
corr_tot = 0
ac = [0 for _ in range(N)]
pen = [0 for _ in range(N)]

for _ in range(M):
  pi, ans = input().split()
  pi = int(pi) - 1
  if ac[pi] == 0:
    if ans == 'WA':
        pen[pi] += 1
    else:
      corr_tot += 1
      ac[pi] = 1
      pen_tot += pen[pi]
    
  
print('{} {}'.format(corr_tot, pen_tot))

Submission status: Accepted

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

s = {i + 1 for i in range(n)}

ac = 0
wa = {i + 1:[0, False] for i in range(n)}


for i in range(m):
  if int(p[i][0]) in s:
    if p[i][1] == 'WA':
      wa[int(p[i][0])][0] += 1
    else:
      ac += 1
      s.discard(int(p[i][0]))
      wa[int(p[i][0])][1] = True
      
wa_wa = 0
for i in range(1, n + 1):
  if wa[i][1]:
    wa_wa += wa[i][0]
print(ac, wa_wa)

Submission status: Accepted

Solution code:
from collections import defaultdict

N,M=map(int,input().split())
P=[]
S=[]
for i in range (M):
	A,B=input().split()
	P.append(int(A))
	S.append(B)
Q=defaultdict(lambda:0)
R=defaultdict(lambda:0)
count=0
for i,j in zip(P,S):
  if Q[i]==0:
    if j=="AC":
      Q[i]=1
      count+=R[i]
    elif j=="WA":
      R[i]+=1
print(sum(Q.values()),count)

Submission status: Accepted

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

AC = 0
WA = 0
PS = {}
for _ in range(M):
    p, S = input().split()
    tmp = PS.get(p)
    # print(PS)
    if tmp == None:
        if S == "AC":
            PS[p] = S
            AC += 1
        else:
            PS[p] = 1
    elif tmp != "AC":
        if S == "AC":
            PS[p] = S
            AC += 1
            WA += tmp
        else:
            PS[p] += 1
print(AC, WA)

Submission status: Accepted

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

# AC = 0
# WA = 0
# PS = {}
# for i in range(M):
#     # print(PS)
#     p, S = input().split()
#     tmp = PS.get(p)
#     # if tmp != None:
#         # print("\t" + tmp)

#     if tmp != "AC":
#         if S == "AC":
#             AC += 1
#         elif S == "WA":
#             WA += 1
#         PS[p] = S

AC = [False] * N
WA = [0] * N

# print((AC))
# print(WA)

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

    if AC[p-1] == False:
        if S == "AC":
            AC[p-1] = True
        else:
            WA[p-1] += 1
# print((AC))
# print(WA)
a = 0
w = 0
for i in range(N):
    if AC[i]:
        a += 1
        w += WA[i]

print(a, w)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
n,m = map(int,input().split())
flag = [0]*n
pena = [0]*n
ans = 0
for i in range(m):
    p,s = map(str,input().split())
    if flag[int(p)-1]==0: 
        if s == "WA" : pena[int(p)-1] += 1 
        else : 
            flag[int(p)-1]=1
            ans += pena[int(p)-1]
#print(flag,pena)
print(sum(flag),ans)

Submission status: Accepted

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

is_acs = [False] * n
wa_counts = [0] * n

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

    if s == "AC":
        is_acs[p] = True

    elif not is_acs[p]:
        wa_counts[p] += 1


ac_count = 0
penalty_count = 0

for a, w in zip(is_acs, wa_counts):
    if a:
        ac_count += 1
        penalty_count += w

print(ac_count, penalty_count)

Submission status: Accepted

Solution code:
from collections import defaultdict
n,m=map(int,input().split())
p,s=[],[]
for i in range(m):
    P,S=input().split()
    p.append(int(P))
    s.append(S)

pena=0
cnt_ac=defaultdict(lambda :0)
cnt_wa=defaultdict(lambda :0)
for x,y in zip(p,s):
    if cnt_ac[x]==0:
        if y=='AC':
            cnt_ac[x]=1
            pena+=cnt_wa[x]

        elif y=='WA':
            cnt_wa[x]+=1

print(sum(cnt_ac.values()),pena)

Submission status: Accepted

Solution code:
import sys
# input = sys.stdin.buffer.readline
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getlist():
    return list(map(int, input().split()))
import math
import heapq
import fractions
from collections import defaultdict, Counter, deque
MOD = 10**9 + 7
INF = 10**15

def getyaku(n):
    res = []
    for i in range(1, int(math.sqrt(n)) + 1):
        if n % i == 0:
            res.append(i)
            res.append(n // i)

    return(sorted(list(set(res))))

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

def main():
    n,m = getlist()
    wa = [0 for i in range(n)]
    ac = [0 for i in range(n)]
    ansa = 0
    ansp = 0
    for i in range(m):
        p, s = input().split()
        p = int(p) -1
        if s == "AC":
            if not ac[p]:
                ansa += 1
                ansp += wa[p]
                ac[p] = 1
        else:
            wa[p] += 1

    print(ansa, ansp)

    return

if __name__ == '__main__':
    main()

"""
9999
3

2916
"""