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())
ac = 0
wa = 0
ref = [0] * N
for i in range(M):
  p, s = map(str, input().split())
  p = int(p) - 1
  if ref[p] != -1:
    if s == 'WA':
      ref[p] += 1
    else:
      wa += ref[p]
      ac += 1
      ref[p] = -1
print(ac, wa)

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
pS_list = [list(input().split()) 
           for nesya in range(m)]
ac = 0
wa = 0
q_list = [0]*n
for ps in pS_list:
  p = int(ps[0])-1
  s = ps[1]
  if q_list[p] == 1:
    continue
  if s == 'WA':
    q_list[p] -= 1
  else:
    a = q_list[p]
    wa -= a
    ac += 1
    q_list[p] = 1
print(ac,wa)

Submission status: Accepted

Solution code:
def main():
    import sys
    input = sys.stdin.readline

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

    was = [0]*N
    acs = [0]*N

    for p, s in pS:
        q_ind = int(p)-1
        if acs[q_ind] == 0:
            if s == 'AC':
                acs[q_ind] = 1
            else:
                was[q_ind] += 1
    ans_wa = 0
    for i in range(N):
        if acs[i] != 0:
            ans_wa += was[i]

    print(sum(acs), ans_wa)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

for i in range(N):
    if AC[i] > 0:
        wa += WA[i]

print(str(ac) + ' ' + str(wa))

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
# l = list()
# for _ in range(M):
#     A, B = input().split()
#     l.append((int(A), B))
# print(l)
#
# d = dict()
# keys =
# v1 = False
# v2 = 0
#
# for k, v in l:
#     d[keys] = (v1, v2)
#     if v2 == "WA":
#         v2 += 1
#         if v == "AC":
#             k = True
#             continue
# print(d)

from collections import defaultdict
d = defaultdict(list)
for _ in range(M):
    p, S = input().split()
    d[int(p)].append(S)
# print(d)

for p, results in d.items():
    is_ac = 'AC' in results
    if not is_ac:
        d[p] = (False, 0)
    else:
        d[p] = (True, results.index('AC'))
# print(d)
cnt = 0
penas = 0
for ac, pena in d.values():
    if ac == True:
        cnt += 1
    penas += pena
print(cnt, penas)

Submission status: Accepted

Solution code:
N,M=list(map(int,input().split()))
S=[list(map(str,input().split())) for i in range(M)]
D={}
D2={}
D3={}
for i in S:
    if D.get(i[0],0)!='AC':
        D[i[0]]=i[1] 
        D2[(i[0],i[1])]=D2.get((i[0],i[1]),0)+1
ans=[0,0]
for i in D.items():
    if i[1]=='AC':
        ans[1]+=D2.get((i[0],'WA'),0)
        ans[0]+=D2.get((i[0],'AC'),0)

print(*ans)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
l=[]
for _ in range(n):l.append(0)
wa=0
for i in range(m):
    p,s=map(str,input().split())
    if l[int(p)-1]==-1:continue
    elif s=="AC":
        wa+=l[int(p)-1]
        l[int(p)-1]=-1
    else: l[int(p)-1]+=1
print(l.count(-1),wa)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
il1 = [int(k) for k in input().split()]
N = il1[0]
M = il1[1]
answered = ['WA']
answered = answered * (N+1)
result = [0, 0]
was = [0]
was = was * (N+1)

for i in range(M):
    il = input().split()
    p = int(il[0])
    s = il[1]
    if (answered[p] == 'AC'):
        pass
    else:
        if (s == 'AC'):
            result[0] = result[0]+1
            answered[p] = s
            result[1] = result[1]+was[p]
        else:
            was[p] = was[p] + 1

print(str(result[0])+" "+str(result[1]))

Submission status: Accepted

Solution code:
n,m = (int(i) for i in input().split())
ac=0
pe=0
p = [0]*(n+1)
a = [0]*(n+1)
for i in range(m):
	x,y = input().split()
	x = int(x)
	if y=="AC":
		a[x]=1
	elif not a[x]: p[x]+=1
