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: Time Limit Exceeded

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

ac_list = []
correct = 0
wrong = [0] * n
penalty = 0

for i in range(m):
    p,s = input().split()
    if s == 'AC' and p not in ac_list:
        ac_list.append(p)
        correct += 1
        penalty += wrong[int(p)-1]
    elif s == 'WA' and p not in ac_list:
        wrong[int(p)-1] += 1 
    else:
        continue

print('{} {}'.format(correct,penalty))

Submission status: Time Limit Exceeded

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

    ac_list = []
    correct = 0
    wrong = [0] * n
    penalty = 0

    for i in range(m):
        p,s = input().split()
        if s == 'AC' and p not in ac_list:
            ac_list.append(p)
            correct += 1
            penalty += wrong[int(p)-1]
        elif s == 'WA' and p not in ac_list:
            wrong[int(p)-1] += 1 
        else:
            continue
    
    print('{} {}'.format(correct,penalty))


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:

def main():
    n,m = map(int, input().split())

    ac_list = []
    correct = 0
    wrong = [0] * n
    penalty = 0

    for i in range(m):
        p,s = input().split()
        if s == 'AC' and p not in ac_list:
            ac_list.append(p)
            correct += 1
        elif s == 'WA' and p not in ac_list:
            wrong[int(p)-1] += 1 
        else:
            continue
    
    for i,k in enumerate(ac_list):
        penalty += wrong[int(k)-1]

    print('{} {}'.format(correct,penalty))


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
def main():
    n,m = map(int, input().split())
    s = [list(input().split()) for i in range(m)]

    ac_list = []
    correct = 0
    wrong = [0] * n
    penalty = 0

    for i,k in enumerate(s):
        if k[1] == 'AC' and k[0] not in ac_list:
            ac_list.append(k[0])
            correct += 1
        elif k[1] == 'WA' and k[0] not in ac_list:
            wrong[int(k[0])-1] += 1 
        else:
            continue
    
    for i,k in enumerate(ac_list):
        penalty += wrong[int(k)-1]

    print('{} {}'.format(correct,penalty))


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
def make_ac_list(list):
    ac_list = []
    co_list = []
    for i,k in enumerate(list):
        if k[1] == 'AC' and k[0] not in co_list:
            ac_list.append([int(k[0]),i])
            co_list.append(k[0])
    return ac_list

def count_penalty(array,list):
    penalty = 0
    for i,k in enumerate(list):
        for j in range(k[1]):
            if array[j] == [str(k[0]),'WA']:
                penalty += 1

    return penalty 


def main():
    n,m = map(int, input().split())
    s = [list(input().split()) for i in range(m)]

    ac_list = make_ac_list(s)
    correct = len(ac_list)
    penalty = count_penalty(s,ac_list)

    print('{} {}'.format(correct,penalty))


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
n,m = list(map(int,input().split()))
counter = 0
data = []
checkd = []
tmp = {}

wa = 0
#入力処理
for i in range(m):
  a,b = input().split()
  if b == "WA":
    if int(a) not in tmp:
      tmp[int(a)] = 0
    tmp[int(a)] += 1  
  elif (( b == "AC") and (int(a)) not in checkd):
    counter += 1
    checkd.append(int(a))
    if int(a) not in tmp:
      tmp[int(a)] = 0  
    wa += tmp[int(a)]


"""
for i in range(m):
  if data[i][1] == "WA":
    if int(data[i][0]) not in tmp:
      tmp[int(data[i][0])] = 0
    tmp[int(data[i][0])] += 1  
  elif ((data[i][1]) == "AC") and (int(data[i][0]) not in checkd):
    counter += 1
    checkd.append(int(data[i][0]))
    if int(data[i][0] ) not in tmp:
      tmp[int(data[i][0])] = 0  
    wa += tmp[int(data[i][0])]
"""    
print(counter,wa)

Submission status: Time Limit Exceeded

Solution code:
n,m = list(map(int,input().split()))
counter = 0
data = []
#入力処理
for i in range(m):
  data.append(input().split())
