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())
PS = sorted([input().split() for i in range(m)], key=lambda x:x[0])
PS += [["",""]]
ac = 0
wa = 0

pre = ""
wa_tmp=0
ac_tmp=0

# if PS[0][1] == "WA":
#     wa_tmp += 1

pre = ""
for p,s in PS:
    if pre!=p:
        wa_tmp=0
        ac_tmp=0
    if s == "AC":
        if not ac_tmp:
            ac+=1 
            wa+=wa_tmp
            wa_tmp=0
            ac_tmp+=1
    elif s == "WA":
        wa_tmp+=1
    pre = p

print(ac,wa)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
ans = {i:0 for i in range(N+1)}
pn = {i:0 for i in range(N+1)}
ans_num = 0
pn_num = 0

for i in range(M):
    p_tmp, S_tmp = input().split()
    p_tmp = int(p_tmp)
    
    if ans[p_tmp] == 0 and S_tmp == "AC":
        ans[p_tmp] = 1
        ans_num += 1
        pn_num += pn[p_tmp]
        
    elif ans[p_tmp] != 1 and S_tmp == "WA":
        pn[p_tmp] = pn[p_tmp] + 1
        
print(ans_num, pn_num)

Submission status: Accepted

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

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

for i in range(m):
    if ps[i][1] == "AC" and AC[int(ps[i][0]) - 1] == 0:
        # ac += 1
        AC[int(ps[i][0]) - 1] = 1
    
    if ps[i][1] == "WA" and AC[int(ps[i][0]) - 1] == 0:
        # wa += 1
        WA[int(ps[i][0]) - 1] += 1

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

print(str(ac) + " " + str(wa))

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
li=[input().split() for i in range(m)]
 
ac=set()
wa=0
 
q=[[0,-1] for i in range(n+1)]
 
for x,y in li:
  if y=="AC" and q[int(x)][1]==-1: #AC出したらこれまでのwaを答えに足して、それ以降はカウントされないようにする
    wa+=q[int(x)][0]
    q[int(x)][1]=0
    ac.add(x)
  elif y=="WA" and q[int(x)][1]==-1:
    q[int(x)][0]+=1
 
print(len(ac),wa)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
fin=[False]*(10**5+10)
pena=0
corr=0
tmp=[0]*(10**5+10)
for _ in range(m):
  p,s=input().split()
  p=int(p)
    
  if fin[p]==True:
    continue
    
  if s=="WA":
    tmp[p]=tmp[p]+1
  if s=="AC":
    corr+=1
    pena+=tmp[p]
    fin[p]=True
        
print(corr,pena)

Submission status: Accepted

Solution code:
# M submissions
# i-th problem, pi-th problem recieved Si verdict ("AC" or "WA")
# Penalty: recieve WA before AC

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

problem_ac = set()
problem_penalty = dict()

for _ in range(M):
    problem, verdict = input().split()

    if problem in problem_ac:
        continue
    elif verdict == "WA":
        problem_penalty[problem] = problem_penalty.get(problem, 0) + 1
    elif verdict == "AC":
        problem_ac.add(problem)

num_ac = len(problem_ac)
num_penalties = sum(penalty for problem, penalty in problem_penalty.items() if problem in problem_ac)
print(num_ac, num_penalties)

Submission status: Accepted

Solution code:
def main():
    N, M = map(int, input().split())
    pre = set()
    wa = [0] * N
    ans, ans2 = 0, 0
    for _ in range(M):
        p, s = input().split()

        if int(p) in pre:
            continue

        if s == 'AC':
            pre.add(int(p))
            ans += 1
        else:
            wa[int(p)-1] += 1

    for i in range(N):
        if (i+1) in pre:
            ans2 += wa[i]
    print(ans, ans2)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
pS = [tuple(input().split()) for i in range(M)]
pS.sort(key=lambda x: x[0])
problems = [0]*N
AC = 0
penalty = 0

for p, S in pS:
    p = int(p)
    if problems[p-1] < 0:
        continue
    else:
        if S == "AC":
            penalty += problems[p-1]
            problems[p-1] = -1
            AC += 1

        else:
            problems[p-1] += 1

print(AC, penalty)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10000000)
# input = sys.stdin.readline
from bisect import *
from collections import *
# from heapq import *
# import functools
# import itertools
# import math
INF = 500000
mod = 10**9+7

