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:
import sys
N, M = map(int, input().split())
PS = sys.stdin.read().strip().split()
ac, wa = [0] * N, [0] * N
for p, s in zip(*[iter(PS)] * 2):
  p = int(p) - 1
  if s == "AC":
    ac[p] = 1
  elif ac[p] == 0:
    wa[p] += 1
penalties = sum(w if a > 0 else 0 for a, w in zip(ac, wa))
print(sum(ac), penalties)

Submission status: Accepted

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

def main():
    n,m=map(int,input().split())
    w=[0]*(n+1)
    a=[0]*(n+1)
    for i in range(m):
        p,s=map(str,input().split())
        p=int(p)
        if a[p]==0:
            if s=='WA':
                w[p]+=1
            else:
                a[p]=1
    wa=0
    for i in range(1,n+1):
        wa=wa+a[i]*w[i]
    print(sum(a),wa)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

i_i = lambda: int(i_s())
i_l = lambda: list(map(int, stdin.readline().split()))
i_s = lambda: stdin.readline().rstrip()

N, M = i_l()
ac = 0
wa = 0
arr = []
h = {}
for _ in range(M):
    p, s = input().split()
    arr.append([int(p), s])
    if h.get(int(p)) is None:
        h[int(p)] = [s] 
    else:
        h[int(p)].append(s)
        
        
for k in h.keys():
    if all(x == 'WA' for x in h[k]):
        continue
    for v in h[k]:
        if v == 'AC':
            ac += 1
            break
        else:
            wa += 1

print(ac, wa)

Submission status: Accepted

Solution code:
def main():
    n, m = map(int, input().split())
    if m == 0:
        print(0, 0)
        return
    ps_list = [list(input().split()) for _ in range(m)]
    ps_list.sort(key=lambda x: x[0])
    now_p = ps_list[0][0]
    not_now_ac_flag = True
    ac_ans = 0
    now_wa = 0
    wa_ans = 0
    for p, s in ps_list:
        if p != now_p:
            now_p = p
            if not not_now_ac_flag:
                wa_ans += now_wa
            not_now_ac_flag = True
            now_wa = 0
        if s == "AC" and not_now_ac_flag:
            ac_ans += 1
            not_now_ac_flag = False
        if s == "WA" and not_now_ac_flag:
            now_wa += 1
    if not not_now_ac_flag:
        wa_ans += now_wa
    print(ac_ans, wa_ans)
main()

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
ans = 0;pel = 0
ansArray = [0] * n
waArray = [0] * n
for i in range(m):
	a,b = map(str,input().split())
	a = int(a)
	if ansArray[a-1] == 0:
		if b == "AC":
			ans += 1
			pel += waArray[a-1]
			ansArray[a-1] = 1
		else:
			waArray[a-1] += 1
print(' '.join(map(str,[ans,pel])))

Submission status: Accepted

Solution code:
import math
N, M = map(int, input().split())
judge = [0]*N
ac = 0
wa = 0
for i in range(M):
  p, S = input().split()
  if judge[int(p)-1] == 'AC':
    pass
  elif S == 'AC':
    wa += judge[int(p)-1]
    judge[int(p)-1] = 'AC'
    ac += 1
  else:
    judge[int(p)-1] += 1
print(ac,wa)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
 
WA=[0]*n
AC=[0]*n
 
for i in range(m):
    problem,status=input().split()
    problem=int(problem)
 
    if status=='WA':
        if AC[problem-1]==1:
            continue
        else:
            WA[problem-1]+=1
    elif status=='AC':
        AC[problem-1]=1

for i in range(n):
    if AC[i]==0:
        WA[i]=0
print(sum(AC),sum(WA))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

lisa = [0] * n
lisw = [0] * n
for i in range(m):
     if lisa[int(p[i])-1] == 0:
          if s[i] == 'WA':
               lisw[int(p[i]) - 1] += 1
          else:
               lisa[int(p[i])-1] = 1
num = 0
for i in range(n):
     if lisa[i] == 1:
          num += lisw[i]



print(sum(lisa),num)

Submission status: Accepted

Solution code:
from collections import defaultdict

