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 = [int(n) for n in input().split()]
solved = {}
result = {}

for i in range(M):
    p, S = input().split()
    status = result.setdefault(p, [])
    if len(status)==0:
        result[p] = []
        solved[p] = False
    if S == 'AC':
        solved[p] = True
    result[p].append(S)

ans = 0
wa = 0
for k, v in solved.items():
    if v:
        ans += 1
        wa += result[k].index('AC')
print(ans , wa)

Submission status: Accepted

Solution code:
N,M=map(int,input().split()) 
L=[list(input().split()) for i in range(M)]
W=[0]*N
A=[0]*N
a=0
w=0
for i in range(M):
  if L[i][1]=="AC":
    A[int(L[i][0])-1]=1
    
  elif L[i][1]=="WA" and A[int(L[i][0])-1]==0:
    W[int(L[i][0])-1]+=1
#for i in A:
  #a+=i
#for i in W:
  #w+=i
for i in range(N):
  if A[i]>0:
    a+=1
    w+=W[i]
print(a,w)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
aa=[[] for i in range(n)]
for x in range(m):
  a,b=input().split()
  d=int(a)-1
  aa[d].append(b)

ac=0
wa=0
for i in range(n):
    a1=0
    a2=0
    for j in range(len(aa[i])):
        if aa[i][j]=="WA":
            a1+=1
        else:
            a2+=1
            break
    if a2==1:
        wa+=a1
        ac+=1
print(str(ac)+" "+str(wa))

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
wa=[0]*N
pen=[0]*N
ac=[0]*N
for x in range(M):
  P,S=input().split()
  if S=="WA" and ac[int(P)-1]==0:
    wa[int(P)-1] += 1
  elif S=="AC" and ac[int(P)-1]==0:
    ac[int(P)-1] += 1
    pen[int(P)-1] = wa[int(P)-1]
print(f"{sum(ac)} {sum(pen)}")

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
aa=[[] for i in range(n)]
for x in range(m):
  a,b=input().split()
  d=int(a)-1
  aa[d].append(b)
  
ans_ac=0
ans_wa=0
for y in range(n):
  ans1=0
  ans2=0
  for z in range(len(aa[y])):
    if aa[y][z]=='WA':
      ans1+=1
    else:
      ans2+=1
      break
  if ans2==1:
    ans_wa+=ans1
    ans_ac+=1
    
print(str(ans_ac)+' '+str(ans_wa))

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
aa=[[] for i in range(n)]
for x in range(m):
  a,b=input().split()
  d=int(a)-1
  aa[d].append(b)
  
ans_ac=0
ans_wa=0
for y in range(n):
  ans1=0
  ans2=0
  for z in range(len(aa[y])):
    if aa[y][z]=='WA' and ans2==0:
      ans1+=1
    elif aa[y][z]=='AC' and ans2==0:
      ans2+=1
      
  if ans2==1:
    ans_wa+=ans1
    ans_ac+=1
    
print(str(ans_ac)+' '+str(ans_wa))

Submission status: Accepted

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

ac_cnt = 0
wa_cnt = 0

ac_ans = 0
wa_ans = 0

for key in ans_dict.keys():
    ac_cnt = ans_dict[key].count('AC')
    wa_cnt = ans_dict[key].count('WA')
    if ac_cnt != 0:
        ac_ans += 1
        # その問題の解答一覧で最初にACとなったインデックスを取得
        ac_index = ans_dict[key].index('AC')
        wa_ans += ans_dict[key][:ac_index].count('WA')
    
print(ac_ans, wa_ans)

Submission status: Accepted

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

wa_num = 0
ac_num = 0

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

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

    if AC[p]:
        continue

    if S == "AC":
        AC[p] = True
        ac_num += 1
        wa_num += WA[p]
    elif S == "WA":
        WA[p] += 1

print(f"{ac_num} {wa_num}")

Submission status: Accepted

Solution code:
N, M = [int(i) for i in input().split()]
AC = 0
WA = 1

