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

ac = 0
wa = 0
for _ in range(M):
    a,b = input().split()
    a = int(a)

    if not solved[a]:
        if b == "AC":
            wa += penalty[a]
            solved[a] = 1
        else:
            penalty[a] += 1

print(sum(solved),wa)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
AC = [0 for i in range(N)]
WA = [0 for i in range(N)]
a = [0 for i in range(N)]
for i in range(M):
  p, S = input().split()
  p = int(p)
  if S == 'AC':
    AC[p-1] = 1
    a[p-1] = 0
  else:
    if AC[p-1] == 0:
      WA[p-1] += 1
      a[p-1] += 1
c = sum(AC)
wa = sum(WA) - sum(a)
print(c, wa, sep=' ')

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
ac=[0]*(10**5+1)
temp=[0]*(10**5+1)
wa=[0]*(10**5+1)
for i in range(M):
  p,S=input().split()
  if ac[int(p)]==0:
    if S=="WA":
      temp[int(p)]+=1
    else:
      ac[int(p)]=1
for i in range(len(ac)):
  wa[i]=ac[i]*temp[i]
print(sum(ac),sum(wa))

Submission status: Accepted

Solution code:
from copy import deepcopy
import math
import string
import collections
from collections import Counter
from collections import deque
from decimal import Decimal
import sys
import fractions
from operator import itemgetter
import itertools
import copy


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


def gcd(a, b):
    while(b != 0):
        a, b = b, a % b
    return a


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
n, m = map(int, input().split())
tmp = [None]*(10**5+10)
for i in range(len(tmp)):
    tmp[i] = [None]*2
for i in range(len(tmp)):
    tmp[i][0] = False
    tmp[i][1] = 0
for _ in range(m):
    p, s = input().split()
    #print(p, s)
    if tmp[int(p)][0] == False and s == 'WA':
        tmp[int(p)][1] += 1
    if s == 'AC':
        tmp[int(p)][0] = True
ans = 0
penalty = 0
for i in range(len(tmp)):
    if tmp[i][0]:
        ans += 1
    if tmp[i][0] == True and tmp[i][1] != None:
        penalty += tmp[i][1]
print(ans, penalty)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
AC_flags = [False] * N
WA_counter = [0] * N
for _ in range(M):
    p, s = input().split()
    p = int(p) - 1
    if AC_flags[p]:
        continue
    elif s == 'WA':
        WA_counter[p] += 1
    else:
        AC_flags[p] = True
penalty = 0
for i in range(N):
    penalty += AC_flags[i] * WA_counter[i]
print(sum(AC_flags), penalty)

Submission status: Accepted

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

print(AC, WA)

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
A = [0 for _ in range(N+1)]
B = [0 for _ in range(N+1)]
for _ in range(M):
    p,S = input().split()
    p = int(p)
    if S=="AC":
        if A[p]==0:
            A[p]=1
    else:
        if A[p]==0:
            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:
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n,m = readInts()
dic = defaultdict(int)
A = set()
for i in range(m):
    a,b = input().split()
    if dic['AC'+a] != 1:
        if b == 'AC':
            dic['AC'] += 1
            dic['AC'+a] = 1
        else:
            dic['WA'] += 1
            dic['WA'+a] += 1
    A.add(a)
for a in A:
    if dic['AC'+a] != 1:
        dic['WA'] -= dic['WA'+a]
print(dic['AC'],dic['WA'])

Submission status: Accepted

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

P = [0] * (n+1)
pena = [0] * (n+1)
for p,s in ps:
    p = int(p)
    if s == "WA":
        if P[p] == 0: pena[p] += 1
    else:
        P[p] = 1
ans = [0,0]
for p,pe in zip(P,pena):
    p = int(p)
    if p == 0: continue
    ans[0] += 1
    ans[1] += pe
print(" ".join(map(str, ans)))

Submission status: Accepted

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

a = [0]*n
b = [0]*n

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

c = 0
d = 0
for i in range(n):
    if a[i] != 0:
        c += a[i]
        d += b[i]
print(c, d)

Submission status: Accepted

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

w_a = [0]*n
a_c = [0]*n
for i in range(m):
    p,s = list(input().split())
    p = int(p)
    if s == 'WA' and (a_c[p-1] == 0):
        w_a[p-1] += 1
    else:
        a_c[p-1] = 1

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

print(str(ac), str(wa))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
wa = [0]*N
ac = [0]*N

