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())
p=[]
s=[]
for i in range(M):
  p0,S0=map(str,input().split())
  p0=int(p0)-1
  p+=[p0]
  s+=[S0]
awlist=[0 for i in range(N)]
walist=[0 for i in range(N)]
wacount=0
account=0
for i in range(M):
  if s[i]=='WA' and awlist[p[i]]==0:
    walist[p[i]]+=1
  elif s[i]=='AC' and awlist[p[i]]==0:
    account+=1
    awlist[p[i]]=1
    wacount+=walist[p[i]]
Answer=[account,wacount]
print(*Answer)

Submission status: Accepted

Solution code:
n, m = list(map(int, input().split()))
ac = [0]*n
wa = [0]*n
for i in range(m):
    pi, si = input().split()
    if si == 'AC':
        ac[int(pi)-1] += 1
    elif ac[int(pi)-1] == 0:
        wa[int(pi)-1] += 1

nac = 0
nwa = 0

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

print(nac, nwa)

Submission status: Accepted

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

p_list = [0]*N
cor_list = [0]*N 

cor_ans = 0
pen_ans = 0

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


print(cor_ans,pen_ans)

Submission status: Accepted

Solution code:
# coding: utf-8


def solve(*args: str) -> str:
    n, m = map(int, args[0].split())
    AC = [False]*n
    WA = [0]*n
    for p, s in map(str.split, args[1:]):
        i = int(p)-1
        if s == 'AC':
            AC[i] |= True
        elif s == 'WA' and not AC[i]:
            WA[i] += 1

    penalty = 0
    for i, ac in enumerate(AC):
        if ac:
            penalty += WA[i]

    return '{} {}'.format(sum(AC), penalty)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))

Submission status: Accepted

Solution code:
n,m = list(map(int,input().split()))
lis = [[] for _ in range(n)]
for i in range(m):
    pc,s = input().split()
    p = int(pc)
    if s=='AC':lis[p-1].append(1)
    else:      lis[p-1].append(0)

a=w=0
for i in range(n):
    tempwa=0
    for j in lis[i]:
        if j==0:tempwa+=1
        elif j==1:
            a+=1
            w += tempwa
            break
print(a,w)

Submission status: Accepted

Solution code:
# coding:utf-8

N, M = map(int, input().split(' '))
ac_stk = [0 for _ in range(N)]
wa_stk = [[True, 0] for _ in range(N)]
pair = []
for _ in range(M):
    p, s = input().split(' ')
    pair.append((int(p), s))
ac = 0
wa = 0

for p, s in pair:
    if s == 'WA':
        wa_stk[p-1][1] += 1
    elif s == 'AC':
        ac_stk[p-1] = 1
        if wa_stk[p-1][0]:
            wa += wa_stk[p-1][1]
            wa_stk[p-1][0] = False

print('{} {}'.format(sum(ac_stk), wa))

Submission status: Accepted

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

problems = [0]*n
accurate = 0
penalty = 0

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

    if s == "AC" and problems[p-1] != -1:
         #初めて正解
         penalty += problems[p-1]
         accurate += 1
         problems[p-1] = -1
    elif s == "WA" and problems[p-1] != -1:
        #正解してない問題を不正解
        problems[p-1] += 1

print(accurate,penalty)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**6)
# input = sys.stdin.readline
ii = lambda: int(input())
mis = lambda: map(int,input().split())
lmis = lambda: list(mis())
INF = float('inf')

def main():
    n,m=mis()
    lis=[0]*(n+1)
    ww=[0]*(n+1)
    wa=0
    for _ in range(m):
        P,s=input().split()
        p=int(P)
        if lis[p]==0:
            if s=='WA': ww[p]+=1
            else:
                lis[p]+=1
                wa+=ww[p]
    print(sum(lis),wa)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N, M = list(map(int, input().split()))
NList = [0] * N
ACSum = 0
WASum = 0
for i in range(M):
  p, s = input().split()
  p = int(p)
  if s == 'WA' and NList[p-1] != -1:
    NList[p-1] += 1
  elif s == 'AC' and NList[p-1] != -1:
    ACSum += 1
    WASum += NList[p-1]
    NList[p-1] = -1
    
