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が提出数
N, M = map(int, input().split())
 
submit = []
for _ in range(M):
  temp = [x for x in input().split()]
  submit.append(temp)
 
ac = [0]*(N + 1)
wa = [0]*(N + 1)
  
for i in range(M):
  result = submit[i][1]
  question = int(submit[i][0])
  
  if result == 'AC' and ac[question] == 0:
    ac[question] = 1
  elif result == 'WA' and ac[question] == 0:
    wa[question] += 1
 
for i in range(N + 1):
  if ac[i] != 1:
    wa[i] = 0
 
print(sum(ac), sum(wa))

Submission status: Accepted

Solution code:
#coding utf-8
n_prob, n_submission = (int(x) for x in input().split())
condition = [[0,0] for _ in range(n_prob)] # 左がクリア状況、右が失敗数
n_penalty = 0
n_ac = 0

for i in range(n_submission):
    tmp = input().split()
    prob_num = int(tmp[0])
    ac_wa = tmp[1]
    if ac_wa == 'AC' and condition[prob_num-1][0] == 0:
        n_penalty += condition[prob_num-1][1]
        n_ac += 1
        condition[prob_num-1][0] = 1
    elif ac_wa == 'WA':
            condition[prob_num-1][1] += 1

print(n_ac , n_penalty)

Submission status: Accepted

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

list_ac = [0 for i in range(N)]
list_pen = [0 for i in range(N)]
list_count = [0 for i in range(N)]

for i in range(M):
  pS = input().split()
  p = int(pS[0])-1
  S = pS[1]
  if S == "AC":
    list_pen[p] += list_count[p] * (1 - list_ac[p])
    list_ac[p] = 1
  else:
    list_count[p] += 1

print(str(sum(list_ac)) + " " + str(sum(list_pen)))

Submission status: Accepted

Solution code:
n,m = list(map(int,input().split()))
ac = 0
wa = 0
y = {i:0 for i in range(1,n+1)}
z = {i:0 for i in range(1,n+1)}

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

for i in range(1,n+1):
  if y[i]:
    wa += z[i]

print(ac,wa)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
 
cor = 0
penalty = 0
dic_penalty = {}
dic = {}
for i in range(M):
  p, S = input().split()
  p = int(p)
  if p not in dic:
    dic[p] = "_"
    dic_penalty[p] = 0
  if (S == "AC") & (dic[p] != "AC"):
    dic[p] = "AC"
    cor = cor+1
    penalty = penalty + dic_penalty[p]
    continue
  elif (S == "WA") & (dic[p] != "AC"):
    dic_penalty[p] = dic_penalty[p] + 1
    
print("{} {}".format(cor, penalty))

Submission status: Accepted

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

# length N list of list of results in chronological order for each problem
# unattempted problems are represented as empty list
list_problem_results = [[] for i in range(N)]

for _ in range(M):
    problem_index, result = input().split()
    problem_index = int(problem_index)-1
    list_problem_results[problem_index].append(result)

# get the total number of problems with at least one AC
count_completed_problems = sum(["AC" in problem for problem in list_problem_results])

# get the number of WA before getting AC on problems where there was at least one AC
overall_penalty_count = 0
for problem in list_problem_results:
    count_penalty = 0
    for result in problem:
        if result == "WA":
            count_penalty += 1
        elif result == "AC":
            overall_penalty_count += count_penalty
            break

print(count_completed_problems, overall_penalty_count)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def main():
  N, M = map(int, input().split())
  acs = [0] * N
  was = [0] * N

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

    if s == 'AC':
      acs[p] = 1
    elif acs[p] == 0:
      was[p] += 1

  s = 0
  p = 0

  for a, w in zip(acs, was):
    if a == 0:
      continue

    s += 1
    p += w

  print(s, p)


if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
from collections import defaultdict