for i in range(M):
  p, s = map(str, input().split())
  p = int(p)
  if (s=='WA') and (ac[p-1]==0):
    wa[p-1] += 1
  else:
    ac[p-1] = 1
    
    
ans_ac = 0
ans_wa = 0
for i in range(N):
  if ac[i] == 1:
    ans_ac += 1
    ans_wa += wa[i]
    
print(str(ans_ac), str(ans_wa))

Submission status: Accepted

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

for _ in range(M):
    p, s = input().split()
    p = int(p)
    if Q[p][0] == 0:
        if s == "WA":
            Q[p][1] += 1
        else:
            AC += 1
            WA += Q[p][1]
            Q[p][0] = 1
    else:
        continue

print(AC, WA)

Submission status: Accepted

Solution code:
from collections import defaultdict
dic = defaultdict(int)
N, M = map(int, input().split())
P = []
S = []
wa = 0
ac = 0
for _ in range(M):
    p, s = input().split()
    p = int(p)
    if s=="AC":
        if not dic[p]==-1:
            wa+=dic[p]
            ac+=1
            dic[p]=-1
    elif s=="WA":
        if not dic[p]==-1:
            dic[p]+=1
print(ac, wa)

Submission status: Accepted

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

ac_ques = np.array([0]*n)
count = np.array([0]*n)

for _ in range(m):
    p,s = map(str, input().split())
    if ac_ques[int(p)-1] == 0:
        if s == "WA":
            count[int(p)-1] += 1
        else:
            ac_ques[int(p)-1] = 1

print(sum(ac_ques),sum(ac_ques * count))

Submission status: Accepted

Solution code:
def resolve():
    N, M = list(map(int, input().split()))
    isac = {}
    wa = {}
    ac = 0
    penalty = 0

    for _ in range(M):
        p, S = list(input().split())
        p = int(p)
        if p not in wa:
            wa[p] = 0
        if S == 'AC':
            if isac.get(p) != True:
                ac += 1
                penalty += wa[p]
                isac[p] = True
        else:
            wa[p] += 1

    print(ac, penalty)
    return


resolve()

Submission status: Accepted

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

isACs = [0] * N
numWAs = [0] * N
numPenalty = 0
for _ in range(M):
    p, res = input().split()
    p = int(p) - 1
    if res == 'AC':
        if not isACs[p]:
            numPenalty += numWAs[p]
        isACs[p] = 1
    else:
        numWAs[p] += 1

numAC = sum(isACs)
print(numAC, numPenalty)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
if m == 0:
  print('0 0')
  exit()
acornot = [False] * n
walst = [0] * n
acsum = 0
for i in range(m):
  subnum, res = input().split()
  subnum = int(subnum) - 1
  if acornot[subnum] == False:
    if res == 'AC':
      acornot[subnum] = True
      acsum += 1
    else:
      walst[subnum] += 1
for i in range(n):
  if acornot[i] == False:
    walst[i] = 0
print(acsum, sum(walst))

Submission status: Accepted

Solution code:
# unihernandez22
# https://atcoder.jp/contests/abc151/tasks/abc151_c
# implementation

class Counter(dict):
    def __missing__(self, i):
        return 0

class BoolDict(dict):
    def __missing__(self, i):
        return False

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

passed = 0
penalties = Counter()

ac = BoolDict()

for i in range(m):
    p, s = input().split()
    if not ac[p]:
        if s == "WA": penalties[p] += 1
        elif s == "AC":
            passed += 1
            ac[p] = True

x = 0
for i in penalties:
    if ac[i]:
        x += penalties[i]

print(passed, x)

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

acCount = 0
waCount = 0
check = [0] * n
waCheck = [0] * n

for i in range(m):
    p, s = map(str, input().split())
    # print(p,s)
    p = int(p)
    if (check[p - 1] == 0):
        if (s == 'WA'):
            waCheck[p - 1] += 1

        else:
            acCount += 1
            waCount += waCheck[p - 1]

            check[p - 1] = 1
    else:
        continue

print(acCount, waCount)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
AC = [False] * (N+1)
WA = [0] * (N+1)
for i in range(M):
    p, S = input().split()
    p = int(p)
    if S == 'AC':
        AC[p] = True
    else:
        if not AC[p]:
            WA[p] += 1
C_AC = 0
A_WA = 0
for i in range(N+1):
    if AC[i]:
        C_AC += 1
        A_WA += WA[i]

print(C_AC, A_WA)

Submission status: Accepted

