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
input = sys.stdin.readline

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

ac = [0 for _ in range(n)]
wa = [0 for _ in range(n)]

for i in range(m):
    if p_s[i][1] == 'WA':
        if ac[int(p_s[i][0]) - 1] == 0:
            wa[int(p_s[i][0]) - 1] += 1
    else:
        ac[int(p_s[i][0]) - 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())
dw=dict()
da=dict()
for i in range(M):
    k,v=input().split()
    if k not in da.keys():
        if v=="WA":
            if k in dw.keys():
                dw[k]+=1
            else:
                dw[k]=1
        else:
            da[k]=1
for k in dw.keys():
    if k not in da.keys():
        dw[k]=0
print(sum(da.values()),sum(dw.values()))

Submission status: Accepted

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

ACSet = set([])
WAList = []
WAcnt = 0

for i in range(M):
    s = input().split()
    # N問と決まっているので、N問分のACが出た時点で判定不要となる
    if len(ACSet) != N:
        if s[1] == 'AC':
            ACSet.add(s[0])
        # WAはまだ正当してない問題についてのみリストに詰める
        elif s[1] == 'WA' and s[0] not in ACSet:
            WAList.append(s[0])

# WAListの内、ACSetに入っている問題の数のみ数える
for i in range(len(WAList)):
    if WAList[i] in ACSet:
        WAcnt += 1

print("{} {}".format(len(ACSet), WAcnt))

Submission status: Accepted

Solution code:
def main():
  AC = 0
  WA = 0
  
  solving = {}
  solved = {}
  
  N,M = map(int, input().split())
  
  for i in range(M):
    p, s = input().split()
    if p in solved:
      continue
    elif s == 'WA':
      if p in solving:
        _wa = solving[p]
        solving[p] = _wa + 1
      else:
        solving[p] = 1
    else:
      AC += 1
      if p in solving:
      	WA += solving[p]
      solved[p] = True
  
  print(AC, WA)
  return 0
 
if __name__ == "__main__":
  main()

Submission status: Accepted

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

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()
    p[i] = int(p_i)




penal_ct = 0
ac_count = 0
# prev_ac_num = -1
ac_list = [False] * N
pos = 0

wa_count = [0] * N

for i in range(M):
    if S[i] == 'WA':
        wa_count[p[i] - 1] += 1
        # print(wa_count[p[i] - 1])
    elif (not ac_list[p[i] - 1]) and S[i] == 'AC': # ACかつ今までにACしてない
        ac_list[p[i] - 1] = True
        ac_count += 1
        if i == 0:
            continue
        penal_ct += wa_count[p[i] - 1]
        # for j in range(i)[::-1]:
        #     if S[j] == 'WA' and p[j] == p[i]:
        #         penal_ct += 1
    # if all(ac_list):
        # break
# print(wa_count)
print(ac_count, penal_ct)

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
seito = 0
penarty = 0
pena = [False for i in range(N+1)]
pena2 = [0 for i in range(N+1)]
for i in range(M):
    p,s = input().split()
    p = int(p)
    if not pena[p]:
        if s == "AC":
            pena[p]=True
            seito += 1
        else:
            pena2[p] += 1

for i in range(N+1):
    if pena[i]:
        penarty += pena2[i]
print(seito,penarty)

Submission status: Accepted

Solution code:
from collections import defaultdict as dd

ac = dd(bool);pen,cor=0,0
wc = dd(int)
n,m = map(int,input().split())
for i in range(m):
	l = input().split()
	p = int(l[0]);ans=l[1]
	if ac[p]==False and ans=='WA':
		wc[p]+=1
	elif ac[p]==False and ans=='AC':
		pen+=wc[p]
		cor+=1
		ac[p]=True
		
print(cor,"",pen)

Submission status: Accepted