def solve():
    N, M = map(int, input().split())
    d = defaultdict(int)
    e = set()
    for _ in range(M):
        a, b = input().split()
        a = int(a)
        if b == 'AC':
            e.add(a)
        if b == 'WA' and a not in e:
            d[a] += 1
    s = 0
    for a in e:
        s += d[a]
    ans = [len(e), s]
    print(*ans)

# print(solve())

# def solve()が@return voidのとき
solve()

Submission status: Accepted

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

wa = [0] * N
pnt = [0] * N
ac = [False] * N

for _ in range(M):
    p, s = list(map(str, input().split()))
    if s == 'WA':
      wa[int(p) - 1] += 1
    elif s == 'AC' and not (ac[int(p) - 1]):
      ac[int(p) - 1] = not (ac[int(p) - 1])
      pnt[int(p) - 1] += wa[int(p) - 1]

print(ac.count(True), sum(pnt))

Submission status: Accepted

Solution code:

if __name__ == '__main__':

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

	A = [[0] * 3 for i in range(n)]

	for _ in range(m):
		x,y = input().split()
		x = int(x)
		A[x-1][0] = x
		if y == "AC":
			A[x-1][1] = 1
		else:
			#ACしていなければ
			if A[x-1][1] == 0:
				#WA +1
				A[x-1][2] += 1

	ac = 0
	wa = 0

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

	print(ac,wa)

Submission status: Accepted

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

ac_check = [False for i in range(n)]
wa_count = [0 for i in range(n)]

clear = 0
error = 0
for i in range(m):
    p, s = input().split()
    p = int(p) - 1

    if s == 'AC' and ac_check[p] == False:
        ac_check[p] = True
        error += wa_count[p]
    elif s == 'WA' and ac_check[p] == False:
        wa_count[p] += 1

for i in range(n):
    if ac_check[i]:
        clear += 1

print(clear, error)

Submission status: Accepted

Solution code:
def resolve():
    import sys
    input = sys.stdin.readline
    n, m = map(int, input().split())
    if m == 0:
        print("{} {}".format(0, 0))
        exit()

    a = list(input().split() for _ in range(m))
    flag = [[0] * n for i in range(2)]
    miss = 0
    correct = 0
    for i in range(m):
        if flag[0][int(a[i][0]) - 1] == 0:
            if a[i][1] == "WA":
                flag[1][int(a[i][0]) - 1] += 1
            elif a[i][1] == "AC":
                correct += 1
                miss += flag[1][int(a[i][0]) - 1]
                flag[0][int(a[i][0]) - 1] = 1
    print("{} {}".format(correct, miss))
resolve()

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
 
def main():
    N, M = map(int, input().split())
 
    ac_check = [False] * N
    p_counts = [0] * N
 
    for i in range(M):
        p, s = input().strip().split()
        p = int(p) - 1
        if s == "AC":
            if not ac_check[p]:
                ac_check[p] = True
        else:
            if not ac_check[p]:# まだ正解していないならペナルティ追加
                p_counts[p] += 1
 
    ac_count = 0
    p_count = 0
    for i in range(N):
        if ac_check[i]:# 正解している問題のみ考慮
            ac_count += 1
            p_count += p_counts[i]
    print(ac_count, p_count)
 
 
if __name__ == "__main__":
    main()

Submission status: Accepted

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

def main():
    N, M = map(int, input().split())

    ac_check = [False] * N
    p_counts = [0] * N

    for i in range(M):
        p, s = input().strip().split()
        p = int(p) - 1
        if s == "AC":
            if not ac_check[p]:
                ac_check[p] = True
        else:
            if not ac_check[p]:# まだ正解していないならペナルティ追加
                p_counts[p] += 1

    ac_count = 0
    p_count = 0
    for i in range(N):
        if ac_check[i]:# 正解している問題のみ考慮
            ac_count += 1
            p_count += p_counts[i]
    print(ac_count, p_count)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import numpy as np

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

seikai = np.zeros(n)
matigai1 = np.zeros(n)
matigai2 = np.zeros(n)
for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    if seikai[p]==1:
        continue
    else:
        if s=='AC':
            seikai[p] = 1
            matigai2[p] = matigai1[p]

        else:
            matigai1[p] += 1

