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:
from collections import defaultdict

N ,M = list(map(int,input().split(" ")))
ac = 0
wa = 0
ac_probs = set()
wa_probs = set()
di =defaultdict(lambda :0)
for _ in range(M):
    p, s =  input().split(" ")
    if s == "AC":
        ac_probs.add(p)
    elif s == "WA":
        if p not in ac_probs:
            di[p] += 1

for temp in ac_probs:
    wa += di[temp]

print(len(ac_probs),wa)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**9)
input = lambda: sys.stdin.readline().rstrip()
inpl = lambda: list(map(int,input().split()))
N, M = inpl()
AC = [False]*N
WA = [0]*N
for i in range(M):
    p, S = input().split()
    p = int(p)
    if S == 'AC':
        AC[p-1] = True
    else:
        if not AC[p-1]:
            WA[p-1] += 1
ans = 0
acs = 0
pens = 0
for i in range(N):
    if AC[i]:
        acs += 1
        pens += WA[i]
print(acs, pens)

Submission status: Accepted

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

import sys
sys.setrecursionlimit(300000)


def solve(N: int, M: int, p: "List[int]", S: "List[str]"):
    a = 0
    w = 0
    ac = [0] * (N + 1)
    wa = [0] * (N + 1)
    for i in range(M):
        if S[i] == 'WA' and not ac[p[i]]:
            wa[p[i]] += 1
        if S[i] == 'AC' and not ac[p[i]]:
            ac[p[i]] = 1
            a += 1
            w += wa[p[i]]
    print(a, w)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    p = [int()] * (M)  # type: "List[int]"
    S = [str()] * (M)  # type: "List[str]"
    for i in range(M):
        p[i] = int(next(tokens))
        S[i] = next(tokens)
    solve(N, M, p, S)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
n, m = [int(i) for i in sys.stdin.readline().split()]
_set = set()
ac = 0
wa = 0
ls = []
for i in range(m):
    p, s = [i for i in sys.stdin.readline().split()]
    if s == "AC":
        _set.add(p)
    ls.append([p, s])

new_set = set()
for p, s in ls:
    if s == "AC":
        new_set.add(p)
    if s == "WA" and p in _set and p not in new_set:
        wa += 1
print(len(_set), wa)

Submission status: Accepted

Solution code:

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

flag = [True] * N
wa = [0] * N

for i in range(M):

    p,s = input().split()
    p = int(p)
    p -= 1

    if s == "WA":

        if flag[p]:
            wa[p] += 1

    if s == "AC":

        flag[p] = False

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



print (ac,wa2)

Submission status: Accepted

Solution code:
import sys
input=sys.stdin.readline
a=b=0
n,m=map(int,input().split())
ans=[0]*n
for i in range(m):
	p,s=input().rstrip().split()
	p=int(p)
	if ans[p-1]<=0:
		if s=="AC":
			a+=1
			b+=-ans[p-1]
			ans[p-1]=1
		else:
			ans[p-1]-=1
print(a,b)

Submission status: Accepted

Solution code:
import sys
def fastio():
    from io import StringIO
    from atexit import register
    global input
    sys.stdin = StringIO(sys.stdin.read())
    input = lambda : sys.stdin.readline().rstrip('\r\n')
    sys.stdout = StringIO()
    register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()

def debug(*var, sep = ' ', end = '\n'):
    print(*var, file=sys.stderr, end = end, sep = sep)

INF = 10**20
MOD = 10**9 + 7
I = lambda:list(map(int,input().split()))
# from math import gcd
from math import ceil
from collections import defaultdict as dd, Counter
from bisect import bisect_left as bl, bisect_right as br

n, m = I()

a = [0] * (n + 1)
b = [0] * (n + 1)

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

ans = 0
for i in range(n + 1):
    if b[i] == 1:
        ans += a[i]
print(sum(b), ans)

Submission status: Accepted

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

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

for p, s in ps:
    p = int(p)

    if ac[p]:
        continue

    if s == "WA":
        wa[p] += 1
    else:
        ac[p] = 1

ans = [0, 0]

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

print(*ans)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
f=[0]*n
ac=0
w=[0]*n
wa=0
for i in range(m):
    p,q=map(str,input().split())
    p=int(p)-1
    if f[p]==0:
        if q=='AC':
            f[p]=1
            ac+=1
            wa+=w[p]
        else:
            w[p]+=1
