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:
# coding: utf-8
# Your code here!

def pin(type=int):
    return map(type,input().split())
#1行ごとに読み込んでいる
#変数一個だけのときはカンマを入れるだけ、input()相当。ちょろい。
#sum関数などintを相手にした関数を書く時に便利なのでデフォルトをint型にする

N,M = pin() 
p=[0 for j in range(0,M)]
S=[0 for j in range(0,M)]
for j in range(0,M):
    p[j],S[j] =pin(str) #p_i,S_iにそれぞれ対応
    #print("sah")
# O(3M)...?
#print(p)
#print(p,S)
#ACした問題番号と各々の問題（後々AC下かを考えない）ペナ数を問題番号別にまとめた配列
AC=[0 for i in range(0,N)]
Penalties = [0 for i in range(0,N)]

#問題番号iと回答番号jについて,
"""
for i in range(0,N):
    for j in range(0,M):
    
        #jがiの回答である時に,WAだったらPenaltiesに1個加算
        if int(p[j])-1==i:
            if (S[j]) == 'WA':
                Penalties[int(p[j])-1] += 1
            else:#それが初めてのACならば、AC数に1を足してcontinueで次の問題i+1へ移る
                AC[int(p[j])-1] = 1
                break
            #print(AC,Penalties)
"""
#double-loop だと　TLEしてしまう O(n^2)はだめみたい

#singleloopしかないねぇ
#回答番号jに着目する
for j in range (0,M):
    if S[j] == "AC":
        if AC[int(p[j])-1]==1:
            continue
        else:
            AC[int(p[j])-1]=1
    else:#wa or something
        if AC[int(p[j])-1]==1:
            continue
        else:
            Penalties[int(p[j])-1]+=1
  # print(AC,Penalties)

for i in range(0,N):
    if AC[i] == 0:
        Penalties[i]=0
#print("///////")    
#print(AC,Penalties)    



#ACリスト内の1の数を数えるのは iter.countだね
print(AC.count(1),sum(Penalties))

Submission status: Accepted

Solution code:
import sys

N, M = [int(i) for i in input().split()]
wa_dict = {}
for line in sys.stdin:
  line = line.rstrip().split()
  if len(line) == 0: break
  p = int(line[0])
  S = line[1]
  if p not in wa_dict:
    if S == "WA":
      wa_dict[p] = 1
    else:
      wa_dict[p] = 0
  elif wa_dict[p] > 0:
    if S == "WA":
      wa_dict[p] += 1
    else:
      wa_dict[p] *= -1
ac = sum([1 for i in wa_dict.values() if i <= 0])
wa = sum([abs(i) for i in wa_dict.values() if i <= 0])
print("{} {}".format(ac, wa))

Submission status: Accepted

Solution code:
#!python3.4.3

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

penalty = [0 for _ in range(n)]
result = [0 for _ in range(n)]

for i in range(m):
    p, s = input().split(' ')
    p = int(p)
    if s == 'AC':
        result[p-1] = 1
    elif s == 'WA' and result[p-1] != 1:
        penalty[p-1] += 1
    
penalty = [x * y for (x, y) in zip(penalty, result)]

print(sum(result), sum(penalty))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
flag = [0]*N
WA = 0
WA_flag = [0]*N
AC = 0
for _ in range(M):
    p, S = input().split()
    p = int(p)
    if S == "AC":
        if flag[p-1] == 0:
            AC += 1
            flag[p-1] = 1
            WA += WA_flag[p-1]
    else:
        WA_flag[p-1] += 1

print("{} {}".format(AC , WA))

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
anslis=set()
plis=[0]*n
acount=0
pcount=0
for i in range(m):
	p,s=map(str,input().split())
	if int(p) not in anslis:
		if s=="WA":
			plis[int(p)-1]+=1
		elif s=="AC":
			anslis.add(int(p))
			acount+=1
			pcount+=plis[int(p)-1]
