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,input().split())
ac=[0]*N
wa=[0]*N

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

penalty=[wa[k] for k in [i for i,j in enumerate(ac) if j!=0]]    
print("%d %d" % (sum(ac),sum(penalty)))

Submission status: Accepted

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

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

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

    if s == 'WA' and ac[int(p)-1] == 0:
            wa[int(p)-1] += 1
    elif s == 'AC' and ac[int(p)-1] == 0:
            ac[int(p)-1] += 1

print('%d %d' % (sum(ac), sum([wa[k] for k in [i for i, j in enumerate(ac) if j != 0]])))

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
 
ac, wa = [0]*N, [0]*N
 
for i in range(M):
    p, s = input().split()
    if s == 'WA' and ac[int(p)-1] == 0:
            wa[int(p)-1] += 1
    elif s == 'AC' and ac[int(p)-1] == 0:
            ac[int(p)-1] += 1
print('%d %d' % (sum(ac), sum([wa[k] for k in [i for i, j in enumerate(ac) if j != 0]])))

Submission status: Accepted

Solution code:
from collections import defaultdict
d = defaultdict(int)
n, m = map(int, input().split())
ac = set()
for i in range(m):
  p, s = map(str, input().split())
  if s == 'AC':
    ac.add(p)
  elif s == 'WA' and p not in ac:
    d[p] += 1
for e in d.keys():
  if e not in ac:
    d[e] = 0
pn = d.values()
print(len(list(ac)), sum(pn))

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
# 正答数, ペナルティー数
q_list = [False] * n
p_count = 0

data = []
for _ in range(m):
    a, b = map(str, input().split())
    data.append([a, b])

# 正解してるものだけオーダーmで回収
for _ in range(m):
    q_num, j = data[_]
    q_num = int(q_num)
    q_num -= 1
    if j == "AC":
        q_list[q_num] = True


q2_list = [False] * n
# 正解してるものだけ途中のWAをカウント
for i in range(m):
    q_num, j = data[i]
    q_num = int(q_num)
    q_num -= 1
    if q2_list[q_num] == False:
        if j == "WA" and q_list[q_num]:
            p_count += 1
        else:
            q2_list[q_num] = True

print(q_list.count(True), p_count)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
def main():
  L=list()
  R=list()
  a,b=map(int,input().split())
  for i in range(b):
    c,d=input().split()
    c=int(c)
    if d=="AC":
      L.append(c)
    elif d=="WA":
      if c not in L:
        R.append(c)
  L=set(L)
  t=len(L)
  P=[1 for i in R if i in L]
  s=sum(P)
  print(t,s)
main()

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
p=[input().split() for _ in range(m)]#よみこみ
q=[0 for _ in range(n)]#間違え数積算
r=[0 for _ in range(n)]#正解出た時点
for a in p:
  e=int(a[0])-1#問題名
  if a[1]=="WA":
    q[e]+=1#間違ってたら一プラス
  else:
    if r[e]==0:
      r[e]=q[e]+1#会ってたら現状の間違え数＋１を追加
c=0
d=0
for b in r:
  if b>0:#あってたら1以上
    c+=1
    d+=b-1
print(c,d)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
ac=[0]*n
pena=[0]*n
for i in range(m):
  p,s=input().split()
  p=int(p)
  if ac[p-1]==0:
    if s=="AC":
      ac[p-1]=1
      LAC=i
    if s=="WA":
      pena[p-1]+=1
if m==0:
  print("0 0")
else:
  pen=0
  for (x,y) in zip(ac,pena):
    pen+=x*y
  print("{} {}".format(ac.count(1),pen))

Submission status: Accepted

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

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

for i in range(M):
    p, s = input().split()
    if s == 'WA' and ac[int(p)-1] == 0:
            wa[int(p)-1] += 1
    elif s == 'AC' and ac[int(p)-1] == 0:
            ac[int(p)-1] += 1
print('%d %d' % (sum(ac), sum([wa[k] for k in [i for i, j in enumerate(ac) if j != 0]])))

Submission status: Accepted

Solution code:
from sys import stdin
from collections import defaultdict

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