print(int(seikai.sum()), int(matigai2.sum()))

Submission status: Accepted

Solution code:
nm = [int(s) for s in input().split()]
ls = [0]*nm[0]
ac = [0]*nm[0]

for x in range(nm[1]):
  ps = [s for s in input().split()]
  p = int(ps[0])
  s = ps[1]
  if ac[p-1] == 0:
    if s == 'WA':
      ls[p-1] += 1
    else:
      ac[p-1] = 1
import numpy as np

print(' '.join(map(str,[sum(ac),np.dot(ac,ls)])))

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
P=list(input().split() for _ in range(M))
manageDo={}
manageWa={}
for n in range(N):
    manageDo[str(n+1)] = 0
    manageWa[str(n+1)] = 0
wa=0
ac=0
for p in P:
    now=manageDo[p[0]]
    if p[1] == 'WA' and now == 0:
        manageWa[p[0]] += 1
    elif p[1] == 'AC' and now == 0:
        ac+=1
        wa+=manageWa[p[0]]
        manageDo[p[0]] = 1

print(ac,wa)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
l=[0]*n
s=set([])
for i in range(m):
  p,q=map(str,input().split())
  if int(p) in s:
    continue
  elif q=='AC':
    s.add(int(p))
  else:
    l[(int(p))-1]+=1
s_l=list(s)
an=len(s_l)
c=0
for i in range(an):
  c+=l[s_l[i]-1]
print(an,c)

Submission status: Accepted

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

a = [0]*n
b = [False]*n
for i in range(m):
    p,s = input().split()
    p = int(p) - 1
    if s == 'AC':
        b[p] = True
    elif b[p] == False:
        a[p] += 1

ac = b.count(True)
wa = 0
for i in range(n):
    if b[i] == True:
        wa += a[i]
print(ac,wa)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
dic = {}
ac = 0
wa = 0
for x in range(M):
    p, s = input().split()
    try:
        dic[p]
    except:
        dic[p] = [False, 0]
    
    if s == 'WA':
        if not dic[p][0]:
            dic[p][1] += 1
        
        
    else:
        if not dic[p][0]:
            dic[p][0] = True
            ac += 1
            wa += dic[p][1]

print(ac, wa)

Submission status: Accepted

Solution code:
import sys
N, M = map(int, input().split())
PS = sys.stdin.read().strip().split()
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 ac[p] == 0:
    wa[p] += 1
penalties = sum(w if a > 0 else 0 for a, w in zip(ac, wa))
print(sum(ac), penalties)

Submission status: Accepted

Solution code:
import math
import copy
from copy import deepcopy
import sys
import fractions
# import numpy as np
from functools import reduce
# import statistics
import heapq
import collections
import itertools
sys.setrecursionlimit(100001)

# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

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

data = []
for i in range(m):
    input_data = input().split()
    tmp_int = int(input_data[0]) -1
    tmp_str = str(input_data[1])
    data.append([tmp_int, tmp_str])

table_cnt = [0]*n
table_bool = [False]*n

ans_ac = 0
ans_wa = 0

for index, result in data:
    if table_bool[index] == False:
        if result == "WA":
            table_cnt[index] += 1
        else:
            table_bool[index] = True
            ans_ac += 1
            ans_wa += table_cnt[index]

print(ans_ac, ans_wa)

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
acwa=[[] for _ in range(n)]
for i in range(m):
    pp,ss = input().split()
    acwa[int(pp)-1].append(ss)

n_ac=0
n_wa=0
for i in range(n):
    if "AC" in acwa[i]:
        n_ac +=1
        n_wa +=acwa[i].index("AC")
print(n_ac,n_wa)

Submission status: Accepted

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

a = [0]*n
b = [False]*n
for i in range(m):
  p,s = input().split()
  p = int(p) - 1
  if s == 'AC':
    b[p] = True
  elif b[p] == False:
    a[p] += 1

ac = b.count(True)
wa = 0
for i in range(n):
  if b[i] == True:
    wa += a[i]
print(ac,wa)

Submission status: Accepted

