Problem: 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 `WA`s received before receiving an `AC` for the first time on that problem.  Find the numbers of Takahashi's correct answers and penalties.

Submission attempts (in order):


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


p = []
s = []
ans = [0]*N
c_wa = [0]*N
c_sum = 0

for i in range(M):
    temp1, temp2 = input().strip().split(" ")
    p.append(int(temp1))
    s.append(str(temp2))
  

for j in range(M):
    
    if s[j] == "WA":
        if ans[p[j]-1] == 0:
            c_wa[p[j]-1] += 1
        elif ans[p[j]-1] == 1:
            pass
        
                
            
    elif s[j] == "AC":
        if ans[p[j]-1] == 0:
            ans[p[j]-1] += 1
        elif ans[p[j]-1] == 1:
            pass
    
    for i in range(N):
        if ans[p[j]-1] == 1:
            c_sum += c_wa[p[j]-1]
        
            
print(sum(ans), c_sum)



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


p = []
s = []
ans = [0]*N
c_wa = [0]*N
pena = 0

for i in range(M):
    temp1, temp2 = input().strip().split(" ")
    p.append(int(temp1))
    s.append(str(temp2))
  

for j in range(M):
    
    if s[j] == "WA":
        if ans[p[j]-1] == 0:
            c_wa[p[j]-1] += 1
        elif ans[p[j]-1] == 1:
            pass
        
                
            
    elif s[j] == "AC":
        if ans[p[j]-1] == 0:
            ans[p[j]-1] += 1
        elif ans[p[j]-1] == 1:
            pass
        
print(c_wa)
for k in range(N):
    if ans[k] == 1:
        pena += c_wa[k]
    

            
print(sum(ans), pena)

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


p = []
s = []
ans = [0]*N
c_wa = 0

for i in range(M):
    temp1, temp2 = input().strip(" ").split(" ")
    p.append(int(temp1))
    s.append(str(temp2))
  

for j in range(M):
    
    if s[j] == "WA":
        print("WA", j, s[p[j]-1])
        if ans[p[j]-1] == 0:
            c_wa += 1
            
    elif s[j] == "AC":
        if ans[p[j]-1] == 1:
            continue
        elif ans[p[j]-1] == 0:
            ans[p[j]-1] += 1
            
print(sum(ans), c_wa)



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


p = []
s = []
ans = [0]*N
c_wa = [0]*N
pena = 0

for i in range(M):
    temp1, temp2 = input().strip().split(" ")
    p.append(int(temp1))
    s.append(str(temp2))
  

for j in range(M):
    
    if s[j] == "WA":
        if ans[p[j]-1] == 0:
            c_wa[p[j]-1] += 1
        elif ans[p[j]-1] == 1:
            pass
        
                
            
    elif s[j] == "AC":
        if ans[p[j]-1] == 0:
            ans[p[j]-1] += 1
        elif ans[p[j]-1] == 1:
            pass
        
for k in range(M):
    if ans[p[k] - 1] == 1:
        pena += c_wa[p[k] - 1]
    

            
print(sum(ans), pena)

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

ans = [0]*N
wc_c = [0]*N
pena = 0

for i in range(M):
    p, s = input().split(" ")
    p = int(p) - 1
    s = str(s)
    
    if s == "AC" and ans[p] == 0:
        ans[p] = 1
        pena += wc_c[p]
        
    elif s == "WA" and ans[p] == 0:
        wc_c[p] += 1
        
print(sum(ans), pena)
      
    

Verdicts: Wrong Answer

Wrong Answer

Runtime Error

Wrong Answer

Accepted