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 _ in range(m)]

check = [True] * (n+1)
wa = [0] * (n+1)
wa_ans = 0
for i in range(m):
    if ps[i][1] == 'AC' and check[int(ps[i][0])]:
        check[int(ps[i][0])] = False
        wa_ans += wa[int(ps[i][0])]
    if ps[i][1] == 'WA':
        wa[int(ps[i][0])] += 1
ans = 0
for i in check:
    if not i:
        ans += 1

print(ans,wa_ans)

Submission status: Accepted

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

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

for el in d:
    if ac[int(el[0]) - 1] == 0:
        if el[1] == 'AC':
            ac[int(el[0]) - 1] += 1
        else:
            wa[int(el[0]) - 1] += 1
        
result = [0] * 2
for i in range(n):
    if ac[i] > 0:
        result[0] += 1
        result[1] += wa[i]
        
print(result[0], result[1])

Submission status: Accepted

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

check = [True] * (n+1)
wa = [0] * (n+1)
wa_ans = 0
for i in range(m):
    if ps[i][1] == 'AC' and check[int(ps[i][0])]:
        check[int(ps[i][0])] = False
        wa_ans += wa[int(ps[i][0])]
    if ps[i][1] == 'WA':
        wa[int(ps[i][0])] += 1
ans = 0
for i in check:
    if not i:
        ans += 1

print(ans,wa_ans)

Submission status: Accepted

Solution code:
def resolve():
    N, M = map(int, input().split())
    complete = [False] * (N + 1)
    wans= [0] * (N + 1)
    ac = 0
    wc = 0
    for _ in range(M):
        p, ans = input().split()
        p = int(p)
        if complete[p]:
            continue
        if ans == 'AC':
            complete[p] = True
            ac += 1
            wc += wans[p]
        else:
            wans[p] += 1
    print(ac, wc)

resolve()

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
aclist = [0]*(n+1)
walist = [0]*(n+1)
for i in range(m):
  p,s = input().split()
  if aclist[int(p)] == 0:
    if s == 'AC':
      aclist[int(p)] += 1
    else:
      walist[int(p)] += 1
for i in range(len(walist)):
  if aclist[i] == 0:
    walist[i] = 0
print(sum(aclist),sum(walist))

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,q = input().split()
    p = int(p)
    if q == 'AC':
        AC[p]=1
    elif q =='WA'and AC[p]==0:
        WA[p]+=1

for m in range(N+1):
    if AC[m]==0:
        WA[m]=0
print(sum(AC),sum(WA))

Submission status: Accepted

Solution code:
N,M = map(int,input().rstrip().split(" "))
ans = [False for _ in range(N + 1)]
wa = [0 for _ in range(N + 1)]
ansi = 0
penai = 0
for i in range(M):
  k = input().rstrip().split(" ")
  if ans[int(k[0])] == False:
    if k[1] == "AC":
      ans[int(k[0])] = True
      penai += wa[int(k[0])]
      ansi += 1
    else:
      wa[int(k[0])] += 1
print(str(ansi) + " " + str(penai))

Submission status: Accepted

Solution code:
N,M = (int(x) for x in input().split())

cnt_ac = [0]*N
cnt_wa = [0]*N
for i in range(M):
  p_i,S_i = (x for x in input().split())
  p_i = int(p_i)
  
  if S_i == 'AC' and cnt_ac[p_i-1] == 0:
    cnt_ac[p_i-1] += 1
    
  elif S_i == 'WA' and cnt_ac[p_i-1] == 0:
    cnt_wa[p_i-1] += 1
    
for i in range(N):
  if cnt_ac[i] == 0:
    cnt_wa[i] = 0
    
print(sum(cnt_ac),sum(cnt_wa))

Submission status: Accepted

Solution code:
n,m = map(int, input().split())
 
arS = [False] * (n+1)
arP = [False] * (n+1)
 
score = 0
penalty = 0

for i in range(m):
	id, res = input().split()
	id = int(id)
	if (res == "AC") and (arS[id]==False):
		arS[id] = True
		score = score+1
		penalty = penalty + arP[id]
	if (res == "WA"): 
		arP[id] = arP[id] + 1
        