Solution code:
[n,m] = [int(i) for i in input().split()]
dic_AC = {}
dic_WA = {}
for i in range(1,n+1):
    dic_AC[i] = 0
    dic_WA[i] = 0

for i in range(m):
    [p,s] = [j for j in input().split()]
    if s == "AC":
        dic_AC[int(p)] = 1
    else:
        if dic_AC[int(p)] == 0:
            dic_WA[int(p)] += 1
ans_1 = sum(dic_AC.values())
ans_2 = 0
for i in range(1,n+1):
    if dic_AC[i] == 1:
        ans_2 += dic_WA[i]
print(ans_1,ans_2)

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
s = sorted([list(map(str,input().split())) for i in range(M)], key = lambda x: x[0])
for i in range(M):
    s[i][0] = int(s[i][0])
clear = 0
pena = 0
pena_pre = 0
if(M == 0):
    print("0 0")
else:
    problem = s[0][0]
    AC_flag = 0
    for i in range(M):
        if(s[i][0] != problem):
            problem = s[i][0]
            AC_flag = 0
            pena_pre = 0
        if(s[i][1] == "AC" and AC_flag == 0):
            clear += 1
            AC_flag = 1
            pena += pena_pre
            pena_pre = 0
        elif(s[i][1] == "WA" and AC_flag == 0):
            pena_pre += 1

    print(str(clear) + " " + str(pena))

Submission status: Accepted

Solution code:
N,M = map(int, input().split())
ps = []
AC = [0]*N
WA = [0]*N
WA_sum = 0
for _ in range(M):
  ps.append(list(input().split()))
for i in range(M):
  if ps[i][1] == 'AC' and AC[int(ps[i][0])-1] == 0:
    AC[int(ps[i][0])-1] = 1
  if ps[i][1] == 'WA' and AC[int(ps[i][0])-1] == 0:
    WA[int(ps[i][0])-1] += 1
for i in range(N):
  if AC[i] == 1:
    WA_sum += int(WA[i])
print(sum(AC), WA_sum)

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
ac=0
wa=0
a=[0]*N
w=[0]*N
for i in range(M):
    P,S=input().split()
    P=int(P)
    if S=="WA":
        w[P-1]+=1
    else:
        if a[P-1]==0:
            a[P-1]+=1
            ac=ac+1
            wa+=w[P-1]
        else:
            pass
print(ac,wa)

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
ac=0
wa=0
a=[0]*N
w=[0]*N
for i in range(M):
    P,S=input().split()
    if S=="WA":
        w[int(P)-1]+=1
    else:
        if a[int(P)-1]==0:
            a[int(P)-1]+=1
            ac=ac+1
            wa+=w[int(P)-1]
        else:
            pass
print(ac,wa)

Submission status: Accepted

Solution code:
#C
n,m=map(int,input().split())
f=False
ps=[]
AC=[0]*n
WA=[0]*n
for i in range(m):
    ps.append(list(input().split()))
for i in range(m):
    if ps[i][1]=='AC'and AC[int(ps[i][0])-1]==0:
        AC[int(ps[i][0])-1]=1
    if ps[i][1]=='WA'and AC[int(ps[i][0])-1]==0:
        WA[int(ps[i][0])-1]+=1
wasum=0
for i in range(n):
    if AC[i]==1:
        wasum+=WA[i]
print(sum(AC),wasum)

Submission status: Accepted

Solution code:
N,M = map(int, input().split())
ps = []
AC = [0]*N
WA = [0]*N
WA_sum = 0
for _ in range(M):
  ps.append(list(input().split()))
for i in range(M):
  if ps[i][1] == 'AC' and AC[int(ps[i][0])-1] == 0:
    AC[int(ps[i][0])-1] = 1
  if ps[i][1] == 'WA' and AC[int(ps[i][0])-1] == 0:
    WA[int(ps[i][0])-1] += 1
for i in range(N):
  if AC[i] == 1:
    WA_sum += int(WA[i])
print(sum(AC), WA_sum)

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
Qnum=[0]*M
rslt=[" "]*M
Pnum=[0]*N #問題当たりのペナルティの数
Flag=[0]*N
ACnum=0
for i in range(M):
    Qnum[i],rslt[i]=input().split()
    Qnum[i]=int(Qnum[i])
    if Flag[Qnum[i]-1]==0:
        if rslt[i]=="AC":
            Flag[Qnum[i]-1]=1
            ACnum+=1
        else:
            Pnum[Qnum[i]-1]+=1