WAinProblem=defaultdict(int)#defaultdictは初期値が0(int)なdict
totalWA=0
totalAC=0
for _ in range(M):
  line=stdin.readline().split()
  problem_number=int(line[0])
  result=line[1]

  if result == "WA":
    if WAinProblem[problem_number]!=-1:#集計終了していなければ
      WAinProblem[problem_number]+=1
  else:#result="AC"
    if WAinProblem[problem_number]!=-1:#集計終了していなければ
      totalWA+=WAinProblem[problem_number]
      totalAC += 1
      WAinProblem[problem_number]=-1#集計終了
print("{} {}".format(totalAC,totalWA))

Submission status: Accepted

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

res = [0, 0]
stat = ['WA' for i in range(n)]
for i in range(m):
    if ps[i][1] == 'AC':
        stat[int(ps[i][0]) - 1] = 'P'
for i in range(m):
    if ps[i][1] == 'AC':
        if stat[int(ps[i][0]) - 1] == 'P':
            res[0] += 1
            stat[int(ps[i][0]) - 1] = 'AC'
    if ps[i][1] == 'WA':
        if stat[int(ps[i][0]) - 1] == 'P':
            res[1] += 1
print('{} {}'.format(res[0], res[1]))

Submission status: Accepted

Solution code:

N,M = map(int,input().split())
PS =[""]*N
PS2 =[0]*N

PENALTY = 0
AC = 0
for m in range(M):
    p,s = map(str,input().split())
    p=int(p)-1
    if PS[p]!="AC" and s=="WA":
        PS2[p]+=1
    elif PS[p]!="AC" and s=="AC":
        AC+=1
        PENALTY+=PS2[p]
        PS[p]="AC"
        
print(AC,PENALTY)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
S = []
A = [0] * (N + 1)
for i in range(0, M):
  a = input().split()
  S.append(a)
  
ac = 0
wa = 0
for a in S:
  s = int(a[0])
  p = a[1]
  if p == 'WA':
    if A[s] >= 0:
      A[s] += 1
  else:
    if A[s] >= 0:
      wa += A[s]
      A[s] = -1
      ac += 1
      
print(*[ac, wa], sep = ' ')

Submission status: Accepted

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

wa_count = { i+1: 0 for i in range(N) }
ac_count = { i+1: False for i in range(N) }
wa,ac = 0,0

for _ in range(M):
  p,s = map(str,input().split())
  p = int(p)
  if s == "AC" and not ac_count[p]:
    ac += 1
    wa += wa_count[p]
    ac_count[p] = True
  else:
    wa_count[p] += 1

print(ac, wa)

Submission status: Accepted

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

done = [0]*n
WA_cnt = [0]*n
for _ in range(m):
  p, s = input().split()
  p = int(p)-1
  if done[p] == 1:
    continue
  else:
    if s=='AC':
      done[p] = 1
    elif s=='WA':
      WA_cnt[p] += 1

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

Submission status: Accepted

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

for i in range(m):
    p, s = map(str, input().split())
    p = int(p)

    if s == "WA" and li[p-1] >= 0: #WAかつ正解前
        li[p-1] += 1 #その問題をWAした数+1
    
    elif s == "AC" and li[p-1] >= 0: #ACかつ正解前
        wa += li[p-1] #それまでにWAした数をカウントに追加
        li[p-1] = -1 #ステータスを正解済に変更
        ac += 1 #AC+1

print(ac, wa)

Submission status: Accepted

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

#S = [[0 for j in range(3)] for i in range(2)]　2行3列の場合
S = [[0 for j in range(3)] for i in range(N)]

for i in range(M):
    A,B=map(str,input().split())
    A=int(A)
    if B=="AC":
        S[A-1][1]="AC"
    elif B=="WA":
        if S[A-1][1]=="AC":
            S[A-1][2]+=0
        else:
            S[A-1][2]+=1

ACcount=0
WAcount=0
for i in range(N):
    if S[i][1]=="AC":
        ACcount+=1
        WAcount+=S[i][2]
        
print(ACcount,WAcount)

Submission status: Accepted

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

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

for _ in range(M):
    p, s = input().split()
    if s == "AC":
        if not A[int(p)-1][0]:
            A[int(p)-1][0] = 1
    else:
        if not A[int(p)-1][0]:
            A[int(p)-1][1] += 1

