Problem:


Score : 300 points

Problem Statement

Takahashi participated in a contest on AtCoder.

The contest had N problems.

Takahashi made M submissions during the contest.

The i-th submission was made for the p_i-th problem and received the verdict S_i (AC or WA).

The number of Takahashi's correct answers is the number of problems on which he received an AC once or more.

The number of Takahashi's penalties is the sum of the following count for the problems on which he received an AC once or more: the number of WAs received before receiving an AC for the first time on that problem.

Find the numbers of Takahashi's correct answers and penalties.

Constraints

N, M, and p_i are integers.

1 \leq N \leq 10^5

0 \leq M \leq 10^5

1 \leq p_i \leq N

S_i is AC or WA.

Input

Input is given from Standard Input in the following format:

N M
p_1 S_1
:
p_M S_M

Output

Print the number of Takahashi's correct answers and the number of Takahashi's penalties.

Sample Input 1

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

Sample Output 1

2 2

In his second submission, he received an AC on the first problem for the first time. Before this, he received one WA on this problem.

In his fourth submission, he received an AC on the second problem for the first time. Before this, he received one WA on this problem.

Thus, he has two correct answers and two penalties.

Sample Input 2

100000 3
7777 AC
7777 AC
7777 AC

Sample Output 2

1 0

Note that it is pointless to get an AC more than once on the same problem.

Sample Input 3

6 0

Sample Output 3

0 0



Sample input:
2 5
1 WA
1 AC
2 WA
2 AC
2 WA


Sample output:
2 2

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
p = []
S = []
flag = [0 for i in range(N)]
wa_cnt_list = [0 for i in range(N)]
ac_cnt = 0
wa_cnt = 0
#print(flag)

for i in range(M):
    pi, Si = input().split()
    p.append(int(pi))
    S.append(Si)
    

# print(p)
# print(S)

for i in range(M):
    # print("now",i)
    if(flag[p[i]-1]==1):
        # print("CONTINUE",p[i])
        continue
    else:
        if(S[i]=='WA'):
            wa_cnt_list[p[i]-1] += 1
            # print("WA No.",p[i],":cnt=",wa_cnt_list[p[i]-1])
        else:
            flag[p[i]-1] = 1
            ac_cnt += 1
            wa_cnt += wa_cnt_list[p[i]-1]

# print(sum(wa_cnt))
# print(ac_cnt)
#print(flag)

print(ac_cnt, wa_cnt)

Submission status: Accepted

Solution code:
H = list(map(int, input().split()))
N = H[0]
M = H[1]
C = [0]*N
A = 0
W = [0]*N
w = 0
for i in range(M):
    X = input().split()
    if (C[int(X[0])-1]==0):
        if (X[1]=="AC"):
            C[int(X[0])-1]=1
            A += 1
        else:
            W[int(X[0])-1]+= 1

for i in range(N):
    if(C[i]==1):
        w+=W[i]
print(str(A)+" "+str(w))

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
P=[]
S=[]
for i in range(M):
  p,s=map(str,input().split())
  P.append(int(p))
  S.append(s)
ac=0
wa=0
U=[0]*(N+1)
T=[0]*(N+1)
#print(P)
#print(S)

for i in range(M):
  if S[i]=="AC":
    U[P[i]]=1
  elif S[i]=="WA" and U[P[i]]!=1:
    T[P[i]] += 1
for i in range(N+1):
  if U[i]==0:
    T[i]=0
print(sum(U),sum(T))

Submission status: Accepted

Solution code:
from collections import defaultdict, deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys
import random
import itertools
import math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt


def LI(): return list(map(int, input().split()))


def LF(): return list(map(float, input().split()))


def LI_(): return list(map(lambda x: int(x)-1, input().split()))


def II(): return int(input())


def IF(): return float(input())


def LS(): return list(map(list, input().split()))


def S(): return list(input().rstrip())


def IR(n): return [II() for _ in range(n)]


def LIR(n): return [LI() for _ in range(n)]


def FR(n): return [IF() for _ in range(n)]


def LFR(n): return [LI() for _ in range(n)]


def LIR_(n): return [LI_() for _ in range(n)]


def SR(n): return [S() for _ in range(n)]