print(acount,pcount)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
lis = [[] for _ in range(N)]
for _ in range(M):
  question, result = input().split()
  question = int(question)
  lis[question-1].append(result)  

AC_times = 0
WA_times = 0
for i in range(N):
  pre_WA_times = 0
  for j in lis[i]:
    passed = False
    if not passed:
      if j == "AC":
        passed = True
        WA_times += pre_WA_times
      elif j == "WA":
        pre_WA_times += 1
    if passed:
      AC_times += 1
      break
      
print(AC_times, WA_times)

Submission status: Accepted

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

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

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

print(sum(ac), pena)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
score = [(False, 0) for i in range(n)]
for i in range(m):
	problem, s = input().split()
	p = int(problem)-1
	if not score[p][0]:
		score[p] = (True, score[p][1]) if s=="AC" else (False, score[p][1]+1)
	

print(sum(i[0] for i in score), sum(j if i else 0 for i, j in score))

Submission status: Accepted

Solution code:
n,m = map(int, input().split())
ac,wa = [0]*n,[0]*n
ans = 0
miss = 0
for i in range(m):
  a,b = map(str, input().split())
  a = int(a)
  if b == "AC":
    if ac[a-1]==0:
      ans += 1
      miss += wa[a-1]
      ac[a-1] += 1
  else:
    if ac[a-1]==0:
      wa[a-1] += 1
    
print("%d %d" %(ans, miss))

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
yes = [False for i in range(n)]
negative = [0 for i in range(n)]
score = [0 for i in range(n)]
for i in range(m):
	problem, s = input().split()
	p = int(problem)
	if s=="AC" and not yes[p-1]:
		yes[p-1] = True
		score[p-1] = negative[p-1]
	else:
		negative[p-1] += 1
	

print(sum(yes), sum(score))

Submission status: Accepted

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

results = {}

for i in range(m):
    line = input().split()
    
    if not line[0] in results:
        results[line[0]] = [0, 0]
    elif results[line[0]][1] == 1:
        continue
    
    if line[1] == "WA":
        results[line[0]][0] += 1
    elif line[1] == "AC":
        results[line[0]][1] = 1

ac_num = 0
wa_in_ac = 0

for key in results:
    if results[key][1] == 1:
        ac_num += 1
        wa_in_ac += results[key][0]

print(ac_num, wa_in_ac)

Submission status: Accepted

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

Submission status: Accepted

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

l.sort(key=lambda x:(x[0],x[2]))

f=""
q=""
a=0
w=0

for i in range(m):
    if l[i][0] != f:
        ww=0
    if l[i][1] == "AC":
        if l[i][0] != q:
            a+=1
            w+=ww
            q=l[i][0]
    else:
        ww+=1
    
    f=l[i][0]

print(a,w)

Submission status: Accepted

Solution code:
def main():
    n,m = map(int,input().split())
    flag = [False for i in range(n+5)]
    AC = 0
    WA = [0 for i in range(n+5)]
    _WA = 0
    for i in range(m):
        input_line = input().split()
        p,s = int(input_line[0]), input_line[1]
        if flag[p] == False:
            if s == "AC":
                AC += 1
                _WA += WA[p]
                flag[p] = True
            else:
                WA[p] += 1
    print(AC,_WA)
    return


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
n,m = map(int, input().split())
a_cnt,p_cnt = [0]*n,[0]*n #正答数、ペナルティ数
for i in range(m):
	p,s = input().split()
	if a_cnt[int(p)-1] == 0: #まだ正答してなかったら
		if s == "AC":
			a_cnt[int(p)-1] = 1
		elif s== "WA": #"WA"
			p_cnt[int(p)-1] += 1
for i in range(n):
	if a_cnt[i] == 0:
		p_cnt[i] = 0
print(sum(a_cnt),sum(p_cnt))

Submission status: Accepted

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

was = 0
for i in range(N):
  was += ACed[i] * wa[i]

print(sum(ACed), was)

Submission status: Accepted

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

