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())
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())
success = [0] * (n+1)
penalty = [0] * (n+1)


for ind in range(m):
    p, s = input().split()
    p = int(p)
    if s == "WA" and success[p] == 0:
        penalty[p] += 1
    elif s == "AC":
        success[p] = 1
penalty = [penalty[ind] * success[ind] for ind in range(n+1)]
print("{} {}".format(sum(success), sum(penalty)))

Submission status: Accepted

Solution code:
n,m = map(int, input().split())
P,S=[],[]
A = {}# {num: (fixed, WA)}
ac,wa = 0,0
for i in range(m):
  p,s=input().split()
  P.append(int(p))
  S.append(s)
for i in range(m):
  num = P[i]
  res = A.get(num)[0] if A.get(num)!=None else False
  
  if S[i]=='AC':
    if res==False:
      ac += 1
      A[num] = (True, A.get(num)[1]) if A.get(num)!=None else (True,0)
  else:
    if res==False:
      A[num] = (False,A.get(num)[1]+1) if A.get(num)!=None else (False,1)

for a in A.values():
  if a[0]:
    wa += a[1]
print(ac,wa)

Submission status: Accepted

Solution code:
n, m = [int(_) for _ in input().split()]
ps_dict = {}
for i in range(m):
    p_, s = input().split()
    p = int(p_)
    if not p in ps_dict.keys():
        ps_dict[p] = [s]
    else:
        ps_dict[p].append(s)

res_ac = 0
res_wa = 0
for k, v in ps_dict.items():
    for i, vi in enumerate(v):
        if vi == 'AC':
            res_ac += 1
            res_wa += i
            break
print(res_ac, res_wa)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
n,m = map(int,input().split())
wc = [0]*n
ac = [0]*n
wa = 0
for _ in range(m):
  p,s = input().split()
  if ac[int(p)-1] == 0:
    if s == "AC":
      ac[int(p)-1] = 1
      wa += wc[int(p)-1]
    else:
      wc[int(p)-1] += 1
print("{} {}".format(sum(ac),wa))

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
ps=[list(input().split()) for i 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(str(cnt1)+" "+str(cnt2))

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
#ac,wa列を作成（pi問題がACならac[i]がTRUE、AC,WAに問わずwa[i]はwaの数）
ac, wa=[False]*n,[0]*n
for i in range(m):
  p,s = input().split()
  p=int(p)
  if s=='AC':
    ac[p-1]=True
  elif (s=='WA') and (ac[p-1]==False):
    wa[p-1]+=1

penalty, clear=0,0
for i,tf in enumerate(ac): #iはインデックス、tfはac[i]
  if tf:
    penalty += wa[i] #piがACされているとき、ペナルティ値を増やす
    clear += 1
print(clear, penalty)

Submission status: Accepted

Solution code:
import numpy as np
n,m=map(int,input().split())
p=[list(input().split()) for _ in range(m)]
a=[0]*(n+1)
w=[0]*(n+1)
for i in range(m):
    if a[int(p[i][0])]==0 and p[i][1]=='AC':
        a[int(p[i][0])]+=1
    if a[int(p[i][0])]==0 and p[i][1]=='WA':
        w[int(p[i][0])]+=1
a=np.array(a)
w=np.array(w)
aw=a*w
print(sum(a),sum(aw))

Submission status: Accepted

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

flag = [0]*n
wa_count_list = [0]*n
wa_count = 0
for i in range(m):
    if s[i] == "WA" and flag[p[i]-1] == 0:
        wa_count_list[p[i]-1] += 1
    elif s[i] == "AC" and flag[p[i]-1] == 0:
        flag[p[i]-1] = 1
    else:
        continue

for i in range(n):
    if flag[i] == 1:
        wa_count += wa_count_list[i]
    else:
        continue

print(flag.count(1), wa_count)

Submission status: Accepted

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

penalty, clear=0,0
for i,tf in enumerate(ac):
  if tf:
    penalty += wa[i]
    clear += 1
print('%d %d'%(clear,penalty))

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
PS = [[x for x in input().split()] for _ in range(M)]
tmp = [0] * (10**5+1)
ac = wa = 0

for P, S in PS:
    if tmp[int(P)]==-1:
        continue
    if S=='WA':
        tmp[int(P)] += 1
    elif S=='AC':
        ac+=1
        wa+=tmp[int(P)]
        tmp[int(P)] = -1
        
print(ac,wa)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import deque, Counter as cnt
from collections import defaultdict as dd
from operator import itemgetter as ig
from bisect import bisect_right as bsr
from math import factorial, ceil, floor
import sys
sys.setrecursionlimit(1000000)

# お約束
args = None
INF = float("inf")
MOD = int(1e9 + 7)


def input(*ps):
    if type(ps[0]) is list:
        return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]
    elif len(ps) == 1:
        return ps[0](next(args))
    else:
        return [p(next(args)) for p in ps]