checkd = []
tmp = {}

wa = 0
for i in range(m):
  if data[i][1] == "WA":
    if int(data[i][0]) not in tmp:
      tmp[int(data[i][0])] = 0
    tmp[int(data[i][0])] += 1  
  elif ((data[i][1]) == "AC") and (int(data[i][0]) not in checkd):
    counter += 1
    checkd.append(int(data[i][0]))
    if int(data[i][0] ) not in tmp:
      tmp[int(data[i][0])] = 0  
    wa += tmp[int(data[i][0])]
    
print(counter,wa)

Submission status: Time Limit Exceeded

Solution code:
n,m = list(map(int,input().split()))
counter = 0
data = []
#入力処理
for i in range(m):
  data.append(input().split())
checkd = []
tmp = {}
for i in range(1,n+1):
  tmp[i] = 0

wa = 0
for i in range(m):
  if data[i][1] == "WA":
    tmp[int(data[i][0])] += 1
  elif ((data[i][1]) == "AC") and (int(data[i][0]) not in checkd):
    counter += 1
    checkd.append(int(data[i][0]))
    wa += tmp[int(data[i][0])]
    
print(counter,wa)

Submission status: Time Limit Exceeded

Solution code:
ac = 0
wa = 0
list1 = []
n,m = list(map(int, input().split()))
for i in range(m):
    a,b = input().split()
    c = [a,b]
    list1.append(c)
    if a not in list1:
        if b == "WA":
            wa = wa + 1
        elif b == "AC":
            list1.append(a)
            ac = ac + 1
print(ac,wa)

Submission status: Time Limit Exceeded

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

a=[]
w=[]
count=0

for j in range(M):
    if ps[j][1]=="WA":
        if ps[j][0] not in a:
            w.append(ps[j][0])
    elif ps[j][1]=="AC":
        if ps[j][0] not in a:
            a.append(ps[j][0])
            count+=w.count(ps[j][0])


print(len(a),count)

Submission status: Time Limit Exceeded

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

a=[]
w=[]
count=0

for j in range(M):
    if ps[j][1]=="WA":
        if ps[j][0] not in a:
            w.append(ps[j][0])
    elif ps[j][1]=="AC":
        if ps[j][0] not in a:
            a.append(ps[j][0])

for i in range(len(a)):
    count+=w.count(a[i])

print(len(a),count)

Submission status: Time Limit Exceeded

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

list = [[] for i in range(N)]
# print(list)

for i in range(M):
    p, S = input().split(" ")
    p = int(p)
    if "AC" not in list[p-1]:
        list[p-1].append(S)
    else:
        pass
pe = 0
cl = 0
for l in list:
    if "AC" in l:
        for i in l:
            if i == "AC":
                cl += 1
            else:
                pe += 1
    else:
        pass
print(cl, pe)

Submission status: Time Limit Exceeded

Solution code:
number,submit=input().rstrip().split()
result=[input().rstrip().split() for i in range(int(submit))]
#print(result)
good=[]
bad=[]
stocK=[]
for i in range(int(submit)):
    if result[i][1]=='WA':       
        bad.append(result[i][0])
    elif result[i][1]=='AC' and result[i][0] not in good:
        good.append(result[i][0])
        stocK.append(bad.count(result[i][0]))
        
#for i in range(len(good)):
#    if good[i] in bad:
#        stock.append(bad.count(good[i]))

print(str(len(good))+' '+str(sum(stocK)))

Submission status: Time Limit Exceeded

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

wa_count, ac_count = 0, 0
WA_List = {}  # {prob_id: wa_count}
AC_list = []  # [prob_id]

for i in range(M):
    id = A_list[i][0]
    if A_list[i][1] == 'AC':
        if not id in AC_list:
            if id in WA_List:
                wa_count += WA_List[id]
            ac_count += 1
            AC_list.append(id)
    else:
        if id in WA_List:
            WA_List[id] += 1
        else:
            WA_List[id] = 1