def solve():
    n, m = map(int, input().split())
    wa_count = 0
    dict1 = defaultdict(int)
    dict2 = defaultdict(int)
    ac_p, wa_p = set(), set()
    for i in range(m):
        p, s = map(str, input().split())
        p = int(p)
        if s == 'AC':
            dict1[p] = 1
            ac_p.add(p)
        else:
            if dict1[p] != 1:
                dict2[p] += 1
                wa_p.add(p)
    for ac in ac_p:
        if ac in wa_p:
            wa_count += dict2[ac]
    print(sum(dict1.values()), wa_count)


if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
l = [0 for i in range(n)]
pena = 0
for i in range(m):
    q,res = input().split()
    if res == "AC":
        if l[int(q)-1] != 1:
            pena += l[int(q)-1]//2
            l[int(q)-1] = 1
    elif l[int(q)-1]%2 == 0:
        l[int(q)-1] +=2

print(l.count(1),pena)

Submission status: Accepted

Solution code:
total = {}
penalty = 0
ac_answer = 0 
n,m = map(int, input().split())
for _ in range(m):
    num,answer = input().split()

    if num in total:
        total[num].append(answer)
    else:
        total[num] = [answer]
        
for answer_value in total.values():
    if "AC" in answer_value:
        penalty += answer_value.index("AC")
        ac_answer += 1
            
print(ac_answer,penalty)

Submission status: Accepted

Solution code:
n, m = list(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 not ac[p]:
        wa[p] += 1
ans = [sum(ac), sum([i * j for i, j in zip(ac, wa)])]
print("{} {}".format(ans[0], ans[1]))

Submission status: Accepted

Solution code:
import numpy as np
n, m = list(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 s == "AC":
        ac[p] = 1
    elif not ac[p]:
        wa[p] += 1
print("{} {}".format(np.sum(ac, dtype=np.int64), np.sum(ac * wa, dtype=np.int64)))

Submission status: Accepted

Solution code:
def solve(string):
    n, m, *ps = string.split()
    n = int(n)
    ac = [0] * n
    wa = [0] * n
    for p, s in zip(*[iter(ps)] * 2):
        p = int(p) - 1
        if s == "AC":
            ac[p] = 1
        elif not ac[p]:
            wa[p] += 1
    return "{} {}".format(sum(ac), sum([w * a for a, w in zip(ac, wa)]))
 
 
if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))

Submission status: Accepted

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

for i in range(M):
  p, S = input().split()
  p = int(p)-1
  if S=="WA":
    if D[p] != -1:
      D[p] += 1
  else:
    if D[p] != -1:
      ansAC += 1
      ansWA += D[p]
      D[p]= -1

print (ansAC,ansWA)

Submission status: Accepted

