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 = list(map(int, input().split()))
dic = {}

for _ in range(m):
  pi, si = input().split()
  pi = int(pi)
  if pi in dic:
    dic[pi].append(si)
  else:
    dic[pi] = [si]

a = 0
p = 0

for s in dic.values():
  if 'AC' in s:
    a += 1
    p += s.index('AC')

print('%s %s'%(int(a), int(p)))

Submission status: Accepted

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

u = [[0 for i in range(2)]for j in range(n)]

for k in range(0,m):
  if(s[k] == "WA" and u[p[k]-1][1] == 0):
    u[p[k]-1][0] += 1
  elif(s[k] == "AC"):
    u[p[k]-1][1] = 1

ans = 0
ac = 0
for i in range(n):
  if(u[i][1] == 1):
    ac += 1
    ans += u[i][0]
print(ac,ans)

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.append([_p, _s])

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

for _p, _s in ps:
    if ac[_p-1]:
        continue

    if _s == "AC":
        ac[_p-1] = True
    elif _s == "WA":
        wa[_p-1] += 1

ans = [0, 0]
for _ac, _wa in zip(ac, wa):
    if _ac:
        ans[0] += 1
        ans[1] += _wa

print(*ans)

Submission status: Accepted

Solution code:
N, M = list(map(int, input().split()))
ACL = [0 for i in range(N)]
WAL = [0 for i in range(N)]
for i in range(M):
  p, s = input().split()
  p = int(p)-1
  if ACL[p] > 0:
    continue
  if s == "AC":
    ACL[p] = 1
    continue
  if s == "WA" and ACL[p] == 0:
    WAL[p] += 1
  
print(sum(ACL), sum([ACL[i] * WAL[i] for i in range(N)]))

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()
    p = int(p) - 1
    if S == 'AC':
        AC[p] = 1
    elif AC[p] == 0:
        WA[p] += 1

print(sum(AC), sum( [AC[i] * WA[i] for i in range(N)] ) )

Submission status: Accepted

Solution code:
def resolve_c():
    n, m = map(int, input().split())
    ac_list = [0] * n
    wa_list = [0] * n
    wa_tmp_list = [0] * n
    for i in range(m):
        p, s = input().split()
        if ac_list[int(p)-1] == 0:
            if s == "AC":
                ac_list[int(p)-1] = 1
                wa_list[int(p)-1] = wa_tmp_list[int(p)-1]
            elif s == "WA":
                wa_tmp_list[int(p)-1] += 1
    print(str(sum(ac_list)) + " " + str(sum(wa_list)))
resolve_c()

Submission status: Accepted

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

ac, wa = [0]*N, [0]*N
for i in range(M):
    if ac[p[i]] == 1:
        continue
    if S[i] == "AC":
        ac[p[i]] = 1
    else:
        wa[p[i]] += 1

acs, was = 0, 0
for i in range(N):
    if ac[i] == 1:
        acs += 1
        was += wa[i]
print(acs, was)

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
A = [0]*(N+1)
mod = 10**8

for i in range(M):
    p,S = input().split()
    p = int(p)
    if S == 'AC':
        if A[p]//mod==0:
            A[p] += mod
    else:
        if A[p]//mod==0:
            A[p] += 1
            
AC = sum(A)//mod
WA = 0
for i in A:
    if i//mod!=0:
        WA += i%mod
print(AC,WA)

Submission status: Accepted

Solution code:
def main():
    n, m = [int(x) for x in input().strip().split()]

    # 正解したかどうか
    flag = [False] * n
    # AC までの挑戦数
    trial = [0] * n
    for _ in range(m):
        tmp = input().strip().split()
        idx = int(tmp[0])-1
        # すでに AC を出している場合
        if flag[idx]:
            continue
        # AC だった場合
        flag[idx] = (tmp[1] == "AC")
        if flag[idx]:
            continue
        # WA とか
        trial[idx] += 1

    # AC
    pen = 0
    for f, t in zip(flag, trial):
        if not f:
            continue
        pen += t

    print(flag.count(True), pen)


