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 = [int(s) for s in input().split(' ')]
ac = 0
wa = 0
result = dict()
fail = dict()
for m in range(M):
    p, s = input().split(' ')
    if p in result and result[p] == 'AC':
        continue
    if s == 'WA':
        fail[p] = fail.get(p, 0) + 1
        result[p] = s
    elif s == 'AC': # AC
        ac += 1
        wa += fail.get(p, 0) 
        result[p] = s
    
print(str(ac) + ' ' + str(wa))

Submission status: Accepted

Solution code:
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
import itertools
from collections import Counter

def main():
    n,m = map(int, input().split())
    dic = {}
    for i in range(1,n+1):
        dic[i] = 0
    ac = 0
    wa = 0
    for i in range(m):
        p,s = input().split()
        p = int(p)
        if dic[p] == 0: # その問題初めての投稿
            if s == "WA":
                dic[p] += 1
            else:
                dic[p] = "AC"
                ac += 1
        elif dic[p] == "AC":
            pass
        else: # WA状態
            if s == "WA":
                dic[p] += 1
            else:
                wa += dic[p]
                dic[p] = "AC"
                ac += 1
    print(ac,wa)



if __name__=="__main__":
    main()

Submission status: Accepted

Solution code:
n, m = [int(i) for i in input().split()]
lst_pena = [[False, 0] for i in range(n)]
cnt_pena = 0
cnt_ca = 0
for i in range(m):
	n, m = [j for j in input().split()]
	n = int(n) - 1
	if lst_pena[n][0] == False and m == 'AC':
		lst_pena[n][0] = True
		cnt_ca += 1
	elif lst_pena[n][0] == False and m == 'WA':
		lst_pena[n][1] += 1
sum_pena = sum([i[1] if i[0] else 0 for i in lst_pena])
print(f'{cnt_ca} {sum_pena}')

Submission status: Accepted

Solution code:
N, M = [int(s) for s in input().split()]
AC = [0] * 10 ** 5
WA = [0] * 10 ** 5

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

print(sum(AC), sum(map(lambda x: x[0] * x[1], zip(AC, WA))))

Submission status: Accepted

Solution code:
import os, sys, re, math

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

successes = [0] * N
penalties = [0] * N
for i in range(M):
    (p, s) = [n for n in input().split()]
    if s == 'AC':
        successes[int(p) - 1] = 1
    else:
        if successes[int(p) - 1] == 0:
            penalties[int(p) - 1] += 1

for i in range(N):
    if successes[i] == 0:
        penalties[i] = 0

print('%s %s' % (sum(successes), sum(penalties)))

Submission status: Accepted

Solution code:
n, m = list(map(int, input().split(' ')))
d = {}
ans_c = 0
ans_w = 0
for i in range(m):
    p, r = input().split(' ')
    if r == 'AC':
        if d.get(p) != 'finished':
            ans_c += 1
            ans_w += d.get(p, 0)
        d[p] = 'finished'
    elif d.get(p) != 'finished':
        d[p] = d.get(p, 0) + 1
print(ans_c, ans_w)

Submission status: Accepted

Solution code:
def resolve():
    N, M = list(map(int, input().split()))
    ACs = [0 for _ in range(N)]
    WAs = [0 for _ in range(N)]
    for _ in range(M):
        p, result = list(input().split())
        p = int(p)
        if result == "AC":
            ACs[p-1] += 1
        else:
            if ACs[p-1] == 0:
                WAs[p-1] += 1
    nac = 0
    nwa = 0
    for i in range(N):
        if ACs[i] >= 1:
            nac += 1
            nwa += WAs[i]
    print(nac, nwa)


if '__main__' == __name__:
    resolve()

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
L = [list(input().split()) for _ in range(M)]
D_1 = {str(c):False for c in range(1, N+1)}
D_2 = {str(c):0 for c in range(1, N+1)}
for l in L:
  if l[1]=="WA" and D_1[l[0]]==False:
      D_2[l[0]] += 1 
  else:
    D_1[l[0]]=True