print(str(ACSum) + ' ' + str(WASum))

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
ans = {}
for i in range(M):
    p, s = list(input().split())
    int(p)
    if p not in ans:
        ans[p] = {"AC": False, "WA": 0}
    if s == "AC":
        ans[p]["AC"] = True
        continue
    if s == "WA":
        if ans[p]["AC"] == True:
            continue
        ans[p]["WA"] += 1
ac = 0
wa = 0
for k, v in ans.items():
    if v["AC"]:
        ac += 1
        wa += v["WA"]
print(ac, wa)

Submission status: Accepted

Solution code:
N, M = [int(i) for i in input().split()]
pSlist = []
for i in range(M):
    buff = input().split()
    p = int(buff[0])-1
    S = str(buff[1])
    pSlist.append([p,S])

AClist = [0 for i in range(N)]
WAlist = [0 for i in range(N)]
AClist_dummy = [0 for i in range(N)]

for p,S in pSlist:
    if AClist[p]==0 and S=="AC":
        AClist[p]=1
    elif AClist[p]==0 and S=="WA":
        WAlist[p]+=1

sumWA = 0
for p in range(N):
    if AClist[p]==1:
        sumWA+=WAlist[p]

print(sum(AClist),sumWA)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
p=[[] for i in range(m)]
s=[[] for i in range(m)]
k=[True for i in range(n)]
ac=0
wa=[0 for i in range(n)]

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

p=list(map(int,p))

for i in range(m):
    if k[p[i]-1]:
        if s[i]=="AC":
            k[p[i]-1]=False
            ac+=1
        else:
            wa[p[i]-1]+=1

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

print(ac,sum(wa))

Submission status: Accepted

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

num = [0]*N
TorF = [False] * N

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

maru = 0
pena = 0

for i in range(N):
    if TorF[i]:
        maru += 1
        pena += num[i]

print(maru, pena)

Submission status: Accepted

Solution code:
n, m = map(int, (input().split()))
got = set()
watbl = [0]*n

ans = 0

for i in range(m):
    p, s = input().split()
    p = int(p)
    if p in got:
        continue
    else:
        if s == 'AC':
            got.add(p)
            ans += 1
        else:
            watbl[p - 1] += 1

pn = 0
for v in got:
    pn += watbl[v - 1]
print(ans, pn)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections


def solve(n, m, hist):
    cor = 0
    pen = 0
    for p, tries in hist.items():
        for i, t in enumerate(tries):
            if t == 'AC':
                cor += 1
                pen += i
                break
    return '{0} {1}'.format(cor, pen)


def input_to_int():
    return [int(r) for r in input().split(' ')]


if __name__ == "__main__":
    n, m = input_to_int()
    hist = collections.defaultdict(list)
    for _ in range(m):
        p, s = input().split(' ')
        hist[p].append(s)
    print(solve(n, m, hist))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
ps=[]
x=[[0,0] for i in range(n)]
#0がWA、1がAC
for i in range(m):
    p,s=input().split()
    p=int(p)-1
    ps.append([p,s])

for i in range(m):
    p,s=ps[i]
    if s=="WA":
        if x[p][0]==0:
            x[p][1]+=1
        else:
            pass
    else:
        if x[p][0]==0:
            x[p][0]=1
            #x[p][1]+=1
        else:
            pass
c1,c2=0,0
for i in range(n):
    if x[i][0]==1:
        c1+=1
        c2+=x[i][1]
print(c1,end=" ")
print(c2)

Submission status: Accepted

Solution code:
import numpy as np
N, M = map(int,input().split())
ansAC = 0
ansWA = 0
zeros = np.zeros(N)
is_solved = set()
for _ in range(M):
    p, S = input().split()
    p = int(p)
    if S == "WA":
        if p-1 not in is_solved:
            zeros[p-1] += 1
    else:
        is_solved.add(p-1)
ansAC = len(is_solved)
ansWA = int(sum(zeros[list(is_solved)]))
print(ansAC, ansWA)

Submission status: Accepted

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