if __name__ == "__main__":
    main()

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()
    p = int(p) - 1
    if S == 'AC':
        AC[p] = 1
    elif AC[p] == 0:
        WA[p] += 1

print(sum(AC), sum( [AC[i] * WA[i] for i in range(N)] ) )

Submission status: Accepted

Solution code:
import numpy as np

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

ifAC = np.zeros(N, dtype='bool')
WAcount = np.zeros(N, dtype='int')

for i in range(M):
    pi, Si = input().split()
    pi = int(pi) - 1
    if Si == 'AC':
        ifAC[pi] = True
    if ifAC[pi] == False and Si == 'WA':
        WAcount[pi] += 1

print(np.sum(ifAC), np.sum(np.dot(WAcount, ifAC)))

Submission status: Accepted

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

flag_ac = [0]*n
cnt_wa = [0]*n
cnt_penalty = 0

for _ in range(m):
    p, s = input().split()
    if s == "WA":
        cnt_wa[int(p)-1] += 1
    elif s == "AC" and flag_ac[int(p)-1] == 0:
        flag_ac[int(p)-1] = 1
        cnt_penalty += cnt_wa[int(p)-1]
        
print(sum(flag_ac), cnt_penalty)

Submission status: Accepted

Solution code:
N = input().split()
N = [int(i) for i in N]
Pi = [[0,0] for i in range(N[0])]
#print(Pi)

Nac = 0
Nwa = 0
for i in range(N[1]):
    M = input().split()
    p = int(M[0])
    judge = str(M[1])

    if(Pi[p-1][1] == 0):
        if(judge == 'AC'):
            Pi[p-1][1] = 1
        else:
            Pi[p-1][0] += 1

for i in range(N[0]):
    if(Pi[i][1] == 1):
        Nac += Pi[i][1]
        Nwa += Pi[i][0]
print(Nac, Nwa)

Submission status: Accepted

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

if M == 0 or N == 0:
    print("{} {}".format(0, 0))
else:

    p = [0]*M
    S = [0]*M

    for i in range(M):
        tmp = input().split()
        p[i] = int(tmp[0])
        S[i] = tmp[1]

    penalty = 0


    correct_set = set()
    for i in range(M):
        if S[i] == 'AC':
            correct_set.add(p[i])

    correct = len(correct_set)

    for i in range(M):
        if S[i] == 'AC' and p[i] in correct_set:
            correct_set.remove(p[i])
        elif S[i] == 'WA' and p[i] in correct_set:
            penalty += 1


            

    print("{} {}".format(correct, penalty))

Submission status: Accepted

Solution code:
nm = [int(i) for i in input().split()]
dic = {}

co = 0
pe = 0

for i in range(0,nm[1]):
  tmp = [j for j in input().split()]
  val = dic.setdefault(tmp[0],['NEW', 0])
  
  if (val[0] == 'NEW') or (val[0] == 'WA'):	#新規追加
    if tmp[1] == 'WA':
      dic[tmp[0]][1] += 1
      dic[tmp[0]][0] = 'WA'
    elif tmp[1] == 'AC':
      co += 1
      pe += dic[tmp[0]][1]
      dic[tmp[0]][0] = 'AC'

print(co, pe)

Submission status: Accepted

Solution code:
n, m = [int(i) for i in input().split()]
solved = [False for _ in range(n)]
failures = [0 for _ in range(n)]

total_success = 0

for _ in range(m):
    res = input().split()
    p = int(res[0])
    if not solved[p - 1]:
        if res[1] == "AC":
            solved[p - 1] = True
            total_success += 1
        else:
            failures[p - 1] += 1

total_fail = sum([f for i, f in enumerate(failures) if solved[i]])
print(total_success, total_fail)

Submission status: Accepted

Solution code:
n,m=map(int, input().split())
acceted=set()
penalty=0
wa_cnt=[0]*(n+1)
for i in range(m):
    p,s=map(str, input().split())
    p=int(p)
    if p in acceted:
        continue
    if s=="AC":
        penalty+=wa_cnt[p]
        acceted.add(p)
    else:
        wa_cnt[p]+=1