def LSR(n): return [LS() for _ in range(n)]


def gcd(x, y):
    if y == 0:
        return x
    return gcd(y, x % y)


def my_index_multi(l, x):
    return [i for i, _x in enumerate(l) if _x == x]


def sosu(x):
    for i in range(2, int(sqrt(x)+1)):
        if x % i == 0:
            return False
    return True


mod = 1000000007
inf = float('INF')


def A():
    A = 'abcdefghijklmnopqrstuvwxyz'
    C = input().rstrip()
    p = 0
    for i in A:
        if C == i:
            p = 1
            continue
        if p == 1:
            print(i)
            return

    return

# B


def B():
    N,K,M = LI()
    A = LI()
    ans=M*N- sum(A)
    if ans>K:
        print(-1)
    elif ans<0:
        print(0)
    else:
        print(ans)


    return

# C


def true():
    S = input()
    S = S[:-1]

    tmp = 0
    for x in range(1 << (len(S)-1)):
        func = S[-1]
        for i in range(len(S)-1):
            if(x & (1 << i)):
                tmp += int(func)
                func = S[-2-i]
            else:
                func = S[-2-i]+func
        tmp += int(func)
    print(tmp)

    return


def C():
    N, M = LI()
    P=[]
    S=[]
    count=set([])
    ans=[0]*1000000
    realans=0
    for i in range(M):

        p,s=input().split()
        p=int(p)
        if s=='AC':
            realans+=ans[p]
            count.add(p)
            ans[p]=0
        if s=='WA' and p not in count:
            
            ans[p]+=1
  


    
    print(len(count),realans)
    

        


        

# D


def D():

    a, b, x = LI()
    BIG = a*a*b/2
    if x > BIG:
        y = 2*b-(2*x/a/a)
        print(math.degrees(math.atan(y/a)))
    else:
        y = 2*x/a/b
        print(math.degrees(math.atan(b/y)))
    return

# E


def E():
    N, K = LI()
    A = LI()
    F = LI()
    A.sort(reverse=True)
    F.sort()
    cost = []
    for i in range(len(N)):
        cost.append(A[i]*F[i])

    a = F[cost.index(max(cost))]

    return

# F


def F():
    N, M = LI()

    value = [0] * M
    power = [0] * M
    for i in range(M):
        a, b = LI()
        value[i] = a
        c = LI()
        L = ['0'] * N
        for k in c:
            L[k - 1] = '1'
        bint = ''.join(L)
        power[i] = int(bint, 2)
    bint = ''.join(list(['1'] * N))
    dp = [inf] * (int(bint, 2)+1)
    t = 0
    cost = 0

    dp[0] = 0
    for s in range(int(bint, 2) + 1):
        for i in range(M):
            t = s | power[i]
            cost = dp[s] + value[i]
            dp[t] = min(dp[t], cost)
    print(-1) if(dp[-1] == inf) else print(dp[-1])

    return

    # you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")


def solution(S):
    # write your code in Python 3.6
    N = len(S)

    pass


# Solve
if __name__ == '__main__':

    C()

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
wa_check=[0 for _ in range(n+1)]
ac_check=[0 for _ in range(n+1)]
for i in range(m):
    p,s=input().split()
    p=int(p)
    if(ac_check[p]==0):
        if(s=='AC'):
            ac_check[p]=1
        else:
            wa_check[p]+=1
wa_ans=[wa_check[i] for i in range(n+1) if ac_check[i]!=0]
print(sum(ac_check),sum(wa_ans))

Submission status: Accepted

Solution code:
problem_num, sub_num = map(int, input().split())
ac = 0
wa = 0
rem_ac = {}
rem_wa = {}
for _ in range(sub_num):
    problem, result = input().split()
    # すでに問題を提出していたら
    if problem in rem_ac.keys():
        # 1ならすでにACしている
        if rem_ac[problem] == 1:
            continue
        # ACしてないなら
        else:
            if result == 'WA':
                rem_wa[problem] += 1
                wa += 1
            else:
                ac += 1
                rem_ac[problem] = 1
    # 初めて提出するなら
    else:
        rem_ac[problem] = 0
        rem_wa[problem] = 0
        if result == 'WA':
            rem_wa[problem] += 1
            wa += 1
        else:
            ac += 1
            rem_ac[problem] = 1

