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())
a = list(input().split() for i in range(m))

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

for b in a:
  p = int(b[0]) - 1
  if ac[p] == 1:
    next
  else:
    if b[1] == 'AC':
      ac[p] = 1
    else:
      wa[p] += 1
wa = [ac[i]*wa[i] for i in range(n)]
print('{} {}'.format(sum(ac),sum(wa)))

Submission status: Accepted

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

lac = [0]*(N+1)
lpcnt = [0]*(N+1)

for i in range(M):
  s = input().split()
  n = int(s[0])
  if s[1] == "AC":
    lac[n] =1
    continue
  if s[1] == "WA" and lac[n] == 0:
    lpcnt[n] += 1

cnt = 0
for i in range(N+1):
  if lac[i] == 1:
    cnt += lpcnt[i]
  
print(sum(lac), end=" ")
print(cnt)

Submission status: Accepted

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

    dict = {}
    for _ in range(M):
        p, s = input().split()
        if not p in dict:
            if s == "AC":
                dict[p] = [1, 0]
            elif s == "WA":
                dict[p] = [0, 1]
        else:
            if dict[p][0] == 0:
                if s == "AC":
                    dict[p][0] = 1
                elif s == "WA":
                    dict[p][1] += 1

    ac = 0
    wa = 0
    for k, v in dict.items():
        if v[0] == 1:
            ac += v[0]
            wa += v[1]

    print(ac, wa)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
p, S = [0]*M, [0]*M
for i in range(0,M):
    p[i], S[i] = input().split()
    p[i] = int(p[i])
s, t = 0, 0
res = []
for i in range(0,N):
    res.append([i,0])
for i in range(0,M):
    if S[i] == "WA":
        res[p[i]-1][1] = res[p[i]-1][1]+1
    elif res[p[i]-1][0] != -1:
        s, t = s+1, t+res[p[i]-1][1]
        res[p[i]-1][0] = -1
print(s, t)

Submission status: Accepted

Solution code:
import copy

N,M=map(int,input().split())
L=[list(map(str,input().split())) for i in range(M)]

for x in range(M):
    L[x][0]=int(L[x][0])

#print(N,M)
#print(L)

S=[]
component=[0,0]
for j in range(N):
    S.append(copy.deepcopy(component))

#print(S)

for k in range(1,M+1):
    if L[k-1][1]=='AC':
        if S[L[k-1][0]-1][0]==0:
            S[L[k-1][0]-1][0]=1
    else:
        if S[L[k-1][0]-1][0]==0:
            S[L[k-1][0]-1][1]+=1
    #print(S)

ansAC=0
ansWA=0

for l in range(N):
    ansAC+=S[l][0]
    if S[l][0]==1:
        ansWA+=S[l][1]

print(ansAC,ansWA)

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
results = [input().split() for _ in range(M)]
solved = set()
missed = dict()
penalty = 0

for p, S in results:
    if p in solved:
        continue

    if S == 'AC':
        solved.add(p)
        penalty += missed[p] if p in missed else 0
    else:
        missed[p] = missed[p] + 1 if p in missed else 1

print(len(solved), penalty)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin

def main():
    n,m = map(int,stdin.readline().split())
    arr= [0 for _ in range(n+1)]
    p=0;a= 0
    for _ in range(m):
        x,y = stdin.readline().split()
        x = int(x)
        if  arr[x] != -1:
            if y == "WA":
                arr[x]+=1
            else:
                a+=1
                p+=arr[x]
                arr[x] = -1
    print(a,p)
main()

Submission status: Accepted

Solution code:
from sys import stdin

def main():
    N,M=[int(x) for x in stdin.readline().split()]
    D=dict()
    AC=0
    WA=0
    for _ in range(M):
        p,a=stdin.readline().split()
        p=int(p)
        if not p in D:
            D[p]=0
        if a=='WA' and D[p]!=-1:
            D[p]+=1
        if a=='AC' and D[p]!=-1:
            WA+=D[p]
            AC+=1
            D[p]=-1
    print(AC,WA)