for j in range(N):
    if Flag[j]==0:
        Pnum[j]=0
print(ACnum,sum(Pnum))

Submission status: Accepted

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

if M == 0:
    print(0, 0)
    exit(0)

P, S = [], []
solved = set({})
counter = {i: 0 for i in range(1, N + 1)}
value1 = 0
value2 = 0
for _ in range(M):
    p, s = input().split()
    p = int(p)
    P.append(p)
    S.append(s)

    if p in solved:
        continue

    if s == 'AC':
        solved.add(p)
        value1 += 1
        value2 += counter[p]

    else:
        counter[p] += 1

print(value1, value2)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
ps = [[] for _ in range(N)]
for i in range(M):
    p, s = input().split()
    p = int(p) - 1
    ps[p].append(s)
wa = 0
ac = 0
for ss in ps:
    tmp_wa = 0
    for s in ss:
        if s == "WA":
            tmp_wa += 1
        else:
            ac += 1
            wa += tmp_wa
            break
print("{} {}".format(ac, wa))

Submission status: Accepted

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

ac = 0
wa = 0
ac_status = [0 for i in range(N)]
wa_status = [0 for i in range(N)]

for _ in range(M):
    p_i, s_i = input().split()
    if s_i == "AC" and ac_status[int(p_i) - 1] == 0:
        ac += 1
        ac_status[int(p_i) - 1] += 1
        wa += wa_status[int(p_i) - 1]
    if s_i == "WA":
        wa_status[int(p_i) - 1] += 1

print(ac, wa)

Submission status: Accepted

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

wa = 0
for _ in range(M):
  p, s = input().split()
  index = int(p)-1
  if s == 'WA' and P[index] != -1:
      P[index] += 1
  elif P[index] > -1:
    wa += P[index]
    P[index] = -1
  
print(P.count(-1), wa)

Submission status: Accepted

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

p = [-1 for _ in range(m)]
s = [-1 for _ in range(m)]

for i in range(m):
    x = input().split()
    p[i] = int(x[0])
    s[i] = x[1]


dic_ac = {}
dic_wa = {}
dic_wa_num = {}

for i in range(m):
    if(s[i] == "AC"):
        if not (p[i] in dic_ac):
            dic_ac[p[i]] = 1
    
    if(s[i] == "WA" and p[i] not in dic_ac):
        if(p[i] in dic_wa):
            dic_wa_num[p[i]] += 1
        else:
            dic_wa[p[i]] = 1
            dic_wa_num[p[i]] = 1
            

wa = 0
ac = 0

for v in dic_ac.values():
    ac += v

for v in dic_ac:
    if(v in dic_wa_num):
        wa += dic_wa_num[v]

  
print(ac,wa)

Submission status: Accepted

Solution code:
from collections import defaultdict

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

cnt = defaultdict(int)
d = defaultdict()

for p, s in ps:
    if s == "AC":
        if d.get(p) is None:
            d[p] = cnt[p]
    else:
        cnt[p] += 1

correct = 0
pena = 0
for k, v in d.items():
    correct += 1
    pena += v

print(correct, pena)

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
AC={}
WA={}
for i in range(M):
    a,b=input().split()
    if not(a in AC.keys()):
        if b=="AC":
            AC[a]=1
        else:
            if a in WA.keys():
                WA[a]+=1
            else:
                WA[a]=1
y=0
for i in AC.keys():
    if i in WA.keys():
        y+=WA[i]
print(sum(AC.values()),y)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Wed Mar  4 18:22:36 2020