print(ac_count, wa_count)

Submission status: Time Limit Exceeded

Solution code:
number,submit=input().rstrip().split()
result=[input().rstrip().split() for i in range(int(submit))]
#print(result)
good=[]
bad=[]
stocK=[]
for i in range(int(submit)):
    if result[i][1]=='AC' and result[i][0] not in good:
        good.append(result[i][0])
        stocK.append(bad.count(result[i][0]))
    else:       
        bad.append(result[i][0])       


print(str(len(good))+' '+str(sum(stocK)))

Submission status: Time Limit Exceeded

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

wa_count, ac_count = 0, 0
WA_List = {}  # {prob_id: wa_count}
AC_list = []  # [prob_id]

for i in range(M):
    if A_list[i][1] == 'AC':
        if not A_list[i][0] in AC_list:
            if A_list[i][0] in WA_List:
                wa_count += WA_List[A_list[i][0]]
            ac_count += 1
            AC_list.append(A_list[i][0])
    else:
        if A_list[i][0] in WA_List:
            WA_List[A_list[i][0]] += 1
        else:
            WA_List[A_list[i][0]] = 1

print(ac_count, wa_count)

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin

N, M = map(int, stdin.readline().rstrip().split())
A_list = [stdin.readline().rstrip().split() for _ in range(M)]

wa_count, ac_count = 0, 0
WA_List = {}
AC_list = []

for i in range(M):
    if A_list[i][1] == 'AC':
        if not A_list[i][0] in AC_list:
            if A_list[i][0] in WA_List:
                wa_count += WA_List[A_list[i][0]]
            ac_count += 1
            AC_list.append(A_list[i][0])
    else:
        if A_list[i][0] in WA_List:
            WA_List[A_list[i][0]] += 1
        else:
            WA_List[A_list[i][0]] = 1

print(ac_count, wa_count)

Submission status: Time Limit Exceeded

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

wa_count, ac_count = 0, 0
WA_List = {}  # {prob_id: wa_count}
AC_list = []  # [prob_id]


def my_append(list):
    AC_list.append(list)


for i in range(M):
    if A_list[i][1] == 'AC':
        if not A_list[i][0] in AC_list:
            if A_list[i][0] in WA_List:
                wa_count += WA_List[A_list[i][0]]
            ac_count += 1
            my_append(A_list[i][0])
    else:
        if A_list[i][0] in WA_List:
            WA_List[A_list[i][0]] += 1
        else:
            WA_List[A_list[i][0]] = 1

print(ac_count, wa_count)

Submission status: Time Limit Exceeded

Solution code:
number,submit=input().rstrip().split()
result=[input().rstrip().split() for i in range(int(submit))]
#print(result)
good=[]
bad=[]
stocK=[]
for i in range(int(submit)):
    if result[i][1]=='WA':       
        bad.append(result[i][0])
    elif result[i][1]=='AC' and result[i][0] not in good:
        good.append(result[i][0])
        stocK.append(bad.count(result[i][0]))
        
#for i in range(len(good)):
#    if good[i] in bad:
#        stock.append(bad.count(good[i]))

print(str(len(good))+' '+str(sum(stocK)))

Submission status: Time Limit Exceeded

Solution code:
number,submit=input().rstrip().split()
result=[input().rstrip().split() for i in range(int(submit))]
#print(result)
good=[]
bad=[]
for i in range(int(submit)):
    if result[i][1]=='AC' and result[i][0] not in good:
        good.append(result[i][0])
    elif result[i][1]=='WA' and result[i][0] not in good:       
        bad.append(result[i][0])
stock=[]
for i in range(len(good)):
    if good[i] in bad:
        stock.append(bad.count(good[i]))

print(str(len(good))+' '+str(sum(stock)))

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
passed = 0
failed = 0
dicto = {}
for i in range(m):
    key, status = input().split()
    if key not in dicto.keys():
        dicto[key] = []
        dicto[key].append(status)
    else:
        if 'AC' not in dicto[key]:
            dicto[key].append(status)