ac = sum(a)
pe = sum(p[i] for i in range(n+1) if a[i])
print(ac, pe)

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
cor = set()
pens = {}
for i in range(m):
  p,s = input().split()
  if s=="AC":
    cor.add(p)
  else:
    if not p in cor:
      if p in pens:
        pens[p] += 1
      else:
        pens[p] = 1
pen = 0
for x in cor:
  if x in pens:  
    pen += pens[x]
print(str(len(cor))+" "+str(pen))

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
cnt = [0]*n
wrong_cnt = [0]*n
wrong = 0
for i in range(m):
    p, s = map(str, input().split())
    p = int(p)-1
    if cnt[p] != 0:
        continue
    if s == "WA":
        if wrong_cnt[p] == 0:
            wrong_cnt[p] = 1
            continue
        elif s == "WA" and wrong_cnt[p] == -1:
            continue
        else:
            wrong_cnt[p] += 1
            continue
    cnt[p] = 1
    wrong += wrong_cnt[p]
    wrong_cnt[p] = -1

correct = 0
for i in cnt:
    correct += i

print(correct, wrong)

Submission status: Accepted

Solution code:
from collections import defaultdict


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

    ac = 0
    wa = 0
    for pp in pS:
        tmp = pS[pp]
        wa_tmp = 0
        for t in tmp:
            if t == 'WA':
                wa_tmp += 1
            else:
                ac += 1
                wa += wa_tmp
                break
    print(ac, wa)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
li = [[0,0] for _ in range(n)]
t1,t2 = 0,0
for i in range(m):
    a,b = input().split()
    if li[int(a)-1][0] != 1:
        if b == "WA":
            li[int(a)-1][1] += 1
        if b == "AC":
            li[int(a)-1][0] += 1
for i in range(n):
    t1 += li[i][0]
    t2 += li[i][1]*li[i][0]
print(t1,t2)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
w,l=0,[0]*n
for i in range(m):
    p,s=input().split()
    p=int(p)-1
    if s=='AC':
        w+=l[p]*(l[p]>=0)
        l[p]=-1
    else:
        l[p]+=(l[p]>=0)
print(l.count(-1),w)

Submission status: Accepted

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

for i in range(m):
    p,s = input().split()
    p = int(p)-1
    if s=='AC':
        penalty[p][0]=1
    else:
        if penalty[p][0]==0:
            penalty[p][1]+=1
a = 0
b = 0
for i in range(n):
    if penalty[i][0]==1:
        a += penalty[i][0]
        b += penalty[i][1]
print(a,b)

Submission status: Accepted

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

def resolve():
    n,m=map(int, input().split())
    if m==0:
        print(0,0)
    else:
        l=[list(input().split()) for i in range(m)]
        wacnt=[0]*n
        accheck=[False]*n
        pcnt=0
        for p,s in l:
            p=int(p)
            if accheck[p-1]:
                continue
            if s=='WA':
                wacnt[p-1]+=1
            elif s=='AC':
                accheck[p-1]=True
                pcnt+=wacnt[p-1]
        print(sum(accheck),pcnt)
resolve()

Submission status: Accepted

Solution code:
def main():
    S=lambda:input()
    I=lambda:int(input())
    L=lambda:list(map(int,input().split()))
    LS=lambda:list(map(str,input().split()))
    
    n,m=L()
    penanum=[0]*n
    acflag=[False]*n
    acsum=0
    penasum=0
    for i in range(m):
        tmp=LS()
        if tmp[1]=='WA':
            penanum[int(tmp[0])-1]+=1
        elif acflag[int(tmp[0])-1]==False:
            penasum+=penanum[int(tmp[0])-1]
            acsum+=1
            acflag[int(tmp[0])-1]=True
            
    print(acsum,penasum)
    
if __name__ == '__main__':
    main()

Submission status: Accepted

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