print(score, penalty)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
d = {}
res = [0, 0]
for i in range(m):
    a, b = map(str, input().split())
    d.setdefault(a, [0, 0])
    if b == "AC" and d[a][0] == 0:
        d[a][0] = 1
        res[0] += 1
        res[1] += d[a][1]
    else:
        d[a][1] += 1
print(res[0], res[1])

Submission status: Accepted

Solution code:
N,M=[int(i) for i in input().split(" ")]
plog={}
for i in range(M):
    p,S=input().split(" ")
    if p in plog:
        plog[p]+=[S]
    else:
        plog[p]=[S]

WA_Count=0
AC_Count=0
for pl in plog:
    _WA_Count=0
    for res in plog[pl]:
        if res=="WA":
            _WA_Count+=1
        elif res=="AC":
            AC_Count+=1
            WA_Count+=_WA_Count
            break
print("%d %d"%(AC_Count,WA_Count))

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
from collections import defaultdict

N,M = map(int,input().split())
AC_dict = defaultdict(int)
ans_AC = 0
ans_WA = 0

for _ in range(M):
    p,s = input().split()
    p = int(p)
    if s == "AC":
        if AC_dict[p] == -1:
            continue
        else:
            ans_AC += 1
            ans_WA += AC_dict[p]
            AC_dict[p] = -1
    else:
        if AC_dict[p] == -1:
            continue
        else:
            AC_dict[p] += 1

print(ans_AC,ans_WA)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
submit = [list(input().split()) for _ in range(M)]
acflag = [False]*N
AC = 0
waflag = [0]*N
WA = 0

for i in range(M):
    if (not acflag[int(submit[i][0])-1]) and submit[i][1] == "AC":
        acflag[int(submit[i][0])-1] = True
        AC += 1
    elif (not acflag[int(submit[i][0])-1]) and submit[i][1] == "WA":
        waflag[int(submit[i][0])-1] += 1

for i in range(N):
    if acflag[i]:
        WA += waflag[i]
print(AC, WA)

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
ac=[0]*N
wa=[0]*N
WA=0
for i in range(M):
  lst=list(map(str,input().split()))
  n=int(lst[0])-1
  if lst[1]=='WA':
    if ac[n]:
      pass
    else:
      wa[n]+=1
  else:
    if ac[n]:
      pass
    else:
      ac[n]=1
      WA+=wa[n]
print(' '.join([str(sum(ac)),str(WA)]))

Submission status: Accepted

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

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

    if s == 'AC':
        AC[p] = 1
    elif s == 'WA'and AC[p] != 1:
        WA[p] += 1

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

print(sum(AC),sum(WA))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np


def main():
    n, m = map(int, input().split())
    ac = np.array([0] * n)
    pena = np.array([0] * n)
    # 
    for _ in range(m):
        p, s = map(str, input().split())
        p = int(p) - 1
        if ac[p] == 0 and s == 'WA':
            pena[p] += 1
        else:
            ac[p] = 1
    print(sum(ac), sum(ac * pena))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
nm=input().rstrip().split(" ")
n=int(nm[0])
m=int(nm[1])
answers=[[] for i in range(n)]
for i in range(m):
    line=input().rstrip().split(" ")
    if line[1]=="AC":
        answers[int(line[0])-1].append(1)
    if line[1]=="WA":
        answers[int(line[0])-1].append(0)
#print(answers)
ac=0
i=0
was=[]
while i<n:
    sums=0
    j=0
    while j<len(answers[i]):
        sums=sums+answers[i][j]
        if sums>0:
            ac+=1
            was.append(j)
            break
        j=j+1
    i=i+1
print(ac,end=" ")
#print(was)
wacount=0
for j in was:
    wacount=wacount+j
print(wacount)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
table = [[0, "None"] for i in range(n+10)]
for i in range(m):
    p, s = input().split()
    p = int(p)
    if table[p][1] == "None" or table[p][1] == "WA":
        if s == "WA":
            table[p][0] += 1
        table[p][1] = s
AC = 0
PEN = 0
for i in table:
    if i[1] == "AC":
        AC += 1
        PEN += i[0]
print(AC, PEN)

Submission status: Accepted

Solution code:
# C - Welcome to AtCoder

import numpy as np

N, M = map(int, input().split())
AC = np.zeros(N, dtype=np.int64)
WA = np.zeros(N, dtype=np.int64)