for item in dicto:
    if 'AC' in dicto[item]:
        failed += dicto[item].count('WA')
        passed += 1
print(passed, failed)

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
passed = 0
failed = 0
dicto = {}
for i in range(m):
    key, status = input().split()
    if key not in dicto.keys():
        dicto[key] = []
        dicto[key].append(status)
    else:
        if 'AC' not in dicto[key]:
            dicto[key].append(status)
for item in dicto:
    if 'AC' in dicto[item]:
        for i in dicto[item]:
            if i == 'WA':
                failed += 1
        passed += 1
print(passed, failed)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import math
import sys
 
lines = sys.stdin.readlines()
N, M = list(map(int, lines[0].split()))
 
if M == 0:
  print("0 0")
else:
  lines = lines[1:]
  d = []
  [ d.extend(list(map(int, l.replace("\n", "").replace("AC", "1").replace("WA", "0").split()))) for l in lines ]
  d = np.array(d).reshape((-1,2)).astype(int)
  QID = np.unique(d[:, 0])
  OK = 0
  NG = 0
  for qid in QID:
    dd = d[np.where(d[:, 0]==qid)]
    if not (1 in set(dd[:, 1])):
      continue
    else:
      ACt = np.where(dd[:, 1]==1)[0]
    if len(ACt)>0:
      OK += 1
      NG += ACt[0]
  print(OK, NG)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import math
import sys

lines = sys.stdin.readlines()
N, M = list(map(int, lines[0].split()))

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

else:
  lines = lines[1:]
  d = []
  [ d.extend(list(map(int, l.replace("\n", "").replace("AC", "1").replace("WA", "0").split()))) for l in lines ]
  d = np.array(d).reshape((-1,2)).astype(int)
  QID = np.unique(d[:, 0])
  OK = 0
  NG = 0
  for qid in QID:
    idx = np.where(d[:, 0]==qid)[0]
    ACt = np.where(d[idx, 1]==1)[0]
    if len(ACt)>0:
      OK += 1
      NG += ACt[0]
  print(OK, NG)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import math
import sys

lines = sys.stdin.readlines()
N, M = list(map(int, lines[0].split()))

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

else:
  lines = lines[1:]
  d = []
  [ d.extend(l.replace("\n", "").split()) for l in lines ]
  d = np.array(d).reshape((-1,2))
  QID = np.unique(d[:, 0])
  OK = 0
  NG = 0
  for qid in QID:
    idx = np.where(d[:, 0]==qid)[0]
    ACt = np.where(d[idx, 1]=="AC")[0]
    if len(ACt)>0:
      OK += 1
      NG += ACt[0]
  print(OK, NG)

Submission status: Time Limit Exceeded

Solution code:
# ABC151 C
n, m = list(map(int, input().split()))
ac = []
wa = {}
cnt_ac = 0
cnt_wa = 0
for _ in range(1, m):
    res = input().split()
    if res[1] == "AC":
        if not res[0] in ac:
            cnt_ac += 1
            ac.append(res[0])
            if res[0] in wa.keys():
                cnt_wa += wa[res[0]]
    else:
        if res[0] in wa.keys():
            wa[res[0]] += 1
        else:
            wa[res[0]] = 1
print(cnt_ac, cnt_wa)

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
li_q = list()
for i in range(m):
    li_q.append(tuple(input().split()))

ac_count = 0
wa_count = 0

for v in range(1, n +1):
    if (str(v), 'AC') in li_q:
        ac_count += 1
        ac_idx = li_q.index((str(v), 'AC'))
        wa_count += li_q[:ac_idx].count((str(v), 'WA'))

print(ac_count, wa_count)

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
results = []
for i in range(m):
    results.append(input().split())
passed = 0
failed = 0
dicto = {}
for item in results:
    key = item[0]
    status = item[1]
    if key not in dicto.keys():
        dicto[key] = []
        dicto[key].append(status)
    else:
        # status exists in dicto[key] already
        if 'AC' not in dicto[key]:
            dicto[key].append(status)