Solution code:
N, M = map(int, input().split(' '))
P_n = [input().split(' ') for _ in range(M)]
ac = set([])
for p in P_n:
    if p[1] == 'AC':
        ac.add(p[0])
correct = 0
incorrect = 0
already = set([])
for p in P_n:
    if p[0] not in already and p[0] in ac:
        if p[1] == 'AC':
            correct += 1
            already.add(p[0])
        elif p[1] == 'WA':
            incorrect += 1
print(str(correct) + ' ' + str(incorrect))

Submission status: Accepted

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

check = {}

for i in range(M):
    p,S = input().split()
    p = int(p)
    if p not in check:
        if S == 'WA':
            check[p] = 1
        else:
            ans += 1
            check[p] = -1
    else:
        if S == 'WA' and check[p] != -1:
            check[p] += 1
        elif S == 'AC' and check[p] != -1:
            pen += check[p]
            ans += 1
            check[p] = -1

print(ans,pen)

Submission status: Accepted

Solution code:
#151
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=='WA' and AC[p-1]==0):
        WA[p-1] += 1
        continue
    if(s=='AC' and AC[p-1]==0):
        AC[p-1] += 1
        continue
WA_num = sum([WA[i] for i in range(len(AC)) if AC[i] == 1])
print(sum(AC), WA_num)

Submission status: Accepted

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

C0 = [0 for _ in range(N + 1)]  # 正答フラグ
C1 = [0 for _ in range(N + 1)]  # WA数

for p, s in PS:
    if C0[int(p)] == 0:
        if s == "AC":
            C0[int(p)] = 1  # 正解フラグを1にする
        else:
            C1[int(p)] += 1  # wa数を増やす


num_ac = sum(C0)
num_wa = sum([i * j for i, j in zip(C0, C1)])

print(num_ac, num_wa)

Submission status: Accepted

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

wa_l = [0]*(n+1)
ac_l = [False]*(n+1)
for _ in range(m):
    p,s = input().split()
    p = int(p)
    if s == 'WA' and not ac_l[p]:
        wa_l[p] += 1
    elif s == 'AC':
        ac_l[p] = True


ans_a = 0
ans_w = 0
for wa,ac in zip(wa_l,ac_l):
    if ac:
        ans_a+=1
        ans_w += wa

print(ans_a,ans_w)

Submission status: Accepted

Solution code:
import numpy as np
import sys

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

if M == 0:
    print("0 0")
    sys.exit()

P, S = np.array([[_ for _ in input().split()] for i in range(M)]).T

dict = {}
for i in range(M):
    if not (P[i] in dict):
        dict.update({P[i]: {"AC": False, "WA": 0}})

    value = dict[P[i]]

    if not value["AC"]:
        if S[i] == "AC":
            dict[P[i]] = {"AC": True, "WA": value["WA"]}
        else:
            dict[P[i]] = {"AC": False, "WA": value["WA"] + 1}

ac = sum(value["AC"] for value in dict.values())
wa = sum(value["WA"] if value["AC"] else 0 for value in dict.values())

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

Submission status: Accepted

Solution code:
f=lambda:input().split()
n,m=map(int,f())
n+=1
a,w=[0]*n,[0]*n
for _ in range(m):
  p,s=f()
  p=int(p)
  if s=='AC': a[p]=1
  elif a[p]<1: w[p]+=1
print(sum(a),sum(i*j for i,j in zip(a,w)))

Submission status: Accepted

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

    if m == 0:
        print(0, 0)
        return 
    else:
        wa = [0 for i in range(n+1)]
        ac = [0 for i in range(n+1)]

        for pro, s in p:
            if ac[int(pro)] == 0:
                if s == 'WA':
                    wa[int(pro)] += 1
                elif s == 'AC':
                    ac[int(pro)] += 1
        
        sum_wa = 0
        for isac, iswa in zip(ac, wa):
            if isac == 1:
                sum_wa += iswa

        print(sum(ac), sum_wa)
    

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    n, m = map(int, input().split())
    ac = [0] * n
    wanum = [0] * n
    for _ in range(m):
        p, s = input().split()
        p = int(p) - 1
        if ac[p]:
            continue
        else:
            if s == 'AC':
                ac[p] = 1
                wanum[p] *= -1
            else:
                wanum[p] -= 1
    wanum2 = [i for i in wanum if i > 0]
    print(sum(ac), sum(wanum2))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