Solution code:
N, M = list(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(AC[p-1] == 0):
    WA[p-1] += 1
for i in range(N):
  if(AC[i] == 0):
    WA[i] = 0
print(sum(AC), sum(WA))

Submission status: Accepted

Solution code:
def solve(n, m, p, s):
    accept = {i+1: False for i in range(n)}
    penalty = {i+1: 0 for i in range(n)}
    for i in range(m):
        if s[i] == "WA":
            if not accept[p[i]]:
                penalty[p[i]] += 1
        else:
            accept[p[i]] = True
    a = sum(accept.values())
    b = sum([v for k, v in penalty.items() if accept[k]])
    return "%d %d" % (a, b)

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

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
correct = {i: 0 for i in range(1,n+1)}
acs = 0
penal = {i: 0 for i in range(1,n+1)}

for _ in range(m):
    p, s = input().split()
    p = int(p)
    if s == 'AC':
        if not correct[p]:
            acs += 1
            correct[p] = 1
    else:
        if not correct[p]:
            penal[p] += 1

wa = 0
for key in penal.keys():
    if correct[key]:
        wa += penal[key]
print(acs, wa)

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n,m = LI()
    ps = [LS() for _ in range(m)]
    c = collections.defaultdict(int)
    r = 0
    o = 0
    for p,s in ps:
        if c[p] == -1:
            continue
        if s == 'AC':
            r += 1
            o += c[p]
            c[p] = -1
        else:
            c[p] += 1

    return JA([r,o]," ")


print(main())

Submission status: Accepted

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

points    = [0] * n
penalty   = [0] * n
penalties = 0

for i in range(m):
  q, ans = input().split()
  q = int(q) - 1
  # まだ正解が出ていない場合
  if(points[q] == 0):
    # 正解の場合
    if(ans == 'AC'):
      points[q] = 1
      penalties += penalty[q]
    # 不正解の場合
    else:
      penalty[q] += 1

print('{} {}'.format(sum(points), penalties))

Submission status: Accepted

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

AC_and_penalty = {i:[False, 0] for i in range(1, N+1)}

for p, s in PS:
  _AC_and_penalty = AC_and_penalty[int(p)]
  if _AC_and_penalty[0]:
    continue
  else:
    if s == "AC":
      _AC_and_penalty[0] = True
    else:
      _AC_and_penalty[1] += 1
    
num_AC = 0
penalty = 0
for cond, p in AC_and_penalty.values():
  if cond:
    num_AC += 1
    penalty += p
    
print("{} {}".format(num_AC, penalty))

Submission status: Accepted

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

Submission status: Accepted

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

AC,WA = 0,0

cnt_AC = [False]*(N+1)
cnt_WA = [0]*(N+1)

for i in range(M):
  p,S = input().split()
  p = int(p)
  if S == 'AC' and not cnt_AC[p]:
    AC += 1
    cnt_AC[p] = True
  elif S == 'WA' and not cnt_AC[p]:
    cnt_WA[p] += 1

for i in range(N+1):
  if cnt_AC[i]:
    WA += cnt_WA[i]
print(AC,WA)

Submission status: Accepted

Solution code:

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

list_AC = [0] * N
list_WAcount = [0] * N
sumAC = 0
sumWA = 0

for i in range(M):
    sp , S = input().split(' ')
    p = int(sp)
    
    if (list_AC[p-1] != 0):
        # 既にAC済みの場合は何もしない
        continue 
    else:
        # 最初に正解したときにそれまでのWA回数を加算
        if S == 'AC':
            sumAC += 1
            list_AC[p-1] = 1
            sumWA += list_WAcount[p-1]
        else:
            list_WAcount[p-1] += 1

print("{} {}".format(sumAC,sumWA))

Submission status: Accepted

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

seitou=0
pe=0
cont=0
q=[0]*(n+1)
pena=[0]*(n+1)
for i in range(m):
    
    p,s=input().split()
    p=int(p)
    if q[p]==0:
        if s=="WA":pena[p]+=1
        if s=="AC":
            seitou+=1
            q[p]=1    
for i in range(n+1):
    if q[i]==1:
        pe+=pena[i]
print(sum(q),pe)

Submission status: Accepted

Solution code:
import sys
N, M = [int(v) for v in sys.stdin.readline().split()]
AC = set()
WA = {}
for i in range(M):
    p, s = sys.stdin.readline().split()
    p = int(p)

    if s == 'AC':
        AC.add(p)
    else:
        if p not in AC:
            if p not in WA:
                WA[p] = 1
            else:
                WA[p] += 1
wa = 0
for a, c in WA.items():
    if a in AC:
        wa += c

print(len(AC), wa)

Submission status: Accepted

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

for i in range(n+1):
  if cnt_ac[i]: wa += cnt_wa[i]
print(ac, wa)

Submission status: Accepted

Solution code:
import numpy as np

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

lst = [[] for i in range(N)]
for i in range(M):
  p, S = input().split()
  p = int(p) - 1
  lst[p].append(S == 'AC')

ac = 0
wa = 0
for Q in lst:
  tmp_wa = 0
  for q in Q:
    if q == True:
      ac += 1
      wa += tmp_wa
      break
    else:
      tmp_wa += 1

print('{:d} {:d}'.format(ac, wa))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
cor, wro = 0,0
solved = [False]*(n+1)
pen = [0]*(n+1)
for i in range(m):
    p,s = input().split()
    p = int(p)
    if s == 'AC' and not solved[p]:
        cor+=1
        solved[p]=True
    elif s == 'WA' and not solved[p]:
        pen[p]+=1
for i in range(n+1):
  if solved[i]:
    wro+=pen[i]
print(cor,wro)

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
list = [0]*a
t_cnt = 0
f_cnt = [0]*a
for i in range(b):
  c, d = map(str,input().split())
  x = int(c) - 1
  if list[x] == 0:
    if d == 'AC':
        list[x] = 1
        t_cnt += 1
    else:
        f_cnt[x] += 1
for i in range(a):
  if list[i] ==0:
    f_cnt[i] = 0
print("{} {}".format(t_cnt, sum(f_cnt)))

Submission status: Accepted

Solution code:
from collections import defaultdict
n, m = map(int, input().split())
a = defaultdict(list)
for _ in range(m):
    p, s = input().split()
    a[p].append(1 if s == "AC" else 0)

ac, wa = 0, 0
for l in a.values():
    pcnt = 0
    for is_ac in l:
        if is_ac:
            ac += 1
            wa += pcnt
            break
        else: pcnt += 1

print(ac, wa)

Submission status: Accepted

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

Submission status: Accepted

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

isAC=[False]*100005
cntWA=[0]*100005
ans=0

for i in range(m):
	num = int(pss[i][0])
	if isAC[num]:
		continue
	if pss[i][1] == "WA":
		cntWA[num]+=1
	else:
		ans+=cntWA[num]
		isAC[num]=True
print(sum(isAC),ans)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
Ps = [ input().split() for _ in range(m)]
Prb = [[-1, -1] for _ in range(n)]
wa, ac = 0, 0
for ps in Ps:
    p, s = int(ps[0])-1, ps[1]
    if Prb[p][0] == -1:
        Prb[p][0] = 0
    if Prb[p][1] == -1:
        if s == 'WA':
            Prb[p][0] += 1
        else:
            Prb[p][1] = 1
            wa += Prb[p][0]
            ac += 1
print(ac, wa)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
# どの問題を正解したかのリストをつくる
ac = [0 for _ in range(n)]
pen = [0 for _ in range(n)]

for _ in range(m):
  p, s = input().split()
  p = int(p) - 1
  if s == 'WA':
    if ac[p] == 0:
      pen[p] += 1
  else:
    ac[p] = 1
# ここまでで、ACしていな問題のWAをカウントしてしまっているので、除外する
for p in range(n):
  if ac[p] == 0:
    pen[p] = 0
print(str(sum(ac)) + ' ' + str(sum(pen)))

Submission status: Accepted

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


N = input_int_list[0]
M = input_int_list[1]

Q_ans_list = [0] * (N+1)

ans_correct = 0
ans_penalty = 0

for i in range(M):
	input_list_i = list( input().split())
	Q_num = int(input_list_i[0])
	if input_list_i[1] == "WA":
		if Q_ans_list[Q_num] != -1:
			Q_ans_list[Q_num] = Q_ans_list[Q_num] + 1
	elif input_list_i[1] == "AC":
		if Q_ans_list[Q_num] != -1:
			ans_correct = ans_correct + 1
			ans_penalty = ans_penalty + Q_ans_list[Q_num]
			Q_ans_list[Q_num] = -1





print(ans_correct,ans_penalty)

Submission status: Accepted

Solution code:
N,M = map(int,raw_input().split())
ans_done = [[0 for i in range(3)] for j in range(N)]

for i in range(M):
  p,S = raw_input().split()
  p = int(p)-1
  if ans_done[p][0] == 0:
    ans_done[p][0] = p+1
    if S == "AC":
      ans_done[p][1] = 1
    else:
      ans_done[p][1] = 2
    if ans_done[p][1] == 2:
      ans_done[p][2] = ans_done[p][2] + 1
  elif ans_done[p][1] == 2:
    if S == "AC":
      ans_done[p][1] = 1
    else:
      ans_done[p][1] = 2
    if ans_done[p][1] == 2:
      ans_done[p][2] = ans_done[p][2] + 1

pen = 0
ans = 0
for i in ans_done:
  if i[1] == 1:
    ans = ans + 1
    pen = pen + i[2]
print ans,pen

Submission status: Accepted

Solution code:
def solve(string):
    n, m, *ps = string.split()
    n = int(n)
    ac = [0] * n
    wa = [0] * n
    for p, s in zip(*[iter(ps)] * 2):
        p = int(p) - 1
        if s == "AC":
            ac[p] = 1
        elif not ac[p]:
            wa[p] += 1
    return "{} {}".format(sum(ac), sum([w * a for a, w in zip(ac, wa)]))


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))