S_1 = sum(D_2[k] for k, v in D_1.items() if v)  
S_2 = sum(D_1.values())
print(S_2, S_1)

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
wa = [0] * 10**6
ac = [0] * 10**6
ans = 0
for i in range(m):
    str_p,str_m = map(str,input().split())
    p = int(str_p)
    if str_m =='WA':
        if ac[p] == 0:
            wa[p] += 1
    else:
        if ac[p] == 0:
            ac[p] = 1
            ans += wa[p]
print(sum(ac),ans)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
ac = [False] * N
wa_cnt = [0] * N
ac_cnt = 0
for i in range(M):
    p, s = input().split()
    p_i = int(p) - 1
    if s == 'WA':
        if not ac[p_i]:
            wa_cnt[p_i] += 1
    else:
        if not ac[p_i]:
            ac[p_i] = True
            ac_cnt += 1

wa_cnt_sum = 0
for i in range(N):
    if ac[i]:
        wa_cnt_sum += wa_cnt[i]

print(ac_cnt,wa_cnt_sum)

Submission status: Accepted

Solution code:
import sys

def main():
    n,m = map(int, input().split())
    pn_list = [0]*n
    a = [0]*m
    b = [0]*m
    ans_ac = 0
    ans_pn = 0
    pn_list[0]== -1
    
    for i in range (m):
        a[i],b[i]=input().split()
        a[i] = (int(a[i]))
        # print(a[i])
        if pn_list[a[i]-1] != -1:
            if b[i]== "AC":
                ans_pn += pn_list[a[i]-1]
                ans_ac +=1
                pn_list[a[i]-1] = -1 #ペナルティリスト初期化
            else:
                pn_list[a[i]-1] += 1

    print(ans_ac,ans_pn)
    
   
if __name__ == "__main__":
    main()

Submission status: Accepted

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

p = [0]*M
s = [0]*M
b = [0]*N
pena = 0
corr = 0

for i in range(M):
    p[i], s[i] = input().split()
    p[i] = int(p[i])
    if b[p[i]-1] != -1:
        if s[i] == "AC":
            pena += b[p[i]-1]
            corr += 1
            b[p[i]-1] = -1
        else:
            b[p[i]-1] += 1

print(corr, pena)

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()
    if s == 'AC':
        ac[int(p) - 1] = 1
    elif ac[int(p) - 1] == 0:
        wa[int(p) - 1] += 1
for i in range(n):
    if ac[i] == 0:
        wa[i] = 0
print(sum(ac), sum(wa))

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
ac_list = [0 for i in range(n+1)]
wa_list = [0 for i in range(n+1)]
p_list = []
ac = 0
pena = 0

for i in range(m):
    p,s = map(str,input().split())
    p = int(p)
    if s == 'AC' and ac_list[p-1] != 1:
        ac += 1
        ac_list[p-1] = 1
        pena += wa_list[p-1]
    elif s == 'WA' and ac_list[p-1] != 1:
        wa_list[p-1] += 1

print(ac, pena)

Submission status: Accepted

Solution code:
n,m=[int(x) for x in input().split()]
Q=[0]*n
R=[0]*n
for i in range(m):
  P,s=input().split()
  p=int(P)
  if s=="AC" and Q[p-1]==0:
    Q[p-1]=1
  elif s=="WA" and Q[p-1]==0:
    R[p-1]+=1
ok=sum(Q)
for j in range(n):
  if Q[j]==0 and R[j]!=0:
    R[j]=0
bad=sum(R)
print(str(ok)+" "+str(bad))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
s = [[] for i in range(n)]
for i in range(m):
    p, S = input().split()
    s[int(p) - 1] += [S]
print(sum('AC' in si for si in s), end=' ')
print(sum(si[:si.index('AC')].count('WA') if 'AC' in si else 0 for si in s))