ac_count = 0
wa_count = 0
data = {}
for _ in range(M):
  p, s = input().split()
  if p in data:
    if data[p][AC] == 1:
      # AC済のものはスキップ
      continue
  if s == "AC":
    if p in data:
      wa_count += data[p][WA]
    ac_count += 1
    data[p] = [1, 0]
  if s == "WA":
    if p in data:
      data[p][WA] += 1
    else:
      data[p] = [0, 1]

print(ac_count, wa_count)

Submission status: Accepted

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

AC = [0]*N
WA = [0]*N
AC_cnt = 0
WA_cnt = 0

p = [0]*M
S = [0]*M

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

for i in range(M):
    q_num = int(p[i])
    if AC[q_num-1] == 0:
        if S[i] == "AC":
            AC[q_num-1] = 1
        else:
            WA[q_num-1] += 1

for i in range(N):
    if AC[i] == 1:
        WA_cnt += WA[i]
        AC_cnt += 1

print(AC_cnt,WA_cnt)

Submission status: Accepted

Solution code:
import sys

def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))
def RN(N): return [input().strip() for i in range(N)]


def main():
    N, M = MI()

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

    ans = [0]*(N+1)
    error = [0]*(N+1)
    e = [0]*(N+1)

    for i in range(M):
        if ans[int(p[i])] == 0:
            if S[i] == "WA":
                error[int(p[i])] += 1
            elif S[i] == "AC":
                ans[int(p[i])] = 1

    sum_ans = sum(ans)
    sum_error = 0
    for i in range(N+1):
        if ans[i] == 1:
            sum_error += error[i]
    print(sum_ans, sum_error)

if __name__ == "__main__":
	main()

Submission status: Accepted

Solution code:
import itertools
# import math

# N = int(input())
# S = input()
# n, *a = map(int, open(0))
N, M = map(int, input().split())
# P = list(map(int, input().split()))
# Q = list(map(int, input().split()))
# S = input()

aced = {}
waed = [0] * (N + 1)

cnt_ac = 0
for i in range(M):
    p_i, S_i = input().split()
    if S_i == 'WA':
        if not p_i in aced:
            waed[int(p_i)] += 1
    else:
        if not p_i in aced:
            cnt_ac += 1
            aced[p_i] = 1

cnt_pena = 0
for k in aced:
    cnt_pena += waed[int(k)]

print(cnt_ac, cnt_pena)
# print(aced)

Submission status: Accepted

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

AC = [0]*N
WA = [0]*N
AC_cnt = 0
WA_cnt = 0

p = [0]*M
S = [0]*M

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

for i in range(M):
    q_num = int(p[i])
    if AC[q_num-1] == 0:
        if S[i] == "AC":
            AC[q_num-1] = 1
        else:
            WA[q_num-1] += 1

for i in range(N):
    if AC[i] == 1:
        WA_cnt += WA[i]
        AC_cnt += 1

print(AC_cnt,WA_cnt)

Submission status: Accepted

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

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

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

r1 = sum(ac)
r2 = sum(wa[i] if ac[i] else 0 for i in range(n))

print(r1, r2)

Submission status: Accepted

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


def main():
  N, M = list(map(int, input().split()))
  PS = []
  for i in range(M):
    p, s = input().split()
    PS.append((int(p)-1, s))

  penas = [0]*(N)
  is_ac = [0]*(N)
  for i in range(M):
    p, s = PS[i]
    if s == 'AC':
      is_ac[p] = True
    elif not is_ac[p]:
      penas[p] += 1

  num_ac = sum(is_ac)
  num_pe = 0

  for i in range(N):
    if is_ac[i]:
      num_pe += penas[i]

  print(num_ac, num_pe)


if(__name__ == '__main__'):
  main()

Submission status: Accepted