Submission status: Accepted

Solution code:
def solve(string):
    n, m, *ps = string.split()
    n = int(n)
    ac = [0] * n
    wa = [0] * n
    for p, s in zip(*[iter(ps)] * 2):
        p = int(p) - 1
        if s == "AC":
            ac[p] = 1
        elif not ac[p]:
            wa[p] += 1
    return "{} {}".format(sum(ac), sum([w if a else 0 for a, w in zip(ac, wa)]))


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))

Submission status: Accepted

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

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

for m in range(M):
  p, S = input().split()
  p = int(p)
  
  if S == 'AC' and AC[p-1] == 0:
    AC[p-1] = 1
  elif S == 'WA' and AC[p-1] == 0:
    WA[p-1] += 1

penalty = 0
for i in range(N):
  if AC[i] == 1:
    penalty += WA[i]
    
print(sum(AC), penalty)

Submission status: Accepted

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

pe = 0
acset = set()
peset = {}

if m > 0:
    for i,name in enumerate(ps):
        p1,s1 = name
        if s1 == "AC" and p1 not in acset:
            acset.add(p1)
            if p1 in peset:
                pe += peset[p1]
        elif p1 not in acset:
            if p1 not in peset:
                peset[p1] = 0
            peset[p1] += 1

ac = len(acset)
print(" ".join(list(map(str, [ac, pe]))))

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