for key, value in rem_ac.items():
    if value == 0:
        wa -= rem_wa[key]

print(ac, wa)

Submission status: Accepted

Solution code:
mon,sub=map(int,input().split())
sei,pen=0,0
f=0
l=[0 for i in range(mon)]#ACで1
ll=[0 for i in range(mon)]
for i in range(sub):
  n,re=input().split()
  n=int(n)
  if l[n-1]==1:f%=2
  elif re=="WA":ll[n-1]+=1
  else:
    l[n-1]=1
    sei+=1
    pen+=ll[n-1]
print(sei,pen)

Submission status: Accepted

Solution code:
cin=input().split()
N=int(cin[0])
M=int(cin[1])


result={}
ac=0
was={}
for i in range(M):
    cin=input().split()
    p=int(cin[0])
    S=str(cin[1])

    log=result.get(p,None)
    if S == "AC" and log != "AC":
        ac+=1
        result[p]="AC"

    if S == "WA" and log != "AC":
        was[p]=was.get(p,0)+1

wa=0
for k,v in result.items():
    if v == "AC":
        wa+=was.get(k,0)
print(str(ac)+" "+str(wa))

Submission status: Accepted

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

answers = []
for x in range(m):
    answers.append(input().split())

correct_answers = set([answer[0] for answer in answers if answer[1] == "AC"])

temp = {k[0]: [] for k in answers}
for x in answers:
    temp[x[0]].append(x[1])

penalties = 0
for x in temp:
    if (temp[x].count("AC") > 0):
        G = temp[x][:temp[x].index("AC")]
        penalties += len(G)


print(len(correct_answers), penalties)

Submission status: Accepted

Solution code:
#coding:utf-8

n, m = map(int, input().split(' '))
pro = [0 for _ in range(n + 1)]

ac_cnt = 0
wa_cnt = 0
for i in range(m):
    idx, res = input().split(' ')
    idx = int(idx)
    if pro[idx] == 'AC':
        continue
    if res == 'AC':
        wa_cnt += pro[idx]
        pro[idx] = 'AC'
        ac_cnt += 1
    else:
        pro[idx] += 1
print(ac_cnt, wa_cnt)

Submission status: Accepted

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

    if(s == "WA" and a[int(p) - 1] == False):
        b[int(p)-1] += 1

print(AC, WA)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
resultList = [[0 for i in range(2)] for j in range(n)]
#print(resultList)
for i in range(m) :
    result = input().split()
    prob = int(result[0]) - 1
    #print(resultList, result[1])
    if result[1] == 'AC' and resultList[prob][0] == 0 :
        resultList[prob][0] = 1
    if result[1] == 'WA' and resultList[prob][0] == 0 :
        resultList[prob][1] += 1

#print(resultList)

ansAC = 0
ansWA = 0
for i in range(n) :
    ansAC += resultList[i][0]
    if resultList[i][0] == 1 :
        ansWA += resultList[i][1]

print(ansAC, ansWA)

Submission status: Accepted

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

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

LIST = [[0, 0] for _ in range(N)]
WA = 0
AC = 0
for i in range(M):
    P, S = input().split()
    if LIST[int(P)-1][0] == 0:
        if S == "AC":
            LIST[int(P)-1][0] = 1
        else:
            LIST[int(P)-1][1] += 1
for i in range(N):
    if LIST[i][0] == 1:
        AC += 1
        WA += LIST[i][1]
print("{} {}".format(AC, WA))

Submission status: Accepted

Solution code:
A = list(map(int , input().split()))
x = []
for i in range(A[1]):
    X=list(input().split())
    x.append(X)
di = {}
for i in x:
    di[int(i[0])] = []
for i in x:
    di[int(i[0])].append(i[1])
sei = 0
go = 0
for k ,v in di.items():
    if 'AC' in v:
        sei += 1
    else:
        continue
    go += v.index('AC')
print('{} {}'.format(sei,go))

Submission status: Accepted

Solution code:
from bisect import bisect_right, bisect_left
from itertools import groupby, permutations, combinations
from fractions import gcd
import numpy as np
from sys import stdin, stderr