q=[0 for q in range(n)]
t=[0 for q in range(n)]
p=[]
x=0
for i in range(m):
    a=list(input().split())
    p.append(a)
    a[0]=int(a[0])
    if a[1]=="AC":
        q[a[0]-1]=1
    else:
        if q[a[0]-1]==0:
            t[a[0]-1]+=1
            
for i in range(n):
    if q[i]==1:
        x+=t[i]
print(str(q.count(1))+" "+str(x))

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
ps = []
ans = [0,0]
wa = [0]*(n+1)
solved = [0]*(n+1)
for i in range(m):
  p,s = input().split()
  p = int(p)
  if not solved[p]:
    if s=="AC":
      ans[0]+=1
      ans[1]+=wa[p]
      solved[p]=1
    else:
      wa[p]+=1

print(ans[0],ans[1])

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
if m==0:
  print("{} {}".format(0,0))
else:
  ac_count=0
  wa_count=0
  ac_list=[0]*n
  wa_list=[0]*n
  for i in range(m):
    p,s=input().split()
    if ac_list[int(p)-1]==0:
      if s=="AC":
        ac_count+=1
        ac_list[int(p)-1]+=1
      else:
        wa_list[int(p)-1]+=1
  for k in range(n):
    if ac_list[k]==1:
      wa_count+=wa_list[k]
  print("{} {}".format(ac_count,wa_count))

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
p=[0]
p*=n
ac=set()
wa=0
for i in range(m):
    pi,si=input().split()
    pi=int(pi)
    if si=='AC' and not pi in ac:
        ac.add(pi) 
        wa+=p[pi-1]
    else:
        p[pi-1]+=1
ans=len(ac)
print(ans,wa,end=' ')

Submission status: Accepted

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

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

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

cnt=AC.count(0)
answer=len(AC)-cnt
ans=sum(WA)
print(answer,ans)

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
if M==0:
  print('0 0')
  exit()
AC=[0]*(N+1)
WA=[0]*(N+1)
for i in range(M):
  p,s=map(str,input().split())
  if s=='AC':
    key=int(p)
    AC[key]+=1
  elif s=='WA' and AC[int(p)]==0:
    WA[int(p)]+=1
for i in range(N+1):
  if AC[i]==0:
    WA[i]=0
ansc=AC.count(0)
ANSC=len(AC)-ansc
ANSW=sum(WA)
print(ANSC,ANSW)

Submission status: Accepted

Solution code:
from collections import defaultdict, deque
import sys, heapq, bisect, math, itertools, string, queue, copy, time
from fractions import gcd
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7
EPS = 10**-7

n, m = map(int, input().split())
memo = [[ 0,0 ] for i in range(n+1)] 
for i in range(m):
    p, s = input().split()
    p = int(p)
    if s == 'AC':
        memo[p][0] = 1
    elif s == 'WA':
        if memo[p][0] == 0:
            memo[p][1] += 1

ac, wa = 0, 0
for i in range(n+1):
    if memo[i][0] == 1:
        ac += 1
        wa += memo[i][1]
#print(memo)
print(*[ac, wa])

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

l=[0]*n
ll=[0]*n
no_ac=0
no_pen=0

for i in range(m):
  a,b=map(str,input().split())
  a=int(a)
  if b=='AC':
    if l[a-1]==0:      
      no_ac+=1
      l[a-1]=1
  else:
    if l[a-1]==0:
      ll[a-1]+=1

for i in range(n):
  if l[i]==1:
    no_pen+=ll[i]
print(no_ac,no_pen)

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
import sys
S=sys.stdin.readlines()
A=set()
WA=[0]*N
B=[0]*N
for i in range(M):
  p,t=S[i].split()
  p=int(p)
  if p not in A and t=="AC":
    A.add(p)
    B[p-1]+=WA[p-1]
  elif p not in A and t=="WA":
    WA[p-1]+=1
print(len(A))
print(sum(B))

Submission status: Accepted

Solution code:
N,M = (int(x) for x in input().split())
Problem = [False]*N
WACount = [0]*N

for T in range(0,M):
    p,s = input().split()
    p = int(p)
    if (not Problem[p-1]) and s=='AC':
        Problem[p-1] = True
    elif (not Problem[p-1]) and s=='WA':
        WACount[p-1] += 1
WACount = [x*y for (x,y) in zip(Problem,WACount)]
print('{} {}'.format(sum(Problem),sum(WACount)))

Submission status: Accepted

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

accurate=[False]*n