N, M = map(int, input().split())
flg = [0] * N
cnt = [0] * N
ans = 0
for i in range(M):
    p, S = input().split()
    p = int(p)-1
    if S == 'WA':
        if flg[p] == 0:
            cnt[p] += 1
    else:
        if flg[p] == 0:
            flg[p] = 1
            ans += cnt[p]
print(sum(flg), ans)

Submission status: Accepted

Solution code:
n,m = list(map(int,input().split()))
a = [0]*n
s=0
pe=0
for i in range(m):
    p,v = input().split()
    p = int(p)
    if(v=="WA"):
        if(a[p-1] != 1):
            a[p-1] = a[p-1]-1
    elif(v == "AC"):
        if(a[p-1]==1):
            continue
        else:
            pe-=a[p-1]
            a[p-1] = 1
            s+=1
print(s,pe)

Submission status: Accepted

Solution code:
[N, M] = [int(i) for i in input().split()]
submits = [0]*M

for i in range(M):
    submits[i] = input().split()

ac = 0

acs = set([])
was = {}

for i in range(1, N+1):
    was[str(i)] = 0

for item in submits:
    if item[0] in acs:
        continue
    elif item[1] == "WA":
        was[item[0]] += 1
    else:
        ac += 1
        acs.add(item[0])
        
pen = 0

for key in was.keys():
    if key in acs:
        pen += was[key]
        
print(' '.join([str(ac), str(pen)]))

Submission status: Accepted

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

Submission status: Accepted

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

r = [False]*n
q = [0]*n

res = 0

for _ in [0]*m:
    p,s = map(str,input().split())
    p = int(p)-1
    if s == 'AC':
        if not r[p]:
            r[p] = True
            res += q[p]
    else:
        q[p] += 1

print(sum(r),res)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import numpy as np

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

ac = np.zeros(n)
wa = np.zeros(n)

for _ in range(m):
    p, s = input().split()
    p = int(p) - 1
    if ac[p] == 1:
        continue
    if s == "WA":
        wa[p] += 1
    else:
        ac[p] = 1

acc = 0
wac = 0
for a, w in zip(ac, wa):
    if a == 1:
        acc += 1
        wac += w

print(acc, int(wac))

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
ans = 0
ans2 = 0
ps = [list(map(str,input().split())) for i in range(M)]
ppp = [tuple(i) for i in ps]
pss = set(sorted(ppp))
check = [[0] for i in range(N+1)]
for i in pss:
    if "AC" in i:
        ans += 1
for i in ps:
    i[0] = int(i[0])
for i in range(len(ps)):
    if ps[i][1] == "WA" and check[ps[i][0]] != [-1]:
        check[ps[i][0]][0] += 1
    if ps[i][1] == "AC" and check[ps[i][0]] != [-1]:
        ans2 += check[ps[i][0]][0]
        check[ps[i][0]][0] = -1
print(ans, ans2)

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
dic = dict(zip(list(range(1,N+1)),[0]*N))
bl = [True]*N
ac,wa = 0,0
for i in range(M):
    p,s = input().split()
    if s == "WA":
        dic[int(p)] += 1
    elif s == "AC":
        if bl[int(p)-1]:
            ac += 1
            wa += dic[int(p)]
            bl[int(p)-1] = False
print(ac,wa)

Submission status: Accepted

Solution code:
import sys

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

if m == 0:
  print('{} {}'.format(0, 0))
  sys.exit()

result = {}
ac_result = 0
wa_result = 0
for i in range(m):
  x = input().split()
  p = int(x[0])
  s = x[1]
  if s == 'AC':
    try:
      if result[p] == 'AC':
        pass
      else:
        wa_result += result[p]
        ac_result += 1
        result[p] = 'AC'
    except:
      ac_result += 1
      result[p] = 'AC'
      pass
  else:
    try:
      if result[p] == 'AC':
        pass
      else:
        result[p] += 1
    except:
      result[p] = 1

print('{} {}'.format(ac_result, wa_result))

Submission status: Accepted

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

total = [0 for a in range(N)]
correct = [0 for a in range(N)]
for ptext, S in pS:
  p = int(ptext)-1
  if S == 'WA' and correct[p] == 0:
    total[p] += 1
  elif S == 'AC':
    correct[p] = 1