ng = [0]*n
ok = [0]*n
for i in range(m):
  if ok[p[i]-1] == 0 and s[i] =='AC':
    ok[p[i]-1] += 1
  elif ok[p[i]-1] == 0 and s[i] =='WA':
    ng[p[i]-1] += 1
result = [x * y for (x, y) in zip(ok, ng)]
print(str(sum(ok)) + ' ' + str(sum(result)))

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
P = [0] * M
S = [""] * M
for i in range(M):
    p, s = input().split()
    P[i] = int(p)
    S[i] = s
ACP = [[0,0] for _ in range(N)]
for i in range(M):
    if ACP[P[i]-1][1] == 1:
        pass
    elif S[i] == "WA":
        ACP[P[i]-1][0] += 1
    else:
        ACP[P[i]-1][1] = 1
ac = 0
pena = 0
for i in range(N):
    ac += ACP[i][1]
    pena += ACP[i][0] * ACP[i][1]
print(ac, pena)

Submission status: Accepted

Solution code:
n, m = list(map(int,input().split()))
a = [0]*1000000
ac = 0
pen = 0
for i in range(m):
    p,s = input().split()
    p = int(p)
    if s == "AC":
        if a[p] == "AC":
            pass
        else:
            ac += 1
            pen += a[p]
            a[p] = "AC"
    else:
        if a[p] == "AC":
            pass
        else:
            a[p] += 1
print(ac,pen)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
ACflags = [False] * N
WAcounts = [0] * N
for _ in range(M):
    p, s = input().split()
    p = int(p) - 1
    if ACflags[p]:
        continue
    if s == 'AC':
        ACflags[p] = True
    else:
        WAcounts[p] += 1

ansAC = 0
ansWA = 0
for i in range(N):
    if ACflags[i]:
        ansAC += 1
        ansWA += WAcounts[i]
print(ansAC, ansWA)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import queue
import copy
import math

# 2つの入力を空白で分割し、数値化
N, M = map(int, input().split())

ac = set()
submits_count_until_AC = {} #

for i in range(0, M):
    p, S = input().split()

    prev = None

    if p in ac:
        continue

    if p in submits_count_until_AC:
        prev = submits_count_until_AC[p]
    else:
        prev = 0

    if S == "AC":
        ac.add(p)
    else:
        submits_count_until_AC[p] = prev + 1


ac_coount = len(ac)

pena = 0

for k, v in submits_count_until_AC.items():
    if k in ac:
        pena += v

print("{} {}".format(ac_coount, pena))

Submission status: Accepted

Solution code:
import numpy as np
N, M = map(int, input().split(' '))
suc_list = np.zeros(N, dtype=np.uint8)
fai_count = np.zeros(N, dtype=np.int32)
for i in range(M):
    p, s = input().split(' ')
    p = int(p) - 1
    if suc_list[p] == 0:
        if s == 'WA':
            fai_count[p] += 1
        else:
            suc_list[p] = 1

print('{} {}'.format(np.sum(suc_list), np.sum(fai_count[suc_list == 1])))

Submission status: Accepted

Solution code:
def A():
    c = input()
    print(chr(ord(c)+1))

def B():
    temp = [int(k) for k in input().split()]
    N = temp[0]
    K = temp[1]
    M = temp[2]
    A = [int(k) for k in input().split()]
    ans = M*N - sum(A)
    if ans <= K:
        print(max(0, ans))
    else:
        print(-1)

from collections import defaultdict
def C():
    temp = [int(k) for k in input().split()]
    N = temp[0]
    M = temp[1]
    penal = defaultdict(int)
    P = []
    S = []
    for i in range(M):
        temp = input().split()
        P.append(int(temp[0]))
        S.append(temp[1])
    ac_problems = set()

    for i in range(M-1, -1, -1):
        if P[i] not in ac_problems and S[i] == 'AC':
            ac_problems.add(P[i])
        elif P[i] in ac_problems:
            if S[i] == 'WA':
                penal[P[i]] += 1
            elif S[i] == 'AC':
                penal[P[i]] = 0
    
    print(len(ac_problems), sum(penal.values()))
C()

Submission status: Accepted

Solution code:
import sys
from collections import defaultdict
input = sys.stdin.readline

