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, raw_input().split())
#print N, M

state = [-1 for i in range(N)]
pena = [0 for i in range(N)]
WA = [0 for i in range(N)]

for i in range(M):
    s = raw_input().split()
    p = int(s[0])
    sc = s[1]
    #print p, sc
    p -= 1
    if (state[p] == 0):
        continue
    if sc == 'WA':
        pena[p] += 1
    else:
        state[p] = 0

ok = 0
pn = 0
for i in range(N):
    if state[i] == 0:
        ok += 1
        pn += pena[i]

print ok, pn

Submission status: Accepted

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

dwa = {}
dac = {}

for i in range(m):
    p, s = input().split()
    if s == "AC":
        if int(p) not in dac:
            dac[int(p)] = 1
        # else:
        #     dac[int(p)] += 1
    else:
        if (int(p) not in dac) and (int(p) not in dwa):
            dwa[int(p)] = 1
        elif int(p) not in dac:
            dwa[int(p)] += 1


# print(dac, dwa)
ans1 = sum(dac.values())
# ans2 = sum(dwa.values())
ans2 = 0
for i in dac.keys():
    if i in dwa:
        ans2 += dwa[i]

print(ans1, ans2)

Submission status: Accepted

Solution code:
nm = list(map(int, input().split()))
n = nm[0]
m = nm[1]

a = []
for i in range(m):
    a.append(input().split())

result_dic = {}

for i in range(n):
    result_dic[str(i+1)] = {'AC': 0, 'WA': 0}

for aa in a:
    if result_dic[aa[0]]['AC'] == 0:
        result_dic[aa[0]][aa[1]] += 1


ac_sum = 0
wa_sum = 0
for i in range(n):
    if result_dic[str(i+1)]['AC'] > 0:
        ac_sum += 1
        wa_sum += result_dic[str(i+1)]['WA']

print(str(ac_sum) + ' ' + str(wa_sum))

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
source_list = []
for i in range(m):
    instr = input()
    source_list_mini = []
    source_list_mini.append(instr.split(" ")[0])
    source_list_mini.append(instr.split(" ")[1])
    source_list.append(source_list_mini)

finish_dic = {}
pena_count_dic = {}
for source in source_list:
    pena_count_dic[source[0]] = 0
    finish_dic[source[0]] = False

for source in source_list:
    if source[1] == "AC":
        finish_dic[source[0]] = True
    else:
        if finish_dic[source[0]] == False:
            pena_count_dic[source[0]] += 1
        
ans_count = 0
for flag in finish_dic.values():
    if flag == True:
        ans_count += 1

pena_count = 0
for pro_num, pena in pena_count_dic.items():
    if finish_dic[pro_num] == True:
        pena_count += pena
     
print(ans_count, pena_count)

Submission status: Accepted

Solution code:
from collections import Counter

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

ac = 0
state = Counter()
penalty = 0
for p, S in pS:
    if state[p] != -1:
        if S == "WA":
            state[p] += 1
        else:
            penalty += state[p]
            ac += 1
            state[p] = -1

print(ac, penalty)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n,m = map(int,input().split())
cnt_pena = 0 # 初めてACが出た時にその時点でのcnt[i] をたす
cnt_ac = 0
cnt = [0]*n # 初めてACが出た時のその問題についてのWA数 ACがすでに出ていたらansに足した後その時点でcnt[i] は負にする
for i in range(m):
    p,s = map(str,input().split())
    if cnt[int(p)-1] >= 0 and s == "WA": 
        cnt[int(p)-1] += 1 
    elif cnt[int(p)-1] >= 0 and s == "AC": 
        cnt_pena += cnt[int(p)-1]
        cnt[int(p)-1] = -1
        cnt_ac += 1
    #print(cnt)
print(cnt_ac,cnt_pena)

Submission status: Accepted

Solution code:
n, m = [int(x) for x in input().split()]
nac = 0
nwa = 0
past = {}
for i in range(m):
    p, s = [x for x in input().split()]
    d = p + s
    if (p + 'AC') in past:
        next
    else:
        if s == 'WA':
            past[d] = 1 if d not in past else past[d] + 1
        else:
            past[d] = 1
            nac += 1
            nwa += 0 if (p + 'WA') not in past else past[p + 'WA']