wa_count=[0]*n
for i in range(m):
    p, s=input().split()
    p=int(p)
    if accurate[p-1] is False and s=="WA":
        wa_count[p-1]+=1
    if accurate[p-1] is False and s=="AC":
        accurate[p-1]=True

ac_count=accurate.count(True)
wa=0
for i in range(n):
    if accurate[i]:
        wa+=wa_count[i]

print(ac_count, wa)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
acCheck = [False] * (N + 1)
waCntList = [0] * (N + 1)
waCnt = 0
for i in range(M):
    query = list(input().split())
    idx = int(query[0])
    if acCheck[idx]:
        continue
    if query[1] == "AC":
        waCnt += waCntList[idx]
        acCheck[idx] = True
    else:
        waCntList[idx] += 1
print(str(acCheck.count(True)), str(waCnt))

Submission status: Accepted

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

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

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

res = ac.count(1)

print(res, ans)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
penalty = {key: 0 for key in range(N+1)}
accept = {key: 0 for key in range(N+1)}
ac = 0
wa = 0

for i in range(M):
    tmp = list(input().split())
    if tmp[1] == 'WA':
        if accept[int(tmp[0])] == 0:
            penalty[int(tmp[0])] += 1
    else:
        if accept[int(tmp[0])] != 1:
            accept[int(tmp[0])] = 1
            ac += 1

for k, v in penalty.items():
    if accept[k] == 1:
        wa += v

print(ac, wa)

Submission status: Accepted

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

AC = set()
WA = [0]*N

for i in range(M):
    k,l = input().split()
    k = int(k)
    if l=="WA":
        if not k in AC:
            WA[k-1] += 1
    
    else:
        if not k in AC:
            AC.add(k)

counter = 0
for i in AC:
    counter += WA[i-1]

print("{} {}".format(len(AC),counter))

Submission status: Accepted

Solution code:
N,M=list(map(int,input().split()))
ans_list=[0]*N
AC_list=[0]*N
 
for m in range(M):
    p,s = input().split()
    p=int(p)
    
    #対象の問題：pがAC済か判定
    if AC_list[p-1]==1:
        continue
    else:
        if s=='AC':
            AC_list[p-1]=1
        else:
            ans_list[p-1]=ans_list[p-1]+1
    
ans_list_=[]
for n in range(N):
    ans_list_.append(AC_list[n]*ans_list[n])
    
print(sum(AC_list),sum(ans_list_))

Submission status: Accepted

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

Submission status: Accepted

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

AC=[0]*N
WA=[0]*N
WAtimes=0
ACtimes=0

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

print(ACtimes,WAtimes)

Submission status: Accepted

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

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

for i in range(m):
    if ac[ps[i]] == 1:
        continue
    if ss[i] == 'AC':
        ac[ps[i]] = 1
    else:
        wa[ps[i]] += 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())
A=0
PE=0
PRO=[[] for i in range(N)]
for i in range(M):
  P,S=input().split()
  P=int(P)-1
  PRO[P].append(S)
#print(PRO)
for i in range(N):
  tmp=0
  for j in range(len(PRO[i])):
    flag=False
    if PRO[i][j]=='AC':
      A+=1
      flag=True
    if PRO[i][j]=='WA':
      tmp+=1
    if flag:
      PE+=tmp
      break
print(A,PE)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import defaultdict
N, M = list(map(int, input().split()))
p = []
s = []
for _ in range(M):
    p_i, s_i = list(input().split())
    p += [int(p_i)]
    s += [s_i]

passed_problem = set()
penalty_problem = defaultdict(int)
for i, p_i in enumerate(p):
    if s[i] == 'WA':
        if not p[i] in passed_problem:
            penalty_problem[p[i]] += 1
    elif s[i] == 'AC':
        passed_problem.add(p[i])

# print(f"penalties:{penalty_problem}", file=sys.stderr)
penalty = 0
for n in passed_problem:
    penalty += penalty_problem[n]    

print("{} {}".format(len(passed_problem), penalty))

Submission status: Accepted

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

result = [False]*n
count = [0]*n
for _ in range(m):
  p,s = input().split()
  p = int(p)-1
  if not result[p]:
    if s == "AC": result[p] = True
    else: count[p] += 1
      
ng = 0
for i in range(n):
  if result[i]:
    ng += count[i]
print(result.count(True),ng)

Submission status: Accepted

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