def main():
    n, m = map(int, input().split())
    ac = 0
    wa = 0
    b = defaultdict(lambda: 0)
    for _ in range(m):
        q, j = input().split()
        if b[q] != -1 and j == 'AC':
            ac += 1
            if q in b:
                wa += b[q]
                b[q] = -1
        else:
            if b[q] != -1:
                b[q] += 1
    print(ac, wa)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def main():
    n, m = list(map(int, input().split()))
    ac_list = [0] * n
    wa_list = [0] * n
    for _ in range(m):
        tmp = input().split()
        contest_num = int(tmp[0]) - 1
        if ac_list[contest_num]:
            continue
        ret = tmp[1]
        if ret == "AC":
            ac_list[contest_num] = 1
        else:
            wa_list[contest_num] += 1

    penalty = [wa_list[i] if ac_list[i] else 0 for i in range(n)]

    print(sum(ac_list), sum(penalty))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

    if p in my_dict:
        my_dict[p].append(s)
    else:
        my_dict[p] = [s]

a_count = 0
w_count = 0

for key, items in my_dict.items():
    flag = False
    buf = 0
    for s in items:
        if s == "AC":
            a_count += 1
            flag = True
            break
        else:
            w_count += 1
            buf += 1
    if not flag:
        w_count -= buf

print(a_count, w_count)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
l=[]
ansac=0
answa=0
a=[0]*(n)
d=dict()
for i in range(m):
  p,s=input().split()
  l.append([int(p),s])
for i in range(m):
  if l[i][1]=='AC':
    if l[i][0] not in d:
      ansac+=1
      answa+=a[l[i][0]-1]
      d[l[i][0]]=0
  else:
    a[l[i][0]-1]+=1
print(ansac,answa)

Submission status: Accepted

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

Submission status: Accepted

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


def main():
    n, m = map(int, input().split())
    ac_count = [0 for _ in range(n)]
    wa_count = [0 for _ in range(n)]

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

        if si == 'WA':
            if ac_count[pi] == 0:
                wa_count[pi] += 1
        else:
            if ac_count[pi] == 0:
                ac_count[pi] = 1

    total_ac = sum(ac_count)
    total_wa = 0

    for ac, wa in zip(ac_count, wa_count):
        if ac == 1:
            total_wa += wa

    print(total_ac, total_wa)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from copy import deepcopy

if __name__ == '__main__':
    a,b  = map(int, input().split())
    count = [0]*a
    count2 = [-1]*a

    ans1 = 0
    ans2 =0
    for i in range(b):
        s = input()
        s = s.split(" ",)
        s1 = int(s[0])-1
        s2 = s[1]
        if count[s1]  >-1:
            if s2 == "AC":
                count2[s1] = deepcopy(count[s1])
                count[s1] = -1
            else:
                count[s1] = count[s1] +1

    for i in count2:
        if i > -1:
            ans1 = ans1+1
            ans2 = ans2 + i
    print(str(ans1) + " "+str(ans2) )

Submission status: Accepted

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

x = [0] * N
result = [0] * N

ans = 0
wa = 0

for i in range(M):
    p, S = input().split()
    if (result[int(p) - 1] == 0) and (S == "WA"):
        x[int(p)-1] += 1
    if (result[int(p) - 1] == 0) and (S == "AC"):
        result[int(p)-1] = 1

ans = sum(result)

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

print(ans, wa)

Submission status: Accepted

Solution code:
n,m = map(int, input().split())
p = [0]*n
q = [False]*n
for _ in range(m):
  v,s = input().split()
  v = int(v)-1
  if q[v]: continue
  if s == 'AC': q[v] = True
  else: p[v] += 1
print(sum(q),sum(p[i] for i in range(n) if q[i]))

Submission status: Accepted

Solution code:
import sys
from pprint import pprint

def solve(n, m, p, s):
    wrong = [0] * n
    solved = {}
    for i in range(n):
        solved[i] = False

    n_ac = 0
    n_wa = 0
    for i in range(m):
        if not solved[p[i]-1] and s[i] == "WA":
            wrong[p[i]-1] += 1
        if not solved[p[i]-1] and s[i] == "AC":
            n_ac += 1
            solved[p[i]-1] = True
            n_wa += wrong[p[i]-1]
    print(n_ac, n_wa)