ac_ans = ac.count(True)
wa_ans = sum([wa[i] for i in range(n) if ac[i] == True])

print(ac_ans, wa_ans)

Submission status: Accepted

Solution code:
N,M = map(int, input().split())
if M==0:
    print("0 0")
    exit()

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

ac_lis =[0]*N
wa_lis =[0]*N

for i in log:
    p,s = int(i[0])-1,i[1]
    if s=="AC":
        ac_lis[p]=1
    elif s=="WA" and not ac_lis[p]:
        wa_lis[p] +=1
for i in range(N):
    if not ac_lis[i]:
        wa_lis[i] = 0
        
print(sum(ac_lis), sum(wa_lis))

Submission status: Accepted

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

ac = [0] * N
wa = [0] * N
buff = [0] * N
for _ in range(M):
    p, S = input().split()
    p = int(p) - 1
    if ac[p] == 0:
        if S == 'AC':
            ac[p] = 1
            wa[p] = buff[p]
        else:
            buff[p] += 1
print(sum(ac), sum(wa))

Submission status: Accepted

Solution code:
N,  M = map(int, input().split())
p = []; S = []
for _ in range(M):
    pi, Si = input().split()
    p.append(int(pi))
    S.append(Si)

wa_count = [0] * N
is_ac = [False] * N
ac = 0; wa = 0
for i in range(M):
    if is_ac[p[i]-1] == True:
        continue
    else:
        if S[i] == 'AC':
            ac += 1
            wa += wa_count[p[i]-1]
            is_ac[p[i]-1] = True
        else:
            wa_count[p[i]-1] += 1

print(ac, wa)

Submission status: Accepted

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

WA = 0

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

    if ac[p] == 0 and s == 'AC':
        ac[p] = 1
        WA += wa[p]

    wa[p] += 1