def lcm(x, y):
    return (x * y) // gcd(x, y)


def main():
    N, M = [int(x) for x in input().split()]
    isAC = [False] * (N+1)
    cntWA = [0] * (N+1)
    cntAC = 0
    cntPN = 0
    for i in range(M):
        p, s = input().split()
        p = int(p)
        if not isAC[p]:
            if s == "AC":
                isAC[p] = True
                cntAC += 1
            else:
                cntWA[p] += 1
    for i in range(1, N+1):
        if isAC[i]:
            cntPN += cntWA[i]

    return " ".join([str(cntAC), str(cntPN)])


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

Submission status: Accepted

Solution code:
dict = {}
N, M = input().split(" ")

ACList = []
WAdict = {}
statusDict = {}
i = 1
while i <= int(M):
    key, ans = input().split(" ")
    if (ans == "AC"):
        ACList.append(key)
        statusDict[str(key)] = "OK"
    elif (ans == "WA" and key not in WAdict and key not in statusDict):
        WAdict[key] = 1
    elif (ans == "WA" and key in WAdict and key not in statusDict):
        WAdict[key] += 1

    i += 1

ACList = set(ACList)

penaList = []
for ACListItem in ACList:
    if (ACListItem in WAdict):
        penaList.append(WAdict[ACListItem])
print(len(set(ACList)), sum(penaList))

Submission status: Accepted

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

ac = 0
wa = [0 for _ in range(n)]
notAC = [True for _ in range(n)]

for i in range(m):
    if s[i] == "AC" and notAC[p[i]-1]:
        notAC[p[i]-1] = False
        ac += 1
    elif s[i] == "WA" and notAC[p[i]-1]:
        wa[p[i]-1] += 1

ans_wa = 0
for i in range(n):
    if not notAC[i]:
        ans_wa += wa[i]
print(ac, ans_wa)

Submission status: Accepted

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

n,m = list(map(int,input().split()))
a = []
dic = {}

ac = 0
wa = 0

for i in range(m):
    a.append(list(map(str,input().split())))

for i in a:
    if i[1] == "AC" and not(i[0]+i[1] in dic.keys()):
        if i[0] + "WA" in dic.keys():
            wa += int(dic[i[0] + "WA"])
        dic[i[0] + i[1]] = "OK"
        ac += 1
    elif i[1] == "WA" and not(i[0]+"AC" in dic.keys()):
        if i[0] + "WA" in dic.keys():
            dic[i[0] + "WA"] = int(dic[i[0] + "WA"]) + 1
        else:
            dic[i[0] + "WA"] = 1

print(str(ac) + " " + str(wa))

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)
ac_cnt=set()
for ps in PS:
    if ps[1]=='AC':
        ac_cnt.add(ps[0])
        ac[int(ps[0])]=1
    if ps[1]=='WA' and ac[int(ps[0])]==0:
        wa[int(ps[0])]+=1
for i in range(1,N+1):
    if str(i) not in ac_cnt:
        wa[i]=0
print(sum(ac),sum(wa))

Submission status: Accepted

Solution code:
n, m = map(int, input().split(' '))
l = {}
ac = 0
er = 0

for _ in range(m):
  num_prob, state = input().split(' ')
  if (num_prob in l) and (l[num_prob] != -1):
    if state == 'WA':
      l[num_prob] += 1
    else:
      er += l[num_prob]
      l[num_prob] = -1
      ac += 1
  elif num_prob not in l:
    l[num_prob] = 0
    if state == 'WA':
      l[num_prob] += 1
    else:
      er += l[num_prob]
      l[num_prob] = -1
      ac += 1
      
print(ac, er)

Submission status: Accepted

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

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


ac = 0
wa = 0

for i in range(n):
    if l[i].count('AC') >= 1:
        ac += 1
        for j in range(len(l[i])):
            if l[i][j] == 'AC':
                break
            else:
                wa += 1
    else:
        pass

print(ac, wa)

Submission status: Accepted

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

#print(l)

wa_ct = 0
ac_ct = 0
wa_l = [0] * (n+1)
ac_l = [False] * (n+1)