for i in range(N):
  if correct[i] == 0:
    total[i] = 0
print(sum(correct), sum(total))

Submission status: Accepted

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


def main():
    sc = Scan()
    N, M = sc.intarr()
    array = []
    for i in range(M):
        p, s = sc.strarr()
        array.append([p, s])

    data = {}
    AC_cnt = 0
    WA_cnt = 0
    for ss in array:
        if ss[0] not in data:
            if ss[1] == 'WA':
                data[ss[0]] = [0, 1]
            elif ss[1] == 'AC':
                data[ss[0]] = [1, 0]
        elif data[ss[0]][0] == 0:
            if ss[1] == 'WA':
                data[ss[0]][1] += 1
            elif ss[1] == 'AC':
                data[ss[0]][0] += 1

    for key in data:
        if data[key][0] != 0:
            AC_cnt += 1
            WA_cnt += data[key][1]

    print(AC_cnt, WA_cnt)


def perm(p):
    if len(p) == 1:
        return [p]
    else:
        s = []
        for i in range(len(p)):
            q = p[i]
            r = perm(p[:i]+p[i+1:])
            for t in r:
                s.append([q] + t)
        return s


class Scan():

    def intarr(self):
        num_array = list(map(int, input().split()))
        return num_array

    def intarr_ver(self, n):
        return [int(input()) for _ in range(n)]

    def strarr(self):
        line = input()
        array = line.split(' ')
        array[-1] = array[-1].strip('\n')
        return array


def display(array):
    for a in range(len(array)):
        if len(array) - a != 1:
            print(array[a], end=' ')
        else:
            print(array[a])


def gcd(a, b):  # 最大公約数
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):  # 最小公倍数
    return a * b // gcd(a, b)


main()

Submission status: Accepted

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

def main():
    syutudai,teisyutsu_count = map(int, input().split())
    result_list = [input().split() for i in range(teisyutsu_count)]
    penalty_count = [0] * syutudai

    penalty_sum = 0
    ac_count = 0
    for result in result_list:
        problem = int(result[0])
        result = result[1]
        if penalty_count[problem-1] == -1:
            continue
        if result == 'AC':
            penalty_sum += penalty_count[problem-1]
            penalty_count[problem-1] = -1
            ac_count += 1
        else:
            penalty_count[problem-1] = penalty_count[problem-1] + 1

    print('{} {}'.format(ac_count,penalty_sum))




if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n,m = (int(i) for i in input().split())
p = []
ac = 0
wa = 0
for i in range(m):
  a,b = (input().split())
  a = int(a)
  p.append([a,b])
x = [0]*n
w = [0]*n
for i in range(m):
  tmp = p[i][0] - 1
  if p[i][1] == "AC":
    x[tmp] = 1
  elif p[i][1] == "WA":
    if x[tmp] == 0:
      w[tmp] += 1
for i in range(n):
  if x[i] == 1:
    ac += 1
    wa += w[i]
print(ac,wa)

Submission status: Accepted

Solution code:
n,m = map(int, input().split())
a = [list(input().split()) for i in range(m)]
b=[[0,0] for i in range(n)]
AC=0
WA=0

for i in range(m):
    if b[int(a[i][0])-1][0]==0 and a[i][1]=='AC':
        b[int(a[i][0]) - 1][0]+=1
    elif b[int(a[i][0])-1][0]==1 and a[i][1]=='AC':
        continue
    elif b[int(a[i][0])-1][0]==0 and a[i][1]=='WA':
        b[int(a[i][0]) - 1][1] +=1
    elif b[int(a[i][0])-1][0]==1 and a[i][1]=='WA':
        continue

for i in range(n):
    if b[i][0]>=1:
        AC+=1
    if b[i][0]>=1 and b[i][1]>=1:
        WA+=b[i][1]
print(AC,WA)

Submission status: Accepted

Solution code:

def main():
    n, m = map(int, input().split())
    dic = {}
    ac, wa = "AC", "WA"
    for _ in range(m):
        p, s = input().split()
        if p not in dic:
            dic[p] = [0, False]  # (wa_count, accepted)
        if dic[p][1]:
            continue
        if s == wa:
            dic[p][0] += 1
        else:
            dic[p][1] = True

    ac_num, wa_num = 0, 0
    for _, (wa_count, accepted) in dic.items():
        ac_num += accepted
        if accepted:
            wa_num += wa_count

    print(ac_num, wa_num)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