Solution code:
if __name__ == "__main__":
    N, M = [int(s) for s in input().split()]
    accepted = [False] * N
    penalties = [0] * N
    for _ in range(M):
        p, S = input().split()
        p = int(p)
        # S = 'AC' or 'WA'
        if S == "AC":
            accepted[p - 1] = True
        if S == "WA" and not accepted[p - 1]:
            penalties[p - 1] += 1

    N_accepted = len([a for a in accepted if a])
    sum_penalties = sum([p for p, a in zip(penalties, accepted) if a])
    print(N_accepted, sum_penalties)

Submission status: Accepted

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


def solve(N: int, M: int, p: "List[int]", S: "List[str]"):
    wa_flag = [0] * N
    num_penalty = 0
    for i in range(M):
        if S[i] == "WA":
            if wa_flag[p[i]-1] != -1:
                wa_flag[p[i]-1] += 1
        else:
            if wa_flag[p[i]-1] != -1:
                num_penalty += wa_flag[p[i]-1]
                wa_flag[p[i]-1] = -1
    num_ac = wa_flag.count(-1)
    print(num_ac, num_penalty)
# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    N, M = map(int, input().split())
    p = [None] * M
    S = [None] * M
    for i in range(M):
        pi, si = input().split()
        p[i] = int(pi)
        S[i] = str(si)
    solve(N, M, p, S)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
question_num, my_submit = list(map(int, input().split(' ')))
sub_list = [[]]*my_submit

for i in range(my_submit):
    sub_list[i] = input().split(' ')

question_results = ['hoge'] + [[False, 0, 0] for i in range(question_num)] # bool(ac?), wa, ac

for j in sub_list:
    if question_results[int(j[0])][0] == False:
        if j[1] == 'WA':
            question_results[int(j[0])][1] += 1
        elif j[1] == 'AC':
            question_results[int(j[0])][0] = True
            question_results[int(j[0])][2] += 1

ac = 0
wa = 0
for k in question_results:
    if k is not 'hoge':
        if k[0] == True:
            ac += 1
            wa += k[1]

print(ac, wa)

Submission status: Accepted

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

D=['0']*N
Z=[0]*N
a=0
p=0
for i in range(M):
  if D[P[i]-1]!='AC'and A[i]=='WA':
    Z[P[i]-1]+=1
    D[P[i]-1]='WA'
  elif D[P[i]-1]!='AC' and A[i]=='AC':
    a+=1
    p+=Z[P[i]-1]
    D[P[i]-1]='AC'

print(a,p)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
accepted=[False for _ in range(n)]
submitted=[0 for _ in range(n)]
for _ in range(m):
    p,s=input().split()
    p=int(p)-1
    if s=='AC':
        accepted[p]=True
    if not accepted[p]:
        submitted[p]+=1
print(sum(accepted),sum(submitted[p] for p in range(n) if accepted[p]))

Submission status: Accepted

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

ans = {}
if M > 0:
  for _ in range(M):
    key, value = input().split()
    if key not in ans:
      ans[key] = []
    ans[key].append(value)
else:
  print(0," ",0)
  exit()

ac = 0
wa = 0

for v in ans.values():
  if 'AC' in v: # ACを出している場合
    for a in v:
      if a == 'WA':
        wa += 1
      else:
        ac += 1
        break
  else: # ACを出していない場合
    continue

print(ac, " ", wa)

Submission status: Accepted

Solution code:
n,m = map(int, input().split())
wa = 0
ac_list = {'AC':{}, 'WA':{}}
if m==0:
    print(0,0)
else:
    for i in range(m):
        p,s = input().split()
        ac_list[s][p] = ac_list[s].get(p, 0) + 1* int(not(p in ac_list['AC'].keys()))
    kyotu_key = list(set(ac_list['AC'].keys()) & set(ac_list['WA'].keys()))
    wa_list = [ac_list['WA'][p] for p in kyotu_key]
    print(len(ac_list['AC'].keys()), sum(wa_list))

Submission status: Accepted

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