Submission status: Accepted

Solution code:
def solve():
    N,M = [int(i) for i in input().split()]
    solved = set([])
    penalty = {}
    for i in range(M):
        problem_id,result = input().split()
        if result == 'AC':
            solved.add(problem_id)
        elif result == 'WA' and problem_id not in solved:
            penalty[problem_id] = penalty.get(problem_id, 0) + 1
    num_penalties = 0
    for problem_id in solved:
        num_penalties += penalty.get(problem_id, 0)
    print(len(solved), num_penalties)


if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
a=0
p=0
L=[0 for _ in range(n)]
for _ in range(m):
  num,s = input().split()
  num=int(num)-1
  if not L[num] == -1:
    if s == "AC":
      a+=1
      p+=L[num]
      L[num]=-1
    else:
      L[num]+=1
print(a,p)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
res=[[]for _ in range(n+1)]
a=0
w=0
for i in range(m):
    p,s=input().split()
    p=int(p)
    res[p].append(s)

for i in range(1,n+1):
    if "AC" in res[i]:
        a+=1
        f=0
        for j in range(len(res[i])):
            if res[i][j]=="WA" and f==0:
                w+=1
            if res[i][j]=="AC":
                f=1
        
print(a,w)

Submission status: Accepted

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

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

results=[]
for i in range(n+1):
  results.append([0,0])
  
ac = 0
wa = 0
memo = [0]*(n+1)
for i in range(m):
  p,s=input().split()
  p = int(p)
  s = s.strip()

  if memo[p] != -1:
    if s == 'WA':
      memo[p] += 1
    else:
      ac += 1
      wa += memo[p]
      memo[p] = -1

print(ac,wa)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
listAC = [0] * n
listWAAC = [0] * n
listWA = [0] * n
for i in range(m):
    p, s = map(str, input().split())
    p = int(p) - 1
    if listAC[p] == 1:
        continue
    if s == 'AC':
        listAC[p] += 1
        listWAAC[p] += listWA[p]
        continue
    listWA[p] += 1

print(sum(listAC), sum(listWAAC))

Submission status: Accepted

Solution code:
NN, MM = list(map(int,input().split()))
ARR = [list(input().split()) for l in range(MM)]

bin = [0]*NN
done = [0]*NN

for ind in range(MM):
    if done[int(ARR[ind][0])-1] == 0:
        if ARR[ind][1] == 'WA':
            bin[int(ARR[ind][0])-1] += 1
        else:
            done[int(ARR[ind][0])-1] = 1

cbin = [x * y for (x,y) in zip(done,bin)]
print(sum(done), sum(cbin))

Submission status: Accepted

Solution code:
def resolve():
    n, m = map(int, input().split())
    co = 0
    pe = 0
    P = [0] * n
    for _ in range(m):
        p, s = input().split()
        ind = int(p)-1
        if P[ind] != -1: #既に正解
            if s == "WA":
                P[ind] += 1
            else:
                pe += P[ind]
                P[ind] = -1
                co += 1
    print(co, pe)
resolve()

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
l = [[] for _ in range(N)]
for i in range(M):
    p, s = input().split()
    l[int(p) - 1].append(s)

correct = 0
penalty = 0
for ll in l:
    if 'AC' not in ll:
        continue
    correct += 1
    penalty += ll.index('AC')

print(correct, penalty)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
l = [[] for _ in range(N)]
for i in range(M):
    p, s = input().split()
    l[int(p) - 1].append(s)

correct = 0
penalty = 0
for ll in l:
    if 'AC' not in ll:
        continue

    correct += 1
    penalty += ll.index('AC')

print(correct, penalty)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
submissions = [list(input().split()) for _ in range(m)]
count_penalty = [0] * (n + 1)
count_ac = [0] * (n + 1)

for i in range(m):
    ploblem = int(submissions[i][0])
    if submissions[i][1] == "AC":
        count_ac[ploblem] = 1

    elif count_ac[ploblem] != 1 and submissions[i][1] == "WA":
        count_penalty[ploblem] += 1