d = {}
ans = [0, 0]

for i in range(M):
  p, s = input().split()
  r = d.get(p, 0)
  if r == 'AC':
    pass
  else:
    if s == 'AC':
      ans[0] += 1
      d[p] = 'AC'
    else:
      ans[1] += 1
      d[p] = r + 1

for key, value in d.items():
  if value != 'AC':
    ans[1] -= value

print(*ans)

Submission status: Accepted

Solution code:
n,m = list(map(int, input().split()))
aclist=[0 for i in range(n)]
ac=0
wa=[0 for i in range(n)]
for i in range(m):
    j = list(input().split())
    j[0]=int(j[0])
    if aclist[j[0]-1]==0:
        if j[1]=='AC':
            ac+=1
            aclist[j[0]-1]=1
        elif j[1]=='WA':
            wa[j[0]-1]+=1
ans=0
for i,j in enumerate(aclist):
    if j==1:
        ans+=wa[i]
print(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 = input().split(' ')
    p = int(p)

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

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

print(AC_cnt, WA_cnt)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
P, S = [], [] 
PS = set()
for _ in range(m):
    p, s = map(str, input().split())
    P.append(int(p))
    S.append(s)
    PS.add((int(p),s))

gotou = 0

sudeni_seitou = set()
for i in range(m):
    if S[i] == 'AC':
        sudeni_seitou.add(P[i])

mou_sudeni_seitou = set()
for i in range(m):
    if S[i] == 'AC':
        mou_sudeni_seitou.add(P[i])
    elif (S[i] == 'WA') and (P[i] in sudeni_seitou) and (P[i] not in mou_sudeni_seitou):
        gotou += 1

seitou = len(sudeni_seitou)

print(str(seitou) + ' ' + str(gotou))

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
P = []
S = []
for i in range(M):
    p,s = input().split()
    p = int(p)
    P.append(p)
    S.append(s)
#print(P)
#print(S)
AC = 0
WA = 0
AC_f = [0] * (N + 1)
WA_f = [0] * (N + 1)
#print(AC_f)
for i in range(M):
    if AC_f[P[i]] == 0:
        if S[i] == "AC":
            AC += 1
            AC_f[P[i]] = 1
        else:
            WA += 1
            WA_f[P[i]] += 1
for i in range(1,N+1):
    if AC_f[i] == 0 and WA_f[i] != 0:
        WA -= WA_f[i]
print(AC,WA)

Submission status: Accepted

Solution code:
n,m = map(int, input().split())
wrong = [0] * n
wrongAns = [0] * n
goodAns = [0] * n
badAnsF = 0
greatAnsF = 0
#print(wrong)
for i in range(m):
  p,s = input().split()
  if(s == "WA"):
    wrong[int(p)-1] += 1
  elif(s == "AC"):
    if(goodAns[int(p)-1] == 0):
      wrongAns[int(p)-1] = wrong[int(p)-1]
      goodAns[int(p)-1] = 1
    
for i in wrongAns:
  badAnsF += i
for i in goodAns:
  greatAnsF += i

print(greatAnsF,badAnsF)

Submission status: Accepted

Solution code:
a = input().split(" ")
n = int(a[0])
m = int(a[1])
ac = dict()
wa = dict()
for i in range(m):
    v = input().split(" ")
    q = int(v[0])
    res = v[1]
    if q in ac:
        continue
    if res == "AC":
        ac[q] = wa.get(q, 0) + 1
    elif res == "WA":
        wa[q] = wa.get(q, 0) + 1

acs = len(ac)
was = 0
for k in ac.keys():
    was = was + wa.get(k, 0)
print(str(acs) + " " + str(was))

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,input().split())
dic={}
w=ac=0
for _ in range(m):
  a,b=input().split()
  if a in dic:
    if dic[a][1]:
      if b == 'WA':
        dic[a][0]+=1
      else:
        ac+=1
        w+=dic[a][0]
        dic[a][1]=False
  else:
    dic[a]=[0,True]
    if b == 'WA':
      dic[a][0]+=1
    else:
      ac+=1
      dic[a]=[0,False]

print(ac,w)

Submission status: Accepted

Solution code:
N, M = [int(a) for a in input().split()]
p = [0] * M
S = [None] * M