ac_flag = [False]*n
wa_counts = [0]*n

for i in range(m):
  p,s = map(str,input().split())
  p = int(p)-1
  if s == 'AC':
    ac_flag[p] = True
  else:    
    if ac_flag[p] == False:
      wa_counts[p] += 1

wa_ans = 0
for i in range(n):
  if ac_flag[i]:
    wa_ans += wa_counts[i]
print('{} {}'.format(sum(ac_flag), wa_ans))

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
ans_ac = 0
ans_wa = 0
lst = []
for i in range(n):
  lst.append([False, 0])
for i in range(m):
  p, s = input().split()
  p = int(p) - 1
  if lst[p][0]:
    continue
  if s == 'WA':
    lst[p][1] += 1
  else:
    ans_ac += 1
    ans_wa += lst[p][1]
    lst[p][0] = True
print(ans_ac, ans_wa)

Submission status: Accepted

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

for _ in range(m):
  num, ans = input().split()
  num = int(num) - 1
  if ans == 'AC':
    if problems[num] == 0:
      problems[num] = 1
  else:
    if problems[num] == 0:
      was[num] += 1
      
for i, problem in enumerate(problems):
  if problem == 0:
    was[i] = 0

print('{} {}'.format(sum(problems), sum(was)))

Submission status: Accepted

Solution code:
N,M=[int(_) for _ in input().split()]
PS=[input().split() for _ in range(M)]
count=[0]*(N+1)
isac=[0]*(N+1)
for p,s in PS:
 p=int(p)
 if isac[p]==1:
    continue
 if s=='AC':
  isac[p]=1
 else:
  count[p]+=1
wa=0
ac=0
for i in range(N+1):
 if isac[i]==1:
  ac+=1
  wa+=count[i]
print(ac,wa)

Submission status: Accepted

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

Submission status: Accepted

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

print(str(numAC) + ' ' + str(sumWA))

Submission status: Accepted

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

ac_list = [0]*(n+1)
wa_list = [0]*(n+1)
wa = 0
ac = 0
if m == 0:
    pass
else:
    for i in range(m):
        p, s = input().split()
        p = int(p)
        if ac_list[p] == 1:
            continue
        if ac_list[p] == 0 and s == 'AC':
            ac_list[p] = 1
        #elif check_list[p] == 0 and s == 'WA':                                          
        else:
            wa_list[p] += 1
    for t_ac, t_wa in zip(ac_list, wa_list):
        if t_ac == 1:
            wa += t_wa
            ac += t_ac
print(ac, wa)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
wacou = [0]*N
acchc = [0]*N
for i in range(M):
  p, s = input().split()
  p = int(p)
  if s=='WA' and acchc[p-1]<1:
    wacou[p-1] += 1
  elif s=='AC' and acchc[p-1]<1:
    acchc[p-1] = 1
  else:
    continue
print(acchc.count(1), sum([x*y for x, y in zip(acchc, wacou)]))

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
ansFlag = [0 for i in range(n)]
waList = [0 for i in range(n)]
ac = 0
wa = 0
for i in range(m) :
  p, S = input().split()
  p = int(p)
  if str(S) == 'AC' and ansFlag[p-1] == 0 :
    ac += 1
    ansFlag[p-1] = 1
  elif ansFlag[p-1] == 0 :
    wa += 1
    waList[p-1] += 1
    
for i in range(len(ansFlag)) :
  if ansFlag[i] == 0 :
    wa -= waList[i]