print(nac, nwa)

Submission status: Accepted

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

Submission status: Accepted

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

flag = [0 for i in range(n)]
wa_count = [0 for i in range(n)]
count_ac = 0
count_wa = 0

for i in range(m):
    p, s = map(str, input().split(' '))
    p = int(p)
    if s == 'AC':
        if not flag[p-1]: # first AC
            count_ac += 1
            flag[p-1] = 1
            count_wa += wa_count[p-1]
    else: # WA
        if not flag[p-1]:
            wa_count[p-1] += 1

print('{} {}'.format(count_ac, count_wa))

Submission status: Accepted

Solution code:
def main():
    N, M = map(int, input().split())
    ans = [False for _ in range(N)]
    wa_list = [0 for _ in range(N)]

    ac = 0
    wa = 0

    for _ in range(M):
        i, result = input().split()
        i = int(i)
        if result == "AC":
            if ans[i-1] == False:
                ac += 1
                ans[i - 1] = True
                wa += wa_list[i-1]
        else:
            if ans[i - 1] == False:
                wa_list[i - 1] += 1
    if sum(ans) == 0:
        wa = 0

    print(ac, wa)
    return 0
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
problems = [False]*n
pen = [0]*n
for i in range(m):
    a,b = input().split()
    a = int(a)-1
    if not problems[a]:
        if b[0] == 'A':
            problems[a] = True
        else:
            pen[a] += 1
ngo = 0
ans = 0
for i in range(n):
    if problems[i]:
        ngo += pen[i]
        ans += 1
print(ans,ngo)

Submission status: Accepted

Solution code:
import math
n,m = map(int,input().split())
ps_ls = [list(input().split()) for i in range(m)]
ans_wa = 0
ans_ac = 0
strk_wa = 0
frag = 1
for i in range(m):
    ps_ls[i][0] = int(ps_ls[i][0])
ps_ls.sort(key=lambda x: x[0])

for i in range(m-1):
    if ps_ls[i][1] == "WA" and frag == 1:
        strk_wa += 1

    if ps_ls[i][1] == "AC":
        if frag == 1:
            ans_ac += 1
        frag = 0
        ans_wa += strk_wa
        strk_wa = 0
    if ps_ls[i][0] != ps_ls[i+1][0]:
        strk_wa = 0
        frag = 1
if ps_ls != []:
    if ps_ls[-1][1] == "AC":
        if frag == 1:
                ans_ac += 1
        ans_wa += strk_wa

print(ans_ac,ans_wa)

Submission status: Accepted

Solution code:
from sys import stdin
N,M = [int(x) for x in stdin.readline().rstrip().split()]
ans = [[] for i in range(N)]
for i in range(M):
    p,s = [(x) for x in stdin.readline().rstrip().split()]
    ans[int(p)-1].append(s)

ac = 0
pe = 0
tmp = 0
flag = False
for j in range(N):
    tmp = 0
    for k in ans[j]:
        if k == "WA":
            tmp += 1
        else:
            ac += 1
            pe += tmp
            tmp = 0
            break
print(ac,pe)

Submission status: Accepted

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

for i in range(m):
    check = input().split()
    if ac[int(check[0])-1]==0:
        if check[1]=='AC':
            ac[int(check[0])-1]=1
        else:
            wa[int(check[0])-1]+=1
for i in range(n):
    if ac[i]==0:
        wa[i]=0
ans = [sum(ac),sum(wa)]
print(*ans,sep=' ')

Submission status: Accepted

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

for i in range(M):
  P[i][0] = int(P[i][0])

ans_status = [0] * N
penalty = [0] * N
ans_count = 0

for i in range(M):
  if ans_status[P[i][0] - 1] != "AC":
    if P[i][1] == "AC":
      ans_status[P[i][0] - 1] = "AC"
      ans_count += 1
    else:
      penalty[P[i][0] - 1] += 1

penalty_count = 0

for i in range(N):
  if ans_status[i] == "AC":
    penalty_count += penalty[i]

print(ans_count, penalty_count)

Submission status: Accepted

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

ac = [0 for i in range(n+1)]
tmp = [0 for i in range(n+1)]

cnt_ac = 0
cnt_pen = 0