num_WA = [0] * N
num_AC = [0] * N

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

    if S[i] == "AC":
        num_AC[p[i]-1] = 1
    else:
        if num_AC[p[i]-1] == 0:
            num_WA[p[i]-1] += 1

nAC = sum(num_AC)
nWA = 0
for i in range(N):
    if num_AC[i] == 1:
        nWA += num_WA[i]

print(nAC, nWA)

Submission status: Accepted

Solution code:
N,M = list(map(int,input().split()))
S = [0]*N #間違った数を入れる。正解は-1
ac = 0
wa = 0
for i in range(M):
    p,s = input().split()
    p = int(p)
    #未正解の時
    if S[p-1] != -1:
        #間違えると
        if s == "WA":
            S[p-1] += 1
        #正解したら、
        else:
            wa += S[p-1]
            ac += 1
            S[p-1] = -1
    #すでに正解している時
    else:
        pass
    """
    print("p,s=",p,s)
    print("i",i)
    print(S)
    print("ac,wa=",ac,wa)
    """
print(ac,wa)

Submission status: Accepted

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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

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

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

print(sum(ac), sum(pn))

Submission status: Accepted

Solution code:
from collections import defaultdict
n,m = map(int,input().split())
d = defaultdict(lambda:['WA',0])

for _ in range(m):
    i,j = input().split()
    if d[i][0] == 'WA':
        d[i][1] += 1
        d[i][0] = j
        
res = [d[x][1]-1 for x in d if d[x][0]=='AC']
print(len(res),sum(res))

Submission status: Accepted

Solution code:
import numpy as np

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

ac = 0
wa = 0
test = [0] * N
count = [0] * N
for i in range(M):
    p_i, s_i = input().split(" ")
    p_i = int(p_i) - 1
    if s_i == "AC":
        test[p_i] = 1
    elif test[p_i] != 1:
        count[p_i] += 1

test = np.array(test)
count = np.array(count)

score = np.sum(test)
pena = np.sum(test * count)
print(str(int(score)) + " " + str(int(pena)))

Submission status: Accepted

Solution code:
import collections
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        N, M = map(int, input().split())
        pS = []
        for _ in range(M):
            tmp = input().split()
            pS.append((int(tmp[0]), tmp[1]))

        ac = 0
        wa = 0
        s_dict = collections.defaultdict(lambda: True)
        wa_dict = collections.defaultdict(int)
        for i in range(M):
            p, s = pS[i]
            if s_dict[p]:
                if s == "AC":
                    ac += 1
                    wa += wa_dict[p]
                    s_dict[p] = False
                else:
                    wa_dict[p] += 1

        print(*[ac, wa])


# Run main
if __name__ == '__main__':
    AtCoder().main()

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
cnt = 0
ac_cnt = 0
wa_cnt = 0
ans_flag = 0
bp = -1
d = []
for i in range(m):
    a, b = map(str, input().split())
    d.append([a, b])
d.sort(key=lambda x: x[0])
# print(d)
for i in range(m):
    p, s = d[i][0], d[i][1]
    # print(p, s)
    if bp != p:
        cnt = 0
        ans_flag = 0
    if s == 'WA' and ans_flag == 0:
        cnt += 1
    elif s == 'AC' and ans_flag == 0:
        ac_cnt += 1
        wa_cnt += cnt
        cnt = 0
        ans_flag = 1
    bp = p

print(ac_cnt, wa_cnt)

Submission status: Accepted

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

import numpy as np
a = np.zeros(N)
flag = np.zeros(N)

for i in range(M):
  p, S = map(str, input().split())
  p = int(p)
  if flag[p-1] == 0 and S == "WA":
    a[p-1] += 1
  if S == "AC":
    flag[p-1] = 1
a = [int(np.sum(flag)), int(np.sum(flag * a))]
print(*a)

Submission status: Accepted

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

for i in range(0,M):
    pi,si = input().split()
    pi = int(pi)
    if ac[pi-1] == 0:
        if si == "WA":
            pn[pi-1] += 1
        else:
            ac[pi-1] = 1

for i in range(0,N):
    if ac[i] == 0:
        pn[i] = 0
        
print(sum(ac),sum(pn))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import numpy as np


DEBUG = False
dprint = print if DEBUG else lambda x : x