result = {}
fin = {}
success = 0
wa_sum = 0
for i in range(m):
    p, s = map(str, input().split())
    if not (p in result):
        result[p] = 0
        fin[p] = False
    if s == 'AC' and not fin[p]:
        fin[p] = True
        success += 1
        wa_sum += result[p]
    elif not fin[p]:
        result[p] += 1

print(success, wa_sum)

Submission status: Accepted

Solution code:
def main():
    N,M=map(int,input().split())
    pS=[[i for i in input().split()] for _ in range(M)]
    ac_wa=[[0,0] for _ in range(N)]
    ac_wa_count=[0,0]
    for p,S in pS:
        p=int(p)
        if S=='WA':
            ac_wa[p-1][1]+=1
        else:
            if ac_wa[p-1][0]==0:
                ac_wa[p-1][0]=1
                ac_wa_count[0]+=1
                ac_wa_count[1]+=ac_wa[p-1][1]
    print(*ac_wa_count)

main()

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
ps = [list(input().split()) for i in range(m)]
ac = [0] * n
wa = [0] * n
for i in range(m):
    if ac[int(ps[i][0]) - 1] == 0:
        if ps[i][1] == "AC":
            ac[int(ps[i][0]) - 1] = 1
        else:
            wa[int(ps[i][0]) - 1] += 1
for i in range(n):
    if ac[i] == 0:
        wa[i] = 0
print(sum(ac), sum(wa))

Submission status: Accepted

Solution code:
from sys import stdin, setrecursionlimit


def main():
    n, m = map(int, stdin.readline().split())
    ac = [0] * n
    wa = [0] * n
    for _ in range(m):
        p, s = map(str, stdin.readline().split())
        p = int(p) - 1
        if ac[p] == 0 and s == 'WA':
            wa[p] += 1
        elif s == 'AC':
            ac[p] = 1
    n_ac = 0
    n_wa = 0
    for i in range(n):
        n_ac += ac[i]
        if ac[i] == 1:
            n_wa += wa[i]

    print(n_ac, n_wa)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat May  9 02:11:20 2020