for i in range(m):
    p,s = map(str,input().split())
    p = int(p)
    
    
    #まだ不正解の場合
    if ac[p] == 0:
        if s == 'WA':
            if tmp[p] >= 0:
                tmp[p] += 1

        if s=='AC':
            ac[p] = 1
            cnt_ac += 1
            if tmp[p] > 0:
                cnt_pen += tmp[p]
                tmp[p] = -1

    #すでに正解した問題の場合
    else:
        continue

print(cnt_ac, cnt_pen)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

l = input().split(" ")
N = int(l[0])
M = int(l[1])
 
wa_dict = {}
answered = set()
 
ac_count = 0
wa_count = 0
 
for n in range(M):
    result = [i for i in input().split(" ")]
    p = result[0]
    if p in answered:
        continue
    s = result[1]
    if s == "WA":
        if p not in wa_dict:
            wa_dict[p] = 1
        else:
            wa_dict[p] += 1
    else:
        ac_count += 1
        if p in wa_dict:
        	wa_count += wa_dict[p]
        answered.add(p)
        if len(answered) == N:
            break
 
print(ac_count, wa_count)

Submission status: Accepted

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

ac_count = 0
wa_count = 0
p_dict = {str(i):[0,0] for i in range(1, n+1)}

for m_i in range(m):
  p,s = input().split()
  if p_dict[p][1] == 0:
    if s=='WA':
      p_dict[p][0] += 1
    elif s=='AC':
      p_dict[p][1] += 1
  
for val in p_dict.values():
  if val[1] == 1:
    ac_count += 1
    wa_count += val[0]
    
print(ac_count, wa_count)

Submission status: Accepted

Solution code:
temp=list(map(int, input().split()))
N=temp[0]
M=temp[1]
f=[0]*N
cnt=0
ac=0
wa=[0]*N
for i in range(M):
  temp=input().split()
  if f[int(temp[0])-1]==0:
    if temp[1]=='WA':
      wa[int(temp[0])-1]+=1
    else:
      f[int(temp[0])-1]=1
      ac+=1
cnt=sum([wa[i] if f[i]==1 else 0 for i in range(N)])
print(str(ac)+' '+str(cnt))

Submission status: Accepted

Solution code:




def main():
    n,m = map(int,input().split())
    d = dict()
    for i in range(m):
        a,b = input().split()
        a = int(a)
        if a not in d:
            d[a] = [0]
        if d[a][-1] != "AC":
            d[a].append(b)
    ac = 0
    pe = 0
    #print(d)
    for i in d.values():
        #print(i)
        if i[-1] == "AC":
            ac += 1
            pe += i.count("WA")
    print(ac,pe)








if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N,M = map(int, input().strip().split())
PS = [input().strip().split() for _ in range(M)]
acset = set()
acc = 0
wacd = {str(i):0 for i in range(1, N+1)}
for p, s in PS:
    if s == "WA" and p not in acset:
        wacd[p] += 1
    if s == "AC" and p not in acset:
        acc += 1
        acset.add(p)
wac = sum([c for i, c in wacd.items() if i in acset])
print(acc, wac)

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.readline

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

WA = [0] * (N + 1)
AC = [False] * (N + 1)
for _ in range(M):
    p, S = readline().split()
    p = int(p)
    if AC[p]:
        continue

    if S == 'AC':
        AC[p] = True
    else:
        WA[p] += 1

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

print(sum(AC), sum(WA))

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
LIST=[0]*(10**5+1)
PLIST=[0]*(10**5+1)

C=0
P=0
for i in range(M):
    A=list(map(str,input().split()))
    if(A[1]=="WA"):
        if(LIST[int(A[0])]==0):
            PLIST[int(A[0])]+=1
    else:
        if(LIST[int(A[0])]==0):
            C+=1
            LIST[int(A[0])]=1

for i in range(len(LIST)):
    P+=LIST[i]*PLIST[i]

print(C,P)

Submission status: Accepted

Solution code:
# import numpy as np
# import math
# import copy
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def main():
    N,M = map(int,input().split())
    pS = [input().split() for _ in range(M)]

    ACWA = [[0,0] for _ in range(N)]
    res = [0,0]

    for i in range(M):
        pnum = int(pS[i][0]) - 1
        result = pS[i][1]
        if result == 'AC':
            if ACWA[pnum][0] == 0:
                ACWA[pnum][0] += 1
                res[0] += 1
                res[1] += ACWA[pnum][1]
        elif result == 'WA':
            ACWA[pnum][1] += 1

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