print(str(ac) + ' ' + str(wa))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(N: int, M: int, p: "List[int]", S: "List[str]"):
    
    dp = [[0, 0] for i in range(N+1)]
    for i in range(M):
        if S[i] == 'AC':
            dp[p[i]][0] = 1
            
        else:
            if dp[p[i]][0] == 0:
                dp[p[i]][1] += 1

    ac = len([dp[i][0] for i in range(1, N+1) if dp[i][0] > 0])
    wa = sum([dp[i][1] for i in range(1, N+1) if dp[i][0] > 0])
    # print(dp[:10])
    # print([dp[i][0] for i in range(1, N+1)])
    print(ac, wa)

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    p = [int()] * (M)  # type: "List[int]"
    S = [str()] * (M)  # type: "List[str]"
    for i in range(M):
        p[i] = int(next(tokens))
        S[i] = next(tokens)
    solve(N, M, p, S)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
p=[list(input().split())for _ in range(m)]
q=[0]*n
c=0
wc=0
for i in range(m):
  if p[i][1] == "WA":
    q[int(p[i][0])-1] += 1
  else:
    if q[int(p[i][0])-1] >= 0:
      c += 1
      wc += q[int(p[i][0])-1]
      q[int(p[i][0])-1] -= 10**6

print(c,wc)

Submission status: Accepted

Solution code:

class Question:
    def __init__(self, AC, WAcount):
        self.AC = AC
        self.WAcount = WAcount


def WelcomeTo():
    N, M = map(int, input().split())
    Qlist = []
    ACcount = 0
    WAcount = 0
    for _ in range(0, N + 1):
        Qlist.append(Question('False', 0))
    for _ in range(M):
        num, judge = input().split()
        num = int(num)
        if Qlist[num].AC == 'True':continue

        if judge == 'AC':
            ACcount += 1
            WAcount += Qlist[num].WAcount
            Qlist[num].AC = 'True'
        elif judge == 'WA':
            Qlist[num].WAcount += 1

    print('{} {}'.format(ACcount, WAcount))


WelcomeTo()

Submission status: Accepted

Solution code:
import numpy as np

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

A=[0 for _ in range(N)]
B=[0 for _ in range(N)]
C=[0 for _ in range(N)]

for i in range(M):
    p,S = input().split()
    p = int(p)-1
    if S == "AC":
        A[p] = 1
        C[p] = B[p]
    elif A[p]==0:
        B[p] += 1
    
A = np.array(A)
C = np.array(C)
print(np.sum(A), np.sum(C))

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
q = ["WA" for i in range(N)]
wa_list = [0 for i in range(N)]
ac_list = [0 for i in range(N)]
wa = 0
ac = 0
for i in range(M):
    p,s = map(str,input().split())
    if s == "WA" and q[int(p)-1] == "WA":
        wa_list[int(p)-1]+=1
    elif s == "AC" and q[int(p)-1] == "WA":
        q[int(p)-1] = "AC"
        ac_list[int(p)-1] = wa_list[int(p)-1]
        #ac+=1
ac = q.count("AC")
wa = sum(ac_list)
print(ac,wa)

Submission status: Accepted

Solution code:
from operator import itemgetter
N,M = map(int,input().split())
p = [0] * M
S = [0] * M
BUF = [[0 for i in range(2)] for i in range(M)]

for i in range(M) :
    p[i],S[i] = map(str,input().split())
    p[i] = int(p[i])
    BUF[i][0] = p[i]
    BUF[i][1] = S[i]
BUF_new = sorted(BUF,key=itemgetter(0))
#print(BUF_new)

Flag = False
buf_goal = 0
buf_pena = 0
buf = -1
buf_2 = 0
buf_3 = -1

for i in range(M) : #余分な情報削除
    if Flag == True :
        if BUF_new[i][0] == buf :
            #BUF_new.pop(i)
            BUF_new[i][1] = 'NULL'
        else :
            Flag = False
            buf = -1
    if Flag == False :
        if BUF_new[i][1] == 'AC' :
            Flag = True
            buf = BUF_new[i][0]