for i in range(M):
    p, S = map(str, input().split())
    if AC[int(p)-1]==0:
        if S=='AC':
            AC[int(p)-1] = 1
        else:
            WA[int(p)-1] += 1

print(sum(AC), sum(AC * WA))

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 = input().split()
    p = int(p)-1
    if ac[p]: continue
    if s == "AC":
        ac[p] = 1

    elif s == "WA":
        wa[p]+=1
AC = 0
pena = 0

for i in range (n):
    AC += ac[i]
    if ac[i]: pena += wa[i]
print(str(AC)+" "+str(pena))

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
L=[0]*N
A=0
W=0
tmp=[0]*N
for i in range(M):
	x,y=input().split()
	t=int(x)
	if L[t-1]==0:
		if y=="WA":
			tmp[t-1]+=1
		else:
			A+=1
			W+=tmp[t-1]
			L[t-1]=1
print(A,W)

Submission status: Accepted

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

Submission status: Accepted

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

A = [0]*N
B = [0]*N

for i in range(M):
  if d[i][1] == 'AC':
    A[int(d[i][0])-1] = 1
  elif A[int(d[i][0])-1] == 0:
    B[int(d[i][0])-1] += 1

c = 0

for i in range(N):
  c += A[i]*B[i]

print("{} {}".format(sum(A),c))

Submission status: Accepted

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

ac_set = set()

penalty_total = 0
penalty_map = {}

for _ in range(M):
  p, s = input().split()
  p = int(p)
  if p in ac_set:
    continue

  if s == "AC":
    ac_set.add(p)
    penalty_total += penalty_map.get(p, 0)
  else:
    if p not in penalty_map:
      penalty_map[p] = 1
    else:
      penalty_map[p] += 1

print(len(ac_set), penalty_total)

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
ps = [list(input().split()) for _ in range(m)]
d = {}
cl_cnt = 0
pl_cnt = 0
for i in ps:
  if int(i[0]) in d:
    if (d[int(i[0])] >= 0) and (i[1] == 'WA'):
      d[int(i[0])] += 1
    elif (d[int(i[0])] >= 0) and (i[1] == 'AC'):
      cl_cnt += 1
      d[int(i[0])] += 1
      pl_cnt += d[int(i[0])]
      d[int(i[0])] = -1
  else:
    if i[1] == 'WA':
      d[int(i[0])] = 0
    else:
      d[int(i[0])] = -1
      cl_cnt += 1
print(cl_cnt,pl_cnt)

Submission status: Accepted

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

answer = 0
penalty = 0

WA = [0 for i in range(N)]
#print(t)
for i in range(M):
    if WA[int(s[i][0])-1] != "AC":
        if s[i][1] == "WA":
            WA[int(s[i][0])-1] += 1
        else:
            penalty += WA[int(s[i][0])-1]
            answer += 1
            WA[int(s[i][0])-1] = "AC"
    #print(WA)
print(answer,penalty)

Submission status: Accepted

Solution code:
N, M = map(int,input().split())
lst=[None]*M
for i in range(M):
    p, S=input().split()
    lst[i]=(int(p), S)

stop_set=set()

WA_count=0
AC_count=0
from collections import defaultdict
WA_dict = defaultdict(lambda: 0)

for el in lst:
    if not el[0] in stop_set:
        if el[1]=='AC':
            AC_count+=1
            stop_set.add(el[0])
        else:
            WA_dict[el[0]] +=1
#print(dict(WA_dict))

new_set=set(WA_dict.keys())&stop_set
#print(new_set)
WA_count=sum([WA_dict[i] for i in new_set])
print(AC_count, WA_count)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
result = [0 for i in range(N)]
right = 0
penalty = 0
for i in range(M):
  p, s = map(str, input().split())
  p = int(p)
  if result[p - 1] != -1:
    if s == "WA":
      result[p - 1] += 1
    else:
      right += 1
      penalty += result[p - 1]
      result[p - 1] = -1
print("{} {}".format(str(right), str(penalty)))

Submission status: Accepted

Solution code:
import numpy as np
problem, answer = map(int, input().split())
ac_count = np.array([0]*problem)
wa_count = np.array([0]*problem)
for i in range(answer):
    a,b = input().split()
    if ac_count[int(a) - 1] == 0 and b == "WA":
        wa_count[int(a) - 1] += 1
    else:
        ac_count[int(a) - 1] = 1

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

