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())
q = [0 for i in range(n)]
alist = []
ac = 0
pe = [0 for i in range(n)]
be = 0
for i in range(m):
    a,b=input().split()
    alist.append((int(a), b))
for i in range(m):
    if q[alist[i][0]-1] == 0:
        if alist[i][1] == 'AC':
            ac += 1
            be = be + pe[alist[i][0]-1]
            q[alist[i][0]-1] = 1
        else:
            pe[alist[i][0]-1] +=  1
    else:
        continue
print(ac,be)

Submission status: Accepted

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

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

for i in a:
    if i[1] == 1:
        wa += i[0]

print(ac,wa)

Submission status: Accepted

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

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

wa = 0
for i in range(n):
    if is_ac[i]:
        wa += wa_cnt[i]
print(ac, wa)

Submission status: Accepted

Solution code:
from collections import defaultdict

N ,M = map(int,input().split())
PS = defaultdict(lambda:[0,0])
for _ in range(M):
    p, s = input().split()
    if s == 'AC':
        PS[p][0] = 1
    else:
        if PS[p][0] == 0:
            PS[p][1] += 1

AC = 0
WA = 0
for v in PS.values():
    AC += v[0]
    WA += v[0]*v[1]


print(AC,WA)

Submission status: Accepted

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

q = [False for _ in range(n)]
wa = [0] * n

for i, s in ps:
    if q[int(i)-1] == False:
        if s == "WA":
            wa[int(i)-1] += 1
        else:
            q[int(i)-1] = True

print(sum(q), sum([v for k, v in enumerate(wa) if q[k]==True]))

Submission status: Accepted

Solution code:

def main():
    n, m = list(map(int, input().split()))
    ret = {}
    for i in range(m):
        q, res = list(input().split())
        if q in ret:
            if ret[q][-1] == 'WA':
                ret[q].append(res)
        else:
            ret[q] = [res]
    ans = 0
    pena = 0
    for k in ret:
        if ret[k][-1] == 'AC':
            ans += 1
            pena += ret[k].count('WA')
    print(ans, pena)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
test,submit=map(int,input().split())
ac_wa_map={}
ac=0
wa=0
wa_counter=[0]*test
for i in range(submit):
    test_no,acwa=input().split()
    if test_no not in ac_wa_map:
        ac_wa_map[test_no]=acwa
        if acwa=="AC":
            ac+=1
        elif acwa=="WA":
            wa_counter[int(test_no)-1]+=1
    elif acwa=="AC" and ac_wa_map[test_no]=="WA":
        ac+=1
        ac_wa_map[test_no]=acwa
        wa+=wa_counter[int(test_no)-1]
    elif acwa=="WA" and ac_wa_map[test_no]=="WA":
        wa_counter[int(test_no)-1]+=1
    

print(ac,wa)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
list_num = list([] for i in range(n))
test = [input().split() for i in range(m)]
for i in test:
  list_num[int(i[0]) - 1].append(i[1])
count = 0
count_ac = 0
count_wa = 0
check = 0
for i in list_num:
  for j in range(len(i)):
    if(i[j] =='WA'):
      count += 1
    elif(i[j] == 'AC'):
      count_ac += 1
      check = 1
      break
  if(check == 1):
    count_wa += count
    check = 0 
  count = 0
print(count_ac , count_wa)

Submission status: Accepted

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

x=[True]*n
cnt=[0]*n
y=0
z=0

for i in range(m):
    p,s=input().split()
    if s=="AC":
        x[int(p)-1]=False
    elif x[int(p)-1]:
        cnt[int(p)-1]+=1


for i in range(n):
    if x[i]==False:
        z+=cnt[i]
        y+=1

print(y,z)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
P = [0] * (N + 1)
S = [0] * (N + 1)
for i in range(M):
  x, p = input().split()
  s = int(x)
  if P[s] == 0:
    if p == 'AC':
      P[s] = 1
    else:
      S[s] += 1
A = sum([S[i] for i in range(N + 1) if P[i] == 1])
print(P.count(1), A)

Submission status: Accepted

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

import sys
# import math
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product                # product(iter, repeat=n)
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4