for item in l:
    if ac_l[int(item[0])] == True:
        continue
    else:
        if item[1] == 'WA':
            #wa_ct += 1
            wa_l[int(item[0])] += 1
        else:
            ac_ct += 1
            wa_ct += wa_l[int(item[0])]
            ac_l[int(item[0])] = True

#print(ac_l)
print(ac_ct, wa_ct)

Submission status: Accepted

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

m = defaultdict(int)
ac = {}

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

pena = 0
for _ in range(M):
    p, s = input().split()
    p = int(p)
    s = s.strip()
    if s == "AC":
        if p not in ac:
            pena += m[p]
            ac[p] = 1
    else:
        if p not in ac:
            m[p] += 1


print("{} {}".format(len(ac.keys()), pena))

Submission status: Accepted

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

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

submits = [0] * m
for i in range(m):
    p, s = input().split()
    submits[i] = (int(p), s.strip())

answer = [0] * (n+1)
for i in range(n):
    answer[i+1] = {'AC':0, 'WA':0}

for submit in submits:
    p, s = submit[0], submit[1]
    if s == 'WA' and answer[p]['AC'] == 0:
        answer[p]['WA'] += 1
        continue
    if s == 'AC':
        answer[p]['AC'] = 1
        continue

ac_num = 0
wa_num = 0
for a in answer[1:]:
    ac_num += a['AC']
    if a['AC'] == 1:
        wa_num += a['WA']
print(ac_num, wa_num)

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
PS = [list(input().split()) for i in range(M)]
PS = [[int(PS[i][0])-1,PS[i][1]] for i in range(M)]
AC = [0]*N
WA = [0]*N

for i in range(M):
    # print(PS[i][0])
    if AC[PS[i][0]] == 0:
        if PS[i][1] == "AC":
            AC[PS[i][0]] = 1
        else:
            WA[PS[i][0]] += 1
        # print(AC,WA)
w = 0
for i in range(N):
    if AC[i] == 1:
        w += WA[i]
print(sum(AC),w)

Submission status: Accepted

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

ac = 0
wa = 0

li_2 = []
for i in range(n):
  li_2.append(0)
wa_li = []
for i in range(n):
  wa_li.append(0)
  
for i in range(m):
  s = list(input().split())
  s[0] = int(s[0])
  if li_2[s[0]-1] == 0:
    if s[1] == "AC":
      ac+=1
      wa+= wa_li[s[0]-1]
      li_2[s[0]-1] =1
    else:
      wa_li[s[0]-1]+=1
print(ac,wa)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
pS = []
pS_dict = {i:[] for i in range(10**5)}
shutugen = set()
for i in range(M):
    tmp = input().split()
    if tmp[1] == "AC":
        pS_dict[int(tmp[0])].append(1)
    else:
        pS_dict[int(tmp[0])].append(0)
    shutugen.add(int(tmp[0]))
    
seitou = 0
penaru = 0
for i in shutugen:
    seitou_i = 0
    penaru_i = 0
    set_i = pS_dict[i]
    for s in set_i:
        if s == 0:
            penaru_i += 1
        else:
            seitou_i += 1
            break
    if seitou_i == 0:
        continue
    else:
        seitou += seitou_i
        penaru += penaru_i
print(seitou, penaru)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
count_wa = 0
count_ac = 0
if m == 0:
    print('0 0')
    exit()
al = [False] * n
wa_list = [0] * n
while True:
    try:
        p, s = map(str, input().split())
        if s == 'AC' and not al[int(p) - 1]:
            count_ac += 1
            al[int(p) - 1] = True
        elif s == 'WA' and not al[int(p) - 1]:
            wa_list[int(p) - 1] = wa_list[int(p) - 1] + 1
    except:
        break
for al_i in range(len(al)):
    if al[al_i]:
        count_wa = count_wa + wa_list[al_i]
print(str(count_ac) + ' ' + str(count_wa))

Submission status: Accepted

Solution code:
N,M=map(int, input().split())
ansY = [0]*N
ansWA = [0]*N
for i in range(M):
  id,ans = input().split()
  idr = int(id)-1
  if ans=='AC':
    ansY[idr]=1
  elif ans=='WA' and ansY[idr]==0:
    ansWA[idr]+=1