Submission status: Accepted

Solution code:
from collections import defaultdict


def main():
    a = list(map(int, input().split()))
    inputs = [input().split() for i in range(a[1])]
    num_ac = 0
    results = defaultdict(int)
    results_wa = defaultdict(int)
    for i in inputs:
        if not results[i[0]]:
            if i[1] == "WA":
                results_wa[i[0]] += 1
            elif i[1] == "AC":
                num_ac += 1
                results[i[0]] = 1
    
    for k in results.keys():
        if results[k] == 0:
            results_wa[k] = 0
    
    num_wa = sum(results_wa.values())
    print(num_ac, num_wa)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
row=m
number=[]
judgment=[]
for p in range(row):
    a,b=input().split()
    number.append(int(a))
    judgment.append(b)

penalist = [0]*n
aclist = [0]*n
anscount=0
penacount=0

for i in range(0,m):
    if judgment[i] == 'WA':
        penalist[number[i]-1] += 1
    else:
        if aclist[number[i]-1] >= 1:
            pass
        else:
            aclist[number[i]-1] += 1
            anscount += 1
            penacount += penalist[number[i]-1]

print(anscount,penacount)

Submission status: Accepted

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

P = [0] * N
sum_WA = 0

for _ in range(M):
    p_i, s_i = list(input().split())
    p_i = int(p_i) - 1
    if P[p_i] != 'AC':
        if s_i == 'WA':
            P[p_i] += 1
        else:
            sum_WA += P[p_i]
            P[p_i] = 'AC'


sum_AC = P.count('AC')
print(sum_AC, sum_WA)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys


def input():
    return sys.stdin.readline()


def resolve():
    n, m = map(int, input().split())
    first_ac_dic = {}
    wa_count_dic = {}
    wa_num = 0
    for i in range(m):
        p, s = input().split()
        p = int(p)

        if s == "AC":
            if p in first_ac_dic:
                pass
            else:
                first_ac_dic[p] = i
                wa_num += wa_count_dic.get(p, 0)
        else:
            wa_count_dic[p] = wa_count_dic.get(p, 0) + 1

    ans_ac = len(first_ac_dic)

    print(ans_ac, wa_num)


if __name__ == "__main__":
    resolve()

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def resolve():
    n, m = map(int, input().split())
    first_ac_dic = {}
    wa_count_dic = {}
    wa_num = 0
    for i in range(m):
        p, s = input().split()
        p = int(p)

        if s == "AC":
            if p in first_ac_dic:
                pass
            else:
                first_ac_dic[p] = i
                wa_num += wa_count_dic.get(p, 0)
        else:
            wa_count_dic[p] = wa_count_dic.get(p, 0) + 1

    ans_ac = len(first_ac_dic)

    print(ans_ac, wa_num)


if __name__ == "__main__":
    resolve()

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
#input = sys.stdin.readline


def resolve():
    n, m = map(int, input().split())
    all_wa = 0
    all_ac = 0
    ac_list = []
    p_list, s_list = [], []
    first_ac_dic = {}

    wa_count_dic = {}
    wa_num = 0
    for i in range(m):
        p, s = input().split()
        p = int(p)
        p_list.append(p)
        s_list.append(s)

        if s == "AC":
            if p in first_ac_dic:
                pass
            else:
                first_ac_dic[p] = i
                wa_num += wa_count_dic.get(p, 0)
        else:
            wa_count_dic[p] = wa_count_dic.get(p, 0) + 1

    ans_ac = len(first_ac_dic)

    print(ans_ac, wa_num)


if __name__ == "__main__":
    resolve()

Submission status: Accepted

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

WAc = 0
ACc = 0
temp = 0
for i in range(N):
    for j in range(len(ps[i])):
        if ps[i][j] == "WA": 
            temp += 1
        else:
            ACc += 1
            WAc += temp
            temp = 0
            break
    else:
        temp = 0
print(ACc, WAc)

Submission status: Accepted

Solution code:
n , m = map(int,input().split(" "))
c = []
ans = 0
pen = 0
for i in range(n):
    c.append(0)