for item in dicto:
    if 'AC' in dicto[item]:
        for i in dicto[item]:
            if i == 'WA':
                failed += 1
        passed += 1

print(passed, failed)

Submission status: Time Limit Exceeded

Solution code:
times = [int(idx) for idx in  input().split()]
datas = [input().split() for idx in range(times[1])]

pen = 0
ans = 0
num = 0
get_ = False
tmp = ""

for i in datas:
  if tmp != i[0]:
      get_ = False
  tmp = i[0]
  num = int(i[0])
  if i[1] == "WA":
        name = [i[0],"AC"]
        if name not in datas:
            datas.remove(i)
        if get_ == False:
            pen += 1
  elif i[1] == "AC":
    if get_ == False:
        ans += 1
    get_=True
print(str(ans) + " " + str(pen))

Submission status: Time Limit Exceeded

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

a=[]
b=[]
count=0

for j in range(M):
    if ps[j][1]=="WA":
        if ps[j][0] not in b:
            a.append(ps[j][0])
    elif ps[j][1]=="AC":
        if ps[j][0] not in b:
            b.append(ps[j][0])

for i in range(len(b)):
    count+=a.count(b[i])

print(len(b),count)

Submission status: Time Limit Exceeded

Solution code:

N , M = [int(n) for n in input().split(' ')]

list_AC =[]
list_WAcount = [0] * N
sumWA = 0

for i in range(M):
    sp , S = input().split(' ')
    p = int(sp)
    
    if (p in list_AC):
        # 既にAC済みの場合は何もしない
        continue 
    else:
        # 最初に正解したときにそれまでのWA回数を加算
        if S == 'AC':
            list_AC.append(p)
            sumWA += list_WAcount[p-1]
        else:
            list_WAcount[p-1] += 1

print("{} {}".format(len(list_AC),sumWA))

Submission status: Time Limit Exceeded

Solution code:

N , M = [int(n) for n in input().split(' ')]

list_AC = []
count_WA = {}
sum_WA = 0
for i in range(M):
    p , S = input().split(' ')
    
    if (p in list_AC):
        # 既にAC済みの場合は何もしない
        continue 
    else:
        if S == 'AC':
            list_AC.append(p)
            if p in count_WA:
                sum_WA += count_WA[p]
        else:
            if p in count_WA:
                count_WA[p] += 1
            else:
                count_WA[p] = 1

print("{} {}".format(len(list_AC),sum_WA))

Submission status: Time Limit Exceeded

Solution code:
N,M = map(int,input().split())
index=[]
ac=[]
pena=[]

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

    #もし初めてp問目が提出されたなら
    if not p in index:
        index.append(p)
        ac.append(0)
        pena.append(0)
    #もしp問目が未ACなら
    if ac[index.index(p)] == 0:
        if s == "AC" :
            ac[index.index(p)] += 1
        else:
            pena[index.index(p)] += 1
AC = 0
PENA = 0

for i in range(len(index)):
    if ac[i] == 1:
        AC += 1
        PENA = PENA+pena[i]
print(AC,PENA)

Submission status: Time Limit Exceeded

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

args = input().split()
n = int(args[0])
m = int(args[1])
ok_list = [0] * 100000
ng_dict = {}
ok_cnt = 0
ng_cnt = 0
for _ in range(m):
    target, score = input().split()
    target = int(target)
    if target in ok_list:
        continue
    else:
        if score == 'AC':
            ok_list[ok_cnt] = target
            ok_cnt += 1
        else:
            if target in ng_dict:
                ng_dict[target] += 1
            else:
                ng_dict[target] = 1

for num in ok_list:
    if num in ng_dict:
        ng_cnt += ng_dict[num]

print(ok_cnt, ng_cnt)

Submission status: Time Limit Exceeded

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