@author: shinba
"""
n,m = map(int,input().split())

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

ac = 0

for i in range(m):
    A = input().split()
    a = int(A[0])
    b = str(A[1])
    if not W[a-1][0]:
        if b == "AC":
            ac += 1
            W[a-1][0] = True
        else:
            W[a-1][1] += 1

wa = 0

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

print(ac,wa)

Submission status: Accepted

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

co = 0
pe = 0

ans_check = [0]*n
wa_check = [0]*n
temp = 0

for i in range(m):
    p,s = input().split()
    p = int(p) - 1
    if s == "AC":
        if ans_check[int(p)] == 0:
            ans_check[int(p)] = 1
            co += 1
            pe +=wa_check[int(p)]
    elif s == "WA":
        wa_check[int(p)] += 1
    


print(co,pe)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
accepted = [0] * N
penalties = [0] * N
for _ in range(M):
    p, ac = input().split()
    p, ac = int(p) - 1, ac == "AC"
    accepted[p] |= ac
    penalties[p] += not accepted[p]
print(sum(accepted), sum(p for ac, p in zip(accepted, penalties) if ac))

Submission status: Accepted

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

WA = [0] * (N+1)
AC = [0] * (N+1)
for i in range(M):
    p, s = input().split()
    p = int(p)
    
    if s == "AC":
        AC[p] = 1
    elif AC[p] == 0:
        WA[p] += 1
            
print(sum(AC), sum(w if a > 0 else 0 for a, w in zip(AC, WA)))

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
ac,wa = 0,0
d = {}
for i in range(m):
  p,s = input().split()
  if p in d:
    if d[p][1]:
      pass
    else:
      if s=="WA":
          d[p][0]+=1
      elif s=="AC":
          d[p][1]=True
          ac+=1
          wa+=d[p][0]
  else:
    if s=="WA":
      d[p]=[1,False]
    elif s=="AC":
      d[p]=[0,True]
      ac+=1
print(ac,wa)

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
P=[];S=[]
judge=[0]*N
wa_c=[0]*N

for m in range(M):
  p,s = input().split()
  P.append(int(p))
  S.append(s)
  
for m in range(M):
  if judge[P[m]-1]==0 and S[m]=="WA":
    wa_c[P[m]-1] +=1
   
  elif judge[P[m]-1]==0 and S[m]=="AC":
    judge[P[m]-1]=1
    

for n in range(N):
  if judge[n]==0:
    wa_c[n]=0
  
  
print(sum(judge),sum(wa_c))

Submission status: Accepted

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

print(sum(ac),pen)

Submission status: Accepted

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

scores = [[0, False] for _ in range(n+1)]

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

    if scores[p][1]:
        continue

    if S == "AC":
        scores[p][1] = True
        continue

    if S == "WA":
        scores[p][0] += 1

score = pena = 0
for count, ac in scores:
    if ac:
        score += 1
        pena += count

print(score, pena)

Submission status: Accepted

Solution code:
if __name__ == "__main__":
    n, m = map(int, input().split())
    result = {}
    for _ in range(m):
        p, s = input().split()
        p = int(p)

        if not p in result:
            result[p] = [s]
        else:
            result[p].append(s)
    
    seikai = 0
    pena = 0

    for key in result:
        ptr = 0
        while ptr < len(result[key]) and result[key][ptr] == 'WA':
            ptr += 1
        
        if ptr == len(result[key]):
            continue

        seikai += 1
        pena += ptr
    print(seikai, pena)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
n,m = [int(i) for i in readline().split()]
ps = []
for _ in range(m):
    p,s = [i for i in readline().split()]
    ps.append([int(p),s])

acs = 0
was = 0
solved = {}
fail_cnt = {}
for p,s in ps:
    if p in solved and solved[p] == 1:
        pass
    elif p in solved and solved[p] == 0 and s == 'AC':
        acs += 1
        solved[p] = 1
        was += fail_cnt[p]
    elif p in solved and solved[p] == 0 and s == 'WA':
        fail_cnt[p] += 1
    elif s == 'AC':
        acs += 1
        solved[p] = 1
    else:
        solved[p] = 0
        fail_cnt[p] = 1
print(acs, was)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

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

wa = 0
marked = [0 for _ in range(n)]
cnt = [0 for _ in range(n)]

for i in range(m):
    x, s = map(str, input().split())
    x = int(x) - 1
    if s == "AC":
        if marked[x] == False:
            wa += cnt[x]
            marked[x] = True
    else:
        cnt[x] += 1

print(sum(marked), wa)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ok = [False] * n
wa_cnt = [0] * n
ac_cnt = 0
for i in range(m):
    p, m = input().split()
    if ok[int(p) - 1]:
        continue
    if m == 'WA':
        wa_cnt[int(p) - 1] += 1
    else:
        ac_cnt += 1
        ok[int(p) - 1] = True

ans_wa = 0
for i in range(n):
    if ok[i]:
        ans_wa += wa_cnt[i]

print(ac_cnt, ans_wa)

Submission status: Accepted

Solution code:
N,M = map(int, input().split())
# 問題ごとの提出リスト
# 1 : WA AC
# 2 : WA 
# 3 : AC
teisyutu_list = {} 

for i in range(1, M+1) :
    q_num, ac_wa = map(str, input().split())

    # 提出済みの問題か判定 
    if q_num in teisyutu_list.keys() :
        # q_num の 提出結果リストを取得する。
        teisyutu_list[q_num].append(ac_wa)
    else : 
        teisyutu_list[q_num] = [ac_wa]

ac_cnt = 0
wa_cnt = 0

for j in teisyutu_list.keys() :
    # AC できない問題は無視する(WAをカウントしない)
    if 'AC' not in teisyutu_list[j] :
        continue
    else :
        ac_cnt += 1

        for k in teisyutu_list[j] :
            if 'WA' == k :
                wa_cnt += 1
            else :
                break

print('%d %d' % (ac_cnt, wa_cnt))

Submission status: Accepted

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

a = [0 for i in range (n)]

ans = 0
pnl = 0
ha = {}

for i in range (m) :
    p , s = input().split()
    p = int(p) - 1
    if s == 'WA' :
        a[p] += 1
    elif str(p) not in ha.keys() :
        ans += 1
        pnl += a[p]
        ha[str(p)] = '1'

print( str(ans) + ' ' + str(pnl))

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
ac=[0]*N
wa=[0]*N
pena=0
acsum=0
for i in range(M):
    p,S=input().split()
    p=int(p)-1
    if S == 'AC':
        if ac[p]==0:
            ac[p]=1
            pena+=wa[p]
            acsum+=1
    else:
        wa[p]+=1
print(acsum,pena)

Submission status: Accepted

Solution code:
n, m = list (map (int, input().split()))
ha = {}
cnt = 0
ans = 0
use = [False for i in range (n + 1)]

for i in range (m) :
    p, s = input().split()
    p = int (p)
    if not use[p] and s == 'AC' :
        cnt += 1
        use[p] = 1;
        ans += ha[p] if p in ha.keys() else 0
        continue
    if use[p] :
        continue
    if not p in ha.keys() :
        ha[p] = 1
    else :
        ha[p] += 1

print (cnt, ans)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
s = [[] for _ in [0]*n]
for _ in [0]*m:
    p, _s = input().split()
    s[int(p)-1] += [_s]
ans = 0
pena = 0
for i in s:
    if 'AC' in i:
        ans += 1
        pena += i[:i.index('AC')].count('WA')
print(ans, pena)

Submission status: Accepted

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations, accumulate
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
import sys
def I(): return int(input())  # '123' -> 123
def Is(): return map(int, input().split())  # '123 456' -> 123, 456
def LI(): return list(map(int, input().split()))  # '123 456' -> [123, 456]
def TI(): return tuple(map(int, input().split()))  # '123 456' -> (123, 456)
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()  # 'aa bb' -> 'aa','bb' or ['aa','bb']
def LS(): return list(input())  # 'abc123' -> ['a','b','c','1','2','3']
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(1000000)
MOD = 1000000007
INF = float('inf')

n, m = Is()
li = [[0]*2 for _ in range(n)]
for _ in range(m):
    p_, s = Ss()
    p = int(p_) - 1
    if s == "AC":
        li[p][0] = 1
    elif s == "WA" and li[p][0] == 0:
        li[p][1] += 1

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# C - Welcome to AtCoder

N, M = map(int, input().split())
AC = {}
WA = {}
for _ in range(M):
    p, s = input().split()
    if p not in AC and p not in WA:
        AC[p], WA[p] = 0, 0
    if AC[p] < 1:
        if s == 'AC':
            AC[p] += 1
        elif s == 'WA':
            WA[p] += 1

for p in AC:
    if AC[p] == 0:
        WA[p] = 0

print(sum(AC.values()), sum(WA.values()))

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
ps = [0] * m
for i in range(m):
    ps[i] = list(map(str,input().split()))
if m == 0:
    print(0,0)
    exit()
countA = [0] * n
countW = [0] * n
cn = 0
for item in ps:
    if item[1] == 'AC' and countA[int(item[0])-1] == 0:
        countA[int(item[0])-1] = 1
        cn += countW[int(item[0])-1]
    else:
        countW[int(item[0])-1] += 1
print(sum(countA),cn)

Submission status: Accepted

Solution code:
N,M=map(int, input().split())
wa=[0]*N # カウント
ac=[0]*N # 何回目でacか
ac_n=0
for _ in range(M):
    p,s=input().split()
    p=int(p)
    if s=='WA':
        wa[p-1]+=1
    if (s=='AC') and (ac[p-1]==0):
        ac[p-1]=wa[p-1]+1
        ac_n+=1
print(str(ac_n)+' '+str(sum(ac)-ac_n))

Submission status: Accepted

Solution code:
import sys

readline = sys.stdin.readline

def main():
    N, M = map(int, readline().split())
    check = [0]*N
    pena = [0]*N
    for _ in range(M):
        p, S = readline().split()
        p = int(p)-1
        if S == 'AC':
            check[p] = 1
        else:
            pena[p] += (not check[p] == 1)*1
    
    ans_ac = sum(check)
    ans_pena = 0
    for i in range(N):
        ans_pena += pena[i] * (check[i] >= 1)
    print(ans_ac, ans_pena)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
A=0
W=0
ANS=[[0]*2 for _ in range(n+1)]
for _ in  range(m):
  i,s=input().split()
  if ANS[int(i)][0]==0:
    if s=='AC':
      ANS[int(i)][0]+=1
    else:
      ANS[int(i)][1]+=1
wa=0
for i in ANS:
  if i[0]==1:
    wa+=i[1]
print(sum([row[0] for row in ANS]),wa)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import defaultdict

N, M = map(int, input().split())
p = [""]*M
S = [""]*M

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

memo_p = defaultdict(int)
memo_s = defaultdict(str)

penalty = 0

for x, y in zip(p, S):
    if memo_s[x]=="AC":
        continue
    elif y=="WA":
        memo_p[x] += 1
    else:
        memo_s[x] = "AC"
        penalty += memo_p[x]
        memo_p[x] = 0

print(sum([i=="AC" for i in memo_s.values()]), penalty)

Submission status: Accepted

Solution code:
N, M = [int(_) for _ in input().split()]
A = [0 for i in range(N+1)]

ac = 0
pen = 0
for i in range(M):
    p, S = input().split()
    p = int(p)
    if A[p] == -1:
        continue
    if S == 'AC':
        ac += 1
        pen += A[p]
        A[p] = -1
    else:
        A[p] += 1
print(ac, pen)

Submission status: Accepted

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

N,M = list(map(int, input().rstrip().split()))
pS_list = []

for i in range(M):
    inp = input().rstrip().split()
    pS_list.append( [int(inp[0]), inp[1]] )

#-----
problem_AC_set = set()
problem_WA_dic = {}

for p,S in pS_list:
    if (S == "AC") and (p not in problem_AC_set):
        problem_AC_set.add(p)
    
    if (S == "WA") and (p not in problem_AC_set):
        problem_WA_dic.setdefault(p, 0)
        problem_WA_dic[p] += 1

cnt_AC = len(problem_AC_set)
cnt_WA = sum([v for k,v in problem_WA_dic.items() if k in problem_AC_set])

print(cnt_AC, cnt_WA)

Submission status: Accepted

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

Submission status: Accepted

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

collect=[0]*N
miss = [0]*N

for a in range(M):
	if S[a] == "AC":
		if collect[P[a]-1] != 1:
			collect[P[a]-1] += 1
	else:
		if collect[P[a]-1] != 1:
			miss[P[a]-1] += 1

AC = sum(collect)
WA = 0
for a in range(N):
	if collect[a] == 1:
		WA += miss[a]


print(AC, WA)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
x = [0] * m
y = [0] * m
z = [0] * n
ac = 0
wa = 0
for i in range(m):
    x[i], y[i] = map(str, input().split())
    if z[int(x[i]) - 1] >= 0:
        if y[i] == 'AC':
            ac += 1
            wa += z[int(x[i]) - 1]
            z[int(x[i]) - 1] = -1
        else:
            z[int(x[i]) - 1] += 1
print(ac, wa)

Submission status: Accepted

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

for i in range(m):
    subs[int(l[i][0])-1].append(l[i][1])

ac, p = 0, 0

for j in range(n):
    if 'AC' in subs[j]:
        ac += 1
        for k in range(len(subs[j])):
                if subs[j][k] == 'WA':
                    p += 1
                else:
                    break

print(ac, p)

Submission status: Accepted

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

mapAC = [False]*(n+1)
countWA = [0]*(n+1)

for i in range(m):
    p, s = input().split()
    p = int(p)
    if s == 'AC':
        mapAC[p] = True
    else:
        countWA[p] += 1*(not mapAC[p])
countWA = map(lambda x, y: x*y, countWA, mapAC)
print(mapAC.count(True), sum(countWA))

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
num = [0]*m
acwa = [0]*m
for i in range(m):
    num[i], acwa[i] = input().split()
account = 0
wacount = 0
sumi = {}
for i in range(m):
    if num[i] in sumi:
        if sumi[num[i]]!='AC':
            if acwa[i] == 'AC':
                account += 1
                wacount += sumi[num[i]]
                sumi[num[i]]= 'AC'
            else:
                sumi[num[i]] += 1
    else:
        if acwa[i] == 'AC':
            account += 1
            sumi[num[i]]= 'AC'
        else:
            sumi[num[i]]= 1

print(account,wacount)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
pss = [list(input().split()) for _ in range(m)]
ac = [0] * n
wa = [0] * n
ans1 = 0
ans2 = 0
for i in range(m):
    if ac[int(pss[i][0]) - 1] == 0:
        if pss[i][1] == 'AC':
            ans1 += 1
            ans2 += wa[int(pss[i][0]) - 1]
            ac[int(pss[i][0]) - 1] = 1
        else:
            wa[int(pss[i][0]) - 1] += 1
    else:
        continue
print(str(ans1) + ' ' + str(ans2))

Submission status: Accepted

Solution code:
n,m = map(int, input().split())
ac_list = [False]*(n+1)
pena_count = [0]*(n+1)
for i in range(m):
  p, s = input().split()
  p = int(p)
  if not ac_list[p]:
    if s == "AC":
      ac_list[p] = True
    else:
      pena_count[p] += 1
ac_count = 0
pena_c = 0
for i in range(1, n+1):
  if ac_list[i]:
    ac_count += 1
    pena_c += pena_count[i]
print(ac_count, pena_c)

Submission status: Accepted

Solution code:

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

for i in range(m):
    pi,si=list(input().split())
    if si=="AC" and ac[int(pi)-1]==False:
        ac[int(pi)-1]=True
    if si=="WA" and ac[int(pi)-1]==False:
        wa[int(pi)-1]+=1

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

print(accnt,wacnt)

Submission status: Accepted

Solution code:
n,m = (int(x) for x in input().split())
memo = [0]*n
pena = [0]*n
ans2 = 0
for i in range(m):
    p,s = (str(x) for x in input().split())
    p = int(p)
    if s=="AC":
        memo[p-1] = 1
    elif s=="WA":
        if memo[p-1]==0:
            pena[p-1] += 1

for j in range(n):
    if memo[j]==1:
        ans2 += pena[j]

print("{} {}".format(sum(memo),ans2))

Submission status: Accepted

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

ac = [0] * n
wa = [0] * n
wa_total = 0
for _ in range(m):
    tmp_i, s = input().split()
    i = int(tmp_i) - 1
    if ac[i] == 1:
        continue
    if s == 'AC':
        ac[i] = 1
        wa_total += wa[i]
    else:
        wa[i] += 1

print(sum(ac), wa_total)

Submission status: Accepted

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

lps = list()

for i in range(M):
    p, s = input().split()
    lps.append([int(p), s])
#print(lps)

lcor = [0] * N
lwrg = [0] * N
for i in range(M):
    if lps[i][1] == "AC":
        if lcor[lps[i][0]-1] == 0:
            lcor[lps[i][0]-1] += 1
    elif lps[i][1] == "WA":
        if lcor[lps[i][0]-1] == 0:
            lwrg[lps[i][0]-1] += 1

for i in range(N):
    if lcor[i] == 0:
        lwrg[i] = 0

print(sum(lcor), sum(lwrg))