N, M = [int(str) for str in input().strip().split()]
ps = [[int(str) if str.isdecimal() else str for str in input().strip().split()] for _ in range(M)]

wa_d = dict()
ac_d = dict()
true_count = 0
pena = 0
for i in ps:
    if not i[0] in ac_d:
        if i[1] == 'WA':
            wa_d[i[0]] = wa_d.get(i[0], 0) + 1
        else:
            ac_d[i[0]] = None
            true_count += 1
            pena += wa_d.get(i[0], 0)

print(true_count, pena)

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
ps = []
for i in range(m):
  p,s = input().split()
  p = int(p)
  ps.append((p,s))
  
ans = [[0]*2 for _ in range(n)]
for i in range(m):
    if ans[ps[i][0]-1][1] == 1:
        continue
    if ps[i][1] == "AC":
        ans[ps[i][0]-1][1] = 1
        continue
    if ps[i][1] == "WA":
        ans[ps[i][0]-1][0]  += 1
        
p = 0
q = 0
for i in ans:
    if i[1] == 1:
        q += 1
        p += i[0]

print(q,p)

Submission status: Accepted

Solution code:
N, M = map(int, input().split(" "))
ac = 0
wa = 0
ans = [0] * N
wro = [0] * N
for i in range(M):
    p, s = input().split(" ")
    if ans[int(p)-1] == 0:
        if s == "AC":
            ac += 1
            ans[int(p)-1] = 1
            wa += wro[int(p)-1]
        else:
            wro[int(p)-1] += 1
print(str(ac) + " " + str(wa))

Submission status: Accepted

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

ac = 0
wa = dict()

done = dict()

for i in range(M):
    p, S = input().split()
    if p in done:
        continue
    if S == "AC":
        ac+= 1
        done[p] = True
    else:
        if p not in wa:
            wa[p] = 0
        wa[p] += 1

_wa = 0
for x in wa:
    if x in done:
        _wa += wa[x]

print(ac, _wa)

Submission status: Accepted

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

seikai_list = ['0'] * n
seikai_count = 0
penalty_count_list = [0] * n

for i in range(m):
    q_number = int(a_list[i][0]) - 1
    # 正解数について
    if seikai_list[q_number] == '0' and a_list[i][1] == 'AC':
        seikai_count += 1
        seikai_list[q_number] = '1'
    # ペナルティについて
    if seikai_list[q_number] == '0' and a_list[i][1] == 'WA':
        penalty_count_list[q_number] += 1 

penalty_count = 0
for i in range(n):
    if seikai_list[i] == '1':
        penalty_count += penalty_count_list[i]

print(seikai_count, penalty_count)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun Jan 12 21:17:12 2020