Solution code:
n,m = list(map(int,input().split()))
ans = [0,0]
p_list = [0]*(n+1)
ac = [0]*(n+1)
for i in range(m):
    ps = input().split()
    p = int(ps[0])
    s = ps[1]
    if s=='AC' and ac[p]==0:
        ans[0] += 1
        ans[1] += p_list[p]
        ac[p] += 1
    else:
        if ac[p]==0:
            p_list[p] += 1
print(*ans, sep=' ')

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
if m != 0:
    l = [list(input().split()) for i in range(m)]
    p,s = [list(i) for i in zip(*l)]
t = [0] * n
ac = 0
wa = 0

for i in range(m):
    if s[i] == 'WA' and t[int(p[i])-1] != 'AC':
        t[int(p[i])-1] += 1
    elif s[i] == 'AC' and t[int(p[i])-1] != 'AC':
        ac += 1
        wa += t[int(p[i])-1]
        t[int(p[i])-1] = 'AC'

print(ac,wa)

Submission status: Accepted

Solution code:
import numpy as np
n,m=map(int, input().split())
AC=[0]*(n+1)
WA=[0]*(n+1)
for _ in range(m):
   p,s=input().split()
   if s=='AC':
        AC[int(p)]=1
   elif s=='WA' and AC[int(p)]==0:
        WA[int(p)] +=1
        
ACn=np.array(AC)
WAp=np.array(WA)

print(sum(AC),sum(ACn*WAp))

Submission status: Accepted

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

ans_num = [0]*(N+1)
ans_pe = [0]*(N+1)

for i in range(M):
  result = t_ans[i][1]
  question = int(t_ans[i][0])
  if result == 'AC' and ans_num[question] == 0:
    ans_num[question] = 1
  elif result == 'WA' and ans_num[question] == 0:
    ans_pe[question] += 1

for i in range(N+1):
  if ans_num[i] != 1:
    ans_pe[i] = 0

print(f'{sum(ans_num)} {sum(ans_pe)}')

Submission status: Accepted

Solution code:
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    n, m = MI()
    ac = [False]*(n+1)
    wa = [0]*(n+1)
    for _ in range(m):
        temp = input().split()
        p, s = int(temp[0]), temp[1]
        if not ac[p]:
            if s == 'AC':
                ac[p] = True
            else:
                wa[p] += 1
    penalty = 0
    for i in range(n+1):
        if ac[i]:
            penalty += wa[i]
    print('{} {}'.format(sum(ac), penalty))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import numpy as np

def solve():
    dp = np.zeros((2, N+1))
#    print(dp)
    ac = 0
    wa = 0
    for i in range(M): 
        if (dp[0][S[i][0]] == 0):
            if(S[i][1] == "WA"):
                dp[1][S[i][0]] += 1
            elif(S[i][1] == "AC"):
                ac += 1
                dp[0][S[i][0]] = 1
                wa += dp[1][S[i][0]]
    print(ac, int(wa))

if __name__=="__main__":

    N, M = list(map(int, input().split()))
    S = []
    for i in range(M):
        a,b = input().split()
        S.append([int(a), b])
#    print(S)
    solve()

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
P = [input().split() for _ in range(M)]
 
wa = [0]*N
ac = [False]*N
 
for ps in P:
  p, s = int(ps[0]), ps[1]
  if ac[p-1]:
    continue
  elif s == 'AC':
    ac[p-1] = True
  else:
    wa[p-1] += 1

print(sum(ac), sum([w*a for w,a in zip(wa, ac)]))

Submission status: Accepted