ans = [0, 0]
for ac, wa in A:
    if ac:
        ans[0] += 1
        ans[1] += wa

print(*ans)

Submission status: Accepted

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    n, m = map(int, input().split())
    penalty = dict()
    penalty_cnt = 0
    ans = set()
    for _ in range(m):
        num, result = input().split()
        if result == 'AC':
            ans.add(num)
            if num not in penalty:
                penalty[num] = 0
        elif num not in ans:
            if num not in penalty:
                penalty[num] = 1
            else:
                penalty[num] += 1
    ans = list(ans)
    for i in range(len(ans)):
        penalty_cnt += penalty[ans[i]]
    print(len(ans), penalty_cnt)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
AC = set()
wa = [0] * (N+1)
 
for _ in range(M):
    p, s = input().split()
    p = int(p)
    if not p in AC:
        if s == 'AC':
            AC.add(p)
        if s == 'WA':
            wa[p] += 1
 
wa_ans = 0
for i in AC:
    wa_ans += wa[i]
 
print(len(AC), wa_ans)

Submission status: Accepted

Solution code:
N, M = map(int,input().split())
Pn = [0] * N
Wrong = 0
Accept = 0
for i in range(M):
    p, S = map(str, input().split())
    p = int(p)
    if S == "WA" and Pn[p-1] >= 0:
        Pn[p-1] += 1
    elif S=="AC" and Pn[p-1] >= 0:
        Wrong += Pn[p-1]
        Pn[p-1] = -1
        Accept += 1
print(Accept, Wrong)

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
a = [-1 for _ in range(n)]
wa = [0 for _ in range(n)]
for i in range(m):
  ps,s = input().split()
  pi = int(ps)
  if(a[pi-1] == 1):
    continue
  elif(s == 'WA'):
    wa[pi-1] += 1
  elif(s == 'AC'):
    a[pi-1] = 1
for l in range(n):
  if(a[l] == -1):
    wa[l] = 0
print(a.count(1),sum(int(i) for i in wa) )

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
ok = 0
ng = 0
Q = [0]*N
for _ in range(M):
    p,s = map(str,input().split())
    if Q[int(p)-1] != -1 and s == "AC":
        ok += 1
        ng += Q[int(p)-1]
        Q[int(p)-1]= -1
    elif Q[int(p)-1] != -1 and s == "WA":
        Q[int(p)-1] += 1
print(ok,ng)

Submission status: Accepted

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

ac = [False] * n
wa = [0] * n
res_ac = 0
res_wa = 0
for _ in range(m):
    p, s = input().split()
    p = int(p)

    if s == "AC":
        if not ac[p-1]:
            ac[p-1] = True
            res_ac += 1
            res_wa += wa[p-1]
    else:
        wa[p-1] += 1

print(res_ac, res_wa)

Submission status: Accepted

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

ac = 0
wa = 0
acs = [0]*(N+1)
was = [0]*(N+1)

for i in range(M):
	p,s = input().split()
	p = int(p)
	if s == "AC":
		if acs[p]==0:
			ac += 1
			wa += was[p]
			acs[p] = 1
	else:
		was[p] += 1

print(ac,wa)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
pnt = {}
ac = {}
for i in range(M):
	p,s = input().split()
	p = int(p)
	if not p in pnt:
		pnt[p] = 0
		ac[p] = 0
	if s == "WA" and ac[p] == 0:
		pnt[p] += 1
	elif s == "AC" and ac[p] == 0:
		ac[p] += 1

for i in pnt:
	if pnt[i] != 0 and ac[i] == 0:
		pnt[i] = 0

print(sum(ac.values()),sum(pnt.values()))

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):
    p, s = input().split()
    if s == 'AC' and AC[int(p)-1] == 0:
        AC[int(p)-1] += 1
    elif s == 'WA' and 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,wa=0,0
task=[0]*N
for m in range(M):
    p,S=input().split()
    p=int(p)-1
    if task[p]!=-1 and S=="WA":
        task[p]+=1
    elif task[p]!=-1 and S=="AC":
        ac+=1
        wa+=task[p]
        task[p]=-1