ac = [False] * (n + 1)
wa = [0] * (n + 1)
for i in range(m):
    if not ac[ps[i][0]]:
        if ps[i][1] == "WA":
            wa[ps[i][0]] += 1
        elif ps[i][1] == "AC":
            ac[ps[i][0]] = True
wa_sum = 0
for i in range(n + 1):
    if ac[i]:
        wa_sum += wa[i]
print(str(ac.count(True)) + " " + str(wa_sum))

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
k = {}
for i in range(M):
  p,s = input().split()
  if p not in k:
    k[p] = [s]
  else:
    k[p].append(s)
ac = 0
wa = 0
for l in k:
  now = 0
  for m in k[l]:
    if m == "WA":
      now += 1
    elif m == "AC":
      ac += 1
      wa += now
      break
print(ac,wa)

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
cnt = 0
pena = 0
problem = [0]*n
ac = 0
penalty = 0
for i in range(m):
    p,s = input().split()
    if problem[int(p)-1] == -1:
        continue
    if s == "WA":
        problem[int(p)-1]+=1
    else:
        ac += 1
        penalty += problem[int(p)-1]
        problem[int(p)-1] = -1
print(ac,penalty)

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
check = [0]*N
ac = 0
penalty = 0
for i in range(M):
  pi, si = input().split()
  pi = int(pi)
  if check[pi-1] == -1:
    continue
  if si == 'WA':
    check[pi-1] += 1
  else:
    ac += 1
    penalty += check[pi-1]
    check[pi-1] = -1
print(ac,penalty)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
info=[]
for i in range(m):
    p,s=input().split()
    info.append([int(p),s])
ac,wa=0,0
plob=[[0,0] for i in range(n+1)] #一個目はACしたことあるか、二個目はWAを何回出してるか
for i in range(m):
    if plob[info[i][0]][0]==0:
        if info[i][1]=="WA":
            plob[info[i][0]][1]+=1
        else:
            ac+=1
            plob[info[i][0]][0]=1
            wa+=plob[info[i][0]][1]
print(str(ac)+" "+str(wa))

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
A = [[] for _ in range(N)]
ac_cnt, wa_cnt = 0, 0
for _ in range(M):
    p, s = input().split()
    if s == "AC":
        A[int(p) - 1].append(1)
    else:
        A[int(p) - 1].append(0)

for x in A:
    if x.count(1) >= 1:
        ac_cnt += 1
        wa_cnt += len(x[0:x.index(1)])
print(ac_cnt, wa_cnt)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
acf,waf=[0]*n,[0]*n
ac,wa=0,0
for i in range(m):
    x,y=input().split()
    x=int(x)
    if y=='AC':
        if acf[x-1]==0:
            ac+=1
            wa+=waf[x-1]
            acf[x-1]+=1
    else:
        waf[x-1]+=1
print(ac,wa)

Submission status: Accepted

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

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

    if s=="WA":
        li[int(p)][0] += 1
    else:
        if li[int(p)][1] == 0:
            ans += 1
            pena += li[int(p)][0]
            li[int(p)][1] = 1

print(ans,pena)

Submission status: Accepted

Solution code:
import copy
import heapq
import math
import fractions

def j(n):
    if n:print("Yes")
    else:print("No")
    exit(0)
rem = 10 ** 9 + 7

"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def iprow():
    return [int(i) for i in input().split()]
def ips():
    return (int(i) for i in input().split())
def ipmultiplerow(n):
    a = []
    for i in range(n):
        a.append(ip())
    return a
def printrow(a):
    for i in a:
        print(i)


def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


n,m = ips()
correct = [0 for i in range(n+1)]
wasu = [0 for i in  range(n+1)]
for loop in range(m):
    q,r = input().split()
    q = int(q)
    if r == "WA":
        if correct[q]==0:
            wasu[q]+=1
    else:
        correct[q] = 1
allwa = 0
for i in range(len(correct)):
    if correct[i]:
        allwa+=wasu[i]
print(sum(correct),allwa)

Submission status: Accepted