for i in range(M) :
    if BUF_new[i][1] == 'WA' :
        if buf_3 == BUF_new[i][0] :
            buf_2 += 1
        else :
            buf_2 = 0
            buf_2 += 1
        buf_3 = BUF_new[i][0]

    if BUF_new[i][1] == 'AC' :
        if buf_3 == BUF_new[i][0] :
            buf_pena += buf_2
            buf_goal += 1
            buf_2 = 0
            buf_3 = -1
        else :
            buf_goal += 1
            buf_2 = 0
            buf_3 = -1
#print(BUF_new)
print(buf_goal,buf_pena)

Submission status: Accepted

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

list_correct = [0] * n
list_pena = [0] * n
for i in range(m):
  if s[i] == "AC":
    if list_correct[p[i]-1] == 0:
      list_correct[p[i]-1] = 1
  else:
    if list_correct[p[i]-1] == 0:
      list_pena[p[i]-1] = list_pena[p[i]-1] + 1
      
sum_correct = sum(list_correct)
combined = [x * y for (x, y) in zip(list_correct, list_pena)]
sum_pena = sum(combined)

print (sum_correct, sum_pena)

Submission status: Accepted

Solution code:
mondaisu,kaitosu=map(int, input().split())
kuroji=[0]*mondaisu
akaji=[0]*mondaisu
for i in range(kaitosu):
    a,kekka = input().strip().split()
    a=int(a)
    if kuroji[a-1]==1:
        pass
    elif kuroji[a-1]==0:
        if kekka=="WA":
            akaji[a-1]+=1
        else:
            kuroji[a-1]=1
for i in range(mondaisu):
    if kuroji[i]==0:
        akaji[i]=0
kurojisum=sum(kuroji)
akajisum=sum(akaji)
print(kurojisum,akajisum)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
penalty = 0
answers = 0
mydict  = {}
for i in range(M):
    tmp1,tmp2 = input().split()
    if tmp1 in mydict.keys():
        if mydict[tmp1][0] == "WA" and tmp2 == "WA":
            mydict[tmp1][1] = mydict[tmp1][1] + 1
        elif mydict[tmp1][0] == "WA" and tmp2 == "AC":
            penalty = penalty + mydict[tmp1][1] 
            mydict[tmp1][0] = tmp2
            answers = answers + 1
        else:
            continue 
    else:
        mydict[tmp1] = [tmp2,0] #keyの登録["判定",不正回数]
        if tmp2 == "WA":
            mydict[tmp1][1] = mydict[tmp1][1] + 1
        else:
            answers = answers + 1
    #print(mydict)
print(answers,end=" ")
print(penalty)

Submission status: Accepted

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

ac = 0
wa = 0

for m in range(M):
    p, S = input().split()
    if p not in dic and S == 'WA':
        dic[p] = {'AC' : 0, 'WA' : 1}
    elif p not in dic and S == 'AC':
        dic[p] = {'AC' : 1, 'WA' : 0}
    elif p in dic and dic[p]['AC'] == 1:
        continue
    elif p in dic and dic[p]['AC'] != 1:
        if S == 'AC':
            dic[p]['AC'] += 1
        else :
            dic[p]['WA'] += 1 

for i in dic:
    if dic[i]["AC"] != 0:
        ac += dic[i]["AC"]
        wa += dic[i]["WA"] 


print('{0} {1}'.format(ac, wa))

Submission status: Accepted

Solution code:
from collections import Counter

x = input().split()
n = int(x[0])
m = int(x[1])

d = {}

ac = 0
pe = 0

c = Counter()

for i in range(m):
    k = input().split()
    pi = int(k[0])
    s = k[1]
    if pi in d:
        continue
    if s == "AC":
        ac += 1
        d[pi] = True
        pe += c[pi]
    else:
        c[pi] += 1

print("{} {}".format(ac, pe))

Submission status: Accepted

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

result = [0]*N
wa = 0
ac = 0

for i in range(M):
    p,s = [i for i in input().split(" ")]
    if result[int(p)-1] != -1:
        if s == 'AC':
            wa += result[int(p)-1]
            result[int(p)-1] = -1
            ac += 1
        else:
            result[int(p)-1] += 1
        
            