print(ac,wa)

Submission status: Accepted

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

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

print(ac, wa)

Submission status: Accepted

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

rslts = [[] for _ in range(n)]
for i in range(m):
    x, y = input().split()
    rslts[int(x) - 1].append(y)
#print(rslts)

ac, p = 0, 0
for j in range(n):
    seq = rslts[j]
    if 'AC' in seq:
        ac += 1
        for k in seq:
            if k == 'WA':
                p += 1
            else:
                break

print(ac, p)

Submission status: Accepted

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

ac_num=0
wr_num=0
for i in range(n):
  if "AC" in check[i]:
    ac_num=ac_num+1
    wr_num=wr_num+check[i].index("AC")

print(str(ac_num)+" "+str(wr_num))

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
di = [[] for _ in range(n)]
ac = 0
wa = 0
for i in range(m):
    a,b = map(str,input().split())
    di[int(a)-1].append(b)
for j in range(n):
    if "AC" in di[j]:
        wa += di[j].index("AC")
        ac += 1
print(ac,wa)

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
a = 0
w = 0
lis = [[] for _ in range(N)]
for i in range(M):
  p,s = map(str,input().split())
  p = int(p)
  lis[p - 1].append(s)
for j in range(N):
  if lis[j].count("AC") > 0:
    a += 1
    w += lis[j].index("AC")

    
print(a,w)

Submission status: Accepted

Solution code:
#C
N,M=map(int,input().split())
re=[0 for i in range(N+1)]
P=[0 for i in range(N+1)]
x=0
y=0
for i in range(M):
    p,S=input().split()
    p=int(p)
    if re[p]=="AC":
        continue
    elif S=="WA":
        P[p]+=1
    elif S=="AC":
        re[p]="AC"
        y+=1
for i in range(1,N+1):
    if re[i]=="AC":
        x+=P[i]
print(y,x)

Submission status: Accepted

Solution code:
N,M = input().split()
l = [0]*int(N) #flg
m = [0]*int(N) #counter
c =0

for i in range(int(M)):
    p,s = input().split()
    if s =="AC":
        if l[int(p)-1]==1:
            pass
        else:
            l[int(p)-1] = 1
            c += m[int(p)-1]
    elif s == "WA":
        m[int(p)-1] += 1



print(l.count(1),c)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
ps=[list(input().split()) for i in range(m)]
pen=[0]*n#ペナ数
rig=[0]*n#ACorWA

for i in range(m):
    if ps[i][1]=="AC":
        rig[int(ps[i][0])-1]=1
    else:
        if rig[int(ps[i][0])-1]==0:
            pen[int(ps[i][0])-1]+=1
cnt1,cnt2=0,0
for i in range(n):
    if rig[i]==1:
        cnt1+=rig[i]
        cnt2+=pen[i]

print(str(cnt1)+" "+str(cnt2))

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
penalty = 0
AC = [0]*N
WA = [0]*N
for i in range(M):
    p, S = input().split()
    if S == 'AC':
        AC[int(p)-1]=1
    else:
        if AC[int(p)-1]==0:
            WA[int(p)-1] += 1
penalty = [a*b for a, b in zip(AC, WA)]
print(sum(AC), sum(penalty))

Submission status: Accepted

Solution code:
N, M = list(map(int,input().split()))
A = []
for i in range(M):
    in1, in2 = input().split()
    A.append([int(in1) - 1, in2])
    
ac = [0 for _ in range(N)]
wa = [0 for _ in range(N)]

for i in range(M):
    if A[i][1] == "AC":
        ac[A[i][0]] = 1
    else:
        if ac[A[i][0]] == 0:
            wa[A[i][0]] += 1
            
ac_sum = sum(ac)

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

print(ac_sum, wa_sum)

Submission status: Accepted

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

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

Submission status: Accepted

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

ACflg = [0] * N
WAflg = [0] * N

WAcnt = 0
for _ in range(M):
    p, S = list(input().split())
    p = int(p)
    if(S == "AC"):
        if(ACflg[p-1] == 0):
            ACflg[p - 1] = 1
            WAcnt += WAflg[p-1]
    
    else:
        if(ACflg[p - 1] == 0):
            WAflg[p - 1] += 1