if __name__ == '__main__':
    n, m = map(int,sys.stdin.readline().strip().split(" "))
    p = [0] * m
    s = [""] * m
    for i in range(m):
        p_i, s[i]  = sys.stdin.readline().strip().split(" ")
        p[i] = int(p_i)
    
    solve(n, m, p, s)

Submission status: Accepted

Solution code:
N ,M = map(int, input().split())
li = []
num = [0] * (N + 1)
for i in range(M):
    li.append(list(input().split()))
countAC = 0
countWA = 0
for i in range(M):
    if num[int(li[i][0])] != -1:
        if li[i][1] == "AC":
            countAC += 1
            countWA +=num[int(li[i][0])]
            num[int(li[i][0])] = -1
        else:
            num[int(li[i][0])] += 1

print(countAC, countWA)

Submission status: Accepted

Solution code:
from collections import defaultdict

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

submit = defaultdict(list)
for i in range(M):
    p,s = map(str, input().split())
    submit[p].append(s)


wa = 0
ac = 0
for k in submit.keys():
    if "AC" in submit[k]:
        for i in range(len(submit[k])):
            if submit[k][i] == "WA":
                wa += 1
            elif submit[k][i] == "AC":
                ac += 1
                break
        


print(ac, wa)

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
AC = [False]*N
WA = [0]*N
for m in range(M):
    p,s = map(str,input().split())
    p = int(p)
    if AC[p-1] == False and s == 'WA':
        WA[p-1] += 1
    elif AC[p-1] == False and s == 'AC':
        AC[p-1] = True
indexes = [i for i, x in enumerate(AC) if x == False]
for i in indexes:
    WA[i] = 0
print(AC.count(True),sum(WA))

Submission status: Accepted

Solution code:
n, m = [int(el) for el in input().split(' ')]
df = []
for i in range(m):
	df.append(input().split(' '))

record = []
for i in range(n):
	record.append([0,0])

for i in range(m):
	x = df[i][1]
	q = int(df[i][0])
	if record[q-1][0] == 1:
		pass
	else:
		if x == "AC":
			record[q-1][0] = 1
		else:
			record[q-1][1] += 1

ans = 0
for i in range(n):
	ans += record[i][0]


pen = 0
for i in range(n):
	if record[i][0] > 0:
		pen += record[i][1]

print(ans, pen)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
A={}
for i in range(m):
    num,result=input().split()
    if num not in A:
        A[num]=[result]
    else:
        A[num] +=[result]

ans,cnt=0,0
for v,m in A.items():
    if "AC" not in m:continue
    for i in m:
        if i=="AC":
            ans +=1
            break
        if i=="WA":
            cnt +=1

print(ans,cnt)

Submission status: Accepted

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

check = {}
error = {}

ans_ac = 0
ans_wa = 0

for i in range(m):
    p,s = map(str, input().split())
    p = int(p)
    if p in check:
        pass
    else:
        if s == "WA":
            if p in error:
                error[p] += 1
            else:
                error[p] = 1
        else:
            if p in check:
                check[p] += 1
            else:
                check[p] = 1
            if p in error:
                ans_wa += error[p]
            ans_ac += 1
print(str(ans_ac) + " " + str(ans_wa) )

Submission status: Accepted

Solution code:
def solve():
    from sys import stdin
    f_i = stdin
    
    N, M = map(int, f_i.readline().split())
    
    cleared = dict(zip(range(N), [False] * N))
    penalty = dict(zip(range(N), [0] * N))
    
    for i in range(M):
        p, S = f_i.readline().split()
        p = int(p) - 1
        if S == 'AC':
            cleared[p] = True
        elif not cleared[p]:
            penalty[p] += 1
    
    clear_count = list(cleared.values()).count(True)
    
    penalty_count = 0
    for k, v in penalty.items():
        if cleared[k]:
            penalty_count += v
    
    print(clear_count, penalty_count)

solve()

Submission status: Accepted

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

n, m = map(int, input().split())
pS = [input().split()[:2] for _ in range(m)]

AC = [0]*n
WA = [0]*n