for i in range(n + 1):
    if count_ac[i] != 1:
        count_penalty[i] = 0

print("{} {}".format(count_ac.count(1), sum(count_penalty)))

Submission status: Accepted

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

n,m=map(int,input().split())
ans=0;wrong=0
d=[0]*n
for i in range(m):
    p,s=input().strip().split()
    p=int(p)-1
    if d[p]!=-1:
        if s=='WA':
            d[p]+=1
        else:
            wrong+=d[p]
            d[p]=-1
            ans+=1
print(ans,wrong)

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
d,ans,wrong = [0]*N,0,0
for _ in range(M):
    p,s = input().split()
    p = int(p)-1
    if d[p] != -1:
        if s == "WA":
            d[p] += 1
        else:
            wrong += d[p]
            d[p] = -1
            ans += 1
print(ans,wrong)

Submission status: Accepted

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

acli = [0]*N
wali = [0]*N

for _ in range(M):
  P,S = map(str,input().split())
  P = int(P)-1
  if acli[P] == 1:
    continue
  if S == "AC":
    acli[P] = 1
  else:
    wali[P] += 1
    
for i in range(N):
  if acli[i] == 0:
    wali[i] = 0
    
print(sum(acli),sum(wali))

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
# [ACしたかどうか, 初ACは何回目の提出か]
prob = [[0] * 2 for _ in range(N + 1)]
# print(prob)
ps_list = [[0, 0]]

for i in range(1, M + 1):
    p, s = input().split()
    p = int(p)
    ps_list.append([p, s])
    if s == "AC" and prob[p] == [0, 0]:
        prob[p] = [1, i]


# print(prob)
# この段階でACは数えられる
ac = 0
for item in prob:
    if item[0] == 1:
        ac += 1

penalty = 0
for i in range(1, M + 1):
    p = ps_list[i][0]
    s = ps_list[i][1]
    if s == "WA" and i < prob[p][1]:
        penalty += 1

print(ac, penalty)

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
correct = [0]*N
penalty = [0]*N
ans_c,ans_p = 0,0
for i in range(M):
    p,s = input().split()
    p = int(p)
    if s=="AC":
        if correct[p-1]==0:
            correct[p-1]+=1
    if s=="WA":
        if correct[p-1]==0:
            penalty[p-1]+=1

ans_penalty = 0
for i in range(N):
    if correct[i]>=1:
        ans_penalty+=penalty[i]
print(sum(correct),ans_penalty)

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
p = [list(map(str,input().split())) for _ in range(m)]
###ACとWAのフラグを作成、ACしたらフラグを立てていく
ac =[0]*(n+1)
wa =[0]*(n+1)
for i in range(m):
    question =int(p[i][0])
    ###フラグが立っていればカウントしない
    if p[i][1] == "AC" and ac[question] == 0:
        ac[question] = 1
     ###同様に一度ACしてフラグがあるならWAもカウントしない
    elif p[i][1] == "WA" and ac[question] == 0:
        wa[question] += 1
for j in range(n+1):
  ###ACしていないならばWAはカウントしない
    if ac[j] == 0:
        wa[j] = 0
       # print(wa)
print(sum(ac),sum(wa))

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
p = [list(map(str,input().split())) for _ in range(m)]
ac =[0]*(n+1)
wa =[0]*(n+1)
for i in range(m):
    question =int(p[i][0])
    if p[i][1] == "AC" and ac[question] == 0:
        ac[question] = 1
    elif p[i][1] == "WA" and ac[question] == 0:
        wa[question] += 1
for j in range(n+1):
    if ac[j] == 0:
        wa[j] = 0
       # print(wa)
print(sum(ac),sum(wa))

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
d,c,wa=[0]*n,0,0
for _ in range(m):
    p,a=input().split()
    p=int(p)-1
    if d[p]!=-1:
        if 'W' in a:
            d[p]+=1
        else:
            wa+=d[p]
            d[p]=-1
            c+=1