Solution code:
def main():
    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 = [int(s) for s in p]
    # 問題によってカウントしたい
    WA = [0] * (n+1)
    # 全体として何個かがわかればいい
    AC = [False] * (n+1)
    wa = 0
    for i in range(m):
        p = int(P[i])
        if AC[p]:
            continue
        else:
            if S[i] == 'WA':
                WA[p] += 1
            else:
                AC[p] = True
                wa += WA[p]
    # なぜか都度足さないとWAを間違えている？
    # wa = sum(WA)
    ac = sum(AC)
    print(ac, wa)
        
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    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 = [int(s) for s in p]
    # 問題によってカウントしたい
    WA = [0] * (n+1)
    # 全体として何個かがわかればいい
    AC = [False] * (n+1)
    cnt = 0
    for i in range(m):
        p = int(P[i])
        if AC[p]:
            continue
        else:
            if S[i] == 'WA':
                WA[p] += 1
            else:
                AC[p] = True
                cnt += WA[p]
    # wa = sum(WA)
    ac = sum(AC)
    print(ac, cnt)
        
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import Counter, defaultdict
import sys

sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools

import queue
from collections import deque


def main():
    num, submit = map(int, input().split())
    fin_flg = [0 for i in range(num + 1)]
    count_ac, count_wa = 0, 0

    for i in range(submit):
        a, b = input().split()
        a = int(a)
        if fin_flg[a] == -1:
            continue
        if b == "AC":
            count_ac += 1
            count_wa += fin_flg[a]
            fin_flg[a] = -1
        else:
            fin_flg[a] += 1

    print(count_ac, count_wa)




if __name__ == '__main__':
    main()

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())
cor=[0]*n
fal=[0]*n
for i in range(m):
  x=int(p[i])
  if cor[x-1]==0:
    if s[i]=='AC':
      cor[x-1]=1
    else:
      fal[x-1]+=1
ans_cor=0
ans_fal=0
for i in range(n):
  if cor[i]==1:
    ans_cor+=1
    ans_fal+=fal[i]
print(ans_cor,ans_fal)

Submission status: Accepted

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

Submission status: Accepted

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

AC = 0
penalty = 0
for i in range(N):
    if accepted[i] == 1:
        AC = AC+1
        if wrong_ans[i]>=1:
            penalty = penalty+wrong_ans[i]
print(AC,penalty)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
point = 0 ; penalty = 0
false = [0] * n
correct = [0] * n
for i in range(m) :
    p, s = input().split()
    p = int(p)
    if s == "WA" and correct[p-1] != 1 :
        false[p-1] += 1
    if s == "AC" :
        correct[p-1] = 1

for i in range(n) :
    if false[i] > 0 and correct[i] == 1 :
        penalty += false[i]

print(sum(correct),penalty)

Submission status: Accepted

Solution code:
n,m = map(int, input().split(" "))
a=[list(map(str, input().split(" "))) for i in range(m)]
check = [False for i in range(n + 1)]
times = [False for i in range(n + 1)]

for i in range(m):
  #print(check)
  #print(a[i])
  if check[(int)(a[i][0])] == False and a[i][1] == "AC":
    #print("OK")
    check[(int)(a[i][0])] = True
  elif check[(int)(a[i][0])] == False and a[i][1] == "WA":
    times[(int)(a[i][0])] += 1
    #print("MISS")

for i in range(n + 1):
  if check[i] == False:
    times[i] = 0
print(check.count(True), sum(times))

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
p,s=[],[]
for i in range(m):
    a,b=map(str,input().split())
    p.append(int(a))
    s.append(b)
c,e=0,0
l=[0]*n
for i in range(m):
    if s[i]=="WA" and l[p[i]-1]==0:
        e+=1
    elif s[i]=="AC" and l[p[i]-1]==0:
        c+=1
        l[p[i]-1]=1
for i in range(m):
    if s[i]=="WA" and l[p[i]-1]==0:
        e-=1
print(str(c)+" "+str(e))

Submission status: Accepted

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

a = [False]*(N+1)
b = [0]*(N+1)



for i in range(M):
    c = input().split()
    if c[1] == "AC":
        a[int(c[0])] = True
    elif c[1] == "WA" and a[int(c[0])] == False:
        b[int(c[0])] += 1
            

for j in range(N+1):
    if a[j] == False:
        b[j] = 0
        