def main():
    mod = 1000000007                  # 10^9+7
    inf = float('inf')
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():  return int(input())
    def mi():  return map(int, input().split())
    def mi_0(): return map(lambda x: int(x)-1, input().split())
    def lmi(): return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():  return list(input())
    
    
    n, m = mi()
    wa_count = [0] * n
    ac = [False] * n
    for _ in range(m):
        p, s = input().split()
        p = int(p) - 1
        if s == 'AC':
            ac[p] = True
        else:
            # WA かつまだ AC していない
            if not ac[p]:
                wa_count[p] += 1
    
    ac_num = 0
    penalty_num = 0
    for problem in range(n):
        if ac[problem]:
            ac_num += 1
            penalty_num += wa_count[problem]
    print("{} {}".format(ac_num, penalty_num))

    

if __name__ == "__main__":
    main()

Submission status: Accepted

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

print(ac,wa)

Submission status: Accepted

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

ac,wa = 0,0
cnt_ac = [0]*(n+1)
cnt_wa = [0]*(n+1)

for i in range(m):
    temp_num = int(s[i][0])
    temp_ans = s[i][1]
    if temp_ans == "WA":#不正解の時
        if cnt_ac[temp_num] != 1:#まだ正解していないなら
            cnt_wa[temp_num] += 1
    else:
        if cnt_ac[temp_num] != 1:#初めて正解したとき
            cnt_ac[temp_num] = 1
            ac += 1
            wa += cnt_wa[temp_num]  
        
print(ac,wa)

Submission status: Accepted

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

Submission status: Accepted

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

    for i in range(M):
        no, sta = input().split()
        commit[int(no)-1].append(sta)

    AC_total = 0
    WA_total = 0

    for i in range(len(commit)):
        WA = 0
        if len(commit[i]) == 0:
                continue
        else:
            for j in range(len(commit[i])):
                if commit[i][j] == "WA":
                    WA += 1
                elif commit[i][j] == "AC":
                    AC_total += 1
                    WA_total += WA
                    break
    print(AC_total, WA_total)
if __name__ == "__main__":
    main()

Submission status: Accepted

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

    for i in range(M):
        no, sta = input().split()
        commit[int(no)-1].append(sta)

    AC_total = 0
    WA_total = 0

    for i in range(len(commit)):
        WA = 0
        for j in range(len(commit[i])):
            if len(commit[i]) == 0:
                continue
            else:
                if commit[i][j] == "WA":
                    WA += 1
                elif commit[i][j] == "AC":
                    AC_total += 1
                    WA_total += WA
                    break
    print(AC_total, WA_total)
if __name__ == "__main__":
    main()

Submission status: Accepted

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

    for i in range(M):
        no, sta = input().split()
        commit[int(no)-1].append(sta)

    AC_total = 0
    WA_total = 0

    for i in range(len(commit)):
        AC = 0
        WA = 0
        for j in range(len(commit[i])):
            if len(commit[i]) == 0:
                continue
            else:
                if commit[i][j] == "WA":
                    WA += 1
                elif commit[i][j] == "AC":
                    AC += 1
                    AC_total += AC
                    WA_total += WA
                    break
    print(AC_total, WA_total)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
ac_counter = [0 for _ in range(N)]
wa_counter = [0 for _ in range(N)]
wa_sum = 0
for _ in range(M):
    line = input().split()
    problem = int(line[0])
    result = line[1]
    if not ac_counter[problem-1] == 1:
        if result == 'AC':
            ac_counter[problem-1] = 1
            wa_sum += wa_counter[problem-1]
        else:
            wa_counter[problem-1] += 1

answer = []
answer.append(str(sum(ac_counter)))
answer.append(str(wa_sum))
print(" ".join(answer))

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
a=[[i for i in input().split()] for j in range(m)]
WANum=[0]*(n+1)
EndFlag=[0]*(n+1)
for x in a:
    if x[1]=="WA" and EndFlag[int(x[0])]==0:WANum[int(x[0])]+=1
    if x[1]=="AC":EndFlag[int(x[0])]=1
c=0
for i,x in enumerate(EndFlag):
    if x==1:c+=WANum[i]
print(sum(EndFlag),c)

Submission status: Accepted

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

for i in range(m):
    question, result=input().split()
    num = int(question) - 1
    if result == "AC" and ans[num]:
        ans[num]=False
        ac+=1
    # WAかつACされていない場合
    elif result == "WA" and ans[num]:
        wa[num] += 1
 
wa_sum = 0

for i in range(n):
    # 問題がACされている場合、その問題番号のWA回数を足す
    if not ans[i]:
        wa_sum += wa[i]
 