print(sum(ac), WA)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
isAC = [False] * N
numWA = [0] * N
for i in range(M):
  p_str, S = map(str, input().split(' '))
  p = int(p_str) - 1
  if S == 'AC':
    isAC[p] = True
  else:
    if isAC[p]:
      continue
    numWA[p] += 1
    
ac = 0
wa = 0
for i in range(N):
  if isAC[i]:
    ac += 1
    wa += numWA[i]
print(str(ac) + " " + str(wa))

Submission status: Accepted

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

obj = {}
ii = 0
jj = 0

for i in range(M):
    p = [x for x in input().split()]
    key = p[0]
    res = p[1]
    if key not in obj:
        obj[key] = {'AC': 0, 'WA': 0}
    if res == 'WA' and obj[key]['AC'] == 0:
        obj[key]['WA'] = obj[key]['WA'] + 1
    if res == 'AC':
        obj[key]['AC'] = 1

for k in obj:
    ii = ii + obj[k]['AC']
    if obj[k]['AC'] > 0:
        jj = jj + obj[k]['WA']


print(ii, jj)

Submission status: Accepted

Solution code:
from collections import defaultdict

N, M = map(int, input().split())
res = defaultdict(list)
for _ in range(M):
    p, s = input().split()
    p = int(p) - 1
    res[p].append(s)

num_AC = num_WA = 0
for p, xs in res.items():
    wa = 0
    for i, x in enumerate(xs):
        if x == 'AC':
            num_AC += 1
            num_WA += wa
            break
        else:
            wa += 1

print(num_AC, num_WA)

Submission status: Accepted

Solution code:
#print("<input>") #
N,M=map(int,input().split())
A=[[] for i in range(N)]
for i in range(M):
    Pi,Si=map(str,input().split())
    Pi=int(Pi)
    A[Pi-1].append(Si)

#print("<test>") #
#print("A=",A) #

nAC=0
nWA=0
inWA=0
j=0
for i in range(N):
    #print("i=",i) #
    if len(A[i])==0:
        pass
    else: 
        while A[i][j]=="WA":
            inWA+=1
            nWA+=1
            #print("j=",j) #
            #print("inWA=",inWA) #
            #print("nWA=",nWA) #
            if j==len(A[i])-1:
                nWA-=inWA
                break
            else:
                pass
            j+=1
        if A[i][j]=="AC":
            nAC+=1
        else:
            pass
        inWA=0
        j=0
        #print("inWA=",inWA) #
        #print("nWA=",nWA) #
        

#print("<ans>") #
print("{0} {1}".format(nAC,nWA))

Submission status: Accepted

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

Submission status: Accepted

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

pe=0

for i in range(M):
  num, result = map(str, input().split())
  num = int(num)-1
  
  if ac[num]==0 and result=='AC':
    ac[num] += 1
    pe += wa[num]
    
  elif ac[num]==0 and result=='WA':
    wa[num] +=1

print(sum(ac), pe)

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
P=[0]*M
S=[0]*M
cor=[0]*N
ac,wa=0,0
for i in range(M):
    P[i],S[i]=input().split()
    P[i]=int(P[i])
    if(S[i]=="AC"):
        cor[P[i]-1]+=1
    else:
        pass
for i in range(M):
    if(cor[P[i]-1]>=1 and S[i]=="WA"):
        wa+=1
    elif(cor[P[i]-1]>=1 and S[i]=="AC"):
        cor[P[i]-1]=0
        ac+=1
    else:
        pass
print("{0} {1}".format(ac,wa))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
NM = input().split()
N = int(NM[0])
M = int(NM[1])
prob = []
probStatus = []
for i in range(M):
    pS = input().split()
    prob.append(int(pS[0]))
    probStatus.append(pS[1])
correctAr = [0] * N
penaltyAr = [0] * N
submissions = [''] * N
for i in range(M):
    if probStatus[i] == 'AC' and submissions[prob[i] - 1] == '':
        correctAr[prob[i] - 1] += 1
        submissions[prob[i] - 1] = 'AC'
    elif probStatus[i] == 'WA' and submissions[prob[i] - 1] == '':
        penaltyAr[prob[i] - 1] += 1