Solution code:
def abc151_c():
    N, M = map(int, input().split())
    seen = [0]*(N+1)
    ac = 0
    wa = 0

    for _ in range(M):
        p, c = input().split()
        p = int(p)
        if seen[p] == -1:
            continue
        if c == "WA":
            seen[p] += 1
        else:
            ac += 1
            wa += seen[p]
            seen[p] = -1
    print("{} {}".format(ac, wa))
abc151_c()

Submission status: Accepted

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

ac = 0
wa = 0
dwa = {}
d = {}

for i in range(m):
  p, s = input().split()
  if d.get(p) == "AC":
    continue
  if p not in dwa:
    dwa[p] = 0
  if s == "WA":
    dwa[p] += 1
  else:
    ac += 1
    wa += dwa[p]
  d[p] = s
  
print(ac, wa)

Submission status: Accepted

Solution code:
l = dict()
t, f = 0, 0
n, m = map(int, input().split(" "))
for _ in range(m):
  p, s = input().split(" ")
  if not p in l:
    l[p] = [None, 0]
  if s == "WA":
    l[p][1] += 1 
  elif s == "AC":
    if l[p][0] != True:
      l[p][0] = True
      t += 1
      f += l[p][1]

print(t, f)

Submission status: Accepted

Solution code:
n,m = (int(i) for i in input().split())

ac,wa = 0,0
score = {i+1:[] for i in range(n)}

for _ in range(m):
    p,s = (i for i in input().split())
    score[int(p)].append(s)

for v in score.values():
    if "AC" in v:
        wa += len(v[:v.index("AC")])
        ac += 1

print(ac,wa)

Submission status: Accepted

Solution code:

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

AC = 0
WA = 0


was = [0]*(N+1)
acs = [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())
pS = []
for _ in range(M):
    pS.append(input().split())

current = 0
penaltyList = [0] * (N+1)
penalty = 0
state = [False] * (N+1)
for i in pS:
    if i[1] == "WA" and (not state[int(i[0])]):
        penaltyList[int(i[0])] += 1
    elif i[1] == "AC" and (not state[int(i[0])]):
        current += 1
        penalty += penaltyList[int(i[0])]
        state[int(i[0])] = True
print(current, penalty)

Submission status: Accepted

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

pen_cnt = [0] * n
ac_flg = [0] * n

cnt = 0
for _ in range(m):
    sub = input().split()
    p = int(sub[0]) - 1
    s = sub[1]
    if s == "WA":
        pen_cnt[p] += 1
    elif s == "AC" and ac_flg[p] == 0:
        ac_flg[p] = 1
        cnt += pen_cnt[p]

print(sum(ac_flg), cnt)

Submission status: Accepted

Solution code:
l = dict()
t, f = 0, 0
n, m = map(int, input().split(" "))
for _ in range(m):
  p, s = input().split(" ")
  if not p in l:
    l[p] = [None, 0]
  if s == "WA":
    if l[p][0] != True:
      l[p][1] += 1
  elif s == "AC":
    if l[p][0] != True:
      l[p][0] = True
      t += 1

for _, v in l.items():
  if v[0]:
    f += v[1]
print(t, f)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
ps = {}
for _ in range(m):
    _p, _s = map(str, input().split())
    _p = int(_p)
    ps.setdefault(_p, [])
    ps[_p].append(_s)

ac = 0
wa = 0
for v in ps.values():
    for i, _v in enumerate(v):
        if _v == "AC":
            ac += 1
            wa += i
            break

print(ac, wa)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
a = [0] * (n+1) #その問題で既に AC が出たか
b = [0] * (n+1) #その問題で WA が出た回数

WA = 0

for i in range(m):

    s = input().split()

    if a[int(s[0])] == 0:
        if s[1] == "AC":
            a[int(s[0])] = 1
            WA += b[int(s[0])]
        else:
            b[int(s[0])] += 1