print(ac, wa_sum)

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
ac = 0
wa = 0
wa_d = {}
ac_d = {}
for i in range(1,n+1):
    ac_d[str(i)] = False
    wa_d[str(i)] = 0

for _ in range(m):
    p,s = input().split()
    if s == "AC":
        if ac_d[p]:
            pass
        else:
            wa += wa_d[p]
            ac += 1
            ac_d[p] = True 
    else:
        wa_d[p] += 1

print (ac,wa)

Submission status: Accepted

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

N, M = map(int, input().split())
ps = [list(input().split()) for _ in range(M)]
pen = [0]*N
rig = [0]*N

for i in range(M):
    if ps[i][1] == "AC":
        rig[int(ps[i][0])-1]=1
    else:
        if rig[int(ps[i][0])-1] == 0:
            pen[int(ps[i][0])-1] += 1

cnt1, cnt2 = 0, 0
for i in range(N):
    if rig[i] == 1:
        cnt1 += rig[i]
        cnt2 += pen[i]

print(cnt1, cnt2)

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
keep=[]
lis=[]
ac=[0]*N
wa=[0]*N
WA=0
for i in range(M):
    ps=input().split()
    keep.append(ps)
    
for j in range(M):
    if keep[j][1]=="AC":
        ac[int(keep[j][0])-1]=1
    elif ac[int(keep[j][0])-1]==0:
        wa[int(keep[j][0])-1]+=1
AC=sum(ac)
for k in range(N):
    WA+=ac[k]*wa[k]
    
print(AC,WA)

Submission status: Accepted

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

cnt=0
for i in range(n):
    if not ans[i]:
        cnt+=wa[i]

print(ac,cnt)

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
PS = [list(map(str,input().split())) for i in range(M)]
A_num = [0]*N
W_num = [0]*N
w=0
#print(PS)
for j in range(M):
    #print(A_num)
    if PS[j][1] == 'WA'and A_num[int(PS[j][0])-1]==0:
        W_num[int(PS[j][0])-1]+=1 
    if PS[j][1]== 'AC' and A_num[int(PS[j][0])-1]==0:
        A_num[int(PS[j][0])-1]=1
s = sum(A_num)
for k in range(N):
    if A_num[k] == 0:
        W_num[k]=0
w = sum(W_num)
print(s,w)

Submission status: Accepted

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

aclist = [0] * n
walist = [0] * n

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

    if aclist[int(p)] == 1:
        continue
    if s == 'AC':
        aclist[int(p)] = 1
    if s == 'WA':
        walist[int(p)]+=1
print(sum(aclist), sum(j for idx, j in enumerate(walist) if aclist[idx] == 1))

Submission status: Accepted

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

wa=0
ac=0

#初期値が0の辞書
from collections import defaultdict
acwa = defaultdict(lambda: [0,0]) 

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

    if s=="AC":
        if acwa[p][0]==0:
            ac+=1
            wa+=acwa[p][1]
            acwa[p][0]=1
    else:
        acwa[p][1]+=1

print(ac,wa)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
penalty_num = [0 for i in range(n)]
acc = 0
ac_flag = [False for i in range(n)]

for i in range(m):
    p, s = input().split()
    q_num = int(p) - 1
    # WA
    if s == 'WA':
        if ac_flag[q_num]:
            continue
        else:
            penalty_num[q_num] += 1
    # AC
    else:
        if ac_flag[q_num]:
            continue
        else:
            ac_flag[q_num] = True
            acc += 1
penalty = 0
for n, flag in zip(penalty_num, ac_flag):
    if flag:
        penalty += n
print('{} {}'.format(acc, penalty))

Submission status: Accepted

Solution code:
import collections
n, m = map(int, input().split())
wa = []
submission = set()
for i in range(m):   
    p, s = input().split()
    if p in submission:
        continue

    if s == "AC":
        submission.add(p)
    else:
        wa.append(p)
wa_count = collections.Counter(wa)
pena = 0
for j in submission:
    x = wa_count[j]
    pena += x

print(len(submission), pena)

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

num = 0 
pena = 0

lis=[0]*n 
sw = [0]*n

for i in range(m): 
    if y[i] == 'WA':
        lis[int(x[i])-1] += 1
    else:
        if sw[int(x[i])-1] == 0:
            num += 1
            pena = pena + lis[int(x[i])-1]
            sw[int(x[i])-1] = 1

        else:
            pass
        