print(ac,wa,sep=' ')

Submission status: Accepted

Solution code:
import sys
import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N, M = list(map(int, readline().split()))
pS = [readline().decode('utf-8').split() for _ in range(M)]
cnt_list = [0] * (N + 1)
ACed_list = [0] * (N + 1)

for p_, s in pS:
    p_ = int(p_)

    if s == 'AC':
        if ACed_list[p_] == 0:
            ACed_list[p_] = 1
    else:
        if ACed_list[p_] == 0:
            cnt_list[p_] += 1

for i in range(N + 1):
    if ACed_list[i] == 0:
        cnt_list[i] = 0

print(sum(ACed_list), sum(cnt_list))

Submission status: Accepted

Solution code:
pro_number, submit_number = [s for s in input().split()]
AC = [0] * int(pro_number)
WA = [0] * int(pro_number)
for i in range(int(submit_number)):
  section,output = [s for s in input().split()]
  if AC[int(section)-1]==0 and output=="WA":
    WA[int(section)-1]=WA[int(section)-1]+1
  
  elif output=="AC":
    AC[int(section)-1]=1

AC_number=0
WA_number=0
for i in range(int(pro_number)):
  if AC[i]==0:
    WA[i]=0
    
  AC_number=AC_number+AC[i]
  WA_number=WA_number+WA[i]

print(AC_number,WA_number)

Submission status: Accepted

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

wa = 0
ac = 0


from collections import defaultdict
dict = defaultdict(list)
for i in range(m):
    dict[p[i][0]].append(p[i][1])

for i in dict:
    if "AC" not in dict[i]:
        continue
    for j in range(len(dict[i])):
        result = dict[i][j]
        if result == "WA":
            wa += 1
        if result == "AC":
            ac += 1
            break

print(ac, wa)

Submission status: Accepted

Solution code:
from operator import itemgetter
N, M = map(int, input().split())
list = []

for k in range(M):
    p, S = map(str, input().split())
    p = int(p)
    if S == 'WA':
        S = 0
    else:
        S = 1
    list.append([k, p, S])

list.sort(key=itemgetter(1))

#0処理忘れない
if M != 0:
    wacount = 0
    correct = 0
    #初期条件
    if list[0][2] == 0:
        w_count = 1
        c_count = 0
        mark = 1
        ans=[0, 0]
    else:
        w_count = 0
        c_count = 1
        mark = 0
        ans = [1, 0]

    for i in range(1, M):
        if list[i][1] == list[i-1][1]:
            if mark == 1:
                if list[i][2] == 0:
                    w_count += 1
                else:
                    ans = [ans[0]+1, ans[1]+w_count]
                    mark *= 0

        else:
            if list[i][2] == 0:
                w_count = 1
                c_count = 0
                mark = 1
            else:
                w_count = 0
                c_count = 1
                mark = 0
                ans = [ans[0]+1, ans[1]]
else:
    ans = [0, 0]
print(ans[0], ans[1])

Submission status: Accepted

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

ac_chk = [0]*(N+1)
wa_chk = [0]*(N+1)
wa = 0
ac = 0

for i in range(M):
	p, S = input().split()
	p = int(p)
	if ac_chk[p] == 0:
		if S == "AC":
			ac_chk[p] = 1
			ac += 1
			wa += wa_chk[p]
			continue
		if S == "WA":
			wa_chk[p] += 1
			continue
	else:
		continue
print(ac, wa)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
#N = int(input())
N, M = map(int, input().split())
L = []
for _ in range(M) :
  L.append(list(map(str, input().split())))
#print(L)

A = [[0 for _ in range(2)] for _ in range(N+1)]

for i in range(M) :
  if L[i][1] == "WA" and A[int(L[i][0])][1] != 1:
    A[int(L[i][0])][0] += 1
  else :
    A[int(L[i][0])][1] = 1