main()

Submission status: Accepted

Solution code:
# coding: utf-8

N, M= (int(x) for x in input().split())

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

check = [[0, False] for x in range(N)]

for ps in pS:
	if ps[1] == "WA":
		if check[ps[0] - 1][1] == False:
			check[ps[0] - 1][0] += 1
	else: # "AC"
		check[ps[0] - 1][1] = True

ans = 0
penalty = 0
for c in check:
	if c[1] == True:
		ans += 1
		penalty += c[0]

print(str(ans) + " " + str(penalty))

Submission status: Accepted

Solution code:
from collections import defaultdict
N, M = map(int, input().split())
P = []
S = []
for i in range(M):
  p, s = input().split()
  P.append(int(p))
  S.append(s)
d = defaultdict(int)
d1 = defaultdict(int)
for i in range(M):
  if S[i] == "WA":
    if d[P[i]] != 1:
      d1[P[i]] += 1
  elif S[i] == "AC":
    d[P[i]] = 1
for i in range(M):
  if d[P[i]] == 0 and d1[P[i]] > 0:
    d1[P[i]] = 0
print(sum(d.values()), sum(d1.values()))

Submission status: Accepted

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

acd=[0 for i in range(N)]
walst=[0 for i in range(N)]
for p,S in pS:
    p=int(p)
    if not acd[p-1]:
        if S=="WA":
            walst[p-1]+=1
        else:
            ac+=1
            acd[p-1]=1
            wa+=walst[p-1]
print(ac,wa)

Submission status: Accepted

Solution code:
import numpy as np

n, m = map(int, input().split())
is_ac = np.zeros(n, dtype=bool)
wc_count = np.zeros(n, dtype=int)

for _ in range(m):
    p, s = input().split()
    p = int(p)
    if not is_ac[p - 1]:
        if s == "WA":
            wc_count[p - 1] += 1
        else:
            is_ac[p - 1] = True
print(is_ac.sum(), wc_count[is_ac].sum())

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N , M = map(lambda x: int(x),input().split())
isAC = ["WA"] * (N+1)
WAcount = [0] * (N+1)
score=0
penalty = 0
for i in range(M):
    p,r = input().split()
    #print(p,r)
    p = int(p)
    #p -= 1
    if isAC[p] =="AC":
        continue
    if r == "WA":
        WAcount[p] += 1
        #print(penalty)
    else:
        isAC[p] = "AC"
        score += 1
        #print(score)
    #print(isAC)
for i in range(N+1):
  if isAC[i]=="AC":
    penalty += WAcount[i]
print(score,penalty)

Submission status: Accepted

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

ans = [[0]*3 for _ in range(N)]
for ps in p_S:
  if ps[1] == "AC":
    ans[int(ps[0]) - 1][1] += 1
  elif ps[1] == "WA" and ans[int(ps[0]) - 1][1] == 0 :
    ans[int(ps[0]) - 1][2] += 1
ac = 0
pe = 0
#print(ans)

for a in ans:
  if a[1] >= 1:
    ac += 1
    pe += a[2]
print(ac, pe)

Submission status: Accepted

Solution code:
import itertools
n , m = list(map(int, input().split()))
p = []
s = []

cheak = [0]*n

for i in range(m):
    x,y = [j for j in input().split()]
    p.append(int(x))
    s.append(y)

ok = 0
out = 0

for i in range(m):
    if s[i]=="AC" and cheak[p[i]-1]==0:
        cheak[p[i]-1]=1
        ok += 1

#print(cheak)

for i in range(m):
    if cheak[p[i]-1]==1 and s[i]=="WA":
        out += 1
    elif cheak[p[i]-1]==1 and s[i]=="AC":
        cheak[p[i]-1]= -1

#print(cheak)      

print(str(ok)+" "+str(out))

Submission status: Accepted

Solution code:
import sys