print(num,pena)

Submission status: Accepted

Solution code:

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

ac_flg = [0]*N
wa_flg = [0]*N
wa_count = 0
ac_count = 0

for i in range(M):
    p, s = input().split()
    if s == 'WA' and ac_flg[int(p)-1] == 0:
        wa_flg[int(p)-1] += 1

    if s == 'AC' and ac_flg[int(p)-1] == 0:
        ac_count += 1
        ac_flg[int(p)-1] =1
        wa_count += wa_flg[int(p)-1]

print(ac_count, wa_count)

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
l = [[0,0] for i in range(n)]
for i in range(m):
  p,s = map(str,input().split())
  p = int(p)-1
  if l[p][1] == 0:
    if s == 'WA':
      l[p][0] += 1
    else:
      l[p][1] += 1
cor = 0
pen = 0
for k in l:
  if k[1] == 1:
    cor += 1
    pen += k[0]
print(cor,pen)

Submission status: Accepted

Solution code:
from collections import Counter
N, M = map(int, input().split())

point = 0
answer_problems = set()
wrong_count = Counter()
for _ in range(M):
    p, s = input().split()
    
    if p in answer_problems:
        continue
    
    if s == 'AC':
        point += wrong_count[p]
        answer_problems.add(p)
    else:
        wrong_count[p] += 1

print(len(answer_problems), point)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
p, s = [], []
pslist = []
for i in range(m):
  row = list(input().split( ))
  pslist.append(row)
aclist = [0] * n
walist = [0] * n
for j, k in pslist:
  j = int(j)
  if k == 'AC':
    if aclist[j - 1] == 0:
      aclist[j - 1] = 1
  if k == 'WA':
    if aclist[j - 1] == 0:
      walist[j - 1] += 1
wacountlist = [x * y for (x, y) in zip(aclist, walist)]
print(sum(aclist), sum(wacountlist))

Submission status: Accepted

Solution code:
import numpy as np
from collections import Counter
n, m = map(int, input().split())
mistake = [0] * (n + 1)
done = [False] * (n + 1)
for _ in range(m):
    p, s = input().split()
    p = int(p)
    if s == 'WA':
        if done[p] == False:
            mistake[p] += 1
    else:
        done[p] = True
counter = Counter(done)
print(counter[True], sum(np.multiply(mistake, done)))

Submission status: Accepted

Solution code:
stdin = open(0).read().split('\n')
N, M = map(int,stdin[0].split())
AC = 0
WA = 0
d = {}
for i in range(1,M+1):
    p, S = stdin[i].split()
    if p in d:
        if d[p]!=0:
            if S=='AC':
                AC += 1
                WA += d[p]
                d[p] = 0
            else:
                d[p] += 1
    else:
        if S=='AC':
            d[p] = 0
            AC += 1
        else:
            d[p] = 1
print(AC,WA)

Submission status: Accepted

Solution code:
from collections import Counter
N, M = map(int, input().split())
correct_cnt = 0
pena_cnt = 0
pena_counter = Counter()

is_AC = dict()
for i in range(N):
    is_AC[i] = False

for i in range(M):
    p, s = input().split()
    p = int(p) - 1
    if is_AC[p] == False:
        if s == "AC":
            is_AC[p] = True
            correct_cnt += 1
        else:
            pena_counter[p] += 1

for key, value in is_AC.items():
    if is_AC[key]:
        pena_cnt += pena_counter[key]
print(str(correct_cnt), str(pena_cnt))

Submission status: Accepted

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

flag = [0] * n
WA_count = [0] * n
total_WA = 0
for i in range(m):
    P, s = input().split()
    p = int(P) - 1
    if s == "WA" and flag[p] == 0:
        WA_count[p] += 1
    elif s == "AC" and flag[p] == 0:
        flag[p] = 1
        total_WA += WA_count[p]
print(sum(flag), total_WA)

Submission status: Accepted

Solution code:
result = [0]*2
N,M = map(int,input().split())
checker = [[0]*2 for i in range(N)]

for i in range(M):
    que, res = input().split()
    que = int(que)

    if res =="WA" and checker[que-1][0]== 0:
        checker[que-1][1] +=1
    
    if res =="AC" and checker[que-1][0]==0:
        checker[que-1][0] = 1
        result[1]+= checker[que-1][1]
        result[0] +=1
print(*result)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
if m == 0:
  print(0, 0)