WA = sum([x * y for (x, y) in zip(ansY, ansWA)])
print(sum(ansY),WA)

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
lis = {}
cs = set()
for i in range(m):
    ps,s = input().split()
    p = int(ps)
    if lis.get(p) == None:
        lis[p] = [0,0]
    if s == "WA":
        if lis[p][0] == 0:
            lis[p][1] += 1
    if s == "AC":
        if lis[p][0] == 0:
            lis[p][0] += 1
            cs.add(p)
pcnt = 0
for i in cs:
    pcnt += lis[i][1]
print(len(cs),pcnt)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
p = []
s = []

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


done = []
for i in range(0,n):
    done.append(False)
wa_num = []
for i in range(0,n):
    wa_num.append(0)

ac = 0
for i in range(0, m):
    num = p[i] - 1
    if not done[num]:
        if s[i] == 'WA':
            wa_num[num] += 1
        else: # 'AC':
            ac += 1
            done[num] = True

wa = 0
for i in range(0,n):
    if done[i]:
        wa += wa_num[i]

print(ac, wa)

Submission status: Accepted

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

rs = []
for i in range(m):
    a,s = map(str,input().split())
    r = [int(a),s]
    rs.append(r)


c = 0
d = 0
acs = [0] * n 
was = [0] * n
for i in range(m):
    if rs[i][1] == 'AC':
        acs[rs[i][0] - 1]  += 1
    elif (rs[i][1] == 'WA') & (acs[rs[i][0] - 1] == 0):
        was[rs[i][0] - 1] += 1

for i in range(n):
    if acs[i] != 0:
        c += 1
        d += was[i]

print(("{} {}").format(c,d))

Submission status: Accepted

Solution code:
N, M = map(int,input().split())
ps = [list(input().split()) for i in range(M)]
wa = 0
ACdict = {}
for i in range(M):
    if ps[i][0] not in ACdict.keys():
        if ps[i][1] == "WA":
            ACdict[ps[i][0]] = 1
        else: ACdict[ps[i][0]] = "AC"
    else:
        if ACdict[ps[i][0]] == "AC":
            continue
        else:
            if ps[i][1] == "WA":
                ACdict[ps[i][0]] += 1
            else: 
                wa += ACdict[ps[i][0]]
                ACdict[ps[i][0]] = "AC"
acs = [k for k, v in ACdict.items() if v == "AC"]
print(len(acs), wa)

Submission status: Accepted

Solution code:


n ,m = list(map(int, input().split()))
flg = [False] * n
wa = [0] * n
ac = 0
for _ in range(m):
    p, s = input().split()
    p = int(p) -1
    if not flg[p]:
        if s == 'WA':
            wa[p] = wa[p] + 1
        else:
            ac = ac + 1
            flg[p] = True

was = [0] * n
for i in range(n):
    if flg[i]:
        was[i] = wa[i]
# print(sum(was))

print("%d %d" % (ac, sum(was)))

Submission status: Accepted

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

import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        # for line in sys.stdin:
        #     lines.append(line)
        lines.append(input())
        (n, m) = [int(e) for e in lines[0].split(" ")]
        for _ in range(m):
            lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]
        (n, m) = [int(e) for e in lines[0].split(" ")]


    ps = [] 
    for i in range(1, m + 1):
        e = lines[i].split(" ")
        p = int(e[0])
        s = e[1]
        ps.append((p, s))

    return (n, m, ps)


def solve(n, m, ps):

    
    submits = dict()
    # for i in range(1, n+1):
    #     submits[i] = []

    for (p, s) in ps:

        ans_list = submits.get(p, [])
        ans_list.append(s)
        submits[p] = ans_list
    
    total_ac = 0
    total_wa = 0
    for (p, ans_list) in submits.items():

        ac = 0
        wa = 0
        for ans in ans_list:
            if ans == 'WA':
                wa = wa + 1
            elif ans == 'AC':
                ac = ac + 1
                break
        
        if ac == 0:
            wa = 0

        total_ac = total_ac + ac
        total_wa = total_wa + wa
        
        if debug:
            log("p=%d, ac=%d, wa=%d" % (p, ac, wa))
            log("total_ac=%d, total_wa=%d" % (total_ac, total_wa))

    result = [total_ac, total_wa] 

    return result


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        print("%d %d" % (result[0], result[1]))
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
ps = [input().split() for _ in range(m)]
all_ac = set(int(p) for p,s in ps if s=='AC')
ac = set()
pena_cnt = 0
ac_cnt = 0
for p,s in ps:
  p = int(p)
  if p in all_ac:
    if p not in ac:
      if s == 'WA':
        pena_cnt += 1
      else:
        ac_cnt += 1
        ac.add(p)