print(sum(a), WA)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
if m == 0: print("{0} {1}".format(0, 0))
else:
    ps, ans = {}, [0, 0]
    for _ in range(m):
        p, s = map(str, input().split())
        if p not in ps.keys():
            ps[p] = 0
        if ps[p] == "AC": continue
        elif ps[p] != "AC":
            if s == "WA":
                ps[p] += 1
            else:
                ans[1] += ps[p]
                ans[0] += 1
                ps[p] = "AC"
    print(*ans)

Submission status: Accepted

Solution code:
# sh_yamaさんの回答
n, m = map(int, input().split())  # n,mはそれぞれ問題数、解いた数
ac = [0 for _ in range(n)]
pen = [0 for _ in range(n)]

for _ in range(m):
    p, s = input().split()  # input().split()を使えばよい
    p = int(p) - 1  # 何問目か？（-1は番目を合わせる為）
    if s == 'WA':
        if ac[p] == 0:  # WAでまだ未ACという事を示す
            pen[p] += 1  # このときペナルティを加える
    else:  # 問題pがACの時
        ac[p] = 1  # p問目を既ACにする

for p in range(n):
    if ac[p] == 0:
        pen[p] = 0  # 未ACの問題はペナルティも０にする

print(sum(ac), sum(pen))

Submission status: Accepted

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

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

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

print(sum(ac),sum([wa[x] for x in range(n) if ac[x]==1]))

Submission status: Accepted

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

grid = []

for i in range(M):
    array = list(map(str, input().strip().split()))
    grid.append(array)

ac_list = [0] * N
wa_list = [0] * N

for a in grid:
    if a[1] == 'AC':
        ac_list[int(a[0]) - 1] = 1
    elif a[1] == 'WA' and ac_list[int(a[0]) - 1] == 0:
        wa_list[int(a[0]) - 1] += 1

for b in range(len(wa_list)):
    if ac_list[b] == 0:
        wa_list[b] = 0

print(str(sum(ac_list)) + ' ' + str(sum(wa_list)))

Submission status: Accepted

Solution code:
import sys

def main():
    N, M = list(map(int,input().split()))
    p_S = [None] * M

    wa_cnt = [0] * N
    ac_flags = [0] * N

    for i in range(M):
        p_S[i] = list(input().split())
        p_S[i][0] = int(p_S[i][0])

    wa_ans, ac_ans = 0, 0

    for j in p_S:
        if j[1] == 'WA':
            wa_cnt[j[0] - 1] += 1

        if j[1] == 'AC' and ac_flags[j[0] - 1] == 0:
            wa_ans += wa_cnt[j[0] - 1]
            ac_ans += 1
            ac_flags[j[0] - 1] = 1


    print(ac_ans, wa_ans)

main()

Submission status: Accepted

Solution code:
class Stats:
    def __init__(self, is_AC=False, cnt=0):
        self.is_AC = is_AC
        self.cnt = cnt


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

S = [Stats() for _ in range(N)]

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

    if not S[p - 1].is_AC:
        S[p - 1].cnt += 1

    if s == 'AC':
        S[p - 1].is_AC = True

print(
    len(list(filter(lambda s: s.is_AC, S))),
    sum(map(lambda s: s.cnt - 1, (filter(lambda s: s.is_AC, S))))
)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
cur = []
kur = []
pen=0
ans=0
for i in range (n+1): cur.append(0)
for i in range (n+1): kur.append(0)
for i in range (m):
    a, b = input().split()
    a = int(a)
    if b=="AC":
        if cur[a]==0:
            pen+=kur[a]
            ans+=1
        cur[a]=1
    else: kur[a]+=1;
print(ans, pen, sep=' ')

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
l=list(input().split() for _ in range(m))
l=sorted(l,key=lambda x:x[0])
import itertools
lll=[]
for (k,g) in itertools.groupby(l,key=lambda x:x[0]):
    lll.append(list(g))
a=0
w=0
for i in range(len(lll)):
    for j in lll[i]:
        if j[1]=="AC":
            a+=1
            w+=lll[i].index(j)
            break