for i in range(m):
    x , s = input().split(" ")
    p = int(x)
    if s == "AC":
        if c[p-1] == 0:
            c[p-1] = 1
            ans += 1
        elif c[p-1] < 0:
            pen += -(c[p-1])
            c[p-1] = 1
            ans += 1
    elif s == "WA":
        if c[p-1] <= 0:
            c[p-1] -= 1
print(str(ans) + " " + str(pen))

Submission status: Accepted

Solution code:
N,M = list(map(int,input().split()))
A = ['a']*N
B = [0]*N
ans1 = 0
ans2 = 0
for i in range(M):
  C,D = input().split()
  C = int(C)-1
  if A[C] == D == 'WA':
    ans1 += 1
    B[C] += 1
  if A[C] == 'a' and D == 'WA':
    ans1 += 1
    B[C] += 1
  if A[C] == 'WA' and D == 'AC':
    ans2 += 1
    A[C] = 'AC'
  if A[C] == 'a' and D == 'AC':
    ans2 += 1
    A[C] = 'AC'
for i in range(N):
  if A[i] == 'a':
    ans1 -= B[i]
print('{0} {1}'.format(ans2,ans1))

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n,m = map(int,input().split())
wa_cnt = [0]*n
pena = 0
solve = 0
for i in range(m):
  p,s = map(str,input().split())
  if s == "WA":
    wa_cnt[int(p)-1] += 1
  else:
    if wa_cnt[int(p)-1] >= 0:
      pena += wa_cnt[int(p)-1]
      solve += 1
      wa_cnt[int(p)-1] = -100010
print(solve,pena)

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
ac = [0] * (n+1)
wa = [0] * (n+1)
lst = []
for _ in range(m):
    p,s = map(str,input().split())
    lst.append([p,s])
    
for i in range(m):
    result = lst[i][1]
    q = int(lst[i][0])
    if result == 'AC' and ac[q] == 0:
        ac[q] += 1
    elif result == 'WA' and ac[q] == 0:
        wa[q] += 1
        
for i in range(n+1):
    if ac[i] != 1:
        wa[i] = 0
        
print(sum(ac),sum(wa))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
hoge=[0 for i in range(n)]
huga=[0 for i in range(n)]
for i in range(m):
  a,b=map(str,input().split())
  if(hoge[int(a)-1]==0 and b=="AC"):
    hoge[int(a)-1]=1
  if(hoge[int(a)-1]==0 and b=="WA"):
    huga[int(a)-1]+=1
    
for i in range(n):
  if(hoge[i]==0):
    huga[i]=0
    
print(sum(hoge),sum(huga))

Submission status: Accepted

Solution code:
n,m = map(int, input().split())
a = [[0, 'WA'] for i in range(n)]
tmp_AC = 0
tmp_WA = 0
for i in range(m):
  l,s = map(str, input().split())
  l = int(l) - 1
  if a[l][1] == 'WA' and s == 'AC':
    a[l][1] = 'AC'
    tmp_AC += 1
    tmp_WA += a[l][0]
  elif a[l][1] == 'WA' and s == 'WA':
    a[l][0] += 1
print(tmp_AC, tmp_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 AC[p]==0:
        if s=='AC':
            AC[p]+=1
        else:
            WA[p]+=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()))
ac_list = [0] * n
wa_list = [0] * n
for _ in range(m):
    p, s = input().split()
    p = int(p) - 1
    if s == "AC":
        ac_list[p] = 1
    if s == "WA":
        if ac_list[p] == 0:
            wa_list[p] += 1
for k in range(n):
    if ac_list[k] == 0:
        wa_list[k] = 0
print(sum(ac_list), sum(wa_list))

Submission status: Accepted

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

d = {}

for i in range(m):
    p, s = map(str,input().split())
    if not p in d:
        d[p] = [0, 0]
    if s == 'WA' and d[p][1] == 0:
        d[p][0] += 1
    elif s == 'AC':
        d[p][1] = 1

ans = 0
pena = 0

for dict in d.values():
    if dict[1] == 1:
        ans += 1
        pena += dict[0]

print('{} {}'.format(ans, pena))

Submission status: Accepted

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

for i in range(m):
  p,s=input().split()
  p = int(p)  
  if s == "AC" and aclis[p-1] == 0:
    aclis[p-1] = 1
    ac += 1
    wa += walis[p-1]
  elif s == "WA" and aclis[p-1] == 0:
    walis[p-1] += 1