print(len(acceted),penalty)

Submission status: Accepted

Solution code:
from collections import defaultdict

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

d = defaultdict(int)

if M > 0:
    for i in range(M):
        p, S = input().split()
        p = int(p)
        if d[(p, 'AC')] > 0 and S == 'AC':
            pass
        elif d[(p, 'AC')] == 0 and S == 'AC':
            d[(p, 'AC')] = 1
        elif d[(p, 'AC')] == 0 and S == 'WA':
            d[(p, 'WA')] += 1

ans = 0
penalty = 0

for i in range(1, N + 1):
    if d[(i, 'AC')]:
        ans += d[(i, 'AC')]
        penalty += d[(i, 'WA')]
        # print(i, ans, penalty)

print('{} {}'.format(ans, penalty))

Submission status: Accepted

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

wa_cnt = [0]*N
ac_flag = [False]*N

for _ in range(M):
    p,S = input().split()
    p = int(p)-1

    if not ac_flag[p]:
        if S == 'WA':
            wa_cnt[p] += 1
        else:
            ac_flag[p] = True


print(sum(ac_flag), sum(c for c,f in zip(wa_cnt,ac_flag) if f))

Submission status: Accepted

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

A = sorted(A, key=lambda a: a[0])
ac = set()
wa = {}

total_ac_cnt = 0
total_wa_cnt = 0

for a in A:
    if a[1] == 'AC':
        if not a[0] in ac:
            ac.add(a[0])
            if a[0] in wa:
                total_wa_cnt += wa[a[0]]
            total_ac_cnt += 1
    else:
        if not a[0] in ac:
            if a[0] in wa:
                wa[a[0]] += 1
            else:
                wa[a[0]] = 1

print(total_ac_cnt, total_wa_cnt)

Submission status: Accepted

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

if M == 0:
  print(0,0)
  exit()
  
a = [0]*(N + 1)
p = [0]*(N + 1)
wa = [0]*(N + 1)

for i in range(M):
  P, S = input().split()
  P = int(P)
  if S == "WA":
    wa[P] += 1
  elif a[P] == 0:
    a[P] += 1
    p[P] = wa[P]

print(sum(a),sum(p))

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
rec = []
for i in range(M):
    p, S = map(str, input().split())
    p = int(p)
    rec.append([p,S])
N_list = [False for i in range(N)]
WA_cnt=[0 for i in range(N)]
penalty = AC_cnt = 0
for i in range(M):
    if rec[i][1] == "AC":
        if N_list[rec[i][0]-1] == False:
            AC_cnt += 1
            N_list[rec[i][0]-1] = True
            penalty += WA_cnt[rec[i][0]-1] 
    if rec[i][1] == "WA":
        if N_list[rec[i][0]-1] == False:
            WA_cnt[rec[i][0]-1] += 1
print(AC_cnt, penalty)

Submission status: Accepted

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

ps = [(int(p)-1, s) for p, s in PS]

ac = [0]*N
wa = [0]*N
for p, s in ps:
    if s == "AC":
        ac[p] = 1
    else:
        if ac[p] == 0:
            wa[p] += 1

print(sum(ac), sum([a*w for a, w in zip(ac, wa)]))

Submission status: Accepted

Solution code:
import sys, heapq
from collections import defaultdict
from itertools import product, permutations, combinations
from bisect import bisect_left # bisect(list, value) -> index

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

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

ac_num = defaultdict(int) # number of AC : dict
wa_num = defaultdict(int) # number of WA : dict
wass = 0 # number of WA : int
for ps in pS:
    p, S = int(ps[0]), ps[1]
    # 一度問題pがACなら飛ばす
    if ac_num[p] == 1:
        continue
    else:
        if S == 'AC':
            ac_num[p] = 1
            # ACになるまでにWAになった数を記録
            wass += wa_num[p]
        elif S == 'WA':
            wa_num[p] += 1
    #print(ac_num, wa_num)

print(sum(list(ac_num.values())), wass)

Submission status: Accepted