#print (A)
ACsum = 0
WAsum = 0
for j in range(N+1) :
  if A[j][1] == 1 :
    ACsum += 1
    WAsum += A[j][0]
  
print(str(ACsum) + " " + str(WAsum))

Submission status: Accepted

Solution code:
def sum(arg):
  ans = 0
  for i in arg:
    ans += i
  return ans

N, M = map(int, input().split())
ac = [0]*N
wa = [0]*N
pe = [0]*N
for i in range(M):
  pi, si = input().split()
  pi = int(pi)
  if si == "AC" and ac[pi-1] == 0:
    ac[pi-1] = 1
    pe[pi-1] = wa[pi-1]
  if si == "WA" and ac[pi-1] == 0:
    wa[pi-1] += 1
print(sum(ac), sum(pe))

Submission status: Accepted

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

temp = {}
acs = set()
for no, result in submits:
  if result == 'AC':
    temp[no] = temp.get(no, 0)
    acs.add(no)
  else:
    if no not in acs:
      temp[no] = temp.get(no, 0) + 1
      
print(len(acs), sum([temp[no] for no in acs]))

Submission status: Accepted

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

ans_list = [0]*(N+1)
pen_list = [0]*(N+1)

for i in range(M):
  p_i, S_i = input().split()
  p_i = int(p_i)
  
  if (ans_list[p_i] == 0):
    if(S_i == "WA"):
      a = pen_list[p_i]
      a += 1
      pen_list[p_i] = a
    elif(S_i == "AC"):
      ans_list[p_i] = 1

pen_lis_ans = list(itertools.compress(pen_list, ans_list))
cor_num = sum(ans_list)
pen_num = sum(pen_lis_ans)
                   
print("{} {}".format(cor_num,pen_num))

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
p_list = []
s_list = []
ac_list = [0] * (n + 1)
ac, wa = 0, 0
if m == 0:
    print(0, 0)
else:
    for i in range(m):
        p, s = map(str, input().split())
        p = int(p)
        p_list.append(p)
        s_list.append(s)
        if s == "WA":
            if ac_list[p] == 0:
                wa += 1
            else:
                continue
        elif s == "AC":
            if ac_list[p] == 0:
                ac += 1
                ac_list[p] = 1
            else:
                continue
    for i in reversed(p_list):
        if ac_list[i] == 0:
            wa -= 1
    print(ac, wa)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
l=[list(input().split()) for i in range(m)]
from collections import defaultdict
cnt_ac=defaultdict(lambda:0)
cnt_wa=defaultdict(lambda:0)

count_wa=0
count_ac=0
for i in range(m):
    if cnt_ac[l[i][0]]==0:
        
        if l[i][1]=='WA':
            cnt_wa[l[i][0]]+=1
        
        elif l[i][1]=='AC':
            cnt_ac[l[i][0]]=1
            count_ac+=1
            count_wa+=cnt_wa[l[i][0]]
print(count_ac,count_wa)

Submission status: Accepted

Solution code:
n, m = list(map(int, input().split()))
d = dict()
score = 0
penalty = 0
pencount = dict()
for i in range(m):
	p, stat = input().split()
	p = int(p)
	# if p not in d:
	# 	d[p] = list()
	if p not in d:
		d[p] = 0
		pencount[p] = 0
	if stat == "AC" and d[p] == 0:
		d[p] = 1
		score += 1
	elif stat == "WA" and d[p] != 1:
		d[p] = 0
		pencount[p] += 1
	elif d[p] == 1:
		pass
for problem in d.keys():
	if d[problem] == 1:
		penalty += pencount[problem]


# for problem in d.keys():
# 	for solution in d[problem]:
# 		if solution:
# 			score += 1
# 			break
# 		else:
# 			penalty += 1
print("{0} {1}".format(score, penalty))

Submission status: Accepted

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