args = input().split()
n = int(args[0])
m = int(args[1])
ok_list = [0] * 100000
ng_dict = {}
ok_cnt = 0
ng_cnt = 0
args_results = [input().split() for i in range(m)]
for args_result in args_results:
    target = int(args_result[0])
    score = args_result[1]
    if target in ok_list:
        continue
    else:
        if score == 'AC':
            ok_list[ok_cnt] = target
            ok_cnt += 1
        else:
            if target in ng_dict:
                ng_dict[target] += 1
            else:
                ng_dict[target] = 1

for num in ok_list:
    if num in ng_dict:
        ng_cnt += ng_dict[num]

print(ok_cnt, ng_cnt)

Submission status: Time Limit Exceeded

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

args = input().split()
n = int(args[0])
m = int(args[1])
ok_list = [0] * 100000
ng_dict = {}
ok_cnt = 0
ng_cnt = 0
args_results = [input().split() for i in range(m)]
for args_result in args_results:
    target = int(args_result[0])
    score = args_result[1]
    if target in ok_list:
        continue
    else:
        if score == 'AC':
            ok_list[ok_cnt] = target
            ok_cnt += 1
        else:
            if target in ng_dict:
                ng_dict[target] += 1
            else:
                ng_dict[target] = 1

for num in ok_list:
    if num in ng_dict:
        ng_cnt += ng_dict[num]

print ok_cnt, ng_cnt

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8

n,m = map(int,input().split(" "))
q_list = []
res_list = []
for i in range(m):
    a,b = input().split(" ")
    q_list.append(int(a))
    res_list.append(b)
    


ac = 0
wa = 0
ac_list = []

for i,j in enumerate(res_list):
    if i == 0:
        if j == "AC":
            ac += 1
            ac_list.append(q_list[i])
        else:
            wa += 1
    elif q_list[i] not in ac_list:
        if j == "AC":
            ac += 1
            ac_list.append(q_list[i])
        else:
            wa += 1
    
    if len(ac_list) == n:
        break

for i,j in enumerate(res_list):
    if q_list[i] not in ac_list:
        wa -= 1



print(ac,wa)

Submission status: Time Limit Exceeded

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

seikai = 0
miss = 0

seikai_list = []  ##既に正解した問題番号のリスト
input_list = [[0 for i in range(2)] for j in range(M)]  ##入力のリスト 問題番号と正誤

for i in range(M):
  tmp = input().split()
  input_list[i][0] = tmp[0]
  input_list[i][1] = tmp[1]
 
a = False

for i in range(M):
  if input_list[i][1] =='AC':
      if (input_list[i][0] in seikai_list) == False:   ##正解リストの中に無ければ
        seikai += 1
        
        for k in range(i):
          if input_list[k][0] == input_list[i][0]:
            if input_list[k][1] == 'WA':
              miss += 1
                
        seikai_list.append(input_list[i][0])
            
print("{} {}".format(seikai, miss))

Submission status: Time Limit Exceeded

Solution code:
n,m = map(int,input().split(" "))
q_list = []
res_list = []
for i in range(m):
    a,b = input().split(" ")
    q_list.append(int(a))
    res_list.append(b)
    


ac = 0
wa = 0
ac_list = []

for i,j in enumerate(res_list):
    if i == 0:
        if j == "AC":
            ac += 1
            ac_list.append(q_list[i])
        else:
            wa += 1
    elif q_list[i] not in ac_list:
        if j == "AC":
            ac += 1
            ac_list.append(q_list[i])
        else:
            wa += 1

for i,j in enumerate(res_list):
    if q_list[i] not in ac_list:
        wa -= 1



print(ac,wa)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
# Your code here!

def pin(type=int):
    return eval("map(type,input().split())")
#1行ごとに読み込んでいる
#変数一個だけのときはカンマを入れるだけ、input()相当。ちょろい。
#下記のようにsum関数などintを相手にした関数を書く時に便利なのでデフォルトをint型にする
N,M = pin()
p=[0 for i in range(0,M)]
S=[0 for i in range(0,M)]
for i in range(0,M):
    p[i],S[i] =pin(str)