print(ac,wa)

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)
    if s=="AC":
        AC[p-1]=1
    else:
        if AC[p-1]==0:
            WA[p-1]+=1
ans_AC=sum(AC)
ans_WA=0
for i in range(n):
    if AC[i]==1:
        ans_WA+=WA[i]
print(ans_AC,ans_WA)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

acs = 0
total_p = 0
penalties = [0] * N
cleared = [False] * N
for _ in range(M):
	p, s = input().split()
	p = int(p) - 1
	if s == "AC":
		if not cleared[p]:
			cleared[p] = True
			total_p += penalties[p]
			acs += 1
	else:
		if not cleared[p]:
			penalties[p] += 1

print(acs, total_p)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
ps = [input().split() for _ in range(m)]
ac = [0]*n
pe = [0]*n
for p, s in ps:
  k = int(p) - 1
  if s == "AC":
    ac[k] = 1
  else:
    if ac[k]:
      continue
    else:
      pe[k] += 1
v, w = 0, 0
for i in range(n):
  if ac[i]:
    v += 1
    w += pe[i]
print(v, w)

Submission status: Accepted

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

num_penals = [0 for _ in range(n+1)]
seikai = 0
ayamari = 0
for _ in range(m):
    nn, res = input().split(" ")
    nn = int(nn)
    if num_penals[nn] is not None:
        if res == "AC":
            seikai += 1
            ayamari += num_penals[nn]
            num_penals[nn] = None
        else:
            num_penals[nn] += 1

out = "%d %d" % (seikai, ayamari)            
print(out)

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
ac=[False for i in range(N+1)] # 1-i
wa=[0 for i in range(N+1)]
for i in range(M):
    p,S=input().split()
    p=int(p)
    if not ac[p]:
        if S=='AC':
            ac[p]=True
        elif S=='WA':
            wa[p]+=1
ans_ac=sum(ac)
ans_p=sum([wa[i] for i in range(N+1) if ac[i]])

# print(ac)
# print(wa)

print(ans_ac,ans_p)

Submission status: Accepted

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

cntAC = 0
cntWA = 0

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

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

    if AC[p] == 0:
        if s == 'AC':
            cntAC += 1
            cntWA += WA[p]
            AC[p] += 1
        else:
            WA[p] += 1

print(cntAC, cntWA, sep=' ')

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
#A = list(map(int,input().split()))
ps = []
ans = [False for i in range(N)]
count = [0 for i in range(N)]
for i in range(M):
    p,s = list(input().split())
    p = int(p)
    if s == 'AC':
        ans[p-1] = True
    else:
        if not ans[p-1]:
            count[p-1] += 1
cans = 0
cac = ans.count(True)
for i in range(N):
    if ans[i]:
        cans += count[i]
