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:
mod = 10 ** 9 + 7
mod2 = 2 ** 61 + 1
from collections import deque
import heapq
from bisect import bisect_left, insort_left, bisect_right

_NUMINT_ALL = list(range(10))


def main():
    ans = solve()

    if ans is True or ans is False:
        YesNo(ans)
    elif ans is not None:
        print(ans)


def solve():
    N, M = iip(False)
    A = iipt(M)
    d = {}

    for p, s in A:
        d[p] = [0, 0]

    for p, s in A:
        if d[p][1] == 1:
            continue
        elif s == "WA":
            d[p][0] += 1
        else:
            d[p][1] = 1

    e = 0
    f = 0
    for a, b in d.values():
        if b == 0:
            continue
        e += a
        f += b

    split_print_space([f, e])

#####################################################ライブラリ集ここから

def kiriage_warizan(a, b):
    return -(-a//b)


def iip(listed=True):  # 数字のinputをlistで受け取る
    d = input().split()
    try:
        ret = [int(i) for i in d]
    except:
        ret = [int(i) if i in _NUMINT_ALL else i for i in d]
        if len(ret) == 1:
            return ret[0]

    if len(ret) == 1 and not listed:
        return ret[0]
    return ret

def iipt(l, listed=False, num_only=True):  # 縦向きに並んでいるデータをリストに落とし込む(iip利用)
    ret = []
    for i in range(l):
        ret.append(iip(listed=listed))
    return ret


def saidai_kouyakusuu(A):  # 最大公約数
    l = len(A)
    while True:
        m = min(A)
        mx = max(A)
        if m == mx:
            return m

        for i in range(l):
            if A[i] % m == 0:
                A[i] = m
            else:
                A[i] %= m


def make_graph_edge_flat(N):  # グラフ作成のための辺をリストで返す
    ret = []
    for i in range(N-1):
        a, b, c = iip()
        a -= 1
        b -= 1
        ret[a].append((b, c))
        ret[b].append((a, c))
    return ret


def sort_tuples(l, index):  # タプルのリストを特定のインデックスでソートする
    if isinstance(l, list):
        l.sort(key=lambda x: x[index])
        return l
    else:
        l = list(l)
        return sorted(l, key=lambda x: x[index])


def count_elements(l):  # リストの中身の個数を種類分けして辞書で返す
    d = {}
    for i in l:
        if i in d:
            d[i] += 1
        else:
            d[i] = 1
    return d


def safeget(l, index, default="exception"):  # listの中身を取り出す時、listからはみ出たり
    if index >= len(l):                      # マイナスインデックスになったりするのを防ぐ
        if default == "exception":
            raise Exception("".join(["safegetに不正な値 ", index, "が渡されました。配列の長さは", len(l), "です"]))
        else:
            return default
    elif index < 0:
        if default == "exception":
            raise Exception("".join(["safegetに不正な値 ", index, "が渡されました。負の値は許可されていません"]))
        else:
            return default
    else:
        return l[index]


def sortstr(s):  # 文字列をソートする
    return "".join(sorted(s))


def iip_ord(startcode="a"):  # 文字列を数字の列に変換する(数字と文字は1:1対応)
    if isinstance(startcode, str):
        startcode = ord(startcode)
    return [ord(i) - startcode for i in input()]


def YesNo(s):  # TrueFalseや1, 0をYesNoに変換する
    if s:
        print("Yes")
    else:
        print("No")


def fprint(s):  # リストを平たくしてprintする(二次元リストを見やすくしたりとか)
    for i in s:
        print(i)


def bitall(N):  # ビット全探索用のインデックスを出力
    ret = []
    for i in range(2 ** N):
        a = []
        for j in range(N):
            a.append(i % 2)
            i //= 2
        ret.append(a)
    return ret

def split_print_space(s):  # リストの中身をスペース区切りで出力する
    print(" ".join([str(i) for i in s]))


def split_print_enter(s):  # リストの中身を改行区切りで出力する
    print("\n".join([str(i) for i in s]))


def soinsuu_bunkai(n):  # 素因数分解
    ret = []
    for i in range(2, int(n ** 0.5) + 1):
        while n % i == 0:
            n //= i
            ret.append(i)
        if i > n:
            break
    if n != 1:
        ret.append(n)
    return ret


def conbination(n, r, mod, test=False):  # nCrをmodを使って計算する
    if n <= 0:
        return 0
    if r == 0:
        return 1
    if r < 0:
        return 0
    if r == 1:
        return n
    ret = 1
    for i in range(n - r + 1, n + 1):
        ret *= i
        ret = ret % mod

    bunbo = 1
    for i in range(1, r + 1):
        bunbo *= i
        bunbo = bunbo % mod

    ret = (ret * inv(bunbo, mod)) % mod
    if test:
        # print(f"{n}C{r} = {ret}")
        pass
    return ret


def inv(n, mod):  #  modnにおける逆元を計算
    return power(n, mod - 2)


def power(n, p, mod_=mod):  # 繰り返し二乗法でn**p % modを計算
    if p == 0:
        return 1
    if p % 2 == 0:
        return (power(n, p // 2, mod_) ** 2) % mod_
    if p % 2 == 1:
        return (n * power(n, p - 1, mod_)) % mod_


def nibutan_func(func, target, left, right, side="left"): # 関数を二分探索
    l = left
    r = right
    while r-l > 1:
        x = (l+r)//2
        if func(x) == target:
            return x
        elif func(x) > target:
            r = x
        else:
            l = x

    if side == "left" or func(x) == target:
        return l
    else:
        return r


def nibutan_list(list_, target, side="left"):  # リストを二分探索
    if not isinstance(list_, list):
        list_ = list(list_)

    l = 0
    r = len(list_)
    while r-l > 1:
        x = (l+r)//2
        if list_[x] == target:
            return x
        elif list_[x] > target:
            r = x
        else:
            l = x

    if side == "left" or list_[x] == target:
        return l
    else:
        return r

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def main(n: int, m: int, p_s: list):
    bool_ac = [False for _ in range(n)]
    count_wa = [0 for _ in range(n)]
    ac, wa = 0, 0

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

        if bool_ac[p - 1]:
            continue

        if s == "AC":
            bool_ac[p - 1] = True
            wa += count_wa[p - 1]
            ac += 1
        elif s == "WA":
            count_wa[p - 1] += 1

    print(ac, wa)


if __name__ == "__main__":
    n, m = map(int, input().split())
    p_s = [input().split() for _ in range(m)]

    main(n, m, p_s)

Submission status: Accepted

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

dict_ac = {i:0 for i in range(N)}
dict_wa = {i:0 for i in range(N)}
# print(dict_ac)
# print(dict_wa)
number = True
index = 0
for i, j in lists:

    if j == "WA":
        i = int(i) - 1
        if dict_ac[i] == 0:
            dict_wa[i] += 1

    elif j == "AC":
        if i not in dict_ac.keys():
            i = int(i) - 1
            dict_ac[i] = 1


# print("AC", dict_ac)
# print("WA", dict_wa)


for i in dict_wa.keys():
    if dict_ac[i] == 0:
        dict_wa[i] = 0
    else:
        continue

# print("AC", dict_ac)
# print("WA", dict_wa)

print(sum(dict_ac.values()), sum(dict_wa.values()))

Submission status: Accepted

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

ac = [0] *N
pena = [0] *N

for _ in range(M):
    P, S = map(str, input().split())
    P = int(P) - 1
    if ac[P]: continue
    if S == 'AC':
        ac[P] = 1
    else:
        pena[P] += 1

AC = 0
PENA = 0

for i in range(N):
    AC += ac[i]
    if ac[i]:
        PENA += pena[i]

print('{} {}'.format(AC, PENA))

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:
        if S=="AC":
            ac[p-1]=1
        elif S=="WA":
            wa[p-1]+=1
            
wacnt=0
for i in range(N):
	if ac[i]>=1:
		wacnt+=wa[i]
		
print(sum(ac), wacnt)

Submission status: Accepted

Solution code:
import sys
import math

from collections import defaultdict
from collections import deque
def load(vtype=int):
    return vtype(input().strip())
def load_list(seplator=" ", vtype=int):
    return [vtype(v) for v in input().strip().split(seplator)]
def exit():
    import sys
    sys.exit(0)
def perm_sub(li, used):
    if len(li) == len(used):
        return [deque()]
    k = []
    for i in range(len(li)):
        if i in used:
            continue
        used.add(i)
        sub_list = perm_sub(li, used)
        for sub in sub_list:
            sub.appendleft(li[i])
        k.extend(sub_list)
        used.discard(i)
    return k
def perm_li(li):
    return perm_sub(li, set())
def perm_n(n):
    return perm_sub(list(range(n)), set())
def join_i(li, sep=""):
    return sep.join([str(e) for e in li])
def li2n(li):
    n, base = 0, 1
    for i in range(len(li)-1, -1, -1):
        n += li[i] * base
        base *= 10
    return n
def sli2ili(li):
    return [int(s) for s in li] 
def prime_list(n):
    li = [i for i in range(2, n+1)]
    for i in range(len(li)):
        if li[i] >= int(math.sqrt(n)):
            break
        if li[i] == -1:
            continue
        for j in range(i+1, len(li)):
            if li[j] % li[i] == 0:
                li[j] = -1
    return [n for n in li if n != -1]
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while True:
        r = a % b
        if r == 0: return b
        a, b = b, r
def lcm(a, b):
    return int(a * b / gcd(a,b))
def all_subset(li):
    s = []
    n = len(li)
    for bit in range(0, (1<<(n+1))):
        ss = set()
        for i in range(0, n):
            if (bit & (1 << i)):
                ss.add(li[i])
        s.append(ss)
    return s
def factorial(n):
    if n == 1:
        return 1
    return n * factorial(n-1)
def mCn(m, n):
    def factorial_ntimes(m, n):
        r = 1
        while n:
            r *= m
            m -= 1
            n -= 1
        return r
    return int(factorial_ntimes(m, n) / factorial(n))


n, m = load_list()

ac = dict()
pena = defaultdict(int)
a, b = 0, 0
for _ in range(m):
    p, r = input().split(" ")
    p = int(p)
    r = r.strip()
    if r == 'AC' and p not in ac:
        a += 1
        ac[p] = 1
        b += pena[p]
    elif r == 'WA' and p not in ac:
        pena[p] += 1

print(a,b)

Submission status: Accepted

Solution code:
N,M = map(int, input().split())
A = {}
C = 0
P = 0
for i in range(M):
    p,S = map(str, input().split())
    if S == 'AC' and A.get(p+S) is None:
        A[p+S] = 0
        C += 1
    elif S == 'WA' and A.get(p+'AC') is None and A.get(p+S) is None:
        A[p+S] = 1
    elif S == 'WA' and A.get(p+'AC') is None:
        A[p+S] += 1
for i in range(1,N+1):
    if A.get(str(i)+'AC') is not None and A.get(str(i)+'WA') is not None:
        P += A[str(i)+'WA']
print(C,P)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
ACs = [0] * N
wa = 0
ac = 0
for _ in range(M):
    p, s = input().split()
    if s == "WA" and ACs[int(p)-1] <= 0:
        ACs[int(p)-1] -= 1
    if s == "AC" and ACs[int(p)-1] <= 0:
        wa -= ACs[int(p)-1]
        ACs[int(p)-1] = 1
        ac += 1
print("{} {}".format(ac, wa))

Submission status: Accepted

Solution code:
import numpy as np

# 入力
N,M = map(int,input().split())

Check_AC = np.zeros(N)
WA_Counter = np.zeros(N)

for i in range(M):
    pi,Si = input().split()
    pi = int(pi)
    # まだ正解していない問題
    if Check_AC[pi-1] == 0:
        if Si == "AC":
            Check_AC[pi-1] = 1
        else:
            WA_Counter[pi-1] += 1
    
print(str(int(sum(Check_AC))) + " " + str(int(np.dot(Check_AC,WA_Counter))))

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
ac = 0
wa = 0
l = [input().split() for i in range(m)]
d = dict()
for i in range(m):
    if l[i][0] + "wa" not in d:
        d[l[i][0] + "wa"] = 0
    if l[i][0] not in d or d[l[i][0]] != "AC":
        d[l[i][0]] = l[i][1]
        if l[i][1] == "AC":
            ac += 1
            wa += d[l[i][0] + "wa"]
        else:
            d[l[i][0] + "wa"] += 1
print(ac, wa)

Submission status: Accepted

Solution code:
from collections import defaultdict

a,b = map(int,input().split())

k=defaultdict(lambda:defaultdict(int))

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

    if k[p].get('AC'):
        continue

    k[p][s] += 1

x = y = 0

for i,j in k.items():
    if j.get('AC'):
        x+=1
        if j.get('WA'):
            y+=j['WA']

    # print(i,j)


print(x,y)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
lis = [list(input().split()) for _ in range(m)]
d = {}
ac, wa = 0, 0
for i in lis:
    if i[0] not in d:
        if i[1] == 'AC':
            ac += 1
            d[i[0]] = 'AC'
        else:
            d[i[0]] = 1
    else:
        if i[1] == 'AC':
            if d[i[0]] != 'AC':
                ac += 1
                wa += d[i[0]]
                d[i[0]] = 'AC'
        else:
            if d[i[0]] != 'AC':
                d[i[0]] += 1
print(ac, wa)

Submission status: Accepted

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

task = [[0, 0] for i in range(n)];
solved = 0;
penalty = 0;

for i in range(m):
    p, s = (j for j in input().split());
    p = int(p) - 1;
    if task[p][0] == 1:
        continue;
    if s == "AC":
        solved += 1;
        penalty += task[p][1];
        task[p][0] = 1;
    else:
        task[p][1] += 1;

print(solved, penalty);

Submission status: Accepted

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

memo=set()
ACcount=0
PEcount={}
for _ in range(m):
	p,s=input().split()
	if p not in memo:
		if s=="AC":
			ACcount+=1
			memo.add(p)
		else:
			if p in PEcount:
				PEcount[p]+=1
			else:
				PEcount[p]=1
count=0
for i in memo:
	if i in PEcount:
		count+=PEcount[i]
print("{} {}".format(ACcount,count))

Submission status: Accepted

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

for _ in range(M):
  x = input().split()
  p = int(x[0])
  S = x[1]
  if S == "AC":
    L[p-1][0] = 1
  elif L[p-1][0] == 0:
    L[p-1][1] +=1

ac = 0
wa = 0
for i in range(N):
    x = L[i][0]
    y = L[i][1]
    if x == 1:
        ac +=1
        wa +=y
        
print(ac,wa)

Submission status: Accepted

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

a=[0]*n
w=[0]*n

ac=0
wa=0

for i in range(m):

  p,s=map(str,input().split())
  p=int(p)

  if a[p-1]==0:
    if s=="AC":
      ac+=1
      wa+=w[p-1]
      a[p-1]=1
    else:
      w[p-1]+=1

print(ac,wa)

Submission status: Accepted

Solution code:
from collections import defaultdict
n, m = map(int, input().split())
ac_set = set()
wa_dic = defaultdict(int)
wa_cnt = 0
for i in range(m):
    p, s = input().split()
    if s == 'AC':
        ac_set.add(p)
    else:
        if p not in ac_set:
            wa_dic[p] += 1
print(len(ac_set), sum(value for key, value in wa_dic.items() if key in ac_set))

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
p = [0 for i in range(m)]
s = ["WA" for i in range(m)]
correct = [0 for i in range(n)]
penalty = [0 for i in range(n)]
for i in range(m):
    temp = input().split()
    p[i], s[i] = int(temp[0]), temp[1]
for i, j in zip(p, s):
    if j == "AC":
        correct[i-1] = True
    else:
        if not correct[i-1]:
            penalty[i-1] += 1
a = 0
b = 0
for i, j in zip(correct, penalty):
    if i:
        a += 1
        b += j
print(a, b)

Submission status: Accepted

Solution code:
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, M = lr()
problems = [False] * N
AC = [0] * N
WA = [0] * N
for _ in range(M):
    p, S = sr().split(); p = int(p) - 1
    if not problems[p] and S == 'WA':
        WA[p] += 1
    if not problems[p] and S == 'AC':
        problems[p] = True
        AC[p] += 1

AC_total = sum(AC)
WA_total = sum(y for x, y in zip(AC, WA) if x)
print(AC_total, WA_total)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
n, m = map(int, input().split())
ac = 0
wa = 0
tmp = {}
d = set()
for _ in range(m):
    p, s = map(str, input().split())
    if p not in tmp:
        tmp[p] = 0
    if p not in d and s == "AC":
        d.add(p)
        ac += 1
        if p in tmp:
            wa += tmp[p]
    if p not in d and s == "WA":
        tmp[p] += 1
print(ac, wa)

Submission status: Accepted

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

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

correct = 0
wrong = 0
for i in range(n):
    correct += lst[i][0]
    if lst[i][0] == 1:
        wrong += lst[i][1]
print(correct, wrong)

Submission status: Accepted

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

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

correct = 0
wrong = 0
for i in range(n):
    correct += lst[i][0]
    if lst[i][0] == 1:
        wrong += lst[i][1]
print(correct, wrong)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

N, M = map(int, input().split(" "))
pen = [0 for i in range(N)]
ans = [False for i in range(N)]
num_pen = 0

for i in range(M):
    p, S = input().split(" ")
    if S == 'AC':
        if not ans[int(p) - 1]:
            num_pen += pen[int(p) - 1]
        ans[int(p) - 1] = True
    elif S == 'WA':
        pen[int(p) - 1] += 1
    else:
        sys.stderr('input error')
print(sum(ans), num_pen)

Submission status: Accepted

Solution code:
from collections import deque
from collections import Counter
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
#pypyではscipy, numpyは使えない
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
#from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
#import numpy as np
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
from datetime import datetime as dt

def main():
  n,m = map(int, readline().split())
  p = [0]*m
  s = ['']*m
  count = [0]*n
  AC = [0]*n
  for i in range(m):
    tmp, s[i] = input().split()
    p[i] = int(tmp)
  for i in range(m):
    if AC[p[i]-1]==0:
      if s[i]=='WA':
        count[p[i]-1] += 1
      else:
        AC[p[i]-1] = 1
  penalty = 0
  for i in range(n):
    if AC[i]==1:
      penalty += count[i]
  print('{} {}'.format(sum(AC),penalty))
  
  
  
if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
n, m = [int(i) for i in 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:
        if s == "AC":
            ac[p-1] = 1
        elif s == "WA":
            wa[p-1] += 1

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

print(sum(ac), wa_sum)

Submission status: Accepted

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n,m = map(int, input().split())
    result = [0]*n
    wa = [0]*n
    ac = [0]*n
    for _ in range(m):
        i = input().rstrip()
        i = i.split()
        p, s = int(i[0]), i[1]
        if s=='WA':
            if result[p-1]==0:
                wa[p-1] += 1
        else:
            if result[p-1]==0:
                result[p-1] = 1
                ac[p-1] += 1
    a = sum(ac)
    b = 0 
    for i in range(n):
        if ac[i]==1:
            b += wa[i]
    print(a, b)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

penalties = [0 for _ in range(N)]
acs = [False for _ in range(N)]

for i, submit in enumerate(submits):
    p = int(submit[0])-1
    if acs[p]:
        continue
    if submit[1] == 'AC':
        acs[p] = True
    else:
        penalties[p] += 1

ac_num = sum(acs)
penalty_num = sum([p for i, p in enumerate(penalties) if acs[i]])

print("{} {}".format(ac_num, penalty_num))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
#
# ~/PycharmProjects/atcoder/C-WelcomeToAtCoder.py
#
N, M = map(int, input().split())
ac_list = [0] * N
wa_list = [0] * N
ac = int(0)
wa = int(0)
is_correct = [False] * N

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

for i in range(M):
    p, s = input().split()
    p = int(p) - 1
    if not is_correct[p]:
        if s == "AC":
            is_correct[p] = True
            ac_list[p] += 1
        else:
            wa_list[p] += 1

for i in range(N):
    if is_correct[i]:
        ac += ac_list[i]
        wa += wa_list[i]

print(ac, wa)

Submission status: Accepted

Solution code:

n, m = map(int, input().split())
bool_lst = [False] * n
ac_lst = [0] * n
wa_lst = [0] * n
for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    if bool_lst[p] == False:
        if s == 'AC':
            bool_lst[p] = True
            ac_lst[p] += 1
        else:
            wa_lst[p] += 1

ac_cnt = 0
wa_cnt = 0
for i in range(n):
    if bool_lst[i] == True:
        ac_cnt += ac_lst[i]
        wa_cnt += wa_lst[i]

print(ac_cnt, wa_cnt)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
bool_lst = [False] * n
ac_lst = [0] * n
wa_lst = [0] * n
for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    if bool_lst[p] == False:
        if s == 'AC':
            bool_lst[p] = True
            ac_lst[p] += 1
        else:
            wa_lst[p] += 1

ac_cnt = 0
wa_cnt = 0
for i in range(n):
    if bool_lst[i] == True:
        ac_cnt += ac_lst[i]
        wa_cnt += wa_lst[i]

print(ac_cnt, wa_cnt)

Submission status: Accepted

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

penalty = 0
a = [[False, 0] for i in range(N)]
count = 0

for i in range(M):
    p, S = input().split()
    p = int(p) - 1
    if a[p][0] == False:
        if S == 'WA':
            a[p][1] += 1
        else:
            a[p][0] = True
            count += 1
    else:
        pass

print(count, sum([a[i][1] for i in range(N) if a[i][0] is True]))

Submission status: Accepted

Solution code:
n, m = map(int,input().split())
 
AC = 0
# 各問題でACがとれているか確認用
# 0 = まだ正解していない, 1 = すでに正解済み
AC_list = [0] * (n + 1)
WA = 0
WA_List = [0] * (n + 1)
 
for i in range(m):
    p,S = input().split()
    p = int(p)
 
    if S == "AC":
        # 初めての正解
        if AC_list[p] == 0:
            AC += 1
            WA += WA_List[p]
            AC_list[p] = 1
        # ※すでに正解している場合は加算しない
    else:
        # まだ正解していない場合
        if AC_list[p] == 0:
            WA_List[p] += 1
        # ※すでに正解している場合は加算しない
 
print(AC,WA)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
p_li, s_li = [], []
for _ in range(m):
    p, s = input().split()
    p_li.append(int(p))
    s_li.append(s)

ac = [0] * n
wa = [0] * n
for i in range(m):
    p, s = p_li[i] - 1, s_li[i]
    if s == 'AC':
        ac[p] += 1
    elif ac[p] == 0:
        wa[p] += 1
    else:
        continue
n_ac, n_wa = 0, 0
for i in range(n):
    if ac[i] != 0:
        n_ac += 1
        n_wa += wa[i]
print('{} {}'.format(n_ac, n_wa))

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(sum(AC),wa)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
ans=[0]*n
pen=[0]*n
res_pen=0
for i in range(m):
  p,s=list(input().split())
  if ans[int(p)-1]!=1:
    if s=="AC":
      ans[int(p)-1]=1
      res_pen+=pen[int(p)-1]
    else:
      pen[int(p)-1]+=1
print(str(sum(ans))+" "+str(res_pen))

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
a=[0]*N#正解した問題一覧
b=[0]*N
for i in range(M):
    s=list(map(str,input().split()))
    if s[1]=="AC" and a[int(s[0])-1]==0:
        a[int(s[0])-1]+=1
    elif s[1]=="AC" and a[int(s[0])-1]==1:
        pass
    elif s[1]=="WA" and a[int(s[0])-1]==0:
        b[int(s[0])-1]+=1
for i in range(N):
    if b[i]>=1 and a[i]==0:
        b[i]=0
    
print(sum(a),sum(b))

Submission status: Accepted

Solution code:
#abc151c
import sys
n,m=map(int,raw_input().split())
fac=[0]*(n+1)
fwa=[0]*(n+1)
ac=0
wa=0
l=[]
for i in range(m):
 p,s=map(str,raw_input().split())
 p=int(p)
 if fac[p]==0:
  if s=='AC':
   fac[p]=1
   ac+=1
   wa+=fwa[p]
  else:
   fwa[p]+=1
print ac,wa

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
ac_list = [0]*n
wa_list = [0]*n
pena = 0
for i in range(m):
    p,s = input().split()
    if s == 'AC':
        if ac_list[int(p)-1] == 0:
            ac_list[int(p)-1] =1
            pena += wa_list[int(p)-1]
        
    if s == 'WA':
        if ac_list[int(p)-1] == 0:
            wa_list[int(p)-1] += 1
            
print('{0} {1}'.format(sum(ac_list) , pena))

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
a = [""] * m
b = [""] * m
c = [0] * n
d = [0]*n
for i in range(m):
    a[i], b[i] = input().split()
for i in range(m):
    if (b[i] == "WA" and 0 == d[int(a[i])-1]):
        c[int(a[i])-1] += 1
    if (b[i] == "AC"):
        d[int(a[i])-1] = 1
p = 0
for i in range(n):
    if (d[i] == 1):
        p += c[i]
print(sum(d), p)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections

N, M = map(int, input().split())
dic = {i+1:[] for i in range(N)}
for i in range(M):
    x, y = input().split()
    dic[int(x)].append(y)
    
ac = 0
cnt = 0
for key in dic.keys():
    tmp = 0
    tmp_ac = 0
    for i in range(len(dic[key])):
        if(dic[key][i] == "AC"):
            ac += 1
            tmp_ac = 1
            break
        tmp += 1
    if(tmp_ac == 1):
        cnt += tmp
print(ac, cnt)

Submission status: Accepted

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

str_l=["WA"]*n
int_l=[0]*n

num=0
ac=0
for pp,s in ps:
    p=int(pp)-1
    if s=="AC":
        str_l[p]="AC"
    else:
        if str_l[p]!="AC":
            int_l[p]+=1

for i in range(n):
    if str_l[i]=="AC":
        num+=int_l[i]
        ac+=1
print(ac,num)

Submission status: Accepted

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


AC_list = [0] * N
penalty_list = [0] * N
ans_penalty_list = [0] * N

for i in range(M):
  if submit[i][1] == "WA":
    penalty_list[int(submit[i][0])-1] += 1
  else:
    if AC_list[int(submit[i][0])-1] == 0:
      AC_list[int(submit[i][0])-1] = 1
      ans_penalty_list[int(submit[i][0])-1] = penalty_list[int(submit[i][0])-1]

print(str(AC_list.count(1)), str(sum(ans_penalty_list)))

Submission status: Accepted

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


def solve(N: int, M: int, p: "List[int]", S: "List[str]"):
    solved = [False]*N
    WAs = [0]*N
    WA = 0
    for i in range(M):
        if not solved[p[i]-1]:
            if S[i] == "WA":
                WAs[p[i]-1] += 1
            else:
                solved[p[i]-1] = True
    penalty = 0
    ACs = 0
    for i in range(N):
        if solved[i]:
            ACs += 1
            penalty += WAs[i]
    print(ACs, penalty)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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:
N, M = map(int, input().split())
p = [0] * M
S = [0] * M
for i in range(M):
    line = input().split()
    p[i] = int(line[0])
    S[i] = line[1]

AC = [False for _ in range(N)]
WA = [0 for _ in range(N)]
for i in range(M):
    if AC[p[i] - 1]:
        pass
    else:
        if S[i] == "AC":
            AC[p[i] - 1] = True
        else:
            WA[p[i] - 1] += 1

n_AC = sum(AC)
n_WA = 0
for i in range(N):
    if AC[i]:
        n_WA += WA[i]

print(" ".join([str(n_AC), str(n_WA)]))

Submission status: Accepted

Solution code:
d = dict()
wa = ac = 0
N, M= map(int,input().split())
for i in range(M):
  a, b = input().split()
  if a not in d:
    d[a] = 0
  if d[a] >= 0 and b == "AC":
    ac += 1
    wa += d[a]
    d[a] = -1
  elif d[a] >= 0:
    d[a] += 1
print(ac,wa)