for p, S in pS:
    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 WA[i] > 0 and AC[i] == 0:
        WA[i] = 0
print(sum(AC), sum(WA))

Submission status: Accepted

Solution code:
nm = input().split(' ');
n = int(nm[0]);
m = int(nm[1]);
flag = [0]*(n+1);
count_wa = [0]*(n+1);

for i in range(m) :
	ps = input().rstrip('\n');
	ps = ps.split(' ');
	p = int(ps[0]);
	s = ps[1];
	if flag[p] == 0 and s == 'AC' :
		flag[p] = 1;
	elif flag[p] == 0 and s == 'WA' :
		count_wa[p] += 1;

for i in range(n+1) :
	if flag[i] == 0 :
		count_wa[i] = 0;

print(sum(flag),sum(count_wa));

Submission status: Accepted

Solution code:
#C
n, m = list(map(int,input().split()))
a = [0]*(n+1)
w = [0]*(n+1)
wrong = 0
for _ in range(m):
    p, s = list(map(str,input().split()))
    p = int(p)
    if s == "WA":
        w[p] +=1
    if s == "AC":
        if a[p] == 0:
            a[p] = 1
            wrong += w[p]
print(sum(a),wrong)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
p = [0 for _ in range(m)]
s = ["" for _ in range(m)]
for i in range(m):
    pi, si = input().split()
    p[i] = int(pi)
    s[i] = si
ac = set()
acc = set()
wa = 0
for i in range(m):
    if s[i] == "AC" and p[i] not in ac:
        acc.add(p[i])
for i in range(m):
    if s[i] == "AC" and p[i] not in ac:
        ac.add(p[i])
    elif s[i] == "WA" and p[i] not in ac and p[i] in acc:
        wa += 1

print(len(ac), wa)

Submission status: Accepted

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

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

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

wa = [v*ac[i] for i,v in enumerate(wa)]
    
print(sum(ac), sum(wa))

Submission status: Accepted

Solution code:
def c_welcome_to_atcoder():
    N, M = [int(i) for i in input().split()]
    Results = []
    for _ in range(M):
        p, s = input().split()
        Results.append((int(p), s))

    count_wa = [0] * (N + 1)
    is_already_ac = [False] * (N + 1)

    for p, s in Results:
        if is_already_ac[p]:
            continue

        if s == 'AC':
            is_already_ac[p] = True
        elif s == 'WA':
            count_wa[p] += 1

    ans_ac = 0
    ans_wa = 0
    for ac, wa in zip(is_already_ac, count_wa):
        if ac:
            ans_ac += 1
            ans_wa += wa
    return '{} {}'.format(ans_ac, ans_wa)

print(c_welcome_to_atcoder())

Submission status: Accepted

Solution code:
# C
N, M = map(int, input().split())
lst = [list(input().split()) for i in range(M)]
ans = [[0,0] for i in range(N)]
for i in lst:
  if (i[1] == 'WA'):
    if (ans[int(i[0])-1][1] != 1):
      ans[int(i[0])-1][0] += 1
  else:
    if (ans[int(i[0])-1][1] == 0):
      ans[int(i[0])-1][1] += 1
ac = 0
wa = 0
for i in ans:
  if (i[1] == 1):
    ac += 1
    wa += i[0]
print(ac, wa)

Submission status: Accepted

Solution code:
import math
import fractions

n, m = map(int, input().split())
ac_list = [0 for _ in range(n)]
wa_list = [0 for _ in range(n)]
wa_cnt = 0
cnt = 1
while cnt <= m:
    p, s = input().split()
    p = int(p)
    if s == "AC":
        ac_list[p - 1] = 1
    else:
        if ac_list[p - 1] == 0:
            wa_list[p - 1] += 1
    cnt += 1
for i in range(n):
    if wa_list[i] >= 1 and ac_list[i] == 1:
        wa_cnt += wa_list[i]
print(sum(ac_list), wa_cnt)

Submission status: Accepted

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

Submission status: Accepted

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

corrects = [0] * n
wrongs = [0] * n

for i in range(m):
  p, cw = input().split()
  num = int(p) - 1
  if cw == "AC" and corrects[num] == 0:
    corrects[num] += 1
  if cw == "WA" and corrects[num] == 0:
    wrongs[num] += 1