print(c,wa)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
data=[0]*n
count,wa=0,0
for i in range(m):
    p,a=input().split()
    p=int(p)-1
    if type(data[p]) is int:
        if a=='WA':
            data[p]+=1
        else:
            wa+=data[p]
            data[p]=''
            count+=1
print(count,wa)

Submission status: Accepted

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

data=[0]*n
s=set()
sum_wa=0

for i in range(m):
    p,a=input().split()
    p=int(p)-1
    if p in s:
        continue
    else:
        if a=='WA':
            data[p]+=1
        else:
            sum_wa+=data[p]
            s.add(p)

print(len(s),sum_wa)

Submission status: Accepted

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

data=[0]*n
s=set()

for i in range(m):
    p,a=input().split()
    p=int(p)-1
    if p in s:
        continue
    else:
        if a=='WA':
            data[p]-=1
        else:
            data[p]*=-1
            s.add(p)

print(len(s),sum([data[i] for i in range(n) if data[i]>0]))

Submission status: Accepted

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

if m==0:
    print(0,0)
    import sys
    sys.exit()

p=[list(input().split()) for _ in range(m)]
correct=set([p[i][0] for i in range(m) if p[i][1]=='AC'])

sum_wa=0
data=[0]*n

for i in range(m):
    if p[i][0] in correct and data[int(p[i][0])-1]==0:
        if p[i][1]=='WA':
            sum_wa+=1
        else:
            data[int(p[i][0])-1]=1

print(sum(data),sum_wa)

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
wa_list= [0]*(N+2)
ac_list=[-1]*(N+2)
for i in range(M):
  p,a = map(str,input().split())
  p = int(p)
  if a =='WA':
    wa_list[p]+=1
  if a =='AC' and ac_list[p] == -1:
    ac_list[p]+=(wa_list[p]+1)
count = 0;count2 = 0
for i in ac_list:
  if i>=0:
    count+=1
    count2+=i
print(count,count2)

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
wa_list= [0]*(N+2)
ac_list=[-1]*(N+2)
for i in range(M):
  p,a = map(str,input().split())
  p = int(p)
  if a =='WA':
    wa_list[p]+=1
  if a =='AC' and ac_list[p] == -1:
    ac_list[p]+=(wa_list[p]+1)
count = 0;count2 = 0
for i in ac_list:
  if i>=0:
    count+=1
    count2+=i
print(count,count2)

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
wa_list= [0]*(N+2)
ac_list=[-1]*(N+2)
for i in range(M):
  p,a = map(str,input().split())
  p = int(p)
  if a =='WA':
    wa_list[p]+=1
  if a =='AC' and ac_list[p] == -1:
    ac_list[p]+=(wa_list[p]+1)
    

#print(ac_list)    
count = 0
count2 = 0
for i in ac_list:
  if i>=0:
    count+=1
    count2+=i
print(count,count2)

Submission status: Accepted

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

if m==0:
    print(0,0)
    import sys
    sys.exit()

p=[list(input().split()) for _ in range(m)]
correct=set([p[i][0] for i in range(m) if p[i][1]=='AC'])

s=set()
sum_wa=0

for i in [p[j] for j in range(m) if p[j][0] in correct]:
    if i[0] in s:
        continue
    else:
        if i[1]=='WA':
            sum_wa+=1
        else:
            s.add(i[0])

print(len(correct),sum_wa)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
lst=[list(input().split()) for i in range(m)]
x,y=0,0
cnt=['?']+[0]*n
cnt2=[0]+[0]*n
for i in lst:
  if i[1]=='WA':
    pin=int(i[0])
    if cnt[pin]!='AC':
      cnt2[pin]+=1
  elif i[1]=='AC':
    cnt[int(i[0])]='AC'

x=cnt.count('AC')