def main():
    n, m = map(int, sys.stdin.readline().split(" "))
    mem = dict()
    ac_count = 0
    wrong_count = 0
    for _ in range(m):
        t, result = sys.stdin.readline().strip().split(" ")
        test_no = int(t)
        if test_no > n:
            continue
        if test_no in mem:
            if mem[test_no] > 0:
                if mem[test_no] == -1:
                    continue
                if result == "WA":
                    mem[test_no] += 1
                else:
                    ac_count += 1
                    wrong_count += mem[test_no]
                    mem[test_no] = -1
        else:
            mem[test_no] = result == "AC"
            if result == "WA":
                mem[test_no] = 1
            else:
                ac_count += 1
                mem[test_no] = 0
    print("%d %d" % (ac_count, wrong_count))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
d={}
for i in range(m):
  p,s=input().split()
  if p in d.keys():
    d[p].append(s)
  else:
    d[p]=[s,]
ac=0
wa=0
for k,v in d.items():
  if "AC" in v:
    for i in v:
      if i=="WA":
        wa=wa+1
      else:
        ac=ac+1
        break

print(ac,wa)

Submission status: Accepted

Solution code:
import sys
bbn=1000000007
	
#+++++

		
def main():
	n,m = map(int, input().split())
	ac_list=[False]*n
	wa_list=[0]*n
	for i in range(m):
		a,b=input().split()
		a=int(a)-1
		if not ac_list[a] and b=='WA':
			wa_list[a]+=1
		elif b =='AC':
			ac_list[a]=True
	ra=sum(ac_list)
	rb=sum([c if t else 0 for c,t in zip(wa_list,ac_list)])
	print(ra,rb)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Submission status: Accepted

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

Submission status: Accepted

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

N,M = map(int,input().split())
a=[tuple(map(str,input().split())) for _ in range(M)]
ac = [0]*N
wa = [0]*N
for i in range(M):
    q = int(a[i][0])-1
    res = a[i][1]
    if res == 'AC':
        ac[q] = 1
    else:
        if ac[q] == 0:
            wa[q] += 1
wa2=0
for i in range(N):
    if ac[i]==1:
        wa2 += wa[i]
print("{} {}".format(sum(ac),wa2))

Submission status: Accepted

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

pena = [0 for x in range(n + 1)]

clear = [False for i in range(n + 1)]

for i in range(m):
    p, c = input().split()
    p = int(p)
    if clear[p] is False:
        if c == "AC":
            clear[p] = True
        else:
            pena[p] += 1

ans_ac = 0
ans_pena = 0

for pe, cl in zip(pena, clear):
    if cl:
        ans_ac += 1
        ans_pena += pe

print(ans_ac, ans_pena)

Submission status: Accepted

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

ac_flag = [0 for _ in range(N)]
wa = ac_flag.copy()

for i in range(M):

    question, result = input().split(" ")
    question = int(question)

    if not ac_flag[question-1] and result == 'WA':
        wa[question - 1] += 1
    
    if result == 'AC':
        ac_flag[question-1] = 1

wa = [x*y for x, y in zip(ac_flag, wa)]
print(sum(ac_flag), sum(x*y for x, y in zip(wa, ac_flag)))

Submission status: Accepted

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

ac_list = [0] * (N+1)
wa_list = [0] * (N+1)
wa_cnt = 0
ac_cnt = 0

for _ in range(M):
  p, S = map(str, input().split())
  if S == 'AC':
    if ac_list[int(p)] == 0:
      ac_cnt += 1
      ac_list[int(p)] = 1
      wa_cnt += wa_list[int(p)]
    else:
      pass
  else:
    if ac_list[int(p)] == 0:
      wa_list[int(p)] += 1
    else:
      pass
    

print(ac_cnt, wa_cnt)

Submission status: Accepted

Solution code:
import numpy as np
N, M = list(map(lambda x: int(x), input().split()))
cleared = np.array([False for i in range(N+1)])
wa_count = np.array([0 for i in range(N+1)])
for _ in range(M):
  p, s = input().split()
  p = int(p)
  
  if cleared[p]:
    continue
  if s == "AC":
    cleared[p] = True
  elif s == "WA":
    wa_count[p] = wa_count[p] + 1