correct = 0
penalty = 0
for i in range(N):
    if submissions[i] == 'AC':
        correct += correctAr[i]
        penalty += penaltyAr[i]

print(correct, penalty)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
won = set()
d = {}
penalties = 0
for i in range(m):
  x = input().split()
  ID = x[0]
  stat = x[1]
  if ID in won:
    continue
  if stat == "WA":
    if (d.get(ID, None)):
      d[ID] += 1
    else:
      d[ID] = 1
  else:
    won.add(ID)

for item in won:
    penalties += d.get(item,0)
print(len(won), penalties)

Submission status: Accepted

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

data = {}

for _ in range(M):
  p_i, result = map(str, input().split())
  if int(p_i) not in data.keys():
    data[int(p_i)] = [False if result == "WA" else True]
  else:
    data[int(p_i)].append(False if result == "WA" else True)

correct_answers = 0
penalties = 0
for prob in data.keys():
  if True in data[prob]:
    i = 0
    correct_answers += 1
    while not data[prob][i]:
      penalties += 1
      i+= 1
    
print(correct_answers, penalties)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
l = [0] * (N + 1)
ac = 0
wa = 0
for _ in range(M):
    p, S = input().split()
    if S == 'WA':
        if l[int(p)] >= 0:
            l[int(p)] += 1
    else:
        if l[int(p)] >= 0:
            wa += l[int(p)]
            ac += 1
            l[int(p)] = -1

print(ac, wa)

Submission status: Accepted

Solution code:
#n = int(input())
#L = list(map(int, input().split()))
#import math
#import sys
#import heapq
#import fractions
#import bisect
#import numpy




NM = list(map(int, input().split()))
ps = [list(input().split()) for i in range(NM[1])]
a=[0]*NM[0]
flg = [True]*NM[0]
for i in range(NM[1]):
    ps[i][0] = int(ps[i][0])

ans = [0]*NM[0]
ac = 0
for i in range(NM[1]):
    if ps[i][1] == "AC" and flg[ps[i][0]-1]:
        flg[ps[i][0]-1] = False
        ans[ps[i][0]-1] = a[ps[i][0]-1]
    if ps[i][1] == "WA" and flg[ps[i][0]-1]:
        a[ps[i][0]-1] += 1

for i in range(NM[0]):
    if flg[i]== False:
        ac += 1
print(ac,sum(ans))

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines


#mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
#import numpy as np

def main():
	n,m=map(int,input().split())
	
	li=[0]*(n+1)
	
	wa=0
	
	for i in range(m):
		p,s=input().split()
		p=int(p)
		s=s.rstrip().decode('utf-8')
		
		if li[p]==-1:
			continue
		if s=="WA":
			li[p]+=1
		else:
			wa+=li[p]
			li[p]=-1
	
	print(li.count(-1),wa)
	
	

if __name__ == "__main__":
	main()

Submission status: Accepted

Solution code:
n,m = map(int, input().split())
ps = [input().split() for i in range(m)]
al = [0] * (n+1)
pe = [0] * (n+1)
ans_a, ans_p = 0,0
for p,s in ps:
  p = int(p)
  if al[p]:
    continue
  if s == "AC":
    al[p] = 1
    ans_p += pe[p]
    ans_a += 1
  else:
    pe[p] += 1
print(ans_a, ans_p)

Submission status: Accepted

Solution code:
listA=[] #appendのために宣言が必要
while True:
    try:
        listA.append(input().split())
    except:
        break;
        
N = int(listA[0][0])
M = int(listA[0][1])

ans = [0] * N
pena = [0] * N

for i in range(1, M+1):
    num=int(listA[i][0]) -1
    res=listA[i][1]
    if res=="WA" and ans[num] == 0:
        pena[num] =  pena[num]+1
    if res=="AC" and ans[num] == 0:
        ans[num] = 1
        
print('%d %d' % (sum(ans), sum(x*y for x,y in zip(ans,pena)  ) ))