print(sum(a),sum(b))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
ans_num_lis = [0 for i in range(N)]
pre_ans_lis = [0 for i in range(N)]
ans_lis = [0 for i in range(N)]
for i in range(M):
  problem, result = input().split()
  problem_num = int(problem)
  if result == "WA":
    pre_ans_lis[problem_num-1] += 1
  if result == "AC" and not ans_num_lis[problem_num-1]:
    ans_num_lis[problem_num-1] = 1
    ans_lis[problem_num-1] = pre_ans_lis[problem_num-1]

print(sum(ans_num_lis), sum(ans_lis))

Submission status: Accepted

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

ac = set()
wa = {}

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

ans = sum([wa[i] for i in ac])

print(len(ac), ans)

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=input().split()
    p=int(p)
    if s=="AC":
        if l[p-1][0]!=1:
            l[p-1][0]=1
    else:
        if l[p-1][0]!=1:
            l[p-1][1]+=1
ac=0
wa=0
for i in range(len(l)):
    ac+=l[i][0]
    if l[i][0]!=0:
        wa+=l[i][1]
print(ac,wa)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
a=[0]*n
ans=0
for i in range(m):
  p,s=input().split()
  p=int(p)-1
  if a[p]!=1:
    if s=='WA':a[p]-=1
    else:
      ans-=a[p]
      a[p]=1
for i in range(n):
  a[i]=max(a[i],0)
print(sum(a),ans)

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
correct=[]
penalty=[0 for i in range(N+1)]
for i in range(M):
  p,S=input().split()
  p=int(p)
  if S=="AC":correct.append(p)
  else:
    if p not in correct: penalty[p] += 1

correct = set(correct)

ans = 0
for p in correct:
  ans += penalty[p]
      
print(' '.join([str(len(correct)), str(ans)]))

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
ps = [list(map(str, input().split())) for _ in range(M)]
ans = [0,0]
cnt = [0]*(N+1)
memo = [0]*(N+1)
for i in range(M):
    p = int(ps[i][0])
    s = ps[i][1]
    if memo[p] == 1:
        continue
    else:
        if s == "WA":
            ans[1] += 1
            cnt[p] += 1
        else:
            ans[0] += 1
            cnt[p] += 1
            memo[p] = 1

for i in range(1,N+1):
    if memo[i] == 0:
        ans[1] -= cnt[i]
        
print(*ans)

Submission status: Accepted

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

penalty_list = [0]*n #問題ごとのACが出るまでのペナルティ数
result_list = [0]*n #問題ごとの最終的にACが出たかどうかのリスト

for i in range(m):
  if sub_list[i][1] =='AC':
    result_list[int(sub_list[i][0]) -1] = 1
  else:
    if result_list[int(sub_list[i][0]) -1] == 0:
      penalty_list[int(sub_list[i][0]) -1] += 1

ac_count = 0
wa_count = 0
for i in range(n):
  if result_list[i] == 1:
    ac_count += 1
    wa_count += penalty_list[i]

print(f'{ac_count} {wa_count}')

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
AClst=[0]*n
WAlst=[0]*n
AC=0
WA=0
for i in range(m):
  res = input().rstrip().split(' ')
  no=int(res[0])
  ans=str(res[1])
  if AClst[no-1]==0 and ans=="WA":
    WAlst[no-1]+=1
  elif AClst[no-1]==0 and ans=="AC":
    AClst[no-1]=1
for j in range(n):
  if AClst[j]==0 and WAlst[j]>0:
    WAlst[j]=0
  AC+=AClst[j]
  WA+=WAlst[j]
print(AC, WA)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
WA = [0] * (N+1)
AC = [0] * (N+1)
Q = [list(input().split()) for _ in range(M)]
for p, s in Q:
  p = int(p)
  if AC[p] == 1:
    continue
  if s == "WA":
    WA[p] += 1
  else:
    AC[p] = 1
ans = 0
for w, a in zip(WA, AC):
  if a:
    ans += w