def nlist(n, v):
    if not n:
        return [] if type(v) is list else v
    return [nlist(n[1:], v) for _ in range(n[0])]


def yesno(v, yes="Yes", no="No", upper=False):
    if upper:
        print([yes.upper(), no.upper()][not v])
    else:
        print([yes, no][not v])


def main():
    """エントリーポイント"""
    N, M = input([int, 2])
    PS = input([[str, 2], M])

    ans = {}
    for p, s in PS:
        if not p in ans:
            ans[p] = [0, 0]
        if s == "AC":
            ans[p][0] = 1
        if s == "WA" and ans[p][0] == 0:
            ans[p][1] += 1
    ac, pen = 0, 0
    for v in ans.values():
        if v[0] == 0:
            continue
        ac += 1
        pen += v[1]
    print(ac, pen)


if __name__ == '__main__':
    args = iter(sys.stdin.read().split())
    main()

Submission status: Accepted

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

Submission status: Accepted

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

ps = []
for _ in range(m):
	p,s = map(str,input().split())
	p = int(p)-1
	ps.append([p,s])

ac = [-1 for _ in range(n)]
wa = [0 for _ in range(n)]
ans_ac = 0
ans_wa = 0
for i in range(m):
	if ps[i][1] == 'WA':
		if ac[ps[i][0]] == -1:
			wa[ps[i][0]] += 1
	else:
		if ac[ps[i][0]] == -1:
			ac[ps[i][0]] = 1
			ans_ac += 1

for i in range(n):
	if ac[i] != -1:
		ans_wa += wa[i]
print(ans_ac,ans_wa)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
l1=[list(input().split()) for i in range(m)]
l2=["WA"]*n
l3=[0]*n
account=0
wacount=0
for i in range(m):
  if l1[i][1]=="WA" and l2[int(l1[i][0])-1]=="WA":
    wacount+=1
    l3[int(l1[i][0])-1]+=1
  if l1[i][1]=="AC":
    l2[int(l1[i][0])-1]="AC"

for i in range(n):
  if l2[i]=="AC":
    account+=1
  else:
    wacount-=l3[i]
print(account,wacount)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#C

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

ac = {i+1:0 for i in range(N)}
wa = {i+1:0 for i in range(N)}

for p, S in pS:
  p = int(p)
  if S=="AC":
    ac[p] = 1
  if S=="WA" and ac[p]==0:
    wa[p] += 1

wa = {i+1:acv*wav for i,[acv,wav] in enumerate(zip(ac.values(), wa.values()))}

print(sum(ac.values()), sum(wa.values()))

Submission status: Accepted

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

ac_count = 0
ac_status = [False]*n
pn_count = 0
wa_count = [0]*n
for i in range(m):
    p,s = input().split()

    if(s == 'AC'):
        if(ac_status[int(p)-1] == False):
            ac_status[int(p)-1] = True
            ac_count = ac_count + 1
            pn_count = pn_count + wa_count[int(p)-1]
    if(s == 'WA'):
        wa_count[int(p)-1] = wa_count[int(p)-1] + 1