main()

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
L = [0]*n
penalty = [0]*n
ans = 0
out = 0
for i in range(m):
  p,q = input().split()
  if q == 'AC':
    if L[int(p)-1] == 0:
      L[int(p)-1] = 1
      ans += 1
  else:
    if L[int(p)-1] == 0:
      penalty[int(p)-1] += 1
for i in range(n):
  if L[i] == 1:
    out += penalty[i]
print(ans,out)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
P = []
S = []
for i in range(m):
    p, s = input().split()
    P.append(p)
    S.append(s)
V = [[0] * 2 for i in range(n)]
for i in range(m):
    j = int(P[i]) - 1
    if V[j][0] != 1:
        if S[i] == 'AC':
            V[j][0] = 1
        else:
            V[j][1] += 1
a = 0
w = 0
for i in range(n):
    if V[i][0] == 1:
        a += 1
        w += V[i][1]
print(a, w)

Submission status: Accepted

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

ans,pen = 0,0
for _ in range(M):
    p,s = input().rstrip().split(' ')
    p = int(p) - 1
    if P[p] == -1:
        continue
    if s == "WA":
        P[p] += 1
    else:
        ans += 1
        pen += P[p]
        P[p] = -1
print(ans,pen)

Submission status: Accepted

Solution code:
N,M = [int(i) for i in input().split()]
P = [0 for _ in range(N)]
ans,pen = 0,0
for _ in range(M):
    p,s = input().split()
    p = int(p) - 1
    if P[p] == -1:
        continue
    if s == "WA":
        P[p] += 1
    else:
        ans += 1
        pen += P[p]
        P[p] = -1
print(ans,pen)

Submission status: Accepted

Solution code:
N,M = [int(i) for i in input().rstrip().split(' ')]
P = [0 for _ in range(N)]
ans,pen = 0,0
for _ in range(M):
    p,s = input().rstrip().split(' ')
    p = int(p) - 1
    if P[p] == -1:
        continue
    if s == "WA":
        P[p] += 1
    else:
        ans += 1
        pen += P[p]
        P[p] = -1
print(ans,pen)

Submission status: Accepted

Solution code:
import numpy as np