print(sum(AC), ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def II(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
ans,pena=0,0
N,M=MI()
P=[0]*N
PENA=[0]*N
for i in range(M):
  p,s=input().split()
  p=int(p)
  p-=1
  if s=='AC':
    if P[p]==0:
      ans+=1
      P[p]=1
      if PENA[p]!=0:
        pena+=PENA[p]
  if s=='WA':
    if P[p]==0:
      PENA[p]+=1
print(ans,pena)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
A = [False] * N
B = [0] * N
cnt = 0
for i in range(M):
    p, S = input().split()
    if not A[int(p) - 1]:
        if S == 'AC':
            cnt += 1
            A[int(p) - 1] = True
        else:
            B[int(p) - 1] += 1
_cnt = 0
for i in range(N):
    if A[i]:
        _cnt += B[i]
print(cnt, _cnt)

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())
    
AC_list=[0]*N
pena=[0]*N
for i in range(M):
    if S[i]=='AC':
        AC_list[int(p[i])-1]+=1
    else:
        if AC_list[int(p[i])-1]==0:
            pena[int(p[i])-1]+=1
num=0
num1=0
for i in range(N):
    if AC_list[i]!=0:
        num+=1
        num1+=pena[i]
print(num ,num1)

Submission status: Accepted

Solution code:

def resolve():
    # WAの数はACを出した問題だけ数える
    N, M = map(int, input().split())

    ans = [False]*N
    WA = [0]*N
    ac, wa_tot = 0, 0
    for _ in range(M):
        q, s = input().split()
        q = int(q)-1
        if ans[q]:
            continue
        if s == "AC":
            ans[q] = True
            ac += 1
            wa_tot += WA[q]
        if s == "WA":
            WA[q] += 1

    print(ac, wa_tot)

if __name__ == "__main__":
    resolve()

Submission status: Accepted

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

wa_n = [0] * n
ac_n = [0] * n

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


print(sum(ac_n), sum(list(itertools.compress(wa_n, ac_n))))

Submission status: Accepted

Solution code:
# !/usr/bin/python3

"""
https://atcoder.jp/contests/abc151/tasks/abc151_c
Welcome at atcoder
"""


if __name__ == "__main__":
    n, m = list(map(int, input().split()))

    accepted = [False for _ in range(n+5)]
    wrong = [0 for _ in range(n+5)]
    ac = wa = 0

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

        if accepted[p]: continue
        elif s == "WA": wrong[p] += 1
        elif s == "AC":
            ac += 1
            wa += wrong[p]
            accepted[p] = True

    print(f"{ac} {wa}")

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
if m > 0:
    p, s = zip(* [input().split() for _ in range(m)])
else:
    p = []
    s = []

ac_dict = {str(i): False for i in range(1, n + 1)}
wa_dict = {str(i): 0 for i in range(1, n + 1)}
ac_num = 0
wa_num = 0
for p_i, s_i in zip(p, s):
    if ac_dict[p_i] == False:
        if s_i == 'AC':
            ac_num += 1
            wa_num += wa_dict[p_i]
            ac_dict[p_i] = True
        elif s_i == 'WA':
            wa_dict[p_i] += 1
print('{} {}'.format(ac_num, wa_num))

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
cnt = [0]*n
total = [0]*n
for i in range(m):
    P=list(input().split())
    p = int(P[0]) - 1
    if P[1] == 'WA' and cnt[p] == 0:
        total[p] += 1
    if P[1] == 'AC' and cnt[p] == 0:
        cnt[p] = True
ans = 0
for i in range(n):
    if cnt[i] == True:
        ans += total[i]
print(sum(cnt),ans)

Submission status: Accepted

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

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

AC = 0
PN = 0
for i in range(N):
    if L[i][0]:
        AC += 1
        PN += L[i][1]
print(AC, PN)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    n, m = [int(x) for x in input().split()]
    ac = set()
    pen = defaultdict(int)
    pp = 0
    for _ in range(m):
        p, S = [x for x in input().split()]
        if p not in ac and S == 'AC':
            ac.add(p)
            pp += pen[p]
        else:
            if not p in ac:
                pen[p] += 1

    print(len(ac), pp)

t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""


"""

Submission status: Accepted

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

Done = [False] * N
W = [0] * N
AC = 0
WA = 0
for _ in range(M):
    p, S = input().split()
    p = int(p) - 1
    if Done[p]:
        continue
    else:
        if S == 'WA':
            W[p] += 1
        else:
            AC += 1
            WA += W[p]
            Done[p] = True
print(AC, WA)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
from collections import defaultdict

(n, m), d, a, b = map(int, input().split()), defaultdict(int), 0, 0
for i in range(m):
	p, s = input()[:-1].split(); p = int(p)
	if d[p] == sys.maxsize: continue
	if s == 'WA': d[p] += 1
	if s == 'AC': b += abs(d[p]); a += 1; d[p] = sys.maxsize
print(a, b)

Submission status: Accepted

Solution code:
import numpy as np
N, M = map(int, input().split())
l = np.zeros((N, 2), dtype = int)
for i in range(M):
    p, S = map(str, input().split())
    if S == 'AC':
        l[int(p) - 1, 0] = 1
    elif S =='WA' and l[int(p) - 1, 0] == 1:
        continue
    else:
        l[int(p) - 1, 1] += 1
print(np.sum(l[:, 0]), np.sum(l[l[:, 0] == 1, 1]))

Submission status: Accepted

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

Submission status: Accepted

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

for _ in range(m) :
    pS[_][0] = int(pS[_][0])

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

for i in range(m) :
    if pS[i][1] == "AC" :
        if ac[pS[i][0]-1] == 0 :
            ac[pS[i][0]-1] += 1
    elif pS[i][1] == "WA" :
        if ac[pS[i][0]-1] == 0 :
            wa[pS[i][0] - 1] += 1

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

print(sum(ac),awa)

Submission status: Accepted

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

judge = [False]*N
WAcnt = [0] * N
ACcnt = 0
for i in range(M):
    p,S = (x for x in input().split())
    p = int(p)
    if judge[p-1] == False:
        if S == "AC":
            judge[p-1] = True
            ACcnt += 1
        else:
            WAcnt[p-1] += 1

WAans = 0
for i in range(N):
    if judge[i] == True:
        WAans += WAcnt[i]

print(ACcnt,WAans)

Submission status: Accepted

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

correct = [0] * N
penalty = [0] * N
for p, s in ps:
    p = int(p)
    if correct[p-1] == 1:
        continue
    if s == 'AC':
        correct[p-1] = 1
    else:
        penalty[p-1] += 1
print(sum(correct), sum([p*c for p, c in zip(penalty, correct)]))

Submission status: Accepted

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

q=['WA' for i in range(n)]
w=[0 for i in range(n)]
ans=0
pen=0
for i in range(m):
    p,s=input().split()
    pi=int(p)-1
    if s=='AC' and q[pi]=='WA':
        ans+=1
        pen+=(w[pi])
        q[pi]='AC'
    else:
        w[pi]+=1
        

        
print(ans,pen)

Submission status: Accepted

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

cnt = [[0, 0] for _ in range(N + 1)]
for p, s in X:
    if s == "AC":
        cnt[p][0] = 1
    elif cnt[p][0] == 0:
        cnt[p][1] += 1

ac = sum(v for v, _ in cnt)
wa = 0
for i in range(N + 1):
    if cnt[i][0] == 1:
        wa += cnt[i][1]
print(ac, wa)

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())
    
AC = [0]*N
WA = [0]*N
ACcount = 0
WAcount = 0
for i in range(M):
    if AC[int(P[i])-1]==0:
        if S[i] == 'WA':
            WA[int(P[i])-1] += 1
        if S[i] == 'AC':
            ACcount += 1
            AC[int(P[i])-1] = 1 
for i in range(N):
    if AC[i] == 1:
        WAcount += WA[i]
print(ACcount,WAcount)