print(ac_count, pn_count)

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

Submission status: Accepted

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

submit = []
for i in range(m):
    temp = [x for x in input().split()]
    submit.append(temp)

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

for i in range(m):
    result = submit[i][1]
    question = int(submit[i][0])

    if result == 'AC' and ac[question] == 0:
        ac[question] = 1
    elif result == 'WA' and ac[question] == 0:
        wa[question] += 1

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

print(sum(ac), sum(wa))

Submission status: Accepted

Solution code:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n,m = iim()
jud = [False for i in range(n)]
pen = [0 for i in range(n)]

for j in range(m):
    p,s = ism()
    p = int(p) - 1
    if jud[p] == False:
        if s == 'AC':
            jud[p] = True
        elif s == 'WA':
            pen[p] += 1

ans = jud.count(True)
cpn = 0
for k in range(n):
    if jud[k] == True:
        cpn += pen[k]

print(ans,cpn)

Submission status: Accepted

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

# print(p_list)

AC_count = 0
WA_count = 0

AC_question = set()
WA_question = dict()

for p_list in p_lists:
    if p_list[0] in AC_question:
        continue

    if p_list[1] == 'AC':
        AC_count += 1

        if p_list[0] in WA_question:
            WA_count += WA_question[p_list[0]]

        AC_question.add(p_list[0])

    if p_list[1] == 'WA':
        if p_list[0] in WA_question:
            WA_question[p_list[0]] = WA_question[p_list[0]] + 1
        else:
            WA_question[p_list[0]] = 1

print(AC_count, WA_count)

Submission status: Accepted

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

d = {}
d_W = {}

for i in range(1, M+1):
    p, S = list(map(str, input().split()))
    if S == "WA":
        if p not in d_W.keys():
            d_W[p] = 1
        else:
            d_W[p] += 1
    else:
        if p not in d_W.keys():
            d[p] = 0
        elif p not in d.keys():
            d[p] = d_W[p]

print(len(d), sum(d.values()))

Submission status: Accepted

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

WA_count = 0
AC_count = 0
Penal = 0
d = {}
d_W = {}

for i in range(1, M+1):
    p, S = list(map(str, input().split()))
    if S == "WA":
        if p not in d_W.keys():
            d_W[p] = 1
        else:
            d_W[p] += 1
    else:
        if p not in d_W.keys():
            d[p] = 0
        elif p not in d.keys():
            d[p] = d_W[p]

    # if S == "WA":
    #     WA_count += 1
    # else:
    #     if p not in d.keys():
    #         d[p] = WA_count
    #         WA_count = 0
    #     else:
    #         WA_count = 0
        # cor.append(p)
        # if AC_count != set(cor):
        #     AC_count = set(cor)
        #     Penal += WA_count
        #     WA_count = 0
        # else:
        #     WA_count = 0