print(cac,cans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
n, m = [int(x) for x in input().strip().split()]
ac = [0] * n
cnt = [0] * n
for i in range(m):
    p, s = [x for x in input().strip().split()]
    p = int(p)
    if ac[p-1]:
        continue
    if s == 'AC':
        ac[p-1] = 1
    elif s == 'WA':
        cnt[p-1] += 1

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

Submission status: Accepted

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


num = [0 for i in range(n)]
correct, penalty = 0, 0

for i in range(m):
    p, s = ps[i], ss[i]
    if num[p] == -1:
        continue

    num[p] += 1
    if s == 'AC':
        correct += 1
        penalty += (num[p] - 1)
        num[p] = -1

print(correct, penalty)

Submission status: Accepted

Solution code:
import sys, math

def input():
    return sys.stdin.readline()[:-1]

def main():
    N, M = map(int,input().split())
    A = [0 for k in range(N)]
    P = [0 for k in range(N)]
    b = 0
    for _ in range(M):
        p, S = input().split()
        if S == "AC":
            if A[int(p)-1] == 0:
                A[int(p)-1] = 1
                b += P[int(p)-1]
        else:
            if A[int(p)-1] == 0:
                P[int(p)-1] += 1
    print(sum(A),b)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
n, m = map(int, input().split())
di = set()
errc = [0] * (n+1)
res = 0
err = 0
for _ in range(m):
    p, s = sys.stdin.readline().split()
    p = int(p)
    if p in di:
        continue
    if s == 'AC':
        di.add(p)
        res += 1
        err += errc[p]
    else:
        errc[p] += 1
print(res, err)

Submission status: Accepted

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

check_AC = [False] * N
for i in range(M):
    p, s = map(str, input().split())
    p = int(p)
    if s == "AC":
        check_AC[p-1] = True
    P[i] = p
    S[i] = s

ans_AC = 0
ans_WA = 0
for i in range(M):
    if check_AC[P[i]-1]:
        if S[i] == "AC":
            ans_AC += 1
            check_AC[P[i] - 1] = False
        else:
            ans_WA += 1
    else:
        continue
print(ans_AC, ans_WA)

Submission status: Accepted

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

N, M = map(int, input().split())
P = [0]*(N+1)
Q = [0]*(N+1)

for _ in range(M):
    f, b = map(str, input().rstrip().split())
    a = int(f)
    if b == "WA":
        if not Q[a]:
            P[a] += 1
    else:
        Q[a] = 1

p = 0
for i in range(N+1):
    if Q[i]:
        p += P[i]
print(sum(Q), p)

Submission status: Accepted

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

N, M = map(int, input().split())
is_AC = [False]*N
pena = [0]*N

for _ in range(M):
    pi, si = input().split()
    pi = int(pi)
    
    if si=='AC':
        is_AC[pi-1] = True
    else:
        if is_AC[pi-1]:
            continue
        else:
            pena[pi-1] += 1

ans0 = is_AC.count(True)
ans1 = 0

for i in range(N):
    if is_AC[i]:
        ans1 += pena[i]

print(ans0, ans1)

Submission status: Accepted

Solution code:
#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]

    N,M = LMIIS()
    S = list()
    P = list()
    counts = [-1]*N
    for i in range(M):
        p,s = input().split()
        p = int(p)-1

        if s == 'AC' and counts[p] < 0:
            counts[p] *= -1
        else:
            if counts[p] < 0:
                counts[p] -= 1
    numac = 0
    nump = 0
    for c in counts:
        if c >= 0:
            numac += 1
            nump += c-1
    print(numac,nump)





if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding=utf-8

import collections
get = lambda: int(raw_input().strip())
gets = lambda: map(int, raw_input().strip().split())
getss = lambda x: [gets() for _ in xrange(x)]


N, M = gets()
count = collections.Counter()
penalty = 0
ac = set()
for i in xrange(M):
    p, s = raw_input().split()
    p = int(p)
    if p in ac: continue
    if s == 'AC':
        ac.add(p)
        penalty += count[p]
    else:
        count[p] += 1
print len(ac), penalty

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter
N, M = map(int, input().split())
acdict = {}
wacounter = Counter()

for m in range(M):
    p, s = input().split()
    if s == 'AC':
        acdict[p] = 1
    else:
        if acdict.get(p):
            continue
        wacounter[p] += 1
ans_ac = len(acdict)
ans_wa = sum([wacounter[key] for key in acdict.keys()])
print(ans_ac, ans_wa)

Submission status: Accepted

Solution code:
n, m = map(int,input().split())
alist=[0]*n
blist=[0]*n
pena=0
ok=0

for i in range(m):
    p, s =input().split()
    toi=int(p)-1
    if s=='AC':
        if alist[toi]!=1:
            alist[toi]=1
            pena+=blist[toi]
            ok+=1
    else:
        if alist[toi]!=1:
            blist[toi]+=1

print(ok, pena)

Submission status: Accepted

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

penalty = 0
nums = [0] * N
isACs = [False] * N
for _ in range(M):
    p, ss = input().split()
    p = int(p) - 1
    if ss == 'WA':
        nums[p] += 1
    else:
        if not isACs[p]:
            penalty += nums[p]
        isACs[p] = True

numAC = isACs.count(True)
print(numAC, penalty)

Submission status: Accepted

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

C=[0]*(N+1)
L=[0]*(N+1)
W=0

for x,y in S:
    if y=="AC":
        L[int(x)]=1

for x,y in S:
    x=int(x)
    if L[x]==0:
        continue

    if y=="AC":
        C[x]=1

    if C[x]==0 and y=="WA":
        W+=1

print(sum(L),W)

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
a = [list(input().split()) for i in range(m)]
ans = [0,0]
solved = [0]*(n+1)
penalty = [0]*(n+1)
for i in range(m):
  x = int(a[i][0])
  if a[i][1] == "AC":
    if solved[x] == 0:
      ans[1] += penalty[x]
    solved[x] = 1
  else:
    penalty[x] += 1
ans[0] = solved.count(1)
print(*ans)

Submission status: Accepted

Solution code:
from collections import defaultdict
d = defaultdict(list)
N,M = list(map(int,input().split()))
for i in range(M):
  p,S = input().split()
  p = int(p)
  d[p].append(S)
AC = 0
penalty = 0
for key,value in d.items():
  if "AC" in value:
    AC+=1
    penalty += value.index("AC")
print(AC,penalty)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
data = [0 for i in range(n)]
for i in range(m):
    p,s=input().split()
    p=int(p)-1
    if s=='WA':
        if data[p]<10000000:
            data[p]+=1
    else:
        if data[p]<10000000:
            data[p]+=10000000

wa=0
ac=0
for i in range(n):
    if data[i]>=10000000:
        ac+=1
        wa+=data[i]-10000000
print(ac,wa)

Submission status: Accepted

Solution code:
problems, submissions= map(int, input().split())
lst = [[0,False] for i in range(problems)]
solved = 0
pen  = 0
for z in range(submissions):
    prob, stat = input().split()
    prob = int(prob) - 1
    if lst[prob][1] == False:
        if stat == "AC":
            lst[prob][1] = True
            pen += lst[prob][0]
            solved += 1
        else:
            lst[prob][0] += 1
print(solved,pen)

Submission status: Accepted

Solution code:
def main():
    import sys
    N,M=list(map(int,sys.stdin.readline().split()))
    dic={}
    st=set()
    for i in range(M):
        p,S=sys.stdin.readline().split()
        p=int(p)
        if S=='AC':
            st.add(p)
            try:
                dic[p]+=0
            except:
                dic[p]=0
        else:
            if p not in st:
                try:
                    dic[p]+=1
                except:
                    dic[p]=1
    
    pena=sum([dic[x] for x in list(st)])
    ac=len(list(st))
    print(' '.join([str(ac),str(pena)]))

main()

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n,m = LI()
    p = [0]*n
    f = [0]*n
    for i in range(m):
        a,b = input().split()
        a = int(a)-1
        if b == "WA" and not f[a]:
            p[a] += 1
        if b == "AC":
            f[a] = 1
    p = [p[i]*f[i] for i in range(n)]
    print(sum(f),sum(p))
    return

#Solve
if __name__ == "__main__":
    solve()

Submission status: Accepted

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



def main():
    N, M = [int(x) for x in input().split()]
    ps = []
    ac = set()
    acnum = 0
    wanum = Counter()
    for _ in range(M):
        p, s = [x for x in input().split()]
        if s == "WA":
            if int(p) not in ac:
                wanum[int(p)] += 1
        if s == "AC":
            if int(p) not in ac:
                acnum += 1
                ac.add(int(p))
        #ps.append(int(p), s)

    wanum2 = 0
    for i in wanum.keys():
        if i in ac:
            wanum2 += wanum[i]

    print(acnum, wanum2)





if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    N, M = map( int, input().split())
    PS = [tuple( input().split()) for _ in range(M)]
    AC = [False]*(N+1)
    C = [0]*(N+1)
    for p, s in PS:
        p = int( p)
        if AC[p]:
            continue
        if s == "AC":
            AC[p] = True
        else:
            C[p] += 1
    ansac = 0
    anspena = 0
    for i in range(N+1):
        if AC[i]:
            ansac += 1
            anspena += C[i]
    print(ansac, anspena)
    
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
wa = [0 for i in range(100005)]
ac = [False for i in range(100005)]
for sa in range(m):
    p, v = input().split()
    p = int(p)
    if v == "WA":
        if ac[p] == False:
            wa[p] += 1
    else:
        ac[p] = True
w = 0
c = 0
for i in range(n+5):
    if ac[i]:
        w += wa[i]
        c += 1
print(c, w)

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
ac=[False]*N
wa=[0]*N
for i in range(M):
  p,s=input().split()
  p=int(p)-1
  if ac[p]:
    continue
  else:
    if s=="WA":
      wa[p]+=1
    if s=="AC":
      ac[p]=True
account=0
wacount=0
for i in range(len(ac)):
  account+=ac[i]
  if ac[i]:
    wacount+=wa[i]
    
print(account,wacount)

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
PS = []
AC_counter = [0 for i in range(N)]
WA_counter = [0 for i in range(N)]
for i in range(M):
    p,s = input().split()
    p = int(p)-1
    if s == 'AC':
        AC_counter[p] = 1
    else:
        if AC_counter[p] == 0:
            WA_counter[p] += 1
WA_ans = 0
for a,b in zip(AC_counter,WA_counter):
    if a > 0:
        WA_ans += b
print(sum(AC_counter),WA_ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n,m=map(int,input().split())
wa=0
data=[0]*(n+1)
AC=[0]*(n+1)
for i in range(m):
    p,s=input().split()
    p=int(p)
    if s=="WA":
        data[p]+=1
    else:
        AC[p]=1
        wa+=max(0,data[p])
        data[p]=-inf
# print(data)
print(sum(AC),wa)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    n,m=MI()
    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
    s=sum(wa[i] for i in range(n) if ac[i])
    print(sum(ac),s)

main()

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
li=[0]*(n+1)
cn=[0]*(n+1)
ac=wa=0
for _ in range(m):
  x,y=input().split()
  x=int(x)
  if y=="AC":
    if li[x]!=1:
      li[x]=1
      ac+=1
      wa+=cn[x]
  else:
    cn[x]+=1
print(ac,wa)

Submission status: Accepted

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

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

print(n-ac.count(0), sum([wa[i] for i in range(n) if ac[i] >= 1]))

Submission status: Accepted

Solution code:
# A happy new year, AtCoder !
N, M = map(int, input().split())
pS = [input().split() for _ in range(M)]

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

for i, (pi_str, Si) in enumerate(pS):
    pi = int(pi_str)
    if Si == 'AC':
        ac[pi - 1] = 1
    else:
        if ac[pi - 1] == 0:
            wa[pi - 1] += 1
        else:
            pass

ans_wa = 0
for i, wai in enumerate(wa):
    if ac[i] > 0: ans_wa += wai

print(sum(ac), ans_wa)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
read = sys.stdin.read

#n = int(input())
#a = [int(i) for i in readline().split()]

n,m = [int(i) for i in readline().split()]

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

ac_num = 0
wa_num = 0

for _ in range(m):
    p,s = [i for i in readline().split()]
    p = int(p)-1
    if ac[p] == 1:
        continue
    
    if s == "WA":
        wa[p] += 1
    else:
        ac[p] += 1
        ac_num += 1
        wa_num += wa[p]

print(ac_num,wa_num)

Submission status: Accepted

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

f = [0]*N
pena = [0]*N
for ps in PS:
    p,s = ps
    p = int(p)
    s = str(s)
    if f[p-1] == 0:
        if s == "AC":
            f[p-1] = 1
        else:
            pena[p-1]+=1
pe = 0        
for i in range(N):
    if f[i] == 1:
        pe+=pena[i]
print(sum(f),pe)

Submission status: Accepted

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

a = [0 for _ in range(n)]
b = [False for _ in range(n)]

ac_count = 0

for _ in range(m):
    p, s = input().split()
    p = int(p)
    if s == 'WA' and not b[p-1]:
        a[p-1] += 1
    elif s == 'AC' and not b[p-1]:
        ac_count += 1
        b[p-1] = True

wa_count = 0

for i in range(n):
    if b[i] == True:
        wa_count += a[i]


print(ac_count, wa_count)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**9)
N,M=map(int,input().split())
B = [0 for i in range(N)]
A = [False for i in range(N)]
for m in range(M):
  p,S=input().split()
  p = int(p)
  if S=="WA":
    if not A[p-1]:
      B[p-1] += 1
  else:
    A[p-1] = True
c = 0
for a,b in zip(A,B):
  if a:
    c+=b

print(sum(A),c)

Submission status: Accepted

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


def solve(n, m, subs):
    is_ac = [False] * n
    num_wa = [0] * n
    total_ac = 0
    total_wa = 0
    for p, s in subs:
        if s == "AC":
            if not is_ac[p]:
                is_ac[p] = True
                total_ac += 1
                total_wa += num_wa[p]
        else:
            if not is_ac[p]:
                num_wa[p] += 1
    return total_ac, total_wa


def main():
    n, m = (int(x) for x in input().split())
    subs = []
    for _ in range(m):
        p0, s = input().split()
        subs.append((int(p0) - 1, s))
    res = solve(n, m, subs)
    print(*res)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
pena = [0]*N
score = 0
flag = [False]*N
for _ in range(M):
    p, S = input().split()
    p = int(p)-1
    if flag[p]:
        continue
    if S == 'AC':
        flag[p] = True
        score+=1
    else:
        pena[p]+=1
res = 0
for i in range(N):
    if flag[i]:
        res+=pena[i]
print(score, res)

Submission status: Accepted

Solution code:
from collections import defaultdict
N, M = map(int, input().split())
D = defaultdict(int)
acd = set()
ac = 0
pen = 0
for i in range(M):
    p, S = input().split()
    p = int(p)
    if S == "WA":
        D[p] += 1
    else:
        if p not in acd:
            acd.add(p)
            ac += 1
            pen += D[p]
print(ac, pen)

Submission status: Accepted

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

accepted = set()
penalty = 0
wa_cnt = [0] * (n+1)

for i in range(m):
    p, s = input().split()
    p = int(p)
    if p in accepted:
        continue
    if s == "AC":
        penalty += wa_cnt[p]
        accepted.add(p)
    else:
        wa_cnt[p] += 1


print(len(accepted), penalty)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
# ps = [list(map(int, input().split())) for _ in range(m)]
ans = [0 for _ in range(n)]
pe = [0 for _ in range(n)]
accnt = 0
pecnt = 0
for i in range(m):
    p, s = input().split()
    p = int(p)
    if ans[p - 1] == 0 and s == "WA":
        pe[p - 1] += 1
    elif ans[p - 1] == 0 and s == "AC":
        ans[p - 1] = 1

for i in range(n):
    if ans[i] == 0:
        pe[i] = 0

print(sum(ans), end = " ")
print(sum(pe), end = "")
print()

Submission status: Accepted

Solution code:
def main():

    N, M = map(int, input().split())
    solved = [0 for _ in range(N)]
    penal = [0 for _ in range(N)]
    for _ in range(M):
        p, S = input().split()
        p = int(p)
        if S == "AC":
            solved[p-1] = 1
        else:
            if solved[p-1] == 0:
                penal[p-1] += 1
    pt = 0
    for i in range(N):
        if solved[i] == 1:
            pt += penal[i]
    return " ".join(map(str, [sum(solved), pt]))

if __name__ == '__main__':
    print(main())

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
l=[0]*n
ac=[False]*n
cnt=0;acnt=0
for i in range(m):
  a,b=input().split()
  a=int(a)
  if ac[a-1]:continue
  if b=="AC":
    cnt+=l[a-1]
    acnt+=1
    ac[a-1]=True
  if b=="WA":
    l[a-1]+=1
print(acnt,cnt)

Submission status: Accepted

Solution code:
import math

def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

# n = int(input())
# a, b
# s = input()

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

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

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

    if S == "AC":
        if memo[p] != -1:
            ac += 1
            wa += memo[p]
            memo[p] = -1
    else:
        if memo[p] != -1:
            memo[p] += 1

print(ac, wa)

Submission status: Accepted

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

for _ in range(M):
    p,S = input().split()
    p = int(p)-1
    if not AC[p]:
        if S == 'AC':
            AC[p] = 1
        else:
            WA[p] += 1
    else:
        continue
WAcount = 0
for i in range(N):
    if AC[i]:
        WAcount += WA[i]
print(sum(AC),WAcount)

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

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
score = [[False,0] for _ in [0]*N]
for _ in range(M):
    p,S = input().split()
    p = int(p)-1
    S = S=="AC"
    if S:
        score[p][0] = True
    else:
        if not score[p][0]:
            score[p][1] += 1
AC = sum(s[0] for s in score)
WA = sum(s[1] for s in score if s[0])
print(AC,WA)

Submission status: Accepted

Solution code:
N, M = map(int, raw_input().split())
A = [False]*N
C = [0]*N
for i in range(M):
  p, S = raw_input().split()
  p = int(p)-1
  if S=="AC":
    A[p] = True
  else:
    if not A[p]:
      C[p] += 1
print sum(A), sum(C[i] for i in range(N) if A[i])

Submission status: Accepted

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

ans1 = 0
ans2 = 0
for w, s in zip(wa, solved):
    if s:
        ans1 += 1
        ans2 += w

print(ans1, ans2)