for i in range(m):
	p,s=input().split()
	p=int(p)-1
	if s[0]=='A' and a[p]==0:
		a[p]=1
		ac+=1
		wa+=b[p]
	elif s[0]=='W':
		b[p]+=1
print(ac, wa)

Submission status: Accepted

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

l=[0 for i in range(n)]
ll=[0 for i in range(n)]
w=0
a=0
for i in range(m):
    p,s=input().split()
    if(l[int(p)-1]==1):continue
    if(s=="WA"):ll[int(p)-1]+=1
    if(s=="AC"):
        l[int(p)-1]=1
        w+=ll[int(p)-1]
        a+=1
print(a,w)

Submission status: Accepted

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

print(sum(acl),wa)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
ac=[0]*n
pn=[0]*n
for i in range(m):
  ps=input().split()
  p=int(ps[0])-1
  s=ps[1]
  if ac[p]:
    continue
  if s=='AC':
    ac[p]=1
  else:
    pn[p]+=1
acs=sum(ac)
pns=sum([x for i,x in enumerate(pn) if ac[i]])
print(acs, pns)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
L1=[0]*(N+1) #正解判定、iは問題分中と一致
L2=[0]*(N+1) #WAのカウント用、iは問題分中と一致

for i in range(M):
    p,S=input().split()
    if L1[int(p)]==1:
        pass
    else:
        if S=='AC':
            L1[int(p)]=1
        else:
            L2[int(p)]+=1

for j in range (N+1):
    if L1[j]==0 and L2[j]>0:
        L2[j]=0

print(sum(L1),sum(L2))

Submission status: Accepted

Solution code:
# import sys
# sys.setrecursionlimit(10 ** 6)
# from decorator import stop_watch
#
#
# @stop_watch
def solve(N, M, pSs):
    result = [0] * (N + 1)
    penalty = [0] * (N + 1)
    for p, S in pSs:
        if S == 'AC':
            result[p] = 1
        else:
            if result[p] == 0:
                penalty[p] += 1
    print(sum(result), sum([result[i] * penalty[i] for i in range(N + 1)]))


if __name__ == '__main__':
    N, M = map(int, input().split())
    pSs = []
    for _ in range(M):
        x = input().split()
        x[0] = int(x[0])
        pSs.append(x)
    solve(N, M, pSs)

Submission status: Accepted

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

arr = []
for i in range(m):
    c = input().split()
    arr.append([(int)(c[0]), c[1]])
#print("{}".format(arr))

penalty_log = {}    # まだACでないWAはここに溜める
success_log = set([])    # 一度でも成功したACはここに溜める

for elem in arr:
    if elem[1] == 'WA':
        if elem[0] not in success_log:
            if elem[0] not in penalty_log:
                penalty_log[elem[0]] = 1
            else:
                penalty_log[elem[0]] += 1

    elif elem[1] == 'AC':
        if elem[0] not in success_log:
            success_log.add(elem[0])

#print("success_log = {}".format(success_log))
#print("penalty_log = {}".format(penalty_log))

success = len(success_log) # ACの個数
penalty = 0 # WAの個数
for k, v in penalty_log.items():
    if k in success_log:
        penalty += v
print("{} {}".format(success, penalty))

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
ac=[0]+[0]*N
wa=[0]+[0]*N

for _ in range(M):
    number,ans=input().split()
    number=int(number)
    if ans=='AC':
        ac[number]=1
    elif ac[number]==0:
        wa[number]+=1

print(sum(ac),sum(c for i,c in enumerate(wa) if ac[i]==1))

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
correct = [False] * n
correct_count = 0
wrong_each_count = [0] * n
wrong_count = 0

for i in range(m):
    p, s = input().split()
    p = int(p)
    if correct[p - 1]:
        continue

    if s == 'AC':
        correct[p - 1] = True
        correct_count += 1
        wrong_count += wrong_each_count[p - 1]
    else:
        wrong_each_count[p - 1] += 1
print(correct_count, wrong_count)

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
ls=[list(input().split()) for _ in range(M)]
AC=[0]*(N+1)
WA=[0]*(N+1)
ans=0
for i in range(M):
  a=int(ls[i][0])
  b=ls[i][1]
  if b=="AC":
    if AC[a]!=1:
      AC[a]=1
      ans+=WA[a]
  else:
    if AC[a]!=1:
      WA[a]+=1
else:
  print(sum(AC),ans)

Submission status: Accepted

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

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

print('{} {}'.format(sum(ac), sum(wa)))