#print(p,S)
#ACした問題番号と各々の問題（後々AC下かを考えない）ペナ数を問題番号別にまとめた配列
AC=[0 for i in range(0,N)]
Penalties = [0 for i in range(0,N)]
#問題番号iと回答番号jについて,
for i in range(0,N):
    for j in range(0,M):
    
        #jがiの回答である時に,WAだったらPenaltiesに1個加算
        if int(p[j])-1==i:
            if (S[j]) == 'WA':
                Penalties[int(p[j])-1] += 1
            else:#それが初めてのACならば、AC数に1を足してcontinueで次の問題i+1へ移る
                AC[int(p[j])-1] = 1
                break
            #print(AC,Penalties)
#print(AC,Penalties)
acnum=0
pennum=0
for i in range(0,N):
    acnum += AC[i]
    if AC[i]==1:
        pennum += Penalties[i]

print(acnum,pennum)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
# Your code here!
n,m = map(int,input().split())
p =[]
s = []
for i in range(m):
    pp,ss = input().split()
    pp =int (pp)
    p.append(pp)
    s.append(ss)
correct_num =[]
for i in range(n):
    correct_num.append(0)
correct = 0
penalty =[]
for i in range(n):
    penalty.append(0)
for i in range(m):
    if s[i] == "AC" :
        correct_num[p[i]-1] = 1
for i in range(n):
    if correct_num[i] == 1:
        correct+=1

for i in range(n) :
    if correct_num[i] ==1:
        for j in range(m):
            if p[j]==i+1 and s[j] == "WA" :
                penalty[i] +=1
            if p[j]==i+1 and s[j] == "AC" :
                break
penaltysum=0
for i in range(n):
    penaltysum+=penalty[i]
print(correct,penaltysum)

Submission status: Time Limit Exceeded

Solution code:
# coding: UTF-8

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

# print(n, m)

nWA = 0
nAC = []
kariWA = []
numlist = [input() for i in range(m)]

# print(numlist)

for j in numlist:
  crnt = j.split(' ')
  if (crnt[1] == 'AC') and (crnt[0] not in nAC):
    nAC.append(crnt[0])
    nWA += kariWA.count(crnt[0])
  elif crnt[1] == 'WA':
    kariWA.append(crnt[0])

print(len(nAC), nWA)

Submission status: Time Limit Exceeded

Solution code:
#c welcome to atcoder
import sys
n,m=map(int,input().split())
ps=[]
num={}
correct=[]
#辞書
ac=0
pena=0
if m==0:
    print('0 0')
    sys.exit()
for i in range(m):
    result=input().split()
    ps.append(result)
    if result[1]=="AC":
        correct.append(result[0])

for x in ps:
    if not x[0] in correct:
        continue
    if x[0] not in num:
        num[x[0]]=0
    if x[1]=="WA" and num[x[0]]==0:
        pena+=1
    if x[1]=="AC" and num[x[0]]==0:
        ac+=1
        num[x[0]]=1

print(ac,pena)

Submission status: Time Limit Exceeded

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

result_list = []

# 正解した問題を入れるlist
done_list = []
correct = 0
pn = 0
done_list = []
pn_list = [0] * n

for i in range(m):
    a,b=input().split()
    
    if a not in done_list and b == "AC":
        done_list.append(a)
        correct += 1
        pn += pn_list[int(a) - 1]
    elif b == "WA":
        pn_list[int(a) - 1] += 1

print(correct, pn)

Submission status: Time Limit Exceeded

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

result_list = []

# 正解した問題を入れるlist
done_list = []
correct = 0
pn = 0
done_list = []
pn_list = [0] * n

for i in range(m):
    a,b=input().split()
    
    if a in done_list:
        pass
    elif b == "WA":
        pn_list[int(a) - 1] += 1
    elif b == "AC":
        done_list.append(a)
        correct += 1
        pn += pn_list[int(a) - 1]