Solution code:
def solve():
    N, M = map(int, input().split())
    WAnum = 0
    ACnum = 0
    WA = [0]*(N+1)
    AC = [False]*(N+1)

    for _ in range(M):
        p, S = map(str, input().split())
        p = int(p)
        if AC[p] == True:
            continue
        if S == 'AC':
            AC[p] = True
            ACnum += 1
            WAnum += WA[p]
        elif S == 'WA':
            WA[p] += 1
        #print(AC, WA)
    #print(AC,WA)
    print(ACnum, WAnum)

solve()

Submission status: Accepted

Solution code:
import sys, heapq
from collections import defaultdict
from itertools import product, permutations, combinations
from bisect import bisect_left # bisect(list, value) -> index

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

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

was = defaultdict(int) # number of WA
chk = defaultdict(int) # chkflg
wass = 0
for ps in pS:
    p, S = int(ps[0]), ps[1]
    if chk[p] == 1:
        continue
    else:
        if S == 'AC':
            chk[p] = 1
            wass += was[p]
        else:
            was[p] += 1

print(sum(list(chk.values())), wass)

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
plist=[]
slist=[]
isAc_list = [False for _ in range(n+1)]
penalty_list = [0 for _ in range(n+1)]
for i in range(m):
  inputs = input().split()
  plist.append(int(inputs[0]))
  slist.append(inputs[1])

correct = 0
penalty = 0
for problem,result in zip(plist,slist):
  if isAc_list[problem]:
    continue
  elif result == 'AC':
    isAc_list[problem] = True
    correct+=1
    penalty+=penalty_list[problem]
  else:
    penalty_list[problem]+=1
print(correct,penalty)

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
da = [list(map(str,input().split())) for i in range(m)]
penalty = [0 for i in range(n)]
accepted = [False for i in range(n)]
for i in range(m):
  now = int(da[i][0]) - 1
  if da[i][1] == 'AC':
    accepted[now] = True
  elif not accepted[now]:
    penalty[now] += 1
AC,WA = 0,0
for i in range(n):
  if accepted[i]:
    AC += 1
    WA += penalty[i]
print(AC,WA)

Submission status: Accepted

Solution code:
a=[int(i) for i in input().split()]
s = [input().split() for i in range(a[1])]
al=[[] for i in range(a[0])]
for i in range(a[1]):
    al[int(s[i][0])-1].append(s[i][1])
ac=0
wa=0
for j in range(a[0]):
    if al[j].count('AC')!=0:
        wa+=al[j].index('AC')
        ac+=1
print(ac,wa)

Submission status: Accepted

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

ps = []
for i in range(m):
    ps.append(list(input().split()))
    ps[i][0] = int(ps[i][0])

cnt_correct = 0
cnt_penalty = 0
cnt_penalty_buf = 0

juge = [1]*n
buf = [0]*n

for i in range(m):
    if ps[i][1] == "AC" and juge[ps[i][0] - 1] == 1 :
        cnt_correct += 1
        cnt_penalty += buf[ps[i][0] - 1]
        juge[ps[i][0] - 1] = 0
        cnt_penalty_buf = 0

    if ps[i][1] == "WA" and juge[ps[i][0] - 1] == 1:
        buf[ps[i][0] - 1] += 1

print(cnt_correct, cnt_penalty)

Submission status: Accepted

Solution code:
def solve(n, m, PS):
    d = {}
    scores = [0, 0]
    for p, s in PS:
        if p not in d:
            d[p] = {'wa': 0, 'ac': 0}
        if d[p]['ac'] > 0:
            continue
        if s == 'AC':
            d[p]['ac'] = 1
            scores[0] += 1
            scores[1] += d[p]['wa']
        else:
            d[p]['wa'] += 1
    return scores

_n, _m = map(int, input().split())
_PS = [input().split() for _ in range(_m)]
print(*solve(_n, _m, _PS))

Submission status: Accepted

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

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

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

for _ in range(M):
    pi, Si = map(str, input().split())
    pi = int(pi)
    if Si == "WA":
        wacount[pi] += 1
    elif ac[pi] == 0:
        wa[pi] = wacount[pi]
        ac[pi] += 1

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