print(a,w)

Submission status: Accepted

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

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

for i in range( m ):
  p = input().split()
  prob_no =int( p[ 0 ])
  if p[ 1 ] == "WA":
    if not ac[ prob_no - 1 ]:
      wa[ prob_no - 1 ] += 1
  else:
    ac[ prob_no - 1 ] = True

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

print( ac_cnt, wa_cnt )

Submission status: Accepted

Solution code:
from bisect import *
from collections import *
from itertools import *
import functools
import sys
import math
from decimal import *
from copy import *
from heapq import *
from fractions import *
getcontext().prec = 30
MAX = sys.maxsize
MAXN = 1000001
MOD = 10**9+7
spf = [i for i in range(MAXN)]
spf[0]=spf[1] = -1
def sieve():
    for i in range(2,MAXN,2):
        spf[i] = 2
    for i in range(3,int(MAXN**0.5)+1):
        if spf[i]==i:
            for j in range(i*i,MAXN,i):
                if spf[j]==j:
                    spf[j]=i
def fib(n,m):
    if n == 0:
        return [0, 1]
    else:
        a, b = fib(n // 2)
        c = ((a%m) * ((b%m) * 2 - (a%m)))%m
        d = ((a%m) * (a%m))%m + ((b)%m * (b)%m)%m
        if n % 2 == 0:
            return [c, d]
        else:
            return [d, c + d]

def charIN(x= ' '):
    return(sys.stdin.readline().strip().split(x))

def arrIN(x = ' '):
    return list(map(int,sys.stdin.readline().strip().split(x)))

def ncr(n,r):
    num=den=1
    for i in range(r):
        num = (num*(n-i))%MOD
        den = (den*(i+1))%MOD

    return (num*(pow(den,MOD-2,MOD)))%MOD

def flush():
    return sys.stdout.flush()

'''*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*'''
n,m = arrIN()

d = defaultdict(list)

for i in range(m):
    a,b = input().split()
    d[int(a)].append(b)
ca = pe = 0
for i in range(1,n+1):
    if "AC" in d[i]:
        ca+=1
        pe+=d[i].index("AC")
print(ca,pe)

Submission status: Accepted

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

args = input().split()
n = int(args[0])
m = int(args[1])
ok = [False] * n
ng = [0] * n
for _ in range(m):
    target, score = input().split()
    target = int(target) - 1
    if score == 'AC':
        ok[target] = True
    else:
        if not ok[target]:
            ng[target] += 1

ok_cnt = 0
ng_cnt = 0
for i in range(n):
    if ok[i]:
        ok_cnt += 1
        ng_cnt += ng[i]
print(ok_cnt, ng_cnt)

Submission status: Accepted

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

d = {i:[False,0] for i in range(1,N+1)}

wa = 0
clear = 0

for i in range(M):
  input_ = input().split()
  p = int(input_[0])
  S = input_[1]
  
  if S == "WA":
    if not d[p][0]:
      # もしWAで、未正解なら不正解カウントを増やす
      d[p][1] += 1
    else:
      # もし既に正解しているのにWAなら、無視する
      pass
  elif S == "AC":
    if not d[p][0]:
      # もしACで、未正解なら正解カウントを増やして正解判定にする
      clear += 1
      d[p][0] = True
    else:
      # もし既に正解していて、またACなら、無視する
      pass
    
for i in d:
  tmp = d[i]
  
  if tmp[0]:
    # もしACしていたら、その不正解カウントをペナルティとして加算
    wa += tmp[1]

print(clear,wa)

Submission status: Accepted

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

ac = [False] * N
wa = [0] * N
for _ in range(M):
   p, S = input().split()
   p = int(p) - 1
   if (S == 'AC'):
      ac[p] = True
   else:
      if not ac[p]:
         wa[p] += 1

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

Submission status: Accepted

Solution code:
from sys import stdin
n,m = map(int, stdin.readline().rstrip().split())

count = 0
penalty = 0
qb = [0]*n
was = [0]*n

for i in range(m):
    p,s = map(str,stdin.readline().rstrip().split())
    p = int(p)
    if s == "AC" and qb[p-1] != "AC":
        qb[p-1] = "AC"
        penalty += was[p-1]
        count += 1
    elif s == "WA":
        was[p-1] += 1
    else:
        pass

print(count, penalty)

Submission status: Accepted

Solution code:

import sys
N,M = map(int, input().split())
A = [tuple(input().split()) for _ in range(M)]
a_cnt = 0
p_cnt = 0
wa = [0] * N
flg = [0] * N

for i in range(M):
  no = int(A[i][0])-1
  if A[i][1] == "AC" and flg[no] == 0:
    a_cnt += 1
    p_cnt += wa[no]
    flg[no] = 1
    continue
  else:
    wa[no] += 1
print(a_cnt, p_cnt)

Submission status: Accepted

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

A = [0 for _ in range(N+1)]
ac, wa = 0, 0

for _ in range(M):
    p, S = input().split()
    p = int(p)
    if A[p] != None:
        if S == "AC":
            ac += 1
            wa += A[p]
            A[p] = None
        else:
            A[p] += 1
print(ac, wa)

Submission status: Accepted

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

a=[0]*n

for i in range(m):
  p,s=input().split()
  p=int(p)
  p-=1
  if a[p]==-1:
    continue
  if s=="AC":
    account+=1
    wacount+=a[p]
    a[p]=-1
  else:
    a[p]+=1

print(account, wacount)

Submission status: Accepted

Solution code:
from collections import defaultdict
N,M = map(int,input().split())
dic = defaultdict(list)
for i in range(M):
    p,s = input().split()
    dic[p].append(s)
nAC = 0
nWA = 0
for k in dic.keys():
    if 'AC' in dic[k]:
        for s in dic[k]:
            if s == 'AC':
                nAC += 1
                break
            nWA += 1
print(nAC,nWA)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
n,m=map(int,input().split())
ac=[0]*n
wa=[0]*n
for i in range(m):
    pi,si=input().split()
    pi=int(pi)-1
    if ac[pi]==1:
        pass
    elif si=="AC":
        ac[pi]=1
    else:
        wa[pi]+=1
print(sum(ac),sum([wa[x] for x in range(n) if ac[x]==1]))

Submission status: Accepted

Solution code:
n,m=(int(x) for x in input().split())

k = {}
l = {}
ok = 0
ng = 0
for i in range(m):
    p,s = input().split()
    if p in k and k[p] == 0 :
        continue
    elif p in k and s == 'AC':
        ok += 1
        k[p] = 0
    elif  s == 'WA':
        ng += 1 
        if p in k:
            k[p] += 1
        else:
            k[p] = 1
    elif  s == 'AC':
        ok+=1
        k[p] = 0

nng = 0
for v,vv in k.items():
    nng += vv

print(ok,ng- nng)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
import collections
d=collections.defaultdict(list)
for i in range(m):
    x,a=input().split()
    x=int(x)
    d[x].append(a)

ac=0
wa=0
for i in d:
    cnt=0
    for j in d[i]:
        if j=="WA":
            cnt+=1
        else:
            ac+=1
            wa+=cnt
            break
print(ac,wa)

Submission status: Accepted

Solution code:
from sys import stdin,setrecursionlimit
setrecursionlimit(10 ** 6)
input = stdin.readline
N, M = map(int, input().split())
ac = [False] * N # index means p
wa = [0] * N # index means p
wa_cnt = 0
for i in range(M):
  p, s = input().split()
  p = int(p) - 1 # index starts from 0
  if ac[p] is False and s == "AC":
    wa_cnt += wa[p]
    ac[p] = True
  elif s == "WA":
    wa[p] += 1
print(ac.count(True), wa_cnt)

Submission status: Accepted

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

ac = 0
wa = 0
wa_c = [0]*n
ac_c = [False]*n

for t in range(m):
    if ac_c[p[t]-1]:
        continue
    if q[t] == "AC":
        ac += 1
        ac_c[p[t]-1] = True
        wa += wa_c[p[t]-1]
    else:
        wa_c[p[t]-1] += 1
print(ac,wa)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
ac = [False] * N # index means p
wa = [0] * N # index means p
wa_cnt = 0
for i in range(M):
  p, s = map(str, input().split())
  p = int(p) - 1 # index starts from 0
  if ac[p] is False and s == "AC":
    wa_cnt += wa[p]
    ac[p] = True
  elif s == "WA":
    wa[p] += 1
print(ac.count(True), wa_cnt)

Submission status: Accepted

Solution code:
N, M = list(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])