#    print(ACflg)
#    print(WAflg)

print(sum(ACflg), WAcnt)

Submission status: Accepted

Solution code:
# input
n, m = map(int, input().split())
submits = []
for i in range(m):
  ta, tb = map(str, input().split())
  submits.append([int(ta), tb])

ac = [0 for i in range(n+1)]
ac_cnt = 0
wa = [0 for i in range(n+1)]
wa_cnt = 0

# main
for s in submits:
  if s[1] == "WA" and ac[s[0]] == 0:
    wa[s[0]] += 1
  if s[1] == "AC" and ac[s[0]] == 0:
    ac[s[0]] += 1

# output
for i in range(n+1):
  if ac[i] == 1:
    ac_cnt += ac[i]
    wa_cnt += wa[i]

print(ac_cnt, wa_cnt)

Submission status: Accepted

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

submit = [input().split() for i in range(M)]
ans = [[0, 0] for i in range(N)]

for i in range(M):
    tmp = int(submit[i][0]) - 1
    if submit[i][1] == 'AC' and ans[tmp][0] == 0:
        ans[tmp][0] += 1
    elif submit[i][1] == 'WA' and ans[tmp][0] == 0:
        ans[tmp][1] += 1

print(sum(ans[i][0] for i in range(N)), sum(ans[i][1] for i in range(N) if ans[i][0] == 1))

Submission status: Accepted

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

Submission status: Accepted

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

right = [False]*n
penalty = [0]*n

for i in range(m):
    p,s = input().split()
    p = int(p)-1
    if right[p]:
        pass
    else:
        if s == "AC":
            right[p] = True
        else:
            penalty[p] += 1
r = 0
pen = 0

for j in range(n):
    if right[j]:
        r += 1
        pen += penalty[j]

print(r,pen)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
A=[0]*n
W=[0]*n
wa=0
ac=0
for _ in range(m):
    p,s=input().split()
    if s=="AC":
        A[int(p)-1]=1
    if s=="WA" and A[int(p)-1]!=1:
        W[int(p)-1]+=1
for i in range(n):
    if A[int(i)]==0:
        W[int(i)]=0

print(sum(A),sum(W))

Submission status: Accepted

Solution code:
#!/usr/bin/env python

def main():
    N, M = map(int, input().split())
    # [AC, WA]
    cnt = [[0, 0] for _ in range(N)]
    for _ in range(M):
        num, status = input().split()
        num = int(num) -1
        if status == "AC":
            if cnt[num][0] == 0:
                cnt[num][0] += 1
        if status == "WA":
            if cnt[num][0] == 0:
                cnt[num][1] += 1

    ac_cnt, wa_cnt = 0, 0
    for i in range(N):
        if cnt[i][0] == 1:
            ac_cnt += cnt[i][0]
            wa_cnt += cnt[i][1]

    print(ac_cnt, wa_cnt, sep=" ")

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import numpy as np

num_of_problems, num_of_submittions = map(int, input().split())
submittions = []
for _ in range(num_of_submittions):
    submittions.append(list(input().split()))

WAs = [0] * num_of_problems
ACs = [0] * num_of_problems

for submittion in submittions:
    problem_index = int(submittion[0]) - 1
    result = submittion[1]

    if result == 'WA' and ACs[problem_index] == 0:
        WAs[problem_index] = WAs[problem_index] + 1

    if result == 'AC' and ACs[problem_index] == 0:
        ACs[problem_index] = 1

# WAありでACなしの問題のペナルティ数を0にする
WAs = np.array(WAs) * np.array(ACs)

print(str(ACs.count(1)) + ' ' + str(sum(WAs)))

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())

ac = [0] * n
pena = [0] * n
wa = [0] * n

for i in range(m):
    p, s = readline().decode().rstrip().split()
    if ac[int(p) - 1] == 0:
        if s == 'AC':
            ac[int(p) - 1] += 1
            pena[int(p) - 1] += wa[int(p) - 1]
        else:
            wa[int(p) - 1] += 1

print(sum(ac), sum(pena))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
input = lambda: sys.stdin.readline().strip()