print(correct, pn)

Submission status: Time Limit Exceeded

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

a=[]
b=[]
count=0
count_1=0

for i in range(M):
    if ps[i][1]=="AC" and ps[i][0] not in a:
        a.append(ps[i][0])

for j in range(M):
    if ps[j][0] not in a:
        pass
    elif ps[j][0] not in b:
        if ps[j][1]=="WA":
            count+=1
        elif ps[j][1]=="AC":
            b.append(ps[j][0])

print(len(a),count)

Submission status: Time Limit Exceeded

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

a=[]
b=[]
count=0
count_1=0

for i in range(M):
    if ps[i][1]=="AC" and ps[i][0] not in a:
        a.append(ps[i][0])

for j in range(M):
    if ps[j][0] not in a:
        pass
    elif ps[j][0] not in b:
        if ps[j][0] in a and ps[j][1]=="WA":
            count+=1
        elif ps[j][0] in a and ps[j][1]=="AC":
            b.append(ps[j][0])

print(len(a),count)

Submission status: Time Limit Exceeded

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

a=[]
b=[]
count=0
count_1=0

for i in range(M):
    if ps[i][1]=="AC" and ps[i][0] not in a:
        a.append(ps[i][0])

for j in range(M):
    if ps[j][0] in b and ps[j][0] not in a:
        pass
    elif ps[j][0] not in b:
        if ps[j][0] in a and ps[j][1]=="WA":
            count+=1
        elif ps[j][0] in a and ps[j][1]=="AC":
            b.append(ps[j][0])

print(len(a),count)

Submission status: Time Limit Exceeded

Solution code:
def main():
    N,M = map(int, input().split())
    l = []
    count_ac = 0
    for i in range(M):
        p,S = input().split()
        if S in 'AC':
            if not [p, S] in l: 
                l.append([p,S])
                count_ac += 1
        else:
            if [p, 'AC'] in l:
                continue
            else:
                l.append([p, S])
    anc_wa = len(l) - count_ac
    print(count_ac, anc_wa)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
def main():
    N,M = map(int, input().split())
    l = []
    count_ac = 0
    for i in range(M):
        p,S = input().split()
        if S in 'AC':
            if not [p, S] in l: 
                l.append([p,S])
        else:
            if [p, 'AC'] in l:
                continue
            else:
                l.append([p, S])
    for i in l:
        if 'AC' in i[1]:
            count_ac += 1
    anc_wa = len(l) - count_ac
    print(count_ac, anc_wa)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

n, m = map(int, input().split())
p, s = [], []
cor, pen = 0, 0
for _ in range(m):
    li = input().split()
    p.append(int(li[0]))
    s.append(li[1])
for j in range(n):
    corFlag = False
    penCnt = 0
    for i in range(m):
        if (p[i] == j + 1):
            if corFlag:
                continue
            elif (s[i] == 'WA'):
                penCnt += 1
            else:
                cor += 1
                corFlag = True
    if corFlag:
        pen += penCnt
print(cor, pen)

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
p, s = [], []
cor, pen = 0, 0
for _ in range(m):
    li = input().split()
    p.append(int(li[0]))
    s.append(li[1])
for j in range(n):
    corFlag = False
    penCnt = 0
    for i in range(m):
        if (p[i] == j + 1):
            if corFlag:
                continue
            elif (s[i] == 'WA'):
                penCnt += 1
            else:
                cor += 1
                corFlag = True
    if corFlag:
        pen += penCnt
print(cor, pen)

Submission status: Time Limit Exceeded

Solution code:
n,m=map(int,input().split())
ac=[]
wa=[0]*n
a=0
w=0
for i in range(m):
    l=input().split()
    if ac.count(l[0])==0:
        if l[1]=='AC':
            ac.append(l[0])
            a+=1
            w+=wa[int(l[0])-1]
        else:
            wa[int(l[0])-1]+=1
    if a==n:
        break
print(a,w)