print(ac_cnt, pena_cnt)

Submission status: Accepted

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

for i in range(M):
	S = list(input().split())
	# print(S)
	num = int(S[0])
	res = S[1]
	if res == "AC":
		seitou[num - 1] = 1
	else:
		if seitou[num - 1] == 0:
			penalty[num - 1] += 1
			
# print(*seitou)
# print(*penalty)
print(sum(seitou), end=" ")

ans = 0

for i in range(N):
	if seitou[i] == 1:
		ans += penalty[i]
print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict

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

submissions = []
for _ in range(m):
    num, result = input().split()
    submissions.append((int(num), result))

score = defaultdict(lambda: {"passed": False, "wa": 0})

for p, s in submissions:
    if score[p]["passed"]:
        pass
    elif s == "AC":
        score[p]["passed"] = True
    elif s == "WA":
        score[p]["wa"] += 1

ans = 0
pena = 0

# print(score)

for v in score.values():
    if v["passed"]:
        ans += 1
        pena += v["wa"]

print(ans, pena)

Submission status: Accepted

Solution code:
N, M = [int(x) for x in input().split()]
p = []; S = []
for _ in range(M):
    p_tmp, S_tmp = input().split()
    p.append(int(p_tmp))
    S.append(str(S_tmp))

AC = [0] * N
WA = [0] * N
for i in range(M):
    if AC[p[i] - 1] == 1:
        continue
    if S[i] == 'AC':
        AC[p[i] - 1] = 1
    else:
        WA[p[i] - 1] += 1
for i in range(N):
    if AC[i] == 0:
        WA[i] = 0
AC_count = sum(AC)
WA_count = sum(WA)
print(AC_count, WA_count)

Submission status: Accepted

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

ac_list = [False] * (N + 1)
ac_count = 0
penalty = [0] * (N + 1)

for i in range(M):
    problem, status = input().split()
    problem = int(problem)

    if status == "AC":
        if not ac_list[problem]:
            ac_count += 1
        ac_list[problem] = True
        continue

    if status == "WA" and not ac_list[problem]:
        penalty[problem] += 1

point = 0
for i, p in enumerate(penalty):
    if ac_list[i]:
        point += p

print(ac_count, point)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
a = {}
for i in range(m):
    p, s = input().split()
    if p not in a:
        a[p] = {'flag':False, 'wa':0}
    if s == 'AC':
        a[p]['flag'] = True
    elif not a[p]['flag']:
        a[p]['wa'] += 1

ac, wa = 0,0
for k, i in a.items():
    if i['flag']:
        ac += 1
        wa += i['wa']
print(ac, wa)

Submission status: Accepted

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

AC = [0] * (N + 1)
WA = [0] * (N + 1)

for _ in range(M):
    pS = input().split()
    n = int(pS[0])
    
    if pS[1] == 'AC':
        AC[n] = 1
    elif (pS[1] == 'WA') & (AC[n] == 0):
        WA[n] += 1
        
# 正解数
correct = len([i for i in AC if i > 0])

# ペナルティ
penalty = sum([x * y for (x, y) in zip(AC, WA)])

print(correct, penalty)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
sub = [list(input().split()) for j in range(m)]
li = [[0 for i in range(n)]for j in range(2)]
for i in range(m):
    x = int(sub[i][0])-1
    if sub[i][1] == 'AC':
        if li[0][x] == 0:
            li[0][x] += 1
    elif li[0][x] == 0:
        li[1][x] += 1
    else:
        next

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

print('{} {}'.format(ac,wa))

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
res=[]
sto, WAsto=[],[]
for i in range(M):
    res.append([x for x in input().split()])