def solve(N: int, M: int, p: "List[int]", S: "List[str]"):
    solved = [False for i in range(N + 1)]
    penalties = [0 for i in range(N + 1)]
    for prob, verd in zip(p, S):
        if not solved[prob]:
            penalties[prob] += verd == 'WA'
            solved[prob] = verd == 'AC'
    print(sum(solved), sum(penalty for i, penalty in enumerate(penalties) if solved[i]))
    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:
## C - Welcome to AtCoder
N ,M = map(int, input().split())
AC = [0] + [0] * N
WA = [0] + [0] * N
for m in range(M):
    p, S = map(str, input().split())
    if S == 'WA' and AC[int(p)] != 1:
        WA[int(p)] += 1
    else:
        AC[int(p)] = 1
print(' '.join([str(x) for x in [sum(AC), sum([WA[i] for i in range(N+1) if AC[i] == 1 ])] ]) )

Submission status: Accepted

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

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

    is_solved = [False] * (N + 1)
    wa_cnt = [0] * (N + 1)
    pena = 0

    for _ in range(M):
        p, s = readline().split()
        p = int(p)
        if s == "WA":
            if is_solved[p]:
                continue
            else:
                wa_cnt[p] += 1
        else:
            if is_solved[p]:
                continue
            else:
                pena += wa_cnt[p]
                is_solved[p] = True

    print(sum(is_solved), pena)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

    is_solved = [False] * (N + 1)
    wa_cnt = [0] * (N + 1)

    for _ in range(M):
        p, s = readline().split()
        p = int(p)
        if s == "WA":
            if is_solved[p]:
                continue
            else:
                wa_cnt[p] += 1
        else:
            is_solved[p] = True

    ac = 0
    pena = 0
    for i in range(1, N+1):
        if is_solved[i]:
            ac += 1
            pena += wa_cnt[i]

    print(ac, pena)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

memo = {key:0 for key in range(1, N+1)}
AC = 0
WA = 0

# print(memo)

for _ in range(M):
    pi, Si = input().split()
    pi = int(pi)
    if memo[pi] != "AC":
        if Si == "WA":
            memo[pi] += 1
        elif Si == "AC":
            AC += 1
            WA += memo[pi]
            memo[pi] = "AC"

print(AC, WA)

Submission status: Accepted

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

    if s == "AC":
        res[int(p)-1]=1
    if s == "WA" and not res[int(p)-1]:
        wa[int(p)-1]+=1
for i in range(n):
    if res[i]:
        pena += wa[i]
print(sum(res), pena)

Submission status: Accepted

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

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

print(sum(AC), w)

Submission status: Accepted

Solution code:
n,m=[int(_) for _ in input().split()]
p=[0 for i in range(m)]
s=[0 for i in range(m)]
for i in range(m):
    _p,_s=input().split()
    p[i]=int(_p)-1
    s[i]=_s

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

for  i in range(m):
    if s[i]=="WA" and not(ac[p[i]]):
        wa[p[i]]+=1
    else:
        ac[p[i]]=True

for i in range(n):
    if not(ac[i]):
        wa[i]=0

print(sum(ac),sum(wa))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
n, m = map(int, input().split())
s = [list(map(str, input().split())) for _ in range(m)]
wa = [0]*n
ac = [0]*n
p = 0
for i in range(m):
    s[i][0] = int(s[i][0])
    ac[s[i][0] - 1] += s[i][1] == 'AC' and ac[s[i][0] - 1] == 0
    wa[s[i][0] - 1] += s[i][1] == 'WA' and ac[s[i][0] - 1] == 0
for j in range(n):
    if ac[j] > 0:
        p += wa[j]
print(sum(ac))
print(p)

Submission status: Accepted

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

ac = 0
wa = 0
res1 = [0]*n
res2 = [0]*n
for i in range(m):
  p, s = list(map(str, input().split()))
  if s == 'AC' and res1[int(p)-1] == 0:
    ac += 1
    res1[int(p)-1] = 1
    wa += res2[int(p)-1]
  elif s == 'WA' and res1[int(p)-1] == 0:
    res2[int(p)-1] += 1
print(ac, wa)