Submission status: Accepted

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

P, S = [], []
for i in range(M):
    _p, _s = list(input().split())
    P.append(int(_p))
    S.append(_s)

Q = []
Q_ans = []
for i in range(N):
    Q.append(0)
    Q_ans.append(False)

for i in range(M):
    q_num = P[i]
    if Q_ans[q_num-1]:
        continue
    if S[i] == "WA":
        Q[q_num-1] += 1
    if S[i] == "AC":
        Q_ans[q_num-1] = True

num_AC, num_WA = 0, 0
for i in range(N):
    if Q_ans[i]:
        num_WA += Q[i]
        num_AC += 1

print(num_AC, num_WA, sep=' ')

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
p, S = [], []

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

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

for _ in range(M):
    pi, Si = map(str, input().split())
    pi = int(pi)
    if Si == "WA":
        wacount[pi] += 1
    elif ac[pi] == 0:
        wa[pi] = wacount[pi]
        ac[pi] += 1

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

Submission status: Accepted

Solution code:
def main():
    N, M = (int(i) for i in input().split())
    A = {str(i+1): ["?", 0] for i in range(N)}
    for m in range(M):
        p, s = (i for i in input().split())
        if A[p][0] == "WA" or A[p][0] == "?":
            A[p][0] = s
            if s == "WA":
                A[p][1] += 1

    ans = [0, 0]
    for a in A.values():
        if a[0] == "AC":
            ans[0] += 1
            ans[1] += a[1]
    print(*ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import numpy as np
n,m = map(int, input().split())
AC = np.array([0]*n)
WA = np.array([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
  else:
    AC[int(p)-1] = 1

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

Submission status: Accepted

Solution code:
import sys

N, M = input().split(' ')
p_acwa_dict = {}
cnt_ac = 0
cnt_wa = 0
pre_p = 0
for line in sys.stdin:
  p, s = line.rstrip().split()
  p = int(p)
      
  pre_p = p
  acwa_cnt_dict = p_acwa_dict.setdefault(p, {'AC': 0, 'WA': 0})
  
  if acwa_cnt_dict['AC'] > 0:
    continue
    
  if s == 'AC':
    acwa_cnt_dict['AC'] += 1
    cnt_ac += 1
    cnt_wa += acwa_cnt_dict['WA']
  elif s == 'WA':
    acwa_cnt_dict['WA'] += 1

print("{} {}".format(cnt_ac, cnt_wa))

Submission status: Accepted

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

answered = [False] * N
will_wa = [0]*N
n_ac = 0
n_wa = 0

for _ in range(M):
  p, s = input().split()
  p = int(p)
  p -= 1
  if not answered[p]:
    if s == 'WA':
      will_wa[p] += 1
    else:
      answered[p] = True
      n_wa += will_wa[p]
      n_ac += 1

print(n_ac, n_wa)

Submission status: Accepted

Solution code:
# input
N, M = map(int, input().split())
P = [0]*M
S = [0]*M

for i in range(M):
    p, S[i] = input().split()
    P[i] = int(p)-1

# process
ac = [0]*N
wa = [0]*N

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

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

# output
print("{} {}".format(ac.count(1), wa_num))

Submission status: Accepted

Solution code:
def get_next_ints(delim=" "):
    return tuple([int(float(x)) for x in input().split(delim)])


def get_next_by_types(*value_types, delim=" "):
    return tuple(
        [t(x) for t, x in zip(value_types, input().rstrip("\n").split(delim))])


def main():
    n, m = get_next_ints()
    ac_count = 0
    wa_count = 0

    from collections import defaultdict
    ac_cache = defaultdict(int)
    wa_cache = defaultdict(int)
    ac_count = 0
    wa_count = 0
    wa = 0
    for i in range(m):

        p, result = get_next_by_types(int, str)

        if ac_cache[p] == 0:
            if result == 'AC':

                ac_cache[p] = 1
                ac_count += 1
                wa_count += wa_cache[p]
                wa = 0
            else:
                wa_cache[p] += 1
    print(ac_count, wa_count)


if __name__ == '__main__':
    main()
if __name__ == '__jupyter__':
    import doctest
    print(doctest.testmod())

Submission status: Accepted

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

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

exactly = 0
penarty = 0
scores = {}

for i in range(M):
    p,s = input().split()
    p = int(p) - 1

    if scores.get(p) is None:
        scores[p] = {"AC":0, "WA":0}
    elif scores[p]["AC"] > 0:
        continue

    if s == "AC":
        scores[p]["AC"] = 1
        exactly += 1
        penarty += scores[p]["WA"]

    elif s == "WA":
        scores[p]["WA"] += 1

print("{0} {1}".format(exactly, penarty))

Submission status: Accepted

Solution code:
num_of_probs, num_of_submission = [ int(i) for i in input().split(" ") ]

solution_table = {}

for i in range(0, num_of_submission):
  prob, result = [ i for i in input().split(" ") ]

  if solution_table.get(int(prob)) == None:
    solution_table[int(prob)] = {"WA": 0, "AC": 0}

  if result == "WA":
    if solution_table[int(prob)]["AC"] == 0:
      solution_table[int(prob)]["WA"] += 1
  else:
    if solution_table[int(prob)]["AC"] == 0:
      solution_table[int(prob)]["AC"] += 1

total_ac = 0
total_wa = 0
for value in solution_table.values():
  if value['AC'] > 0:
    total_wa += value['WA']
    total_ac += value['AC']

print( total_ac, total_wa )

Submission status: Accepted

Solution code:
def wczytaj_liste(): 
    wczytana_lista = input()
    lista_znakow = wczytana_lista.split()
    ostateczna_lista = []
    for element in lista_znakow:
        ostateczna_lista.append(int(element))
    return ostateczna_lista 

def atcoder(): 
    N, M = wczytaj_liste()
    odpowiedzi_string = []
    for i in range(M): 
        odpowiedzi_string.append(input())
    odpowiedzi_lista = []
    for string in odpowiedzi_string: 
        zadanie, wynik = string.split()
        nr_zadania = int(zadanie)
        odpowiedzi_lista.append((nr_zadania, wynik))
    rozwiazane_zadania = set()
    zle_rozwiazania = {}
    for i in range(N+1): 
        zle_rozwiazania[i] = 0
    for nr_zadania, wynik in odpowiedzi_lista:
        if nr_zadania not in rozwiazane_zadania: 
            if wynik == 'WA':
                zle_rozwiazania[nr_zadania] += 1
            else: 
                rozwiazane_zadania.add(nr_zadania)
    kary = 0 
    poprawne = len(rozwiazane_zadania)
    for nr_zadania in rozwiazane_zadania: 
        kary += zle_rozwiazania[nr_zadania]
    print(poprawne, kary)

atcoder()

Submission status: Accepted

Solution code:
def solve(n, m, PS):
    d = {}
    scores = [0, 0]
    for p, s in PS:
        if p not in d:
            d[p] = {'wa': 0, 'ac': 0}
        if d[p]['ac'] > 0:
            continue
        if s == 'AC':
            d[p]['ac'] = 1
            scores[0] += 1
            scores[1] += d[p]['wa']
        if s == 'WA':
            d[p]['wa'] += 1
    return scores

_n, _m = map(int, input().split())
_PS = [input().split() for _ in range(_m)]
_scores = solve(_n, _m, _PS)
print(_scores[0], _scores[1])

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

N, M = map(int, input().split())
l = [[0] * 2 for i in range(N)] # [ペナルティ数, 過去に正解したかどうか, ]
ok = 0
ng = 0

for i in range(M):
    p, s = input().split()
    p = int(p)-1
    if s == 'WA':
        l[p][0] += 1
    elif l[p][1] == 0:
        l[p][1] += 1
        ok += 1
        ng += l[p][0]
        
print('{} {}'.format(ok, ng))

Submission status: Accepted

Solution code:
'''C - Welcome to AtCoder
高橋君は AtCoder のコンテストに参加しています。

このコンテストでは、 N 問の問題が出題されます。
高橋君はコンテスト中に M回の提出を行いました。

i 回目の提出は pi番目の問題への提出であり、結果は Si (AC または WA) でした。
高橋君の正答数は、AC を 1回以上出した問題の数です。
高橋君のペナルティ数は、高橋君が AC を 1 回以上出した各問題において、初めて AC を出すまでに出した WA の数の総和です。
高橋君の正答数とペナルティ数を答えてください。

入力
入力は以下の形式で標準入力から与えられる。

N M
p1 S1
:
pM SM

2 5
1 WA
1 AC
2 WA
2 AC
2 WA
>
2 2

100000 3
7777 AC
7777 AC
7777 AC
>
1 0

6 0
>
0 0
'''
import numpy as np

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

AC = np.array([0]*N) # 正解を入れる箱
WA = np.array([0]*N) # 不正解を入れる箱

for _ in range(M):
    p, S = input().split()
    
    if AC[int(p)-1] ==0 and S == "WA": # まだ「正解が出てない & 不正解」
        WA[int(p)-1] += 1              # なら不正解の箱に＋１
    else:
        AC[int(p)-1] = 1               # それ以外は正解の箱に１
    
print(sum(AC), sum(WA*AC)) # ただし不正解の箱は最後まで正解が出なかった問題はペナルティ無しにする必要があるので、正解の箱の中身と掛け合わせて消しておく。

Submission status: Accepted

Solution code:
import numpy as np
 
N,M = map(int,input().split()) 
 
AC = np.array([0]*N)
WA = np.array([0]*N)
 
for i in range(M):
    p,S = input().split()
    
    if AC[int(p)-1] ==0 and S == "WA":
       WA[int(p)-1] += 1
    else:
        AC[int(p)-1] = 1

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

Submission status: Accepted

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

wa_counter = [ 0 for i in range(N)]
ac_flag = [ 0 for i in range(N)]
penalty_sum = 0

for i in range(M):
  P, outcome = map(str, input().split())
  P = int(P) -1
  if ac_flag[P] == 0 and outcome == "AC":
    ac_flag[P] = 1
    penalty_sum += wa_counter[P]
  elif ac_flag[P] == 0 and outcome == "WA":
    wa_counter[P] += 1
  else:
    pass

print(sum(ac_flag), penalty_sum)

Submission status: Accepted

Solution code:
def run():
  N, M = map(int, input().split())
  s_li = [0]*(N+1)
  e_li = [0]*(N+1)
  for m in range(M):
    p, s = input().split()
    p = int(p)
    if s == 'WA':
      if s_li[p] == 0:
        e_li[p] += 1
    else:
      s_li[p] = 1
  print(sum(s_li), sum([s*e for s, e in zip(s_li, e_li)]))

if __name__ == '__main__':
  run()

Submission status: Accepted

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

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

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

penalty = 0
AC_count = 0
for i in range(N):
    penalty += li[i][0]*li[i][1]
    AC_count += li[i][1]

print(AC_count,penalty)

Submission status: Accepted

Solution code:
import numpy as np
n, m = map(int, input().split())
result = [[0, 0] for _ in range(n)]

for i in range(m):
    a, b = input().split()
    a = int(a) - 1

    if b == "AC":
        result[a][0] = 1
    elif not result[a][0]:
        result[a][1] += 1
print(np.sum(result, axis=0)[0], np.prod(result, axis=-1).sum())

Submission status: Accepted

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

accurate = [0] * n
correct = 0
wrong = [0] * n
penalty = 0

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

print('{} {}'.format(correct,penalty))

Submission status: Accepted

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

Submission status: Accepted

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

ac_tf = [0] * n
wa_num = [0] * n

for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    if s == "AC":
        if ac_tf[p] == 0:
            ac += 1
            wa += wa_num[p]
            ac_tf[p] = 1
    else:
        wa_num[p] += 1
            
print(ac, wa)

Submission status: Accepted

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

er_c = 0
ac_c = 0

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

flag = [0]*N

for i in reversed(range(M)):
    if ps[i][1] == 'AC':
        flag[int(ps[i][0])-1] = 1

for i in range(M):
    if flag[int(ps[i][0])-1] == 1:
        if i == 0:
            if ps[i][1] == 'WA':
                er_c += 1
            else:
                ac_c += 1
                flag[int(ps[i][0])-1] = -1
        elif ps[i][1] == 'WA':
            er_c += 1
        elif ps[i][1] == 'AC':
                ac_c += 1
                flag[int(ps[i][0])-1] = -1

print(ac_c, er_c)

Submission status: Accepted

Solution code:
import sys
import numpy as np
sys.setrecursionlimit(100000000)
from collections import defaultdict
import collections
d = defaultdict(int)
d_TF = defaultdict(bool)

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

    if ps[i][1] == 'AC':
        d_TF[ps[i][0]] = True

    if d_TF[ps[i][0]] == False and ps[i][1] == 'WA':
        d[ps[i][0]] += 1



#print(d)

ansAC = 0
ansWA = 0
for key in d_TF:
    if d_TF[key] == True:
        ansAC += 1
        ansWA += d[key]

print(ansAC,ansWA)

Submission status: Accepted

Solution code:
from sys import stdin
# stdin = open("testdata.txt", "r")

def input():
	return stdin.readline().strip()

from collections import defaultdict

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

penalties = defaultdict(int)
p_count = 0

answered = dict()

for _ in range(m):
	q, ans = input().split()
	if int(q) not in answered:
		if ans=='AC':
			p_count += penalties[int(q)]
			answered[int(q)] = 1
		else:
			penalties[int(q)] += 1
print(len(answered), p_count)

Submission status: Accepted

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

ans = [0]*N
wc_c = [0]*N
pena = 0

for i in range(M):
    p, s = input().split(" ")
    p = int(p) - 1
    s = str(s)
    
    if s == "AC" and ans[p] == 0:
        ans[p] = 1
        pena += wc_c[p]
        
    elif s == "WA" and ans[p] == 0:
        wc_c[p] += 1
        
print(sum(ans), pena)

Submission status: Accepted

Solution code:
N,M = map(int, input().split())
P_S = [input().split() for _ in range(M)]
ac = [0]*(N)
wa = [0]*(N)
for i in range(M):
    no = int(P_S[i][0])
    result = P_S[i][1]
    if ac[no-1] ==0 and result == "AC":
        ac[no-1] =1    
    elif ac[no-1] ==0 and result =="WA":
        wa[no-1] += 1
for i in range(N):
    if ac[i] != 1:
        wa[i] = 0
print(sum(ac),sum(wa))

Submission status: Accepted

Solution code:


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


p = []
s = []
ans = [0]*N
c_wa = [0]*N
pena = 0

for i in range(M):
    temp1, temp2 = input().strip().split(" ")
    p.append(int(temp1))
    s.append(str(temp2))
  

for j in range(M):
    
    if s[j] == "WA":
        if ans[p[j]-1] == 0:
            c_wa[p[j]-1] += 1
        elif ans[p[j]-1] == 1:
            pass
        
                
            
    elif s[j] == "AC":
        if ans[p[j]-1] == 0:
            ans[p[j]-1] += 1
        elif ans[p[j]-1] == 1:
            pass
        
for k in range(N):
    if ans[k] == 1:
        pena += c_wa[k]
    

            
print(sum(ans), pena)

Submission status: Accepted

Solution code:
# history :: {int : (int, bool)}
n, m = [int(x) for x in input().split()]
history = { i+1 : [0, False] for i in range(n)}

for _ in range(m):
  pi, result = input().split()
  translated_pi = int(pi)
  if result == 'WA' and not history[translated_pi][1]:
    history[translated_pi][0] += 1
  else:
    history[translated_pi][1] = True

ac_count = 0
penalty_count = 0
for result in history.values():
  if result[1]:
    ac_count += 1
    penalty_count += result[0]

print("{} {}".format(ac_count, penalty_count))