@author: over-
"""

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

Submission status: Accepted

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

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

answer = []
for i in range(M):
    [p, S] = [i for i in input().split()]
    answer.append((int(p), S))

matome = []
for i in range(N):
    matome.append([0, 0])

for (p, S) in answer:
    if S == 'AC':
        matome[p-1][0] = 1
    elif S == 'WA':
        if matome[p-1][0] == 0:
            matome[p-1][1] += 1

# 正答数とペナルティ
correct = 0
penalty = 0
for [ac, wa] in matome:
    if ac == 1:
        correct += 1
        penalty += wa

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, M = map(int,input().split())
list = [list(input().split()) for i in range(M)]
flag_ac = [0] * N
penalty_score = [0] * N
ans_seitou = 0
ans_penalty = 0
for i in range(M):
    if list[i][1] == "AC":
        if flag_ac[int(list[i][0]) - 1] == 0:
            flag_ac[int(list[i][0]) - 1] = 1
            ans_seitou += 1
            ans_penalty += penalty_score[int(list[i][0]) - 1]

    if list[i][1] == "WA":
        if flag_ac[int(list[i][0]) - 1] == 0:
            penalty_score[int(list[i][0]) - 1] += 1

print(ans_seitou,ans_penalty)

Submission status: Accepted

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


sub = [list(input().split()) for _ in range(M)]

AC_set = set()
WA_dic = {}

AC_cnt = 0
WA_cnt = 0

for p, ans in sub:
    p = int(p)
    if ans == 'AC':
        if p not in AC_set:
            AC_cnt += 1
            AC_set.add(p)
    else:
        if p not in AC_set:
            if p not in WA_dic:
                WA_dic[p] = 1
            else:
                WA_dic[p] += 1

for p in AC_set:
    WA_cnt += WA_dic.get(p, 0)

print(AC_cnt, WA_cnt)

Submission status: Accepted

Solution code:
import sys
input=sys.stdin.readline
n,m=map(int,input().split())
AC=[False]*n
WA=[0]*n
for _ in range(m):
    p,s=input().split()
    p=int(p)-1
    if s=='AC':
        AC[p]=True
    else:
        if AC[p]:
            continue
        WA[p]+=1
ac=0
wa=0
for i in range(n):
    if AC[i]:
        ac+=1
        wa+=WA[i]
print(ac,wa)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
table = {}
ac = 0
pena = 0
pena_arr = [0 for _ in range(n + 1)]
for _ in range(m):
    a, b = input().split()
    a = int(a)
    if a in table:
        continue
    if b == "AC":
        ac += 1
        table[a] = True
    elif b == "WA":
        pena_arr[a] += 1
pena = 0
for i in range(1, n + 1):
    if pena_arr[i] > 0 and i in table:
        pena += pena_arr[i]
print(ac, pena)

Submission status: Accepted

Solution code:
from sys import stdin 
n,m = [int(x) for x in stdin.readline().rstrip().split()]
a = []
for i in range(m):
    a.append([x for x in stdin.readline().rstrip().split()])
ac = [0] * n
wa = [0] * n
WA = 0
for i in range(m):
    if a[i][1] == 'WA':
        wa[int(a[i][0])-1] += 1
    if a[i][1] == 'AC':
        if ac[int(a[i][0])-1] == 0:
            WA += wa[int(a[i][0])-1]
        ac[int(a[i][0])-1] = 1
print(sum(ac),WA)

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
T=[]
frag=[0 for y in range(N)]
p=[0 for y in range(N)]
a=0
for i in range(M):
  s=list(map(str,input().split()))
  T.append(s)
for i in range(M):
  if T[i][1]=='WA' and frag[int(T[i][0])-1]==0:
    p[int(T[i][0])-1]=p[int(T[i][0])-1]+1
  elif T[i][1]=='AC' and frag[int(T[i][0])-1]==0:
    a=a+1
    frag[int(T[i][0])-1]=1
for i in range(N):
  if frag[i]==0:
    p[i]=0
print(a,sum(p))

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()
    idx = int(p) -1
    if ac[idx]==1:
        continue
    else:
        if s == 'AC':
            ac[idx]=1
        else:
            wa[idx] += 1
w = sum([v for i, v in enumerate(wa) if ac[i]==1])
a = sum(ac)
print(a, w)

Submission status: Accepted

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

WA=[]
solved=[]
for i in range(1,N+1):
   a=[i,0]
   WA.append(a)
   b=[i,False]
   solved.append(b)

AC_count=0
WA_count=0
for i in range(M):
   if results[i][1]=="WA":
      if solved[results[i][0]-1][1]==False:
         WA[results[i][0]-1][1]+=1

   elif results[i][1]=="AC":
      if solved[results[i][0]-1][1]==False:
         AC_count+=1
         solved[results[i][0]-1][1]=True

for i in range(N):
   if solved[i][1]==True:
      WA_count+=WA[i][1]

print(AC_count,WA_count)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
a = [0]*N
b = [0]*N
pena = 0
for i in range(M):
    p, s = input().split()
    if s == 'WA' and a[int(p)-1] == 0:
        b[int(p)-1] += 1
    if s == 'AC' and a[int(p)-1] == 0:
        a[int(p)-1] = 1
        pena += b[int(p)-1]
print(sum(a),pena)

Submission status: Accepted

Solution code:
import numpy as np

def resolve():
    N, M = map(int, input().split())
    ACs = np.zeros(N)
    WAs = np.zeros(N)
    
    c_ac = 0
    c_wa = 0

    for i in range(M):
        p, s = input().split()
        if s == "WA":
            if ACs[int(p) - 1] == 0:
                WAs[int(p) - 1] += 1
        if s == "AC":
            ACs[int(p) - 1] += 1
            if ACs[int(p) - 1] == 1:
                c_ac += 1
                c_wa += WAs[int(p) - 1]

    print(int(c_ac), int(c_wa))
    

if __name__ == "__main__":
    resolve()