else:
  wa_dic = {}
  ac_dic = {}
  for _ in range(m):
    p, s = input().split()
    if s == 'WA' and (p not in ac_dic):
      if p in wa_dic:
        wa_dic[p] += 1
      else:
        wa_dic[p] = 1
    elif s == 'AC' and (p not in ac_dic):
      ac_dic[p] = 1
  ac = 0
  for v in ac_dic.values():
    ac += v
  wa = 0
  for k, v in wa_dic.items():
    if k in ac_dic:
      wa += v
  print(ac, wa)

Submission status: Accepted

Solution code:
# 初期入力
N,M = (int(x) for x in input().split(" "))
S = []

#　問題種類をキー、ac,waを値の辞書
mondai_acwa ={i:list() for i in range(1,N+1) }
q_id =0
result =""
for i in range(M):
    q_id_str,result = (x for x in input().split())
    mondai_acwa[int(q_id_str)].append(result)

# ACが初めてでた時のindex＝その問題のWAの数（各問題）
ac_sum=0
wa_sum=0

for i,v_wa in mondai_acwa.items():
    if 0 < len(v_wa):
        if "AC" in v_wa: #ACがないときはWAも数えない
            ac_i =v_wa.index("AC") 
            ac_sum +=1
            wa_sum += ac_i
print(ac_sum,wa_sum)

Submission status: Accepted

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

penalty = [0] * n
isAC = [False] * n

for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    if s == "WA":
        if not isAC[p]:
            penalty[p] += 1
    else:
        isAC[p] = True
for i in range(n):
    if not isAC[i]:
        penalty[i] = 0
print(sum(isAC), sum(penalty))

Submission status: Accepted

Solution code:
import sys

readline = sys.stdin.readline

def main():
    N, M = map(int, readline().split())
    aclist = [0] * N
    wrongcount = [0] * N
    for _ in range(M):
        p, S = readline().split()
        q = int(p)-1
        if aclist[q] == 0 and S == 'WA':
            wrongcount[q] += 1
        if S == 'AC':
            aclist[q] = 1

    pena = 0
    for i in range(N):
        if aclist[i] == 1:
            pena += wrongcount[i]
    ac = sum(aclist)

    print(ac, pena)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
ques = [0] * N
ans = 0
pen = 0
for i in range(M):
    a, b = map(str, input().split())
    if ques[int(a)-1] >= 0 and b == "WA":
        ques[int(a)-1] += 1
    elif ques[int(a)-1] >= 0 and b == "AC":
        ans += 1
        pen += ques[int(a)-1]
        ques[int(a)-1] = -1
        
print(ans, pen)

Submission status: Accepted

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

ac_list = [0 for _ in range(N)]
wa_list = [0 for _ in range(N)]

for i in range(M):
    if ac_list[int(L[i][0]) - 1] != 1:
        if L[i][1] == 'AC':
            ac_list[int(L[i][0]) - 1] = 1
        else:
            wa_list[int(L[i][0]) - 1] += 1

wrong = 0
for i in range(N):
    if ac_list[i] == 1:
        wrong += wa_list[i]

print(sum(ac_list), wrong)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
ans = [False for _ in range(n)]
f = [0 for _ in range(n)]
t = 0
fsum = 0
for i in range(m):
    a, b = input().split()
    if not ans[int(a) - 1]:
        if b == 'AC':
            t += 1
            ans[int(a) - 1] = True
            fsum += f[int(a) - 1]
        else:
            f[int(a) - 1] += 1
print(t, fsum)

Submission status: Accepted

Solution code:
# N = 2
# M = 5
# ARR = [
#     [1, 'WA'],
#     [1, 'AC'],
#     [2, 'WA'],
#     [2, 'AC'],
#     [2, 'WA']
# ]
#
#
#
# N = 100000
# M = 3
# ARR = [
#     [7777, 'AC'],
#     [7777, 'AC'],
#     [7777, 'AC'],
# ]
#
#
# N = 6
# M = 0
# ARR = []

N, M = map(int, input().split())
ARR = []

for i in range(M):
    index, value = input().split()
    ARR.append([int(index), value])