if __name__ == "__main__":
  _n, _m = map(int, input().split())
  results = []
  flag = set()
  ans_ac = 0
  ans_wa = 0
  for i in range(_m):
    _p, _s = input().split()
    _p = int(_p)
    if _s == 'AC':
      flag.add(_p)
    results.append((_p, _s))

  ans_ac = int(len(flag))

  for p, s in results:
    if s == 'WA' and p in flag:
      ans_wa += 1
    else:
      flag.discard(p)

  print(ans_ac, int(ans_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):
  a,b = input().split()
  a = int(a) - 1
  if b == 'AC':
    ac[a] = 1
  elif ac[a] == 0:
    wa[a] += 1
for i in range(n):
  wa[i] *= ac[i]
print(sum(ac),sum(wa))

Submission status: Accepted

Solution code:
#!/usr/bin/python3
# -*- coding:utf-8 -*-

import numpy

def main():
  n, m = map(int, input().strip().split())
  counts = numpy.zeros(n).astype(numpy.int)
  flags = numpy.zeros(n).astype(numpy.int)
  for _ in range(m):
    p, s = input().strip().split()
    p = int(p)
    if s == 'WA' and flags[p-1] != 1:
      counts[p-1] += 1
    if s == 'AC':
      flags[p-1] = 1
  print(numpy.sum(flags), numpy.sum(counts * flags))

if __name__=='__main__':
  main()

Submission status: Accepted

Solution code:
[N, M] = map(int, input().rstrip().split(' '))
ps = []
ss = []

result = {}
ac = 0
wa = 0

was = [0 for i in range(N+1)]

for i in range(M):
    [p, s] = input().rstrip().split(' ')
    # 初めての結果
    if result.get(p) == None:
        result[p] = s
        if s == "WA":
            was[int(p)] += 1
        elif s == "AC":
            ac += 1
    # すでにAC済み
    elif result[p] == "AC":
        continue
    #  すでにWA済み
    else:
        # 今回正解
        if s == "AC":
            result[p] = s
            wa += was[int(p)]
            ac += 1
        # 今回不正解
        else:
            was[int(p)] += 1

print(" ".join(map(str, [ac, wa])))

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
mondai = [[0 for i in range(N)] for i in range(2)]
ans = 0
for i in range(M):
    p,s = input().split()
    if s == "WA":
        mondai[0][int(p)-1] += 1
    elif s == "AC":
        if mondai[1][int(p)-1]:
            continue
        ans += mondai[0][int(p)-1]
        mondai[1][int(p)-1] = 1
print(sum(mondai[1]),ans)

Submission status: Accepted

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

ac = 0
wa = 0

penaltyTemp = [0] * (N + 1)
Correct  = [0] * (N + 1)

for i in range(M):
    tp, S = input().split()
    P = int(tp)
    if Correct[P] == 1:
        continue
    if S == "WA":
        penaltyTemp[P] += 1
    else:
        ac += 1
        wa += penaltyTemp[P]
        Correct[P] += 1

print(ac, wa)

Submission status: Accepted

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

ac = 0
wa = 0

l = [0] * (N + 1)

for num in range(M):
    p, s =  input().split()
    p = int(p)
    if s == "AC":
        if l[p] <= 0:
            ac += 1
            wa += -l[p]
            l[p] = 1
        
         
    else:
        if l[p] <= 0:
            l[p] -= 1
        
print(*[ac, wa])

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def roundUp(a, b):
        return -(-a // b)

    @staticmethod
    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    @staticmethod
    def toLowerMultiple(a, x):
        return (a // x) * x

    @staticmethod
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    @staticmethod
    def sign(n):
        if n == 0:
            return 0
        if n < 0:
            return -1
        return 1

    @staticmethod
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


class PriorityQueue:
    def __init__(self, l=[]):
        self.__q = l
        heapq.heapify(self.__q)
        return

    def push(self, n):
        heapq.heappush(self.__q, n)
        return

    def pop(self):
        return heapq.heappop(self.__q)


MOD = int(1e09) + 7
INF = int(1e15)


def main():
    # sys.stdin = open("sample.txt")
    N, M = Scanner.map_int()
    P, S = [str] * M, [str] * M
    for i in range(M):
        P[i], S[i] = Scanner.string().split()
    ac, wa = 0, 0
    acs = defaultdict(bool)
    was = defaultdict(int)
    for i in range(M):
        if S[i] == "AC":
            if not acs[P[i]]:
                ac += 1
                wa += was[P[i]]
                acs[P[i]] = True
        else:
            was[P[i]] += 1
    print(ac, wa)
    return


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import numpy as np

def main():
    N, M = map(int, input().split())
    acc = [False] * (N+1)
    pen = [0] * (N+1)
    for _ in range(M):
        p, S = input().split()
        p = int(p)
        if S[0] == 'A':
            acc[p] = True
        else:
            if not acc[p]:
                pen[p] += 1
    n_pen = 0
    for i in range(1, N+1):
        if acc[i]:
            n_pen += pen[i]
    print('{} {}'.format(sum(acc), n_pen))

    

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import numpy as np

def main():
    # N, M = map(int, input().split())
    # PS = {}
    # for i in range(M):
    #     row = input().split()
    #     row[0] = int(row[0])
    #     if row[0] not in PS:
    #         PS[row[0]] = [row[1]]
    #     else:
    #         PS[row[0]].append(row[1])

    # n_correct = 0
    # n_penalty = 0
    # for p in PS:
    #     if 'AC' in PS[p]:
    #         n_correct += 1
    #         for result in PS[p]:
    #             if result == 'AC':
    #                 break
    #             if result == 'WA':
    #                 n_penalty += 1
    
    # print('{} {}'.format(n_correct, n_penalty))

    N, M = map(int, input().split())
    accepted = [False] * N
    penalties = [0] * N
    for _ in range(M):
        q, res = input().split()
        q = int(q) - 1
        if res[0] == 'A':
            accepted[q] = True
        elif res[0] == 'W' and not accepted[q]:
            penalties[q] += 1

    s_acc = 0
    s_pen = 0
    for i in range(N):
        if accepted[i]:
            s_acc += 1
            s_pen += penalties[i]

    print('{} {}'.format(s_acc, s_pen))
    

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import defaultdict

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

"""考え方
普通にやる
"""

ans_ac = 0
ac_p_set = set()
wa_dict = defaultdict(int)

for m in range(M):
  p,s = input().split()
  
  # 既に正解していたらスキップ
  if p in ac_p_set:
    continue
  
  # acの場合は、過去にacしていなかったら正解数を1増やす
  if s == 'AC':
    ac_p_set.add(p)
    ans_ac += 1
  # 不正解の場合は、「まだ正解していない」かつ「最終的には一回は正解する」場合に計上する
  else:
    wa_dict[p] += 1
    

ans_wa = sum(wa_dict[i] for i in ac_p_set)
print(ans_ac,ans_wa)

Submission status: Accepted

Solution code:
import numpy as np
n,m = map(int,input().split())

p = []
s = []
ans_a = np.zeros(n)
ans_p = np.zeros(n)

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

for i in range(m):
    if s[i] == "AC":
        ans_a[p[i]-1] = 1
    elif ans_a[p[i]-1] == 0:
        ans_p[p[i]-1] += 1

for i in range(n):
    if ans_a[i] == 0:
        ans_p[i] = 0

print(int(np.sum(ans_a)),int(np.sum(ans_p)))

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
F = [0 for _ in range(N)]
W = [0 for _ in range(N)]
w = 0
for i in range(M):
  p,s = map(str,input().split())
  if F[int(p)-1] == 1:
    continue
  if s == 'WA':
    W[int(p)-1] += 1
  elif s == 'AC':
    F[int(p)-1] = 1
    w += W[int(p)-1]
print(sum(F),w)

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
D = [[]for i in range(N)]
AC = 0
WA = 0
for i in range(M):
  plobNum,res = input().split()
  D[int(plobNum)-1].append(res)

for prob in D:
  wa_ = 0
  for submit in prob:
    if submit == "WA" :
      wa_+=1
    elif submit == "AC":
      AC+=1
      WA +=wa_
      break

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

Submission status: Accepted

Solution code:
import numpy as np

def main():
    N, M = map(int, input().split())
    PS = {}
    for i in range(M):
        row = input().split()
        row[0] = int(row[0])
        if row[0] not in PS:
            PS[row[0]] = [row[1]]
        else:
            PS[row[0]].append(row[1])

    n_correct = 0
    n_penalty = 0
    for p in PS:
        if 'AC' in PS[p]:
            n_correct += 1
            for result in PS[p]:
                if result == 'AC':
                    break
                if result == 'WA':
                    n_penalty += 1
    
    print('{} {}'.format(n_correct, n_penalty))
        


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
d=dict()
c=0
p=0
for _ in range(m):
    a,b=map(str,input().split())
    if a not in d:
        if b=="WA":
            d[a]=["WA",1]
        else:
            c+=1
            d[a]=["AC",1]
    else:
        if b=="WA":
            if d[a][0]=="AC":
                continue
            else:
                d[a][1]+=1
        else:
            #print(d[a][0])
            if d[a][0]=="AC":
                continue
            c+=1
            #print(d[a][1])
            d[a][0]="AC"
            p+=d[a][1]
#print(d)
print(c,p)

Submission status: Accepted

Solution code:
class Item():
    def __init__(self, state, wrongCount):
        self.state = state
        self.wrongCount = wrongCount


N, M = map(int, input().split())
items = {}
pena = 0
correct = 0
for i in range(0, M):
    p, S = input().split()

    if p not in items:
        items[p] = Item("", 0)

    if items[p].state == "AC":
        continue

    if S == "AC":
        items[p].state = S
    else:
        pena = pena + 1
        items[p].state = S
        items[p].wrongCount = items[p].wrongCount + 1

items = {k: v for k, v in items.items() if v.state == "AC"}
print("{0} {1}".format(len(items), sum(v.wrongCount for v in items.values())))

Submission status: Accepted

Solution code:
N,M = [int(x) for x in input().split()]
ac = [0]*(N+1)
wa = [0]*(N+1)
for i in range(M):
  p,s = input().split()
  if s =="AC" and ac[int(p)]==0:
    ac[int(p)]=1
  if s=="WA" and ac[int(p)]==0:
    wa[int(p)]+=1
ans = 0
answa = 0
for i in range(N+1):
  if ac[i]==1:
    ans+=1
    answa+=wa[i] 
print(ans,answa)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
list_penalties = {str(i): 0 for i in range(1, N+1)}
list_correct = {str(i): 0 for i in range(1, N+1)}
total_penalty = 0
for _ in range(M):
  p, s = input().split()
  if list_correct[p] == 0:
    if s == "WA": list_penalties[p] += 1
    elif s == "AC":
      list_correct[p] = 1
      total_penalty += list_penalties[p]
print(sum(value for key, value in list_correct.items()), total_penalty)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
ans = [0, 0]
ac = [False for _ in range(n)]
wa = [0 for _ in range(n)]

for _ in range(m):
    tmp, s = input().split()
    p = int(tmp)
    # 正解済みならスキップ
    if(ac[p-1]):
        continue
    # 正解ならAC数とWA数を加算
    if(s == "AC"):
        ans[0] += 1
        ans[1] += wa[p-1]
        ac[p-1] = True
    # 不正解なら暫定WA数を加算
    else:
        wa[p-1] += 1
 
print("{} {}".format(*ans))

Submission status: Accepted

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

ac = 0
wa = 0

challengable = [True] * n
wa_cnt = [0] * n

for _ in range(m):
    num, res = input().split()
    num = int(num)

    if not challengable[num-1]:
        continue

    if res == "AC":
        ac += 1
        challengable[num-1]=False
        wa += wa_cnt[num-1]
    else:
        wa_cnt[num-1]+=1

print(ac,wa)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
dp = [0]*(N+1)
li = []
kaku = [0]*(N+1)
dpp = [0]*(N+1)
count =0
for m in range(M):
    p,s = input().split()
    p = int(p)
    li.append([p,s])
    
for i in li:
    if i[1]=="WA":
        dp[i[0]] += 1
    
    else:
        if dpp[i[0]] ==0:
            dpp[i[0]]=1
            kaku[i[0]] = dp[i[0]]


print(sum(dpp),sum(kaku))

Submission status: Accepted

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

wa_total = [0]*N
wa_count = [0]*N 
ac_flg = [False]*N

for p,s in p_s:
    p = int(p)-1
    if not ac_flg[p]:
        if s == 'AC':
            ac_flg[p] = True
            wa_count[p] = wa_total[p]
        else:
            wa_total[p] += 1

print(ac_flg.count(True),sum(wa_count))

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
P = []
S = []
flag = [False for i in range(0, N)]
for i in range(0, M):
    x, y = map(str, input().split())
    P.append(int(x)-1)
    S.append(y)
ans = [0, 0]
wa = [0 for i in range(0, N)]
for i in range(0, M):
    if not flag[P[i]]:
        if S[i] == 'AC':
            flag[P[i]] = True
            ans[0] += 1
            ans[1] += wa[P[i]]
        else:
            wa[P[i]] += 1
print(*ans)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
pS = [list(input().split()) for i in range(M)]
c = [0 for _ in range(N)]
penalty = [0 for _ in range(N)]
ac = 0
sum_penalty = 0

for i in range(M):
    num = int(pS[i][0])
    if c[num - 1] == 0:
        if pS[i][1] == 'WA':
            penalty[num - 1] += 1
        else:
            c[num - 1] = 1
            sum_penalty += penalty[num - 1]
            ac += 1

print(ac, sum_penalty)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import numpy as np


def main():
    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))


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
x = [[0] * 2 for _ in range(n)]
AC = WA = 0
for _ in range(m):
    a, b = input().split()
    if x[int(a) - 1][0] == 0 and b == 'WA':
        x[int(a) - 1][1] += 1
    elif x[int(a) - 1][0] == 0 and b == 'AC':
        AC += 1
        WA += x[int(a) - 1][1]
        x[int(a) - 1][0] = 1
print(AC, WA)

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()

def indexs(l, x, default=-1):
    if x in l:
        return l.index(x)
    else:
        return -1

if M == 0:
	print(0, 0)
else:
	temp = [input().split() for _ in range(M)]
	temp.append([N+1, "WA"])
	temp.sort(key=lambda x:int(x[0]))
	temp = [list(x) for x in zip(*temp)]
	p, S = list(map(int, temp[0])), temp[1]

	index = 0
	AC = 0
	WC = 0
	a = []
	for i in range(M):
		if p[i]!=p[i+1]:
			a.append(indexs(S[index:i+1], "AC"))
			index = i+1
	index = 0
	for i in range(M):
		if p[i]!=p[i+1]:
			if a[index]>=0:
				AC += 1
				WC += a[index]
			index += 1	
	print(AC, WC)

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
if M!=0:
  pS=[list(input().split()) for i in range(M)]
else:
  print(0,0)
  exit()

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

for i in range(M):
  n=int(pS[i][0])-1
  if pS[i][1]=="WA" and ac[n]==0:
    wa[n]+=1
  elif pS[i][1]=="AC" and ac[n]==0:
    ac[n]+=1
    penalty+=wa[n]

print(sum(ac),penalty)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
prob = {}
for i in range(m):
  pi, si = input().split()
  prob.setdefault(int(pi), [])
  prob[int(pi)].append(si)

ac_cnt = 0
pen_cnt = 0
for key, val in prob.items():
  if 'AC' not in val:
    continue
  ac_idx = val.index('AC')
  ac_cnt += 1
  pen_cnt += ac_idx
print(ac_cnt, pen_cnt)

Submission status: Accepted

Solution code:
from collections import defaultdict
N, M = map(int, input().split())

aced = [False]*N
D = defaultdict(int)
ac = 0
pena = 0
for _ in range(M):
    id, judge = input().split()
    id = int(id)-1
    if judge == "WA":
        D[id] += 1
    else:
        if not aced[id]:
            aced[id] = True
            ac += 1
            pena += D[id]
print(ac, pena)

Submission status: Accepted

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

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

x = {}  
for _ in range(M):
  a,w = map(str,input().split())
  x.setdefault(int(a),[]).append(w)
  
ac = at = wa = wt = 0  
for k,v in x.items():
  for j in v:
    if j == 'AC':
      at += 1
      break
    elif j =='WA':
      wt += 1
  if at == 0:
    wt = 0
  else:
    ac += at
    wa += wt
    at = 0
    wt = 0
      
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()
    if AC[int(p)-1] == 0:
        if s == "WA":
            WA[int(p)-1] += 1
        elif s == "AC":
            AC[int(p)-1] = 1
print(sum(AC),sum(w*a for w,a in zip(WA,AC)))

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
wa, ac = [0]*(N+1), [0]*(N+1)
wa_ac = 0
for i in range(1, M+1):
  pi, Si = input().split()
  pi = int(pi)
  if Si == 'WA' and ac[pi] == 0: 
    wa[pi] += 1
  elif Si == 'AC' and ac[pi] == 0:
    ac[pi] += 1

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

print('{} {}'.format(sum(ac), wa_ac))

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
AC = [0]*(N+1)
WA = [0]*(N+1)
for i in range(M):
    P, S = input().split()
    P = int(P)
    if S == "AC" and AC[P] == 0:
        AC[P] = 1
    elif S == "WA" and AC[P] == 0:
        WA[P]+=1
print(sum(AC), sum(w*a for w, a in zip(AC, WA)))

Submission status: Accepted

Solution code:
def main():
    n,m=map(int,input().split())
    r=set()
    x={}
    for _ in range(m):
        p,s=input().split()
        if p not in r:
            if s=='WA':
                x[p]=x.setdefault(p,0)+1
            else:
                x[p]=x.setdefault(p,0)
                r.add(p)
    print(len(r),sum(x[p] for p in r)) 

main()

Submission status: Accepted

Solution code:
import numpy as np

n, m = map(int, input().split())
suc = np.array([0]*(n+1))
pen = np.array([0]*(n+1))

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

    if suc[p] == 0 and s == "WA":
        pen[p] += 1
    else:
        suc[p] = 1

print(sum(suc), sum(suc*pen))

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
ans=0
l=[0] * n
d={}
for i in range(m):
  p,s=input().split()
  q=int(p)-1
  if q in d:
    continue
  if s=="AC":
    ans+=l[q]
    d[q]=s
  else:
    l[q]+=1
print(len(d),ans)

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
acs = [0] * n 
was = [0] * n
for i in range(m):
    question , result = map(str,input().split())
    question_int= int(question) -1 
    if acs[question_int] == 0:
        if result == "AC":
            acs[question_int] = 1
        else:
            was[question_int] += 1

cnt_ac = sum(acs)
cnt_wa = 0

for i in range(n):
    if acs[i] == 1:
        cnt_wa += was[i]

print(cnt_ac,cnt_wa)

Submission status: Accepted

Solution code:
N, M = [int(i) for i in input().split()]
pS = {}

for _ in range(M):
    a, s = [i for i in input().split()]
    if a not in pS:
        pS[a] = {}
        if s == 'AC':
            pS[a]['AC'] = True
        else:
            pS[a]['count'] = 1
    else:
        if s == 'AC':
            pS[a]['AC'] = True
        elif 'AC' not in pS[a]:
            pS[a]['count'] += 1

s = 0
a = 0
for v in pS.values():
    if 'AC' in v and 'count' in v:
        s += v['count']
    if 'AC' in v:
        a += 1
    
print(a, s)

Submission status: Accepted

Solution code:
from collections import defaultdict

N, M = map(int, input().split())
d = defaultdict(list)
penalty = 0
accepted = 0

for p, S in (input().split() for _ in range(M)):
    d[p].append(S)

for k, v in d.items():
    tmp = 0
    for i in v:
        if i=="AC":
            accepted += 1
            penalty += tmp
            break
        else:
            tmp += 1

print(accepted, penalty)

Submission status: Accepted

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

seikai = [False] * (n + 1)
wa_list = [0] * (n + 1)
ac = 0
wa = 0
for i in range(m):
    p, s = input().split()

    if not seikai[int(p)]:
        if s == "WA":
            wa_list[int(p)] += 1
        else:
            ac += 1
            wa += wa_list[int(p)]
            seikai[int(p)] = True
print(ac, wa)

Submission status: Accepted

Solution code:
def read_line():
    tokens = input().split()
    p = int(tokens[0])
    S = tokens[1]
    return p, S

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

wa_counters = [0 for _ in range(N + 1)]
correct_answers = 0
penalties = 0
for _ in range(M):
    p, S = read_line()
    if wa_counters[p] == -1:
        continue

    if S == "AC":
        penalties += wa_counters[p]
        correct_answers += 1
        wa_counters[p] = -1
    else:
        wa_counters[p] += 1

print(correct_answers, penalties)

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
prbs = [ [0] for _ in range(1,n+1)]
#print(prbs)
for _ in range(m):
    i,j = map(str,input().split())
    i = int(i)
    i -= 1
    if prbs[i][-1] != "AC":
        prbs[i].append(j)
pen = 0
for i in range(n):
    if prbs[i][-1] == "AC":
        pen += prbs[i].count("WA")
ans = 0
for i in range(n):
    ans += prbs[i].count("AC")
#print(prbs)
print(ans,pen)