@author: Kanaru Sato
"""

N, M = list(map(int, input().split()))
submits = [input().split() for i in range(0,M)]

D = {}

for ans in submits:
    if ans[1] == "AC":
        if ans[0] not in D:
            D[ans[0]] = 0

D_flag = D.copy()

for ans in submits:
    if (ans[0] in D) and (D_flag[ans[0]] == 0):
        if ans[1] == "WA":
            D[ans[0]] += 1
        if ans[1] == "AC":
            D_flag[ans[0]] = 1

if M == 0:
    print(0,0)
else:
    print(len(D), sum(D.values()))

Submission status: Accepted

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

for _ in range(M):
    p, s = input().split()
    p = int(p)
    if not p in AC:
        if s == 'AC':
            AC.add(p)
        if s == 'WA':
            wa[p] += 1

wa_ans = 0
for i in AC:
    wa_ans += wa[i]

print(len(AC), wa_ans)

Submission status: Accepted

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

for _ in range(M):
    p, s = input().split()
    p = int(p)
    if not p in AC:
        if s == 'AC':
            AC.add(p)
        if s == 'WA':
            wa[p] += 1

wa_ans = 0
for i in range(1,N+1):
    if i in AC:
        wa_ans += wa[i]

print(len(AC), wa_ans)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
ok=[0]*(n+1)
pe=[0]*(n+1)
for _ in range(m):
    q,s=input().split()
    q=int(q)
    if s=="WA" and ok[q]==0:
        pe[q]+=1
    else:
        ok[q]=1
for i in range(n+1):
    if ok[i]==0:
        pe[i]=0
print(sum(ok),sum(pe))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
  import sys
  input = sys.stdin.buffer.readline
  n,m=map(int,input().split())
  a,w,l,k=0,0,[0]*n,[0]*m
  for _ in k:
    p,s=input().split()
    p=int(p)-1
    if l[p]>=0:
      if s==b'AC':
        a+=1
        w+=l[p]
        l[p]=-1
      else:
        l[p]+=1
  print(a,w)
  
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
  import sys
  input = sys.stdin.buffer.readline
  n,m=map(int,input().split())
  ac,wa,l,k=0,0,[0]*n,[0]*m
  for _ in k:
    p,s=input().split()
    p=int(p)
    if type(l[p-1])==int:
      if s==b'AC':
        ac+=1
        wa+=l[p-1]
        l[p-1]=''
      else:
        l[p-1]+=1
  print(ac,wa)
  
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
  import sys
  input = sys.stdin.readline
  n,m=map(int,input().split())
  ac,wa,l=0,0,[0]*n
  for _ in [0]*m:
    p,s=input().split()
    if type(l[int(p)-1])==int:
      if s=='AC':
        ac+=1
        wa+= l[int(p)-1]
        l[int(p)-1]=str(l[int(p)-1])
      else:
        l[int(p)-1]+=1
  print(ac,wa)
  
if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
AC_or_not = [False] * N
n_penalty = [0] * N
cnt_ac = 0
cnt_pen = 0

for _ in range(M):
    prob, wa_ac = input().split()
    prob = int(prob) - 1
    if wa_ac == 'AC':
        if not AC_or_not[prob]:
            cnt_pen += n_penalty[prob]
            cnt_ac += 1
            AC_or_not[prob] = True
    else:
            n_penalty[prob] += 1

print(cnt_ac ,cnt_pen)

Submission status: Accepted

Solution code:
import numpy as np

N, M = map(int, input().split())
AC_or_not = np.array([0] * N)
n_penalty = np.array([0] * N)

for _ in range(M):
    prob, wa_ac = input().split()
    prob = int(prob) - 1
    if wa_ac == 'AC':
        AC_or_not[prob] = 1
    else:
        if not AC_or_not[prob]:
            n_penalty[prob] += 1

print(sum(AC_or_not), sum(n_penalty * AC_or_not))

Submission status: Accepted

Solution code:
"""
注意点：ACしていないWAはペナルティ数とはカウントされない
      また、ACの後にペナルティしたものはカウントされない
データ構造：
  WA:dict形式でカウントアップ
  AC:配列で末尾に挿入