print(sum(corrects))

wrong_ans = 0
for i in range(n):
  if corrects[i] == 1:
    wrong_ans += wrongs[i]
    
print(wrong_ans)

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
p = [list(map(str,input().split())) for i in range(m)]
answa = [0] * (n+1)
ans = [False] * (n+1)

#print(p)
for i in range(m):
    #print(p[i][1])
    #print(ans[int(p[i][0])])
    #print(sum(ans),sum(answa))
    #print(ans)
    if p[i][1] == "WA" and ans[int(p[i][0])] == False:
        answa[int(p[i][0])] += 1
    elif p[i][1] == "AC":
        ans[int(p[i][0])] = True

tmp = 0
#print(ans)
for i in range(1,n+1):
    if ans[i]:
        tmp += answa[i]

print(sum(ans),tmp)

Submission status: Accepted

Solution code:
N,M=map(int, input().split())
results = [[0,0] for i in range(N)]
wa=0
ac=0
for i in range(M):
    P,S=map(str, input().split())
    P = int(P) - 1
    if S == 'AC':
        if results[P][0] == 0:
            wa += results[P][1]
            results[P][1] = 0
            ac += 1
            results[P][0] += 1
    else:
        results[P][1] += 1

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

Submission status: Accepted

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

dict = {}
for i in range(m):
    p,s=input().split()
    dict.setdefault(p,[]).append(s)

ac_count=0
wa_count=0
for p,s in dict.items():
    is_ac=False
    wa_tmp_count=0
    for ans in s:
        if ans=='AC':
            ac_count+=1
            is_ac=True
        else:
            wa_tmp_count+=1
        if is_ac:
            wa_count+=wa_tmp_count
            break
print(ac_count, wa_count)

Submission status: Accepted

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

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

for p, s in ps:
    p = int(p) - 1
    if ac[p] == 0:
        if s == "AC":
            ac[p] = 1
        else:
            wa[p] += 1

wa = [ac[i] * wa[i] for i in range(n)]
print(sum(ac),sum(wa))

Submission status: Accepted

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

ok=0
ac = [0]*n
penalty = [0]*n

for i in range(m):
    p,s = input().split()
    p=int(p)
    if s=="WA":
        if ac[p-1]==0:
            penalty[p-1]+=1
    elif s=="AC":
        if ac[p-1]==0:
            ok+=1
            ac[p-1]=1
ans=0
for i in range(n):
    if ac[i]==1:
        ans+=penalty[i]
print(ok,ans)

Submission status: Accepted

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

ansAC=0
ansP=0

n=[0]*N
AC=[0]*N

for i in range(M):
    p,s =map(str,input().split())
    p=int(p)-1
    if AC[p]==1:continue
    if s=="AC":
        ansP+=n[p]
        ansAC+=1
        AC[p]=1
    else:
        n[p]+=1

print(ansAC,ansP)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
a = [0] * n
ans_1 = 0
ans_2 = 0
for i in range(m):
    p, s = map(str, input().split())
    if a[int(p) - 1] >= 0:
        if s == "WA":
            a[int(p) - 1] += 1
            ans_2 += 1
        else:
            a[int(p) - 1] = -1
            ans_1 += 1
for i in range(n):
    if a[i] > 0:
        ans_2 -= a[i]
print(ans_1, ans_2)

Submission status: Accepted

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

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

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

    if cnt[p][0] > 0:
        continue

    if s == "AC":
        cnt[p][0] += 1
        res[0] += 1
        res[1] += cnt[p][1]
    elif s == "WA":
        cnt[p][1] += 1

print(res[0], res[1])

Submission status: Accepted

Solution code:
N, M = map(int,input().split())
ps = dict()
for m in range(M):
    a = input().split()
    if a[0] not in ps:
        ps[a[0]] = []
    ps[a[0]].append(a[1])
ans = [0, 0]
for x in ps:
    if "AC" in ps[x]:
        for y in ps[x]:
            if y == "WA":
                ans[1] += 1
            else:
                ans[0] += 1
                break
print(ans[0],ans[1])