ac = 0
wa = [0]*n
d = [False]*n

for _ in range(m):
    p, s = input().split()
    p = int(p)-1
    if not d[p] and s == 'AC':
        ac += 1
        d[p] = True
    elif not d[p] and s == 'WA':
        wa[p] += 1
p = 0
for i in range(n):
    if d[i]:
        p += wa[i]
print(ac, p)

Submission status: Accepted

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


r = ['WA']*(N+1)
wa_li = [0]*(N+1)
o = []
c = 0
ac_c = 0

for ps in li:
    index = int(ps[0])
    if ps[1] == 'WA':
        if r[index] == 'WA':
            wa_li[index]+=1

    else: # AC
        if r[index] == 'WA':
            r[index] = 'AC'
            ac_c += 1
        else:
            pass

p_c =0
for i,v in enumerate(r):
    if v == 'AC':
        p_c+=wa_li[i]

print(ac_c, p_c)

Submission status: Accepted

Solution code:
N, M =[int(n) for n in input().split()]
p = {}
s = {}
for i in range(M):
    P, S = input().split()
    if S=='WA' and P not in p:
        c = s.setdefault(P, 0)
        c += 1
        s[P] = c
    else:
        if not p.setdefault(P, 0):
            p[P] = 1
for k in s:
    if k not in p:
        s[k] = 0 
print(sum(p.values()), sum(s.values()))

Submission status: Accepted

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

correct = [0] * n
penalty = [0] * n
for i in range(m):
    tgt = p[i] - 1
    if correct[tgt] == 1:
        continue
    if s[i] == 'AC':
        correct[tgt] += 1
    elif s[i] == 'WA':
        penalty[tgt] += 1

for i in range(m):
    tgt = p[i] - 1
    if correct[tgt] == 0:
        penalty[tgt] = 0

print('{0} {1}'.format(sum(correct), sum(penalty)))

Submission status: Accepted

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

solved = set()
correct = 0
penalty = 0
penalty_memo = [0] * (n+1)

for _ in range(m):
    p,s = input().split()
    p = int(p)

    if p not in solved:
        if s == "WA":
            penalty_memo[p] += 1
        else:
            correct += 1
            penalty += penalty_memo[p]
            solved.add(p)

print(correct, penalty)

Submission status: Accepted

Solution code:
import sys
from collections import defaultdict
 
N,M = list(map(int, sys.stdin.readline().strip().split()))
counter = {"WA":0, "AC":0}
solv = defaultdict(list)
for i in range(M):
  p, s = sys.stdin.readline().strip().split()
  if len(solv[p])==0:
    solv[p].append(0)
    solv[p].append(0)
  if solv[p][1]==1: continue
  elif s=="WA":
    solv[p][0] += 1
  elif s=="AC" and solv[p][1]==0:
    solv[p][1] = 1
    counter["WA"] += solv[p][0]
    counter["AC"] += solv[p][1]

print(counter["AC"], counter["WA"])

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

N,M = map(int, readline().decode("utf-8").split())

aclist = [0 for _ in range(0, N+1)]
walist = [0 for _ in range(0, N+1)]

for _ in range(0, M):
    p,s = readline().decode('utf-8').split()
    p = int(p)

    if s == "AC":
        aclist[p] = 1
    if s == "WA" and aclist[p] == 0:
        walist[p] += 1

sum_wa = 0
for i,x in enumerate(walist):
    if aclist[i] == 1:
        sum_wa += x

print(sum(aclist), sum_wa)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
abc = {}
ac_cnt = 0
wa_cnt = 0
for i in range(m):
    p, s = map(str, input().split())
    abc.setdefault(p, []).append(s)
for key in abc.keys():
    if "AC" in abc[key]:
        idx = abc[key].index("AC")
        ac_cnt += 1
        wa_cnt += idx
    else:
        ac_cnt += 0
        wa_cnt += 0
print(ac_cnt, wa_cnt)