WAnum = 0
ACnum = 0

WA = [0] * N
AC = [0] * N

for i in range(M):
    num = p[i] - 1
    # 未得点のときだけ影響
    if(AC[num] >= 1):
        continue

    if(S[i] == 'WA'):
        WA[num] += 1

    elif(S[i] == 'AC'):
        AC[num] = 1
        ACnum += 1
        WAnum += WA[num]

print(ACnum, WAnum)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
PS = [list(map(str, input().split())) for _ in range(M)]
ac = [False] * N # index means p
wa = [0] * N # index means p
wa_cnt = 0
for ps in PS:
  p = int(ps[0]) - 1 # index starts from 0
  s = ps[1]
  if not ac[p] and s == "AC":
    wa_cnt += wa[p]
    ac[p] = True
  elif s == "WA":
    wa[p] += 1
print(ac.count(True), wa_cnt)

Submission status: Accepted

Solution code:
N,M = map(int, input().split())
AC = [0]*N
WA = [0]*N
score = 0
pen = 0
for i in range(M):
  p,S = input().split()
  p = int(p)-1
  if AC[p] == 1:
    continue
  elif S == "WA":
    WA[p] += 1
  elif S == "AC":
    AC[p] = 1
    score += 1
    pen += WA[p]
print(score,pen)