一通り舐めた後AD配列をforで回してペナルティ数合計するか？
"""

N,M = list(map(lambda x: int(x), input().split()))
wa_count = [0] * N
ac_list = [False] * N
answer = 0

for _ in range(M):
  p,s = input().split()
  p = int(p)
  if s == 'WA':
    wa_count[p-1] += 1
  if s == 'AC' and ac_list[p-1] == False:
    answer += wa_count[p-1]
    ac_list[p-1] = True

ac_count = ac_list.count(True)

print(ac_count, answer)

Submission status: Accepted

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

eva = [[0, 0] for _ in range(n)]

ac = 0
penalty = 0

for i in range(m):
    q, s = input().split()
    if eva[int(q) - 1][1] == 0:
        if s == "WA":
            eva[int(q) - 1][0] += 1
        else:
            eva[int(q) - 1][1] += 1
            ac += 1
            penalty += eva[int(q) - 1][0]
    else:
        pass

print(ac, penalty)

Submission status: Accepted

Solution code:
AC = 0
WA = 0
N, M =map(int, input().split())
A = [0]*N
for i in range(M):
    p, S = input().split()
    q = int(p)-1
    if S == 'AC' and A[q] != -1:
        AC += 1
        WA += A[q]
        A[q] = -1
    elif S == 'WA' and A[q] != -1:
        A[q] += 1
print(AC, WA)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

flag = [False] * n
cnt = [0 for i in range(n)]
for i in ps:
    if i[1] == 'WA' and flag[int(i[0]) - 1] == False:
        cnt[int(i[0]) - 1] += 1
    elif i[1] == 'AC':
        flag[int(i[0]) - 1] = True
penal_cnt = 0
for i in range(len(flag)):
    if flag[i] == True:
        penal_cnt += cnt[i]
print(sum(flag), penal_cnt)

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
a = [False]*n
b = [0]*n
for i in range(m):
    p,s = input().split()
    p = int(p)
    if s == 'AC':
        a[p-1] = True
    if s == 'WA' and a[p-1] == False:
        b[p-1] += 1
correct = a.count(True)
penalty = 0
for i in range(len(a)):
    if a[i] == True:
        penalty += b[i]
print(correct, penalty)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
isAC = [False for _ in range(N)]
correct = 0
penalty = [0 for _ in range(N)]
for _ in range(M):
    tmp = input().split()
    pi, Si = int(tmp[0]), tmp[1]
    if not isAC[pi-1]: # すでにAC
        if Si == 'AC':
            isAC[pi-1] = True
            correct += 1
        else:
            penalty[pi-1] += 1
pnl = 0
for idx in range(N):
    if isAC[idx]:
        pnl += penalty[idx]
print(correct, pnl)

Submission status: Accepted

Solution code:
# import math
# from fractions import gcd

import numpy as np
# import scipy as scp

# 入力の受け取り
n,m = map(int,input().split())
# 列ベクトルとかの受け取り
times = m
table = []
for _ in range(times):
    table.append(list(input().split()))

statusAC = {}
answer_status = {}

for question_num , ACorWA in table:
    question_num = int(question_num)
    if question_num in statusAC:
        continue
    else:
        if ACorWA == "AC":
            statusAC[question_num] = "AC"
            if question_num in answer_status:
                answer_status[question_num] += ACorWA
            else:
                answer_status[question_num] = ACorWA
        else:
            if question_num in answer_status:
                answer_status[question_num] += ACorWA
            else:
                answer_status[question_num] = ACorWA

def penalty_count(dic):
    penalty_count = 0
    for num in dic:
        if "AC" in dic[num]:
            penalty_count  += (len(dic[num])-2)//2
        else:
            continue
    return penalty_count

# print(answer_status)
ans = len(statusAC)
penalty = penalty_count(answer_status)

print(ans,penalty)

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
a = [False]*n
b = [0]*n
for i in range(m):
    p,s = input().split()
    p = int(p)
    if s == 'AC':
        a[p-1] = True
    if s == 'WA' and a[p-1] == False:
        b[p-1] += 1
correct = a.count(True)
penalty = 0
for i in range(len(a)):
    if a[i] == True:
        penalty += b[i]
print(correct, penalty)

Submission status: Accepted

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

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

for i in range(m):
  x,y = input().split()
  x = int(x)
  if y == 'AC':
    a[x-1] = True
  elif y == 'WA' and a[x-1] == False:
    b[x-1] += 1

ac = 0
wa = 0
for i in range(n):
  if a[i] == True:
    ac += 1
    wa += b[i]
    
print(ac, wa)