print(len(d), sum(d.values()))

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
ps=[list(input().split()) for i 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(str(cnt1)+" "+str(cnt2))

Submission status: Accepted

Solution code:
import sys
n,m = map(int,input().split())
ma = [list(input().split()) for _ in range(m)]
if len(ma) == 0:
    print(0,0)
    sys.exit()
#print(ma)
#[['1', 'WA'], ['1', 'AC'], ['2', 'WA'], ['2', 'AC'], ['2', 'WA']]

li = [[False,0,0] for _ in range(n)]
#print(li) 
#[[False, 0, 0], [False, 0, 0]]

for m in ma:
    ind = int(m[0])-1
    st =  m[1]
    if st == 'WA' and li[ind][0] == False:
        li[ind][2] += 1
    elif st == 'AC' and li[ind][0] == False:
        li[ind][1] += 1
        li[ind][0] = True

ok_count = 0
ng_count = 0
for l in li:
    if l[0]:
        ok_count += l[1]
        ng_count += l[2]
print(ok_count,ng_count)

Submission status: Accepted

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

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

for i in range(m):
    a,b=input().split()
    a=int(a)-1
    if not ac[a]:
        if b=="WA":
            wa[a]+=1
        else:
            ac[a]=1
a=0
w=0
for i in range(n):
    if ac[i]:
        a+=1
        w+=wa[i]
print(a,w)

Submission status: Accepted

Solution code:
import copy
N,M=map(int,input().split())
ans={}
for i in range(M):
    p,S=map(str,input().split())
    ans.setdefault(p,[]).append(S)

ac=0
wa=0

for i in ans.keys():
    wa_count=0
    for j in ans[i]:
        if j=="WA":
            wa_count+=1
        elif j=="AC":
            ac+=1
            wa+=wa_count
            break
print(ac,wa)

Submission status: Accepted

Solution code:
import sys

n, m = map(int, sys.stdin.readline().split())
pv = []
for _ in range(m):
    p, s = sys.stdin.readline().split()
    p = int(p) - 1
    v = 1 if s == 'AC' else 0
    pv.append((p, v))

def main():
    wa = [0] * n
    ac = [0] * n
    for p, v in pv:
        wa[p] += (ac[p] | v) ^ 1
        ac[p] |= v
    for p in range(n): wa[p] *= ac[p]
    print(sum(ac), sum(wa))

if __name__ ==  '__main__':
    main()

Submission status: Accepted

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

acdic={}
wadic={}
for i in range(n):
    acdic[i+1]=False
    wadic[i+1]=0

acnum=0
wanum=0
for i in range(m):
    p,s=map(str,input().split())
    p=int(p)
    if s=="AC" and acdic[p]==False :
        acnum+=1
        acdic[p]=True
        wanum+=wadic[p]
    else:
        wadic[p]=wadic[p]+1

print("{0} {1}".format(acnum,wanum))

Submission status: Accepted

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

flag_correct = [False]*(n+1)
count_correct = 0
list_count_pena = [0]*(n+1)
count_pena = 0
for i,ans in enumerate(list_pS):
  if ans[1] == 'AC':
    if not(flag_correct[int(ans[0])]):
      count_correct +=1 
      flag_correct[int(ans[0])] = True
  if ans[1] == 'WA':
    if not(flag_correct[int(ans[0])]):
      list_count_pena[int(ans[0])] +=1

for i,pena in enumerate(flag_correct):
  if flag_correct[i]:
    count_pena += list_count_pena[i]
      
print(count_correct, count_pena)

Submission status: Accepted

Solution code:
from math import floor,ceil,sqrt,factorial,log
from collections import Counter, deque
from functools import reduce
import numpy as np
def S(): return input()
def I(): return int(input())
def MS(): return map(str,input().split())
def MI(): return map(int,input().split())
def FLI(): return [int(i) for i in input().split()]
def LS(): return list(MS())
def LI(): return list(MI())
def LLS(): return [list(map(str, l.split() )) for l in input()]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def LLSN(n: int): return [LS() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]

n, m = MI()

ac = 0
wa = 0
acp = [False] * (n+1)
wap = [0] * (n+1)
for i in range(m):
    id, result = MS()
    id = int(id)
    if acp[id]:
        continue

    if result == "WA":
        wap[id] += 1
    else:
        acp[id] = True
        ac += 1
        wa += wap[id]

print(ac, wa)

Submission status: Accepted

Solution code:
def countnumber(l):
  for i in range(l):
    p,s=input().split()
    p=int(p)
    if x[p-1]==0:
      if s=="WA":
        y[p-1]+=1
      else:
        x[p-1]+=1
  X=sum(x)
  Y=0
  for i in range(n):
    if x[i]==1:
      Y+=y[i]
  return X,Y

n,m=map(int,input().split())
x=[0]*n
y=[0]*n
result1,result2=countnumber(m)

print(result1,result2)

Submission status: Accepted

Solution code:

def myAnswer(N:int,M:int,p:list,S:list) -> None:
   ac = 0
   wa = 0
   dic = {}
   for key,value in zip(p,S):
      if(key in dic.keys()):
         dic[key].append(value)
      else:
         dic[key] = [value]
   for values in dic.values():
      if(("AC" in values)):
         for v in values:
            if(v == "AC"):
               ac+=1
               break
            else:
               wa+=1
   print(ac,wa)

def modelAnswer():
   tmp=1
def main():
   N, M = map(int,input().split())
   p =[]
   S = []
   for _ in range(M):
      tmp = list(map(str,input().split()))
      p.append(tmp[0])
      S.append(tmp[1])
   myAnswer(N,M,p[:],S[:])
if __name__ == '__main__':
   main()

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 ac[p]:
        continue
    if s == 'WA':
        wa[p] += 1
    else:
        ac[p] = 1

a, b = 0, 0
for c, w in zip(ac, wa):
    if c == 0:
        continue
    a += 1
    b += w
print(a, b)

Submission status: Accepted

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

ans = 0
penalty = 0

for i in range(M):
    p, S = input().split()
    if p in solve_problem:
        continue

    if S == 'AC':
        solve_problem.add(p)
        ans += 1
        penalty += WA[int(p)-1]
    if S == 'WA':
        WA[int(p)-1] += 1

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

Submission status: Accepted

Solution code:
import math

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

d = {}
for i in range(1, n + 1):
    d[i] = {"AC": False, "WA": 0}

acc, wac = 0, 0
for _ in range(m):
    q, m = input().split(" ")
    q = int(q)

    if not d[q]["AC"]:
        if m == "WA":
            d[q]["WA"] += 1
        elif m == "AC":
            d[q]["AC"] = True
            acc += 1
            wac += d[q]["WA"]

print(acc, wac)

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
P=[-1 for _ in range(N)]
S=[-1 for _ in range(N)]
# 負，暫定のペナルティー数，　正，確定したペナルティー数
ans_num = 0
for i in range(M):
    p,s = input().split()
    p = int(p) - 1
    # 初めて正解した場合．
    if S[p] < 0 and s=='AC':
        S[p] = -S[p] - 1 # 最初は-1だから
        ans_num+=1
    # 正解してないのに間違っていた場合
    elif S[p] < 0 and s=='WA':
        S[p] -= 1
penalty_num=0
for s in S:
    if s<0:
        continue
    penalty_num += s
print(ans_num, penalty_num)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
ac=[0 for i in range(n)]
l=[0 for i in range(n)]
for i in range(m):
    p,s=input().split()
    p2=int(p)
    if s=="AC":
        ac[p2-1]=1
    elif ac[p2-1]==0:
        l[p2-1]+=1
ans1=sum(ac)
ans2=0
for i in range(n):
    if ac[i]>0:
        ans2+=l[i]
print(ans1,ans2)

Submission status: Accepted

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

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

sl = set()
ans = 0
pen = 0
WA = [0 for _ in range(N)]
for i in range(M):
    p, S = input().split()
    if p in sl:
        continue

    if S == 'AC':
        ans += 1
        sl.add(p)
        pen += WA[int(p) - 1]
    else:
        WA[int(p) - 1] += 1

print(ans, pen)

Submission status: Accepted

Solution code:

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

data = {}
ps = [0] * N
ACs = []

num_ac = 0
num_wa = 0


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

    if ps[p] == 0:
        ps[p] = 1
        data[p] = {'AC':0, 'WA':0}

    if S == 'AC' and data[p]['AC'] == 0:
        ACs.append(p)
        data[p]['AC'] += 1
        num_ac += 1
        num_wa += data[p]['WA']

    if S == 'WA' and data[p]['AC'] == 0:
        data[p][S] += 1

print(num_ac, num_wa)

Submission status: Accepted

Solution code:
# ABC151C - Welcome to AtCoder

n,m=map(int,input().split())
acs=[0]*n
was=[0]*n

for i in range(m):
    p,s=input().split()
    p=int(p)
    if s=="AC":
        acs[p-1]+=1
    else:
        if not acs[p-1]:
            was[p-1]+=1

ac,wa=0,0
for i in range(n):
    if acs[i]:
        ac+=1
        wa+=was[i]

print(ac,wa)

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
ac = 0
wa = 0
acbox = [0]*(n+1) #配列作って初期化
wabox = [0]*(n+1)
for i in range(m):
  p,q = input().split()
  p = int(p)
  if q == "WA":
    if acbox[p] == 0:
      wabox[p] += 1
  else:
    if acbox[p] == 0:
      ac += 1
      wa += wabox[p]
      acbox[p] =+ 1
print(ac,wa)

Submission status: Accepted

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

for _ in range(m):
  p, s = input().split()
  if submit.get(p, -1) == -1:
    submit[p] = [0, 0]
  if (submit[p])[0] == 0:
    if s == 'AC':
      (submit[p])[0] += 1
    else:
      (submit[p])[1] += 1
      
ac = 0
wa = 0
for i in submit.values():
  if i[0] > 0:
    ac += i[0]
    wa += i[1]

print(ac, wa)

Submission status: Accepted

Solution code:
'''
INPUT SHORTCUTS
N, K = map(int,input().split())
N ,A,B = map(int,input().split())
string = str(input())
arr = list(map(int,input().split()))
N = int(input())
'''
N,M = map(int,input().split())
sub = [ -1 for _ in range(N) ]
penalty = 0
score = 0
for _ in range(M):
	p , s = map(str,input().split())
	p = int(p)
	if s=='WA':
		if sub[p-1]==-1:
			sub[p-1]=1
		elif sub[p-1]>=1:
			sub[p-1]+=1
	elif s=='AC':
		if sub[p-1]==-1:
			score+=1
			sub[p-1]=0
		elif sub[p-1]>=1:
			penalty+=sub[p-1]
			score+=1
			sub[p-1]=0
print(score,penalty)

Submission status: Accepted

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

skip_flag = [False] * (n + 1)
wa_count_list = [0] * (n + 1)

ac = 0
wa = 0

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

    if skip_flag[p]:
        continue

    if s == "AC":
        ac += 1
        wa += wa_count_list[p]
        skip_flag[p] = True
    elif s == "WA":
        wa_count_list[p] += 1

print(ac, wa)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
l = [0 for _ in range(n+1)]
ans = 0
penalty = 0
for _ in range(m):
    p, s = input().split()
    p = int(p)
    if l[p] >= 0:
        if s == 'WA':
            l[p] += 1
        else:
            ans += 1
            penalty += l[p]
            l[p] = -1
print(ans, penalty)

Submission status: Accepted

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

wa = [0] * N
w = 0
ac = set()
for i in range(M):
    if S[i] == "AC":
        if p[i] in ac:
            pass
        else:
            ac.add(p[i])
            w += wa[p[i] - 1]
    else:
        wa[p[i] - 1] += 1
print(len(ac), w)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
P = [0] * 10**5
score, penalty = 0, 0
for i in range(M):
    p, s = map(str, input().split())
    p = int(p)
    if s == 'AC' and P[p-1] != -1:
        penalty += P[p-1]
        score += 1
        P[p-1] = -1
    elif P[p-1] != -1:
        P[p-1] += 1
print(score, penalty)

Submission status: Accepted

Solution code:
from collections import defaultdict, deque
import sys
import heapq
import bisect
import itertools
import queue
import copy
import time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7

def inp(): return int(sys.stdin.readline())

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

def inpl_str(): return list(sys.stdin.readline().split())

n, m = inpl()
l = [1] * n
a = 0
q = 0
for i in range(m):
    p, s = inpl_str()
    p = int(p)
    if l[p-1] > 0:
        if  s == 'AC':
            q += l[p-1]-1
            l[p-1] = 0
            a+=1
        else:
            l[p-1]+=1
print(a, q)

Submission status: Accepted

Solution code:
num, all_ans = [int(i) for i in input().split(" ")]
d_wa = [0 for _ in range(num)]
d_ac = [0 for _ in range(num)]
ans = 0

for _ in range(all_ans):
    ans_num, ac_wa = [i for i in input().split(" ")]
    if d_ac[int(ans_num) - 1] == 1: continue
    if ac_wa == "AC": 
        d_ac[int(ans_num) - 1] = 1
        continue
    if ac_wa == "WA":
        d_wa[int(ans_num) - 1] += 1
        continue

for num, i in enumerate(d_ac):
    if i:
       ans += d_wa[num]

print(sum(d_ac),ans)

Submission status: Accepted

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

def main():
     n, m = map(int, input().split())
     ac_list = [False for i in range(n)]
     wa_list = [0 for i in range(n)]
     ac_ans = wa_ans = 0

     for i in range(m):
          p, s = input().split()
          p = int(p) - 1
          if not ac_list[p]:
               if s == 'AC':
                    ac_list[p] = True
                    ac_ans += 1
                    wa_ans += wa_list[p]
               else:
                    wa_list[p] += 1
     
     print('{} {}'.format(ac_ans, wa_ans))

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
p = [0]*(n+1)
q = [False]*(n+1)
for _ in range(m) :
  v,s = input().split()
  v = int(v)
  if q[v]:
      continue
  if s[0] == 'A':
      q[v] = True
  else :
      p[v] += 1
print(sum(q), sum(p[i] for i in range(n+1) if q[i]))

Submission status: Accepted

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

acl=[0]*n
wal=[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:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()
p = [0]*M
S = [0]*M
cnt_penalty = [0]*N
cnt_ac = [0]*N

for i in range(M):
  p[i], S[i] = input().split()
  p[i] = int(p[i])
  
for i in range(M):
  if cnt_ac[p[i]-1] == 0:
    if S[i] == "WA":
      cnt_penalty[p[i]-1] += 1
    elif S[i] == "AC":
      cnt_ac[p[i]-1] = 1
      
for i in range(N):
  if cnt_ac[i] == 0:
    cnt_penalty[i] = 0

print(sum(cnt_ac), sum(cnt_penalty))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
account=0
wacount=0
acbox=[0]*(a+1)
wabox=[0]*(a+1)
for i in range(b):
  p,q=input().split()
  p=int(p)
  if q=="WA":
    if acbox[p]==0:
      wabox[p]+=1
  else:
    if acbox[p]==0:
      account+=1
      wacount+=wabox[p]
      acbox[p]=+1
print(account,wacount)

Submission status: Accepted

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

l = [0]*(n + 1)
ac = 0
wa = 0

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

print(ac, wa)

Submission status: Accepted

Solution code:
N,M = [int(v) for v in input().split()]
wa_total = [0 for _ in range(N)]
ac_flag = [False for _ in range(N)]

for _ in range(M):
    p,ans = [v for v in input().split()]
    p = int(p) - 1

    if not ac_flag[p]:
        if ans == "AC":
            ac_flag[p] = True
        else:
            wa_total[p] += 1

ac_ans = 0
wa_ans = 0

for a,b in zip(wa_total,ac_flag):
    if b:
        ac_ans += 1
        wa_ans += a
print(ac_ans,wa_ans)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
ac = set()
npena = dict()
for i in range(m):
    np, res = input().split()
    if res == 'AC':
        ac.add(np)
    elif np not in ac:
        npena[np] = npena.get(np, 0) + 1
res2 = 0
for np in ac:
    res2 += npena.get(np,0)
print(len(ac), res2)

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 s == "WA":
        if ac[p-1] != 1:
            wa[p-1] += 1

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

print(sum(ac), sum(wa))