for i in range(len(cnt)):
  if cnt[i]=='AC':
    y+=cnt2[i]
print(x,y)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
progress = {}
# initialize
for i in range(N):
  progress[str(i+1)] = ["notCorrect",0]
correct = 0

for i in range(M):
  question, result = map(str, input().split())
  if (progress[question][0] == "notCorrect"):
    if (result == "WA"):
      progress[question][1] += 1
    else:
      progress[question][0] = "correct"
      correct += 1
  else:
    continue
penalty = 0
for i in range(N):
  if (progress[str(i+1)][0] == "correct"):
    penalty += progress[str(i+1)][1]
print(str(correct)+" "+str(penalty))

Submission status: Accepted

Solution code:
def readinput():
    n,m=map(int,input().split())
    tries=[]
    for _ in range(m):
        p,s=input().split()
        p=int(p)
        tries.append((p,s))
    return n,m,tries

def main(n,m,tries):
    point=[[0,0] for i in range(n+1)]
    for i in range(m):
        p,s=tries[i]
        if s=='WA':
            if point[p][0]>0:
                continue
            else:
                point[p][1]+=1
        else:
            point[p][0]+=1
    ac=0
    wa=0
    for i in range(1,n+1):
        if point[i][0]>0:
            ac+=1
            wa+=point[i][1]
    
    return ac,wa

if __name__=='__main__':
    n,m,tries=readinput()
    ans=main(n,m,tries)
    print(' '.join(map(str,ans)))

Submission status: Accepted

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

maru = [0]*n
pena = [0]*n

for i in range(m):
    p,s = input().split()
    p = int(p)
    if s =="AC":
        maru[p-1] = 1
    else:
        if maru[p-1]==0:
            pena[p-1]+=1

penapena = [maru[i]*pena[i] for i in range(n)]

print(maru.count(1),sum(penapena))

Submission status: Accepted

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


def II():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


def LI():
    return list(map(int, sys.stdin.readline().split()))


def main():
    n, m = MI()

    isACed = [0] * n
    submmited = [0] * n

    for i in range(m):
        p, res = input().split()
        p = int(p)
        if isACed[p - 1] == 0 and res == "WA":
            submmited[p - 1] += 1

        if res == "AC":
            isACed[p - 1] = 1
    acs = 0
    was = 0
    for i in range(n):
        if isACed[i] == 1:
            acs += 1
            was += submmited[i]

    print(acs, was, sep=" ")


main()

Submission status: Accepted

Solution code:
# coding: utf-8
import math
N, M = map(int,input().split())
#N = int(input())
#K = int(input())
#S = input()
ans = 0
#l = list(map(int,input().split()))
#A = list(map(int,input().split()))
F = [False] * (N+1)
pen = 0
P = [0] * (N+1)
for i in range(M):
    p, s = map(str,input().split())
    p = int(p)
    if s == "WA" and not F[p]:
        P[p] += 1
    if s == "AC" and not F[p]:
        ans += 1
        pen += P[p]
        F[p] = True

print(ans, pen)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
data = [0]*N
solved = [False]*N
for _ in range(M):
    p, S = input().split()
    p = int(p) - 1
    if solved[p] == False and S == "WA":
        data[p] += 1
    if solved[p] == False and S == "AC":
        solved[p] = True

print(sum(solved),sum( x*y for x, y in zip(data, solved)) )

Submission status: Accepted

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

for i in range(M):
  p, s = input().split()
  if s == "AC":
    if flag[int(p)-1] == False:
      ac+=1
      wa+=wal[int(p)-1]
      flag[int(p)-1] = True
  if s == "WA":
    if flag[int(p)-1] == False:
      wal[int(p)-1]+=1

print(ac,wa)

Submission status: Accepted

Solution code:
from sys import stdin
import sys
import math
from functools import reduce
import itertools

n,m = [int(x) for x in stdin.readline().rstrip().split()]