print("{} {}".format(sum(np.array(cleared) *1), sum(wa_count[cleared])))

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
S = [0] * N
r,w = 0,0
for i in range(M):
	p, s = input().split()
	if S[int(p)-1] >= 0:
		if s == 'AC':
			r+=1
			w+=S[int(p)-1]
			S[int(p)-1] = -1
		else:
			S[int(p)-1] = S[int(p)-1] + 1
print(r,w)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
status = {str(i): 0 for i in range(1, N+1)}
error = 0
for _ in range(M):
  q, r = input().split()
  if r == "AC": 
    if status[q] <= 0: 
    	error += -(status[q])
    status[q] = 1
  elif r =="WA":
    if status[q] <= 0: 
      status[q] -= 1

print(sum([i for i in status.values() if i > 0]), error)

Submission status: Accepted

Solution code:
from sys import stdin
n,m = [int(x) for x in stdin.readline().rstrip().split()]

li = [list(stdin.readline().rstrip().split()) for _ in range(m)]
lin = [0]*(n+1)
wor = [0]*(n+1)

for i in li:
    if lin[int(i[0])] == 0:
        if i[1] == "WA":
            wor[int(i[0])] += 1
        elif i[1] == "AC":
            lin[int(i[0])] = 1
wa = 0
for i in range(n+1):
    if lin[i] == 1:
        wa += wor[i]

print(sum(lin),wa)

Submission status: Accepted

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

arr = [False]*n
warr = [0]*n

for i in range(m):
    p,s = input().split()
    p = int(p)-1
    if arr[p]:
        pass
    else:
        if s == "AC":
            arr[p] = True
        else:
            warr[p] += 1

warr = [warr[i] if arr[i] else 0 for i in range(n)]
answer = str(sum(arr)) + " " + str(sum(warr))
print(answer)

Submission status: Accepted

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

n, m = map(int, input().split())
check_list = [0] * n
ac_count = 0
wa_count = 0
wa_list = [0] * n
for i in range(0, m):
    p, s = input().split()
    if check_list[int(p) - 1] == 0:
        if s == "WA":
            wa_list[int(p) - 1] += 1
        else:
            ac_count += 1
            check_list[int(p) - 1] = 1
            wa_count += wa_list[int(p) - 1]
print(ac_count, wa_count)

Submission status: Accepted

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

N,M = map(int,readline().split())
PS = [line.split() for line in readlines()]

AC = [False] * (N+1)
WA_cnt = [0] * (N+1)

penal = 0
for p,s in PS:
    p = int(p)
    if AC[p]:
        continue
    if s == b'WA':
        WA_cnt[p] += 1
    else:
        AC[p] = True
        penal += WA_cnt[p]

ac = sum(AC)
print(ac, penal)

Submission status: Accepted

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

AB=[]
for i in range(M):
    a,b=map(str,input().split())
    AB.append([a,b])

AC,WA=0,0
cu=AB[0][0]
L=[[0,0] for i in range(N+1)]

for i in range(M):
    t,s=int(AB[i][0]),AB[i][1]
    if L[t][0]==1:
        continue
    elif s=='AC':
        L[t][0]+=1
    else:
        L[t][1]+=1

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

print(AC,WA)

Submission status: Accepted

Solution code:
from collections import Counter

N, M = input().split()
N, M = int(N), int(M)
p = [0] * M
S = [0] * M

cnt_wa = Counter()
cnt_ac = Counter()
cnt_wa_all = 0
cnt_ac_all = 0
for i in range(M):
    pt, S = input().split()
    p = int(pt)

    if cnt_ac[p] == 0:
        if S == 'WA':
            cnt_wa.update([p])
        if S == 'AC':
            cnt_ac.update([p])
            cnt_ac_all += 1
            cnt_wa_all += cnt_wa[p]

print(cnt_ac_all, cnt_wa_all)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
cnt = [0]*n

ac_cnt = 0
wa_cnt = 0
for _ in range(m):
    _p, _s = map(str, input().split())
    _p = int(_p)-1
    #print("%d %s"%(_p, _s))
    if cnt[_p] != -1:
        #print(_s)
        if _s == 'WA':
            cnt[_p] += 1
        else:
            ac_cnt += 1
            wa_cnt += cnt[_p]
            cnt[_p] = -1

print("%d %d"%(ac_cnt, wa_cnt))

Submission status: Accepted