print(ac,wa)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
a = set()
d = {}
penalty = 0
for i in range(M):
    p, S = input().split()
    if S == 'AC' and int(p) not in a:
        a.add(int(p))
        if p in d:
            penalty += d.pop(p)
    else:
        if p in d:
            d[p] += 1
        else:
            d[p] = 1
print(len(a), penalty)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
Counted = [0 for _ in range(N)]
num1 = 0
num2 = 0
subnum2 = [0 for l in range(N)]
for j in range(M):
  p, S = input().split()
  p_ = int(p)
  if S == "AC" and Counted[p_ -1] == 0:
    num1 += 1
    num2 += subnum2[p_ - 1]
    Counted[p_ -1] = 1
  elif S == "WA" and Counted[p_-1] == 0:
    subnum2[p_ - 1] += 1
print("{} {}".format(num1, num2))

Submission status: Accepted

Solution code:
nm = input().split()
n = int(nm[0])
m = int(nm[1])

p = []
r = []

for i in range(m):
	pr = input().split()
	p.append(int(pr[0]))
	r.append(pr[1])

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

if m != 0:
	for l in range(m):
		if r[l] == 'AC' and flg[p[l]-1] !=  'ac':
			ac += 1
			wa += flg[p[l]-1]
			flg[p[l]-1] = 'ac'
		elif  flg[p[l]-1] != 'ac' :
			flg[p[l]-1] += 1

print(ac)
print(wa)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
ac = [False] * N
wa = [0] * N
for _ in range(M):
    p, s = input().split()
    p = int(p) - 1
    if not ac[p]:
        if s == "AC":
            ac[p] = True
        else:
            wa[p] += 1
accnt = len([1 for x in ac if x])
wacnt = sum([wa[i] for i in range(N) if ac[i]])
print(accnt, wacnt)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
query = [tuple(input().split()) for _ in range(m)]
 
wa = [0] * n
ac = [0] * n
for p, result in query:
    p = int(p) - 1
    if result == 'AC':
        ac[p] = 1
    if result == 'WA' and ac[p] == 0:
        wa[p] += 1
 
accept = 0
penalty = 0
for i in range(n):
    if ac[i]:
        penalty += wa[i]
        accept += 1
 
print(accept, penalty)

Submission status: Accepted

Solution code:

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

AC = 0
# 各問題でACがとれているか確認用
# 0 = まだ正解していない, 1 = すでに正解済み
AC_list = [0] * (n + 1)
WA = 0
WA_List = [0] * (n + 1)

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

    if S == "AC":
        # 初めての正解
        if AC_list[p] == 0:
            AC += 1
            WA += WA_List[p]
            AC_list[p] = 1
        # ※すでに正解している場合は加算しない
    else:
        # まだ正解していない場合
        if AC_list[p] == 0:
            WA_List[p] += 1
        # ※すでに正解している場合は加算しない

print(AC,WA)

Submission status: Accepted

Solution code:
n, m=map(int, input().split())
a=set()
d={}
pena=0
for i in range(m):
    p, s=input().split()
    if s=="AC" and int(p) not in a:
        a.add(int(p))
        if p in d:
            pena+=d.pop(p)
    else:
        if p in d:
            d[p]+=1
        else:
            d[p]=1
print(len(a), pena)

Submission status: Accepted

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

ans = 0
for _ in range(m):
    p, s = input().split()
    p = int(p) - 1
    if s == 'AC' and ac[p] == False:
        ans += wa[p]
        ac[p] = True
    else:
        wa[p] += 1
print(sum([ac[i] for i in range(n)]), ans)

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
p=[0]*M
S=[0]*M
sei=[0]*N
pena=[0]*N
total=[0]*N

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

  if S[i]=="AC":
    if sei[p[i]-1]>=1:
      pass
    else:
      sei[p[i]-1] +=1
      
  else: # WAのとき
    if sei[p[i]-1]>=1:
      pass
    else: #0のとき
      pena[p[i]-1] +=1

for j in range(N):
  total[j]=sei[j]*pena[j]
  
print(sum(sei),sum(total))

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
ac=[0 for i in range (n)]
wa=[0 for i in range (n)]
grid = []
for i in range(m):
    a,b = input().split()
    if  ac[int(a)-1] == 1:
        continue
    if b == 'AC':
        ac[int(a)-1] = 1
    elif b == 'WA':
        wa[int(a)-1] += 1