for i in range(N):
    sto.append(0)
    WAsto.append(0)
#print(res)
#print(int(res[0][0]))
#print(sto)

for i in range(M):
    if res[i][1]=="AC" and sto[int(res[i][0])-1]!=-1:
        WAsto[int(res[i][0])-1]=sto[int(res[i][0])-1]
        sto[int(res[i][0])-1]=-1 
    elif sto[int(res[i][0])-1]!=-1:
        sto[int(res[i][0])-1]+=1        

#for i in range(M):
#    if sto[i]!=-1:
#        WAsto[i]+=sto[i]
WA=sum(WAsto)
#print(sto)
AC=sto.count(-1)

print(AC,WA)

Submission status: Accepted

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

dp = [0 for _ in range(n+1)]

def ans(dp, n, m) -> list:
    if m == 0:
        return [0, 0]

    ac = 0
    wa = 0
    i = 0
    while i < m:
        q, r = input().split()
        q = int(q)

        if dp[q] == None:
            pass
        elif r == 'WA':
            dp[q] += 1
        elif r == 'AC':
            ac += 1
            wa += dp[q]
            dp[q] = None

        i += 1

    return [ac, wa]

a = ans(dp, n, m)

print(*a)

Submission status: Accepted

Solution code:
# AtCoder Beginner Contest 151: C (2020/01/12)
N, M = map(int, input().split())
ANS = [0 for i in range(N)]
PNL = [0 for i in range(N)]
p = [0 for i in range(M)]
S = ['' for i in range(M)]
for i in range(M):
    l = input().split()
    p[i] = int(l[0])
    S[i] = str(l[1])
for i in range(M):
    if ANS[p[i]-1] == 0:
        if S[i] == 'AC':
            ANS[p[i]-1] = 1
        else:
            PNL[p[i]-1] = PNL[p[i]-1] + 1
ans = 0
pnl = 0
for i in range(N):
    if ANS[i] == 1:
        ans = ans + 1
        pnl = pnl + PNL[i]
print(ans, pnl)

Submission status: Accepted

Solution code:
n,m = map(int, input().split())
ac=0
wa=0
pp=set()
d={}
for i in range(0,m):
    p,s = input().split()
    if p in pp:
        continue
    if s == 'AC':
        pp.add(p)
        ac=ac+1
        wa = wa+d.get(p, 0)
    if p in d.keys():
        d[p] = d[p] + 1
    else:
        d[p]=1
print(ac, wa)

Submission status: Accepted

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

N=int(N)
M=int(M)

Ps=[]
Ss=[]

for i in range(M):
    p,s=input().split(" ")
    Ps.append(int(p))
    Ss.append(s)

#間違えたら-=1 ,正解したら=1 
cleared=[0]*(N+1)

AC_n=0
WA_n=0

for i in range(M):

    if Ss[i]=="WA":
        if not cleared[Ps[i]]==1:
            cleared[Ps[i]]-=1

    if Ss[i]=="AC":
        if cleared[Ps[i]]<=0:
            AC_n+=1
            WA_n-=cleared[Ps[i]]
            cleared[Ps[i]]=1

print(AC_n,WA_n)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
D={}
for i in range(m):
    p,s=input().split()
    if p not in D:
        if s=="AC":
            D[p]=[["AC",1],["WA",0]]
        else:
            D[p]=[["AC",0],["WA",1]]
    else:
        if D[p][0][1]==1:
            continue
        else:
            if s=="AC":
                D[p][0][1]+=1
            else:
                D[p][1][1]+=1
AC,WA=0,0
for i in D:
    if D[i][0][1]==1:
        AC+=1
        WA+=D[i][1][1]

print(AC,WA)

Submission status: Accepted

Solution code:
import sys
n, m = map(int, sys.stdin.readline().split())
a=[sys.stdin.readline().split() for i in range(m)]
wa = [0 for i in range(n)]
ac = [0 for i in range(n)]

for i in range(m):
    p = int(a[i][0])-1
    s = a[i][1]
    if s=="WA" and ac[p]==0:
        wa[p] +=1
        #print(wa, 'wa')
    elif s=="AC":
        ac[p] = 1
        #print(ac, 'ac')

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