Solution code:
# coding: utf-8
N, M = map(int, input().split())
ac, wa = 0, 0
l = {}
T = {}
idx, sta = -1, -1
for i in range(M):
    tmp = input().split()
    p = int(tmp[0])
    s = tmp[1]
    if p not in l.keys():
        l[p] = 0
        T[p] = False
    if s == "AC" and not T[p]:
        ac += 1
        T[p] = True
    if s == "WA" and not T[p]:
        wa += 1
        l[p] += 1
cnt = 0
for k in l.keys():
    if not T[k]:
        cnt += l[k]
print(ac, wa-cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, M = [int(n) for n in input().split(' ')]
WA = {}
AC = {}
for i in range(M):
    p, S = [n for n in input().split(' ')]
    if p not in WA:
        WA[p] = 0
    if S == "WA":
        WA[p] += 1
    else:
        if p not in AC: 
            AC[p] = WA.pop(p)
print(len(AC), sum(AC.values()))

Submission status: Accepted

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

answer = [[False, 0] for i in range(n)]

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

  if s == 'AC':
    answer[p][0] = True
  else:
    answer[p][1] += 1

cor = sum(map(lambda x: x[0], answer))
pen = sum(map(lambda x: x[1] if x[0] == True else 0, answer))
print(cor, pen)

Submission status: Accepted

Solution code:
N ,M = map(int,input().split())
P_list = [0 for i in range(N+1)]
AC_count = 0
WA_count = 0

for i in range(M):
    box = input().split()
    if P_list[int(box[0])] != "AC":
        if box[1] == "AC":
            AC_count += 1
            WA_count += P_list[int(box[0])]
            P_list[int(box[0])] = "AC"
        elif box[1] == "WA":
            P_list[int(box[0])] += 1


print(AC_count,WA_count)

Submission status: Accepted

Solution code:
all_question, submission_count = map(int, input().split())
results = {}
for _ in range(submission_count):
    question_num, res = input().split()
    if question_num not in results:
        results[question_num] = []
    results[question_num].append(res)


def get_index(l, x):
    if x in l:
        return l.index(x)
    else:
        return -1

clear_count = penalty_count = 0

for questuin_num, res_list in results.items():
    index = get_index(res_list, "AC")
    if index == -1:
        continue
    penalty_count += index
    clear_count += 1

print(clear_count, penalty_count)

Submission status: Accepted

Solution code:
N, M = map(int, input().split(' '))
penalty = [0] * N
actually = [False] * N
for i in range(M):
    ptmp, stmp = input().split(' ')
    pi = int(ptmp)-1
    if actually[pi] == False:
        if stmp == 'WA':
            penalty[pi] += 1
        else:
            actually[pi] = True

sum_penalty = 0
sum_correct = 0
for i in range(N):
    if actually[i] == True:
        sum_correct += 1
        sum_penalty += penalty[i]
print(sum_correct, sum_penalty)

Submission status: Accepted

Solution code:
from collections import defaultdict
N,M = map(int,input().split())
d1 = defaultdict(lambda:False)
d2 = defaultdict(lambda:0)
for i in range(M):
    p,s = input().split()
    if s == 'WA':
        if not d1[p]:
            d2[p] += 1
    else:
        if not d1[p]:           
            d1[p] = True
ans = [0,0]
for p in d1:
    if d1[p]:
        ans[0] += 1
        ans[1] += d2[p]
print(*ans)

Submission status: Accepted

Solution code:
n, m = [int(x) for x in input().split()]
ac = [0] * (n + 1)
wa = [0] * (n + 1)

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

print(sum(ac), sum([p for a, p  in zip(ac, wa) if a == 1]))

Submission status: Accepted

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

Submission status: Accepted

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


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

acs, was = 0, 0

for i in range(n):
    acs += ac[i]
    was += ac[i] * wa[i]

print(acs, was)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
AC=[0]*(n+1)
pen=[0]*(n+1)
for i in range(m):
    p,s=input().split()
    p=int(p)
    if s=="AC":
        AC[p]=1
    else:
        if AC[p]==0:
            pen[p]+=1
print(sum(AC),sum([AC[i]*pen[i] for i in range(n+1)]))

Submission status: Accepted

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

print(str(ac)+' '+str(wa))