def calculate(n, m, arr):
    acResult = [-1 for i in range(n)]
    waResult = [0 for i in range(n)]

    for index in range(m):
        i = arr[index][0] - 1
        if arr[index][1] == 'AC':
           if acResult[i] == -1:
               acResult[i] = index
           else:
               if acResult[i] > index:
                   acResult[i] = index

    for index in range(m):
        i = arr[index][0] - 1
        if arr[index][1] == 'WA':
            if index < acResult[i] and acResult[i] > -1:
                waResult[i] = waResult[i] + 1


    result1 = 0
    result2 = 0
    for index,ac in enumerate(acResult):
        if ac > -1:
            result1 = result1 + 1
            result2 = result2 + waResult[index]



    print(result1,result2)

calculate(N, M, ARR)

Submission status: Accepted

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


def solve(N: int, M: int, p: "List[int]", S: "List[str]"):
    from collections import defaultdict
    ac = set()
    wcc = defaultdict(int)
    for pp, ss in zip(p, S):
        if pp in ac:
            continue
        if ss == 'WA':
            wcc[pp] += 1
        else:
            ac.add(pp)
    print(len(ac), sum((c for p, c in wcc.items() if p in ac), 0))


# 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())
a = [0]*n
AC,WA=0,0
for i in range(m):
    x,y = input().split()
    x = int(x)
    if a[x-1]!=-1 and y=="WA":
        a[x-1]+=1
    if a[x-1]!=-1 and y=="AC":
        WA+=a[x-1]
        AC+=1
        a[x-1]=-1
print(AC,WA)

Submission status: Accepted

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

ans_list = [[0 for i in range(2)] for j in range(n)]
#print(ans_list[0])
for i in range(m):
    p_num = int(p_list[i][0])
    if ans_list[p_num-1][0] != 1:
        if p_list[i][1] == "WA":
            ans_list[p_num-1][1]  =  ans_list[p_num-1][1] + 1
        else:
            ans_list[p_num-1][0]  = 1
count1 = 0
count2 = 0
for i in range(n):
    if ans_list[i][0] == 1:
        count1 += 1
        count2 += ans_list[i][1]
print(count1,count2)

Submission status: Accepted

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

for i in range(M):
  if S[i] == 'WA':
    if ac[P[i]-1] == 'WA':
      wa[P[i]-1] += 1
  else:
    ac[P[i]-1] = 'AC'
for j in range(N):
  if ac[j] == 'WA':
    wa[j] = 0
print(ac.count('AC'),sum(wa))

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
penalty = [0] * N
AC = [False] * N

for _ in range(M):
    p, S = input().split()
    p = int(p) - 1
    if S == "AC":
        AC[p] = True
    else:
        if not AC[p]:
            penalty[p] += 1

for i in range(N):
    if not AC[i]:
        penalty[i] = 0 

print("{} {}".format(sum(AC), sum(penalty)))

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
p=[]
s=[]
ac=["WA"]*n
wa=[0]*n
for i in range(m):
	pp,ss=input().split()
	p.append(int(pp))
	s.append(ss)
for i in range(m):
	if s[i]=="AC":
		ac[p[i]-1]="AC"
	else:
		if ac[p[i]-1]=="WA":
			wa[p[i]-1]+=1
for i in range(n):
	if ac[i]=="WA":
		wa[i]=0
print(ac.count("AC"),sum(wa))

Submission status: Accepted

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

str_l = ['WA'] * n
int_l = [0] * n

for pp, s in ps:
    p = int(pp)-1
    if s == 'AC':
        str_l[p] = 'AC'
    else:
        if str_l[p] != 'AC':
            int_l[p] += 1

num = 0
ac = 0
for i in range(n):
    if str_l[i] == 'AC':
        num += int_l[i]
        ac += 1
print(ac, num)

Submission status: Accepted

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

Submission status: Accepted

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

#print(ps)
str_l = ['WA'] * n
#print(str_l)
int_l = [0] * n

num = 0
ac = 0
for pp, s in ps:
    p = int(pp)-1
    if s == 'AC':
        str_l[p] = 'AC'
    else:
        if str_l[p] != 'AC':
            int_l[p] += 1

for i in range(n):
    if str_l[i] == 'AC':
        num += int_l[i]
        ac += 1

print(ac, num)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

N, M = rl()
S = []
for i in range(M):
    p, s = rs().split()
    S.append((int(p), s))
ans = 0
pena = 0
penas = [0] * (N+1)
flags = [False] * (N+1)
for p, s in S:
    if flags[p]: continue
    if s == 'AC':
        flags[p] = True
        pena += penas[p]
        ans += 1
    else:
        penas[p] += 1
print(ans, pena)