check = [0 for i in range(n)]
count = [0 for i in range(n)]

for i in range(m):
    p, q = [x for x in stdin.readline().rstrip().split()]
    p = int(p)

    if q == 'AC':
        check[p-1] = 1

    if q == 'WA' and check[p-1] == 0:
        count[p-1] = count[p-1] + 1

for i in range(n):
    if check[i] == 0: count[i] = 0

print(sum(check), sum(count))

Submission status: Accepted

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


for i in range(M):
    # print(AC_list)
    # print(WA_list)
    p, S = map(str,input().split())
    p = int(p)-1
    if S == "AC" and AC_list[p] == 0:
        AC_list[p] = 1
    elif S == "WA" and AC_list[p] == 0:
        WA_list[p] +=1
    else:
        continue

for i in range(N):
    if AC_list[i] == 0:
        WA_list[i] = 0

print("{} {}".format(sum(AC_list), sum(WA_list)))

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
ans = [0]*n
tmp = [0]*n
pen = [0]*n
for i in range(m):
  inp = input().split()
  if inp[1] == "AC":
    ans[int(inp[0])-1] = 1
    pen[int(inp[0])-1] = tmp[int(inp[0])-1]
  elif inp[1] == "WA":
    if ans[int(inp[0])-1] == 0:
      tmp[int(inp[0])-1] += 1
        
print("{0} {1}".format(sum(ans),sum(pen)))

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
memo2 = [False for i in range(n)]
memo = [0 for i in range(n)]
count1,count2 = 0,0
for i in range(m):
    p,l = input().split()
    p = int(p)-1
    if memo2[p]:
        continue
    else:
        if l == 'WA':
            memo[p]+=1
        else:
            memo2[p] = True
            count2 += 1
            count1+=memo[p]
print(count2,count1)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
S = [[] for _ in range(n)]
pe = [0] * n
co = [0] * n
for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    S[p] += [s]
for i, s_ in enumerate(S):
    if all(j == 'WA' for j in s_):
        continue
    for s in s_:
        if s == 'AC':
            co[i] = 1
            break
        else:
            pe[i] += 1
print(sum(co), sum(pe))

Submission status: Accepted

Solution code:
(N,M),*ps = [s.split() for s in open(0)]

ps = [(int(p),s=='WA') for p,s in ps]

from collections import Counter
cnt = Counter()
acs = set()

for p,s in ps:
    if p not in acs:
        if s:
            cnt[p] += 1
        else:
            acs.add(p)
a = len(acs)
b = sum(cnt[ac] for ac in acs)
print(a,b)

Submission status: Accepted

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

solved = [False] * n
ac_cnt = 0
wa_l = [0] * n

for i in range(m):
    cn, cj = int(a[i][0]) - 1, a[i][1]
    if not solved[cn]:
        if cj == 'WA':
            wa_l[cn] += 1
        else:
            ac_cnt += 1
            solved[cn] = True
wa_cnt = 0
for i in range(n):
    wa_cnt += solved[i] * wa_l[i]
print(ac_cnt, wa_cnt)

Submission status: Accepted

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

flag = [False]*n
nums = [0]*n
for _ in range(m):
  p,s = input().split()
  p = int(p)-1
  if s == "AC": flag[p] = True
  elif flag[p] == False: nums[p] += 1
ac = flag.count(True)
wa = 0
for i in range(n):
  if flag[i]: wa += nums[i]
print(ac, wa)

Submission status: Accepted

Solution code:
import sys
import time
import math
import itertools as it
def inpl():
    return list(map(int, input().split()))
st = time.perf_counter()
# ------------------------------

N, M = inpl()
ac = [False] * (N+10)
wa = [0] * (N+10)

a = 0
w = 0
for _ in range(M):
    p, S = input().split()
    p = int(p)
    if S == 'WA':
        if not ac[p]:
            wa[p] += 1
    else:
        if not ac[p]:
            ac[p] = True
            a += 1
            w += wa[p]