Submission status: Accepted

Solution code:
n,m=[int(x) for x in input().rstrip().split()]
dic={}
wa=[0 for i in range(n)]
ac=[0 for i in range(n)]
ans=0
pena=0
for i in range(m):
  p,s=[x for x in input().rstrip().split()]
  p=int(p)
  if p in dic:
    if dic[p]=="WA" and s=="WA":
      wa[p-1]+=1
    elif dic[p]=="WA" and s=="AC":
      ac[p-1]=1
      dic[p]="AC"
      pena+=wa[p-1]

  else:
    if s=="AC":
      ac[p-1]=1
      dic[p]="AC"
    else:
      dic[p]=s
      wa[p-1]=1

print(sum(ac),pena)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

for i in range(M):
    p, S = map(str, input().split())
    p = int(p)
    if S == "WA":
        if arr[p-1][1] == 0:
            arr[p-1][0] += 1
    elif S == "AC":
        arr[p-1][1] = 1

ac_sum = 0
wa_sum = 0

for j in range(N):
    ac_sum += arr[j][1]
    if arr[j][1] == 1:
        wa_sum += arr[j][0]

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

Submission status: Accepted

Solution code:


NM=list(map(int,input().split()))
ac_count=0
wa_count=0

dic={}
ac_flag={}
for i in range(NM[0]+1):
    s=str(i)
    dic[s]=0
    ac_flag[s]=False

for i in range(NM[1]):
    ps=list(input().split())
    p=ps[0]
    S=ps[1]
    if S=="WA" and ac_flag[p]==False:
        dic[p]+=1
    elif S=="AC" and ac_flag[p]==False:
        ac_count+=1
        wa_count+=dic[p]
        ac_flag[p]=True
    else:pass
    
print(str(ac_count)+" "+str(wa_count))

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
mon = [0]* n
ac =0
wa = 0
for i in range(m):
    p,s = list(input().split())
    p = int(p)-1
    if mon[p] <0:
        continue
    if s == 'AC':
        ac += 1
        wa += mon[p]
        mon[p] = -1
    else:
        mon[p] += 1

print(ac,wa)

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
AC = [0] * N
WA = [0] * N
a = 0
b = 0
for i in range(M):
    s = list(input().split())
    c = int(s[0])
    if s[1] == "AC":
        AC[c - 1] = 1
    elif AC[c - 1] == 0:
        WA[c - 1] += 1
for i in range (N):
    if AC[i] == 1:
        a += 1
        b += WA[i]
print(a,b)

Submission status: Accepted

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

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

print(ac,wa)

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
submit = []
for i in range(m):
    temp = [x for x in input().split()]
    submit.append(temp)
#print(submit)

ac = [0] * (n + 1)
wa = [0] * (n + 1)

for i in range(m):
    result = submit[i][1]
    question = int(submit[i][0])

    if result == 'AC' and ac[question] == 0:
        ac[question] = 1
    elif result == 'WA' and ac[question] == 0:
        wa[question] += 1

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

print(sum(ac), sum(wa))

Submission status: Accepted

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

for i in range(m):
  p,s = input().split()
  p = int(p) - 1
  if number[p]!=-1:
    if s == "WA":
      number[p]+=1
    elif s == "AC":
      ac+=1
      wa+=number[p]
      number[p]=-1
print(ac,wa)

Submission status: Accepted

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

ac = set()
wa = {}
c = 0
for p,s in ps:
  if p in ac:
    continue

  if s == 'WA':
    if p in wa:
      wa[p] += 1
    else:
      wa[p] = 1

  if s == 'AC':
    ac.add(p)
    if p in wa:
      c += wa[p]
    continue

print(len(ac) , c)

Submission status: Accepted

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

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

print(ac,wa)

Submission status: Accepted

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

acline = [0]*n
wanum = [0]*n

for i in range(m):
    num, acwa = map(str, input().split())
    
    num = int(num) -1
    
    if acwa == "AC":
        acline[num] = 1
    else:
        if acline[num] == 1:
            continue
        else:
            wanum[num] += 1
            
for j in range(n):
    if acline[j] == 0:
        wanum[j] = 0
            
print(sum(acline), sum(wanum))