Submission status: Accepted

Solution code:
def main():
    N, M = map(int, input().split())
    l = []
    for _ in range(M):
        p, s = input().split()
        l.append((int(p), s))
    da = {}
    dp = {}
    p = 0
    a = 0
    for i in range(M):
        if l[i][0] in da:
            continue
        elif l[i][1] == 'AC':
            a += 1
            da[l[i][0]] = True
            if l[i][0] in dp:
                p += dp[l[i][0]]
        else:
            if l[i][0] in dp:
                dp[l[i][0]] += 1
            else:
                dp[l[i][0]] = 1
    print(a, p)
main()

Submission status: Accepted

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

acc = [ False ] * N
pena = [ 0 ] * N 
for p, S in results:
  p = int(p) - 1
  if acc[p] is False:
    acc[p] = True if S == 'AC' else False 
    pena[p] = pena[p] + 1 if S == 'WA' else pena[p] 

wa = 0
for i in range(N):
  wa += pena[i] if acc[i] is True else 0
    
print(sum(acc), wa)

Submission status: Accepted

Solution code:
def main():
    N, M = map(int, input().split())
    AC = [False] * N
    WA = [0] * N
    w = 0
    for _ in range(M):
        p, s = input().split()
        p = int(p) - 1
        if s == 'AC' and not AC[p]:
            w += WA[p]
            AC[p] = True
        if s == 'WA':
            WA[p] += 1
    print(AC.count(True), w)

main()

Submission status: Accepted

Solution code:
# coding: utf-8

n,m = map(int,input().split(" "))
ac_list = [0] * n
wa_list = [0] * n


wa = 0

for i in range(m):
    a,b = input().split(" ")
    if ac_list[int(a) - 1]:
        continue
    if b == "AC":
        ac_list[int(a) - 1] = 1
        wa += wa_list[int(a)-1]
    else:
        wa_list[int(a)-1] += 1
        
print(sum(ac_list),wa)