print(a, w)

# ------------------------------
ed = time.perf_counter()
print('time:', ed-st, file=sys.stderr)

Submission status: Accepted

Solution code:
import sys
import time
import math
import itertools as it
def inpl():
    return list(map(int, input().split()))
st = time.perf_counter()
# ------------------------------

N, M = inpl()
ac = [False] * (N+10)
wa = [0] * (N+10)

for _ in range(M):
    p, S = input().split()
    p = int(p)
    if S == 'WA':
        if not ac[p]:
            wa[p] += 1
    else:
        ac[p] = True

a = 0
w = 0
for i in range(N+10):
    if ac[i]:
        a += 1
        w += wa[i]

print(a, w)

# ------------------------------
ed = time.perf_counter()
print('time:', ed-st, file=sys.stderr)

Submission status: Accepted

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

pena = [0]*(10**5 + 1)

wa = 0
ac = 0

for i in range(m):
    p, s = map(str, input().split())
    if s == "WA" and pena[int(p)] != -1:
        pena[int(p)] += 1
    elif s == "WA" and pena[int(p)] == -1:
        continue
    elif s == "AC" and pena[int(p)] == -1:
        continue
    else:
        ac += 1
        wa += pena[int(p)]
        pena[int(p)] = -1

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

Submission status: Accepted

Solution code:
import bisect,collections,copy,heapq,itertools,math,string
import numpy as np
import sys
sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

# N =I()
N,M= LI()
if M==0:
    print(0,0)
    exit()
pS = [LS() for _ in range(M)]
# print(pS)

_p,S = zip(*pS)

p = list(map(int,_p))

WA = np.zeros(N+1)
AC = np.full(N+1,False, dtype=bool)

penalty = 0
for i in range(M):
    if AC[p[i]]:
        continue
    if S[i]=='WA':
        WA[p[i]] += + 1
    else:
        AC[p[i]]=True
        penalty += WA[p[i]]        

AC_count = np.count_nonzero(AC)        

# space output
print(AC_count,int(penalty))

#Ap = np.array(A)



# if ans:
#     print('Yes')
# else:
#     print('No')

Submission status: Accepted

Solution code:
n,m = list(map(int,input().split()))
d = {}
ac = 0
wa = [0] * (n+1)
wa_sum = 0

for i in range(m):
  p,s = input().split()
  p = int(p)
  if p in d:
    if d[p] == 'AC':
      pass
    else:
      if s == 'AC':
        d[p] = 'AC'
        ac += 1
        wa_sum += wa[p]
      else:
        wa[p] += 1
  else:
    d[p] = s
    if s == 'AC':
      ac += 1
    else:
      wa[p] += 1

print(ac,wa_sum)

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
ls2 = []
for i in range(M):
    A,B = map(str,input().split())
    ls = [int(A)-1,B]
    ls2.append(ls)

Pena = 0
corr = 0

#ls3 = sorted(ls2, key=lambda x: x[0])
lsans = [[] for i in range(N)]
for i in range(M):
    lsans[ls2[i][0]].append(ls2[i][1])

for i in range(N):
    if 'AC' in lsans[i]:
        for ans in lsans[i]:
            if ans == 'WA':
                Pena += 1
            if ans == 'AC':
                corr += 1
                break
print(corr,Pena)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
ac = 0
is_AC = [False] * (N + 1)
WA_cnt = [0] * (N + 1)
for i in range(M):
    p, s = input().split()
    p = int(p)
    if s == 'WA':
        if is_AC[p]:
            continue
        else:
            WA_cnt[p] += 1
    else:
        if is_AC[p]:
            continue
        else:
            is_AC[p] = True
            ac += 1

wa = 0
for i in range(N + 1):
    if is_AC[i]:
        wa += WA_cnt[i]
print(ac, wa)
'''
うまくいかなかったパターン
1 4
1 WA
1 WA
1 WA
1 WA
'''