ac_con,wa_con = 0,0
for i in range(n):
    if ac[i] == 0:
        continue
    else:
        ac_con+=1
        wa_con+=wa[i]
print(ac_con,wa_con)

Submission status: Accepted

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

pena=np.array([0]*N)
status=np.array([0]*N)


for i in range(M):
  p,s=tuple(input().split())
  p=int(p)
  if s=="WA":
    if status[p-1]!=1:
      pena[p-1]+=1
  if s=="AC":
    if status[p-1]!=1:
      status[p-1]=1
nac=sum(status)
npena=sum(pena*status)
print(nac, npena)

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()
    if ac[int(p)]==1:
        continue
    if s=='AC':
        ac[int(p)]=1
    elif s=='WA':
        wa[int(p)]+=1

ac_ans,wa_ans=0,0
for a,w in zip(ac,wa):
    if a==0:
        continue
    ac_ans+=a
    wa_ans+=w

print(ac_ans,wa_ans)

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
ac=[False for _ in range(N+1)]
wa=[0 for _ in range(N+1)]
for i in range(M):
    p,S=input().split()
    p=int(p)
    if S=='AC':
        ac[p]=True
    elif ac[p]==False:
        wa[p]+=1
for i in range(N+1):
    if ac[i]==False:
        wa[i]=0
print(sum(ac),sum(wa))

Submission status: Accepted

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

l=list(input().split() for _ in range(m))

w=[0]*n
a=[0]*n
seitou=0
pena=0

for i in l:
    k=int(i[0])-1
    if a[k]==0:
        if i[1]=="AC":
            a[k]+=1
        else:
            w[k]+=1

seitou=sum(a)
for j in range(n):
    if int(a[j])==1:
        pena+=w[j]
        
print(seitou,pena)

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline

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

p = []
S = []
ans = 0
pena = 0
count = [0] * N
check = set()
for _ in range(M):
    l = list(map(str, input().split()))
    p.append(int(l[0]))
    S.append(l[1])

for i in range(M):
    if p[i] not in check:
        if S[i] == 'AC':
            pena += count[p[i]-1]
            ans += 1
            check.add(p[i])
        elif S[i] == 'WA':
            count[p[i]-1] += 1

print(ans, pena)

Submission status: Accepted

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

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

for _ in range(M):
  p, s = input().split()
  p, s = int(p), str(s)
  if ac[p]: continue

  if s == 'AC': ac[p] = True
  else: wa[p] += 1

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

print(ans1, ans2)

Submission status: Accepted

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

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

#0が正答したかどうか（正答が1）、1がペナルティの数
ans = [[0,0] for i in range(n)]

for i in range(m) :
  if s[i] == 'AC' :
    ans[p[i]-1][0] = 1
  if s[i] == 'WA' and ans[p[i]-1][0] == 0 :
    ans[p[i]-1][1] += 1

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

print(ac,pe)

Submission status: Accepted

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

wal=[0]*n
acl=[0]*n

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

wa=0
for i,ac in enumerate(acl):
    if ac == 1:
        wa+=wal[i]    
    
print(sum(acl),wa)

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
ac_dir = {}
wa_dir = {}

for _ in range(m):
    p, s = input().split()
    if s == 'AC' and p not in ac_dir:
        ac_dir[p] = 1
    
    elif s == 'WA' and p not in wa_dir and p not in ac_dir:
        wa_dir[p] = 1
    
    elif s == 'WA' and p in wa_dir and p not in ac_dir:
        wa_dir[p] += 1

print(sum(ac_dir.values()), sum([k for j, k in wa_dir.items() if j in ac_dir]))

Submission status: Accepted

Solution code:
N, M = map(int, input().split(' '))
AC_dir = {}
WA_dir = {}
for i in range(M):
    p, S = input().split(' ')
    if S == 'AC' and p not in AC_dir:
        AC_dir[p] = 1
    elif S == 'WA' and p not in WA_dir and p not in AC_dir:
        WA_dir[p] = 1
    elif S == 'WA' and p in WA_dir and p not in AC_dir:
        WA_dir[p] += 1
print(sum(AC_dir.values()), sum([k for j, k in WA_dir.items() if j in AC_dir]), sep=' ')