Search is not available for this dataset
name
stringlengths
2
112
description
stringlengths
29
13k
source
int64
1
7
difficulty
int64
0
25
solution
stringlengths
7
983k
language
stringclasses
4 values
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int M = sc.nextInt(); int waNum = 0; int acNum = 0; int[] wa = new int[N]; boolean[] ac = new boolean[N]; for (int i = 0; i < M; i++) { int p = sc.nextInt()-1; String S = sc.next(); if (S.equals("AC") && !ac[p]) { waNum += wa[p]; acNum++; ac[p] = true; } else if (S.equals("WA") && !ac[p]) { wa[p]++; } } System.out.println(acNum + " " + waNum); } }
JAVA
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
n,m=map(int,input().split()) ac=[0]*(n+1) wa=[0]*(n+1) for i in range(m): p,s=input().split() if ac[int(p)]!=1: if s=='WA': wa[int(p)]=wa[int(p)]+1 else: ac[int(p)]=1 for i in range(n+1): if ac[i]==0: wa[i]=0 print(sum(ac),sum(wa))
PYTHON3
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
#include <bits/stdc++.h> using namespace std; int N, M, ac, pe, p; string S; int main() { cin >> N >> M; vector<int> wa(N + 1, 1); while (M-- && cin >> p >> S) if (wa[p]) { if (S == "AC") ac++, pe += --wa[p], wa[p] = 0; else wa[p]++; } cout << ac << " " << pe; }
CPP
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
#include<bits/stdc++.h> using namespace std; int main() { int n,m,i,j,k,pen=0,ans=0; string cw; cin>>n>>m; int prob[n+1]; for(i=1;i<=n;i++) prob[i]=0; for(i=1;i<=m;i++) { cin>>j>>cw; if(cw=="WA" && prob[j]!=-1) { prob[j]++; } else if(cw=="AC" && prob[j]!=-1) { ans++; pen+=prob[j]; prob[j]=-1; } } cout<<ans<<" "<<pen<<endl; }
CPP
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
#include "bits/stdc++.h" using namespace std; const int N=1e5+20; int n,m,p,ac,cost[N],ans; char s[10]; bool solved[N]; int main() { scanf("%d%d",&n,&m); for(int i=0;i<m;i++) { scanf("%d %s",&p,s); if(solved[p]) continue; if(s[0]=='A') solved[p]=true,ac++; else cost[p]++; } for(int i=1;i<=n;i++) if(solved[i]) ans+=cost[i]; printf("%d %d",ac,ans); }
CPP
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
# coding=utf-8 import collections get = lambda: int(raw_input().strip()) gets = lambda: map(int, raw_input().strip().split()) getss = lambda x: [gets() for _ in xrange(x)] N, M = gets() count = collections.Counter() penalty = 0 ac = set() for i in xrange(M): p, s = raw_input().split() p = int(p) if p in ac: continue if s == 'AC': ac.add(p) penalty += count[p] else: count[p] += 1 print len(ac), penalty
PYTHON
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
#include<bits/stdc++.h> using namespace std; const int maxn=1e5+6; int vis[maxn],c[maxn],cnt,ans; int n,m; int main() { scanf("%d %d",&n,&m); for(int i=1;i<=m;++i) { int a;char s[4]; scanf("%d",&a); scanf("%s",s); if(s[0]=='A'&&vis[a]==0) cnt++,ans+=c[a],vis[a]=1; else c[a]++; } printf("%d %d",cnt,ans); }
CPP
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
n, m = map(int, input().split()) s = [[] for i in range(n)] for i in range(m): p, S = input().split() s[int(p) - 1] += [S] print(sum('AC' in si for si in s), end=' ') print(sum(si[:si.index('AC')].count('WA') if 'AC' in si else 0 for si in s))
PYTHON3
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
n,m=map(int,input().split()) pp=[0]*n res=0 qq=[True]*n for i in range(m): i,j=input().split() i=int(i) i-=1 if j=="AC": if qq[i]: qq[i]=False res+=pp[i] else: pp[i]+=1 print(qq.count(False),res)
PYTHON3
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int M = sc.nextInt(); int[] P = new int[M]; String[] S = new String[M]; for (int i = 0; i < M; i++) { P[i] = sc.nextInt(); S[i] = sc.next(); } sc.close(); boolean[] ac = new boolean[N]; int[] pe = new int[N]; for (int i = 0; i < M; i++) { int p = P[i] - 1; if (ac[p]) continue; String s = S[i]; if ("WA".equals(s)) { pe[p]++; } else if ("AC".equals(s)) { ac[p] = true; } } long ans1 = 0; long ans2 = 0; for (int i = 0; i < N; i++) { if (ac[i]) { ans1++; ans2 += pe[i]; } } System.out.println(ans1 + " " + ans2); } }
JAVA
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
#include<bits/stdc++.h> using namespace std; map<int,int>vis; int flag[200005]; int main() { int n, m, a, ok=0, res=0, c=0; cin>>n>>m; string s; while(m--) { cin>>a>>s; if(s=="AC"&&flag[a]==0) { c++; flag[a]=1; res=res+vis[a]; vis[a]=0; } else if(s=="WA"){ vis[a]++; } } cout<<c<<" "<<res<<endl; }
CPP
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); Set<Integer> set = new HashSet<>(); int ac = 0, wa = 0; int[] cnt = new int[n+1]; for(int i=0;i<m;i++) { int p = sc.nextInt(); String s = sc.next(); if(s.equals("WA")) cnt[p]++; else { if(!set.contains(p)) { ac++; wa+=cnt[p]; set.add(p); } } } System.out.println(ac+" "+wa); } }
JAVA
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
#include<iostream> #include<cstdio> using namespace std; char a[10],s[10]; int n,K,m,x,bok[101010],ans,fs; int main() { scanf("%d%d",&n,&m); for(int i=1;i<=m;i++) { scanf("%d%s",&x,s+1); if(s[1]=='A'&&bok[x]!=1) fs+=-bok[x],bok[x]=1; else if(s[1]=='W'&&bok[x]!=1) bok[x]--; } for(int i=1;i<=n;i++) ans+=(bok[i]==1); printf("%d %d\n",ans,fs); return 0; }
CPP
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
AC = 0 WA = 0 N, M =map(int, input().split()) A = [0]*N for i in range(M): p, S = input().split() q = int(p)-1 if S == 'AC' and A[q] != -1: AC += 1 WA += A[q] A[q] = -1 elif S == 'WA' and A[q] != -1: A[q] += 1 print(AC, WA)
PYTHON3
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
n,m = map(int,input().split()) a=[0]*n w=[0]*n ac=0 wc=0 for _ in range(m): p,s=input().split() p=int(p)-1 if a[p]==0: if s=="AC": a[p]=1 ac+=1 wc+=w[p] else: w[p]+=1 print(ac,wc)
PYTHON3
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
N,M=map(int,input().split()) ansAC=0 ansP=0 n=[0]*N AC=[0]*N for i in range(M): p,s =map(str,input().split()) p=int(p)-1 if AC[p]==1:continue if s=="AC": ansP+=n[p] ansAC+=1 AC[p]=1 else: n[p]+=1 print(ansAC,ansP)
PYTHON3
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; int t, a = 0, b = 0; string s; vector<int> p(n+1, 0); vector<bool> ac(n+1, false); for (int i = 0; i < m; ++i) { cin >> t >> s; if (ac[t]) continue; if (s == "AC") { b += p[t]; ++a; ac[t] = true; } else { ++p[t]; } } cout << a << " " << b << endl; }
CPP
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
#include "bits/stdc++.h" using namespace std; int main() { long long N, M, AC = 0, WA = 0; map<long long, long long> mpA; map<long long, bool> mpB; cin >> N >> M; for (int i = 0; i < M; i++) { long long P; string S; cin >> P >> S; if (S == "AC") { if (!mpB[P]) AC++, WA += mpA[P], mpB[P] = true; } else { if (!mpB[P]) mpA[P]++; } } cout << AC << " " << WA << endl; }
CPP
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
import java.util.*; public class Main{ public static void main(String[]args){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); int idata[] = new int[m]; String sdata[] = new String[m]; boolean ac[] = new boolean[10000000]; int a = 0; int w = 0; int wdata[] = new int[10000000]; for (int i = 0;i<m ;i++ ) { idata[i] = sc.nextInt(); sdata[i] = sc.next(); } for (int i = 0;i<m ;i++ ) { if (ac[idata[i]]==false) { if (sdata[i].equals("WA")) { wdata[idata[i]]++; w++; }else{ a++; ac[idata[i]]=true; } } } for (int i = 0;i<m ;i++ ) { if (ac[idata[i]]==false) { w = w-1; } } System.out.println(a+" "+w); } }
JAVA
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
N,M=map(int,input().split()) L=[0]*N R=[0]*N right=0 pena=0 for _ in range(M): p,s=input().split() p=int(p) p-=1 if R[p]==0: if s=='AC': right+=1 R[p]=1 pena+=L[p] else: L[p]+=1 print(right,pena)
PYTHON3
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
#include<cstdio> #include<algorithm> using namespace std; int main(void) { int n,m,p,i,j,c[100000]={0},c2=0,c3=0,flg[100000]={0}; char s[3]; scanf("%d%d",&n,&m); for(i=0;i<m;i++){ scanf("%d %s",&p,s); if(flg[p]==0&&s[0]=='W') c[p]++; if(flg[p]==0&&s[0]=='A'){ c2+=c[p]; c3++; flg[p]=1; } } printf("%d %d\n",c3,c2); return 0; }
CPP
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
#include <bits/stdc++.h> using namespace std; int main() { int n,m,p,ac=0,pe=0; string s; cin >> n >> m; vector<int> wa(n+1,0); vector<bool> ok(n+1,false); for(int i=0;i<m;i++){ cin >> p >> s; if (!ok[p] && s == "WA") wa[p]++; else if (!ok[p] && s == "AC") {ac++;pe += wa[p];ok[p] = true;} } cout << ac << " " << pe << endl; }
CPP
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
N, M = map(int, input().split()) AC = [0] * N WA = [0] * N for _ in range(M): p, s = input().split() p = int(p) - 1 if s == 'AC': AC[p] = 1 elif AC[p] < 1: WA[p] += 1 WA = [w if AC[p] else 0 for p, w in enumerate(WA)] print(sum(AC), sum(WA))
PYTHON3
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
import java.util.Scanner; public class Main { public static void main(String[] args) { // 自分の得意な言語で // Let's チャレンジ!! Scanner sc = new Scanner(System.in); // 問題数 int n = sc.nextInt(); // 提出数 int m = sc.nextInt(); // 正当数 int sei = 0; // ペナ数 int pena = 0; // 仮ペナマップ int[] iArr = new int[n + 1]; // 正当マップ boolean[] bArr = new boolean[n + 1]; for (int i = 0; i < m; i++) { // 問題番号 int nm = sc.nextInt(); // WA or AC String kekka = sc.next(); if ("AC".equals(kekka)) { if (!bArr[nm]) { sei++; pena += iArr[nm]; bArr[nm] = true; } } else { if (!bArr[nm]) { iArr[nm] = iArr[nm] + 1; } } } System.out.println(sei + " " + pena); } }
JAVA
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
import java.util.*; class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); boolean[] AC = new boolean[100005]; int[] WA = new int[100005]; int N = sc.nextInt(); int M = sc.nextInt(); int ac=0; int wa=0; for(int i=0;i<M;i++) { int p = sc.nextInt(); String S = sc.next(); if(S.equals("AC")) { AC[p]=true; } else { if(AC[p]==false) { WA[p]++; } } } for(int i=0;i<100005;i++) { if(AC[i]==true) { ac++; wa=wa+WA[i]; } } System.out.println(ac + " " + wa); } }
JAVA
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
#include<bits/stdc++.h> using namespace std; const int N = 2e5+100; bool ok[N]; int pen[N]; int main(){ int n,m; cin>>n>>m; int x; string ve; int ans=0,pens=0; for(int i=1;i<=m;i++){ cin>>x>>ve; if(ve=="AC"){ if(!ok[x]) ans++; ok[x]=1; }else{ if(!ok[x]){ pen[x]++; } } } for(int i=1;i<=n;i++){ if(ok[i]) pens+=pen[i]; } cout<<ans<<' '<<pens<<endl; return 0; }
CPP
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
import java.util.*; class Main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); boolean[] qac = new boolean[n+1]; int[] qwa = new int[n+1]; int ac = 0; int wa = 0; for(int i = 0;i < m;i++){ int sub = sc.nextInt(); String res = sc.next(); if(res.equals("AC")){ qac[sub] = true; }else{ if(!qac[sub]) qwa[sub]++; } } for(int i = 1;i < n+1;i++){ if(qac[i]){ ac++; wa += qwa[i]; } } System.out.println(ac+" "+wa); } }
JAVA
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
import java.util.*; public class Main { public static void main(String[] args) throws Exception { // Your code here! Scanner scn = new Scanner(System.in); int n = scn.nextInt(); int m = scn.nextInt(); int[] a = new int[n]; int[] pena = new int[n]; int clear = 0; int total = 0; for(int i = 0; i < m; i++){ int pm = scn.nextInt()-1; String sm = scn.next(); if(a[pm] == 1){ }else if(sm.equals("AC")){ clear++; a[pm]=1; }else{ pena[pm]++; } } int penalty = 0; for(int i = 0; i < n; i++){ if(a[i] == 1){ penalty += pena[i]; } } System.out.println(clear+" "+penalty); } }
JAVA
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
#include<bits/stdc++.h> using namespace std; #define maxn 100005 int a[maxn];char s[10]; int main(){ int n,m,x,ans1=0,ans2=0;scanf("%d%d",&n,&m); for(int i=0;i<m;i++){ scanf("%d%s",&x,s); if(a[x]==-1)continue; if(s[0]=='A')ans1++,ans2+=a[x],a[x]=-1; else a[x]++; } printf("%d %d\n",ans1,ans2); return 0; }
CPP
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
#include <bits/stdc++.h> using namespace std; int main(){ int N,M,p,a=0,w=0;string J;cin>>N>>M; vector<bool>x(N,false); vector<int>WA(N,0); for(int i=0;i<M;i++){ cin>>p>>J; if(J=="AC"){ if(!x.at(p-1)){a++;x.at(p-1)=true;w+=WA.at(p-1);} } else if(!x.at(p-1))WA.at(p-1)++; } cout<<a<<" "<<w<<endl; }
CPP
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
#include<bits/stdc++.h> using namespace std; vector<bool> v(100001,false); vector<int> c(100001,0); int main() { int n,m; cin>>n>>m; int a1=0,a2=0; while(m--) { int p; string s; cin>>p>>s; if(v[p-1]==false) { if(s=="AC") v[p-1]=true,a2+=c[p-1],a1++; else c[p-1]++; } } cout<<a1<<" "<<a2<<"\n"; return 0; }
CPP
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
import sys input() ac,wa={*()},{} nc=np=0 for ln in sys.stdin: p,S=ln.split() if p in ac: continue if p not in wa: wa[p]=0 if S=='AC': ac.add(p) nc+=1 np+=wa[p] else: wa[p]+=1 print(nc,np)
PYTHON3
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
#include <cstdio> #include <string> #include <vector> using namespace std; int main(void){ int N,M,A1=0,A2=0; char S[3]; scanf("%d %d",&N,&M); vector<bool> P(N+1); vector<int> P2(N+1); for(int i=0;i<M;i++){ int p; scanf("%d %s",&p,S); string s=S; if(P[p]) continue; if(s=="AC") P[p]=true,A1++,A2+=P2[p]; else P2[p]++; } printf("%d %d\n",A1,A2); return 0; }
CPP
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
n,m=map(int,input().split()) num=[0]*n wa=0 ac=0 for i in range(m): p,s=input().split() p=int(p) if s=="WA" and num[p-1]!=-1: num[p-1]+=1 elif s=="AC" and num[p-1]!=-1: ac+=1 wa+=num[p-1] num[p-1]=-1 print(ac,wa)
PYTHON3
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
n,m=map(int,input().split()) l=[[0 for i in range(2)]for j in range(n+1)] wa,ac=0,0 for i in range(m): p,s=input().split() p=int(p) if s=="WA" and l[p][1]==0: l[p][0]+=1 elif s=="AC" and l[p][1]==0: l[p][1]+=1 ac+=1 wa+=l[p][0] print(ac,wa)
PYTHON3
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
import java.util.*; public class Main { static Scanner sc = new Scanner(System.in); public static void main(String[] args) { int n = sc.nextInt(); int m = sc.nextInt(); boolean[] alreadyAC = new boolean[n]; long[] penaltyCount = new long[n]; for(int i = 0; i < m; ++i) { int p = sc.nextInt() - 1; String s = sc.next(); if(!alreadyAC[p]) { penaltyCount[p] += (s.equals("WA")) ? 1 : 0; alreadyAC[p] = s.equals("AC"); } } long acSum = 0, penaltySum = 0; for(int i = 0; i < n; ++i) { acSum += (alreadyAC[i]) ? 1 : 0; penaltySum += (alreadyAC[i]) ? penaltyCount[i] : 0; } System.out.printf("%d %d", acSum, penaltySum); } }
JAVA
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
import java.util.BitSet; import java.util.Scanner; class Solver { static final Solver INSTANCE = new Solver(); void solve(Scanner sc) { int N = sc.nextInt(); int M = sc.nextInt(); int[] penalties = new int[N]; BitSet set = new BitSet(N); for (int i = 0; i < M; i++) { int p = sc.nextInt() - 1; boolean s = sc.next().equals("AC"); if (s) { set.set(p); } if (!set.get(p)) { penalties[p]++; } } int sum = 0; for (int i = set.nextSetBit(0); i >= 0; i = set.nextSetBit(i + 1)) { sum += penalties[i]; } System.out.println(set.cardinality()); System.out.println(sum); } } class Main { public static void main(String... args) { Scanner in = new Scanner(System.in); Solver.INSTANCE.solve(in); in.close(); } }
JAVA
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
N, M = map(int, input().split()) P = [0] * (N + 1) S = [0] * (N + 1) for i in range(M): x, p = input().split() s = int(x) if P[s] == 0: if p == 'AC': P[s] = 1 else: S[s] += 1 A = sum([S[i] for i in range(N + 1) if P[i] == 1]) print(P.count(1), A)
PYTHON3
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
N,M = map(int,raw_input().split()) ans_done = [[0 for i in range(3)] for j in range(N)] for i in range(M): p,S = raw_input().split() p = int(p)-1 if ans_done[p][0] == 0: ans_done[p][0] = p+1 if S == "AC": ans_done[p][1] = 1 else: ans_done[p][1] = 2 if ans_done[p][1] == 2: ans_done[p][2] = ans_done[p][2] + 1 elif ans_done[p][1] == 2: if S == "AC": ans_done[p][1] = 1 else: ans_done[p][1] = 2 if ans_done[p][1] == 2: ans_done[p][2] = ans_done[p][2] + 1 pen = 0 ans = 0 for i in ans_done: if i[1] == 1: ans = ans + 1 pen = pen + i[2] print ans,pen
PYTHON
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
#include<bits/stdc++.h> using namespace std; int aa[100009],ww[100009]; int main(){ int n,m; int a=0,w=0; cin>>n>>m; for(int i=0;i<m;i++){ int p; string s; cin>>p>>s; if(s=="AC"&&aa[p]==0){ aa[p]++; a++; w+=ww[p]; } else{ ww[p]++; } } cout<<a<<" "<<w<<endl; return(0); }
CPP
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
#include<bits/stdc++.h> using namespace std; int wrong[100005]; int accepted[100005]; int main() { int N,M,correct=0,penalty=0;cin>>N>>M; for(int i=1;i<=M;i++) { int p;string s;cin>>p>>s; if(accepted[p]) continue; if(s=="AC") { accepted[p]++; correct++; penalty += wrong[p]; } else if(s=="WA") { wrong[p]++; } } cout<<correct<<" "<<penalty<<"\n"; return 0; }
CPP
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
import sys from collections import defaultdict N,M=map(int, sys.stdin.readline().split()) ac=set() wa=defaultdict(lambda: 0) wa_cnt=0 for _ in range(M): p,s=sys.stdin.readline().split() if s=="AC": ac.add(p) if wa[p] != "Done": wa_cnt+=wa[p] wa[p]="Done" elif s=="WA": if wa[p] != "Done": wa[p]+=1 print len(ac),wa_cnt
PYTHON
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
# 2020/01/12 n,m=map(int,input().split()) ps=[0]*(n+1) ac=0 wa=0 for i in range(m): p,s=input().split() p=int(p) if ps[p]>0:continue if s=='WA': ps[p]-=1 else: wa+=-ps[p] ps[p]=1 ac+=1 print(*[ac,wa])
PYTHON3
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
import java.util.Scanner; public class Main { public static void main(String...args){ Scanner scanner=new Scanner(System.in); int N =scanner.nextInt(); int M =scanner.nextInt(); int[] penaltyCount=new int[N+1]; int penalty=0; int win=0; for(int i=0; i<M; i++){ int p=scanner.nextInt(); String result=scanner.next(); if(penaltyCount[p]==-1){ continue; } if(result.equals("WA")){ penaltyCount[p]++; }else{ win++; penalty=penalty+penaltyCount[p]; penaltyCount[p]=-1; } } System.out.println(win+" "+penalty); } }
JAVA
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
import java.util.Scanner; public class Main { public static void main(String[] args) { // ABC151C - Welcome to AtCoder Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); int[] p = new int[m]; String[] s = new String[m]; int[] ac = new int[n]; int[] wa = new int[n]; int acCnt = 0; int waCnt = 0; for (int i = 0; i < m; i++) { p[i] = sc.nextInt(); s[i] = sc.next(); if (s[i].equals("AC")) { if (ac[p[i] - 1] == 0) { acCnt++; waCnt += wa[p[i] - 1]; } ac[p[i] - 1]++; } else { if (ac[p[i] - 1] == 0) { wa[p[i] - 1]++; } } } System.out.println(acCnt + " " + waCnt); } }
JAVA
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
import java.util.*; import java.math.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); int[] p = new int[m]; String[] s = new String[m]; int w = 0; int a = 0; int[] data = new int[100001]; if (m != 0) { for (int i = 0; i < m; i++) { p[i] = sc.nextInt(); s[i] = sc.next(); } for (int i = 0; i < m; i++) { if (s[i].equals("WA") && data[p[i]]>=0) { data[p[i]]++; } else if (s[i].equals("AC") && data[p[i]]>=0) { a++; w += data[p[i]]; data[p[i]] = -1; } } } System.out.println(a+" "+w); } }
JAVA
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
n,m=map(int,input().split()) x=[True]*n cnt=[0]*n y=0 z=0 for i in range(m): p,s=input().split() if s=="AC": x[int(p)-1]=False elif x[int(p)-1]: cnt[int(p)-1]+=1 for i in range(n): if x[i]==False: z+=cnt[i] y+=1 print(y,z)
PYTHON3
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
#include<iostream> using namespace std; int main() { int n,m; cin>>n>>m; int j,i,a[n],w[n]; char v[3]; for(i=0;i<n;i++){a[i]=0;w[i]=0;} for(i=0;i<m;i++) { cin>>j>>v; j--; if(v[0]=='A')a[j]=1; else if(a[j]==0)w[j]++; } int p=0,c=0; for(i=0;i<n;i++) { if(a[i]==1) { c++; p+=w[i]; } } cout<<c<<" "<<p; }
CPP
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
#include <iostream> using namespace std; int main() { int n, m, p, ac = 0, wa = 0; string s; cin >> n >> m; int q[n+1]; for(int i=0; i<n+1; i++) { q[i] = 0; } for(int i=0; i<m; i++) { cin >> p >> s; if (q[p] == -1) continue; if (s == "WA") { q[p]++; } else { ac++; wa += q[p]; q[p] = -1; } } cout << ac << ' ' << wa << endl; return 0; }
CPP
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); sc.nextLine(); boolean[] answer = new boolean[n]; for(int i=0;i<n;i++) { answer[i] = false; } int[] wacount = new int[n]; for(int i=0;i<n;i++) { wacount[i] = 0; } int wacountsum = 0; for(int i=0;i<m;i++) { int p = sc.nextInt(); String s = sc.next(); sc.nextLine(); if(s.equals("AC") && !(answer[p-1])) { answer[p-1] = true; wacountsum += wacount[p-1]; } else if(s.equals("WA") && !(answer[p-1])) { wacount[p-1]++; } else { } } int correctnum = 0; for(int i=0;i<n;i++) { if(answer[i]) { correctnum++; } } System.out.println(correctnum + " " + wacountsum); } }
JAVA
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
import java.util.Scanner; public class Main { public static final MyScanner in = new MyScanner(); public static void main(String[] args) { final String AC = "AC"; final String WA = "WA"; int N = in.nextInt(); int M = in.nextInt(); boolean[] accepteds = new boolean[N]; int[] waCnts = new int[N]; int acCnt = 0; int waCnt = 0; for(int i=0; i < M; i++) { if (acCnt == N) break; int p = in.nextInt(); boolean isAc = in.next().equals(AC); int idx = p-1; if (accepteds[idx]) continue; if (isAc) { acCnt++; waCnt += waCnts[idx]; accepteds[idx] = true; } else { waCnts[idx]++; } } System.out.println(acCnt + " " + waCnt); } public static class MyScanner{ Scanner sc = new Scanner(System.in); String nextLine() {return sc.nextLine();} String next() {return sc.next();} int nextInt() {return Integer.valueOf(sc.next());} long nextLong() { return Long.valueOf(sc.next());} } }
JAVA
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
#include<cstdio> #include<algorithm> using namespace std; int flg[100001]={0},cnt[100001]={0}; int main(void) { int n,m,p,i,wa,ac; char s[3]; scanf("%d %d",&n,&m); wa=0; ac=0; for(i=0;i<m;i++){ scanf("%d %s",&p,s); if(flg[p]==0&&s[0]=='W'){ cnt[p]++; } if(flg[p]==0&&s[0]=='A'){ flg[p]=1; ac++; wa+=cnt[p]; } } printf("%d %d\n",ac,wa); return 0; }
CPP
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
N, M = map(int, input().split()) AC, WA, C = 0, 0, [0] * N for _ in range(M): p, S = input().split() p = int(p) - 1 if C[p] >= 0: if S == 'AC': AC, WA, C[p] = AC + 1, WA + C[p], -1 else: C[p] += 1 print(AC, WA)
PYTHON3
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
import java.util.Scanner; public class Main { public static void main (String args[]) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); int m = scan.nextInt(); int p[] = new int[n]; int s[] = new int[n]; int ok = 0; int ng = 0; for(int i = 0; i < m; i++) { int pn = scan.nextInt() -1; String sn = scan.next(); if(p[pn] == 1) { continue; } else { if(sn.equals("AC")) { p[pn] = 1; } else { s[pn]++; } } } for(int i = 0; i < n; i++) { if(p[i] == 1) { ok++; ng = ng + s[i]; } } System.out.println(ok + " " + ng); } }
JAVA
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
#include <bits/stdc++.h> using namespace std; int main() { int n, m; scanf("%d%d", &n, &m); map<int, char> mp; map<int, int> cnt; int ans1 = 0, ans2 = 0; for (int i = 0; i < m; i++) { int p; scanf("%d", &p); char c; scanf(" %c%*c", &c); if (c == 'A') { if (mp[p] == 'A') continue; mp[p] = 'A'; ans1++; ans2 += cnt[p]; } else cnt[p]++; } printf("%d %d\n", ans1, ans2); }
CPP
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
import java.util.Scanner; public class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); // get value from StandardIn int prob = sc.nextInt(); int post = sc.nextInt(); int accept = 0; int wrong = 0; int wrongCount[] = new int[prob]; boolean result[] = new boolean[prob]; for(int i=0;i<prob;i++){ result[i] = false; wrongCount[i] = 0; } int num; String res; for(int i=0;i<post;i++){ num = sc.nextInt(); res = sc.next(); if(result[num-1] == false && res.equals("AC")){ result[num-1] = true; accept++; wrong += wrongCount[num-1]; }else if(result[num-1] == false && res.equals("WA")){ wrongCount[num-1] ++; } } System.out.println(accept + " " + wrong); } }
JAVA
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int m=sc.nextInt(); boolean[] x=new boolean[n+1]; Arrays.fill(x,false); int[] y=new int[n+1]; int sum=0,num=0; for(int i=0;i<m;i++) { int a=sc.nextInt(); String s=sc.next(); if(s.equals("AC")) { x[a]=true; }else { if(!x[a]) y[a]++; } } for(int i=0;i<n+1;i++) { if(x[i]) num+=y[i]; if(x[i]) sum++; } System.out.print(sum+" "+num); } }
JAVA
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
n,m=map(int,input().split()) ac=[0]*(n+1) wa=[0]*(n+1) for i in range(m): a,b=map(str,input().split()) a=int(a) if ac[a]==0: if b=='WA': wa[a]+=1 else: ac[a]=1 print(sum(ac)) ans=0 for i in range(n+1): if ac[i]==1: ans+=wa[i] print(ans)
PYTHON3
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
N,M=map(int, input().split()) a=[0]*(N+1) w=[0]*(N+1) for _ in range(M): p,s=input().split() p=int(p) if s=='AC': a[p]=1 else: if a[p]==0: w[p]+=1 a2=0 w2=0 for n in range(N+1): if a[n]==1: a2+=a[n] w2+=w[n] print(a2, w2)
PYTHON3
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
import java.util.*; public class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); String[] S = sc.nextLine().split(" "); int N = Integer.parseInt(S[0]); int M = Integer.parseInt(S[1]); boolean[] check = new boolean[N]; int[] sum_wa = new int[N]; int ac = 0, wa = 0; for(int i = 0; i < M; i++){ String[] T = sc.nextLine().split(" "); int A = Integer.parseInt(T[0])-1; if(!check[A]){ if(T[1].equals("WA")){ sum_wa[A]++; }else{ check[A]= true; } } } for(int i = 0; i < N; i++){ if(check[i]){ ac++; wa += sum_wa[i]; } } System.out.println(ac+" "+wa); } }
JAVA
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
import java.util.*; public class Main { public static void main(String args []){ Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int M = sc.nextInt(); int [] OPT = new int[N+1]; int [] check = new int[N+1]; int AC_sum = 0; int WA_sum = 0; for(int i=0;i<=N;i++){ OPT[i]=0; check[i]=0; } for(int i=0;i<M;i++){ int p = sc.nextInt(); String s = sc.next(); if(s.charAt(0)=='A'&&OPT[p]==0) OPT[p]=1; else if(s.charAt(0)=='W'&& OPT[p]==0) check[p]++; } for(int i=1;i<=N;i++){ if(OPT[i]==1){ WA_sum+=check[i]; AC_sum++; } } System.out.print(AC_sum+" "+WA_sum); } }
JAVA
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
f=lambda:input().split() n,m=map(int,f()) sa,lw=set(),[0]*n for _ in range(m): p,s=f() if p in sa: continue if s=='AC': sa.add(p) else: lw[int(p)-1]+=1 print(len(sa),sum(lw[int(p)-1] for p in sa))
PYTHON3
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
import java.util.*; import java.math.*; public class Main{ public static void main(String[] args){ Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int m=sc.nextInt(); int[] p=new int[m]; String[] s=new String[m]; for(int i=0; i<m; i++){ p[i]=sc.nextInt()-1; s[i]=sc.next(); } int t=0; int f=0; boolean[] tf=new boolean[n]; int[] countf=new int[n]; for(int i=m-1; i>=0; i--){ if(s[i].equals("AC")){ if(!tf[p[i]]){ tf[p[i]]=true; t++; }else{ countf[p[i]]=0; } }else if(tf[p[i]] && s[i].equals("WA")){ countf[p[i]]++; } } for(int i=0; i<n; i++){ f+=countf[i]; } System.out.println(t+" "+f); } }
JAVA
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
n,m=[int(x) for x in input().split()] ac=[0]*n wa=[0]*n a=0 b=0 for i in range(m): P,s=input().split() p=int(P)-1 if s=="AC": if ac[p]==0: ac[p]=1 a+=1 b+=wa[p] else: if ac[p]==0: wa[p]+=1 print(a,b)
PYTHON3
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
n,m=map(int,input().split()) x=[list(input().split()) for i in range(m)] a=0 p=0 x.sort(key=lambda x:x[0]) t='a' for i in range(m): if t!=x[i][0]: w=0 t=x[i][0] f=1 if f: if x[i][1]=='AC': a+=1 p+=w f=0 else: w+=1 print(a,p)
PYTHON3
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
N, M = map(int, input().split()) ac = 0 wa = 0 ref = [0] * N for i in range(M): p, s = map(str, input().split()) p = int(p) - 1 if ref[p] != -1: if s == 'WA': ref[p] += 1 else: wa += ref[p] ac += 1 ref[p] = -1 print(ac, wa)
PYTHON3
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
#include <bits/stdc++.h> using namespace std; bool vis[100010]; int p[100010]; int main() { ios::sync_with_stdio(false); int n,m,cnt=0,ans=0; cin>>n>>m; for(int i=1;i<=m;i++){ int x;string s; cin>>x>>s; if(vis[x]) continue; if(s=="AC"){ vis[x]=1; cnt++; ans+=p[x]; } else{ p[x]++; } } cout<<cnt<<" "<<ans<<endl; return 0; }
CPP
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
import java.util.*; class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int M = sc.nextInt(); int[] wa = new int[N]; boolean[] clear = new boolean[N]; int waCnt = 0; int ac = 0; for (int i=0; i<M; i++) { int p = sc.nextInt() - 1; String s = sc.next(); if (!clear[p]) { if (s.equals("AC")) { clear[p] = true; waCnt += wa[p]; ac++; } else { wa[p]++; } } } System.out.println(ac + " " + waCnt); } }
JAVA
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
N,M=map(int,input().split()) t=[0]*(N+1) e=[0]*(N+1) for i in range(M): p,s=input().split() if t[int(p)]==0 and s=="WA": e[int(p)]+=1 if t[int(p)]==0 and s=="AC": t[int(p)]=1 for i in range(N+1): if t[i]==0: e[i]=0 print(sum(t),sum(e))
PYTHON3
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
#include <bits/stdc++.h> using namespace std; int main(){ int N, M; cin >> N >> M; bool ok[100010] = {}; int cnt[100010] = {}; int ac = 0; int pn = 0; for(int i = 0; i < M; i++){ int p; string s; cin >> p >> s; if(ok[p]) continue; else if(s == "AC"){ ok[p] = true; ac ++; pn += cnt[p]; } else if(s == "WA") cnt[p] ++; } cout << ac << " " << pn << endl; }
CPP
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
N,M=map(int,input().split()) ac,wa=0,0 task=[0]*N for m in range(M): p,S=input().split() p=int(p)-1 if task[p]!=-1 and S=="WA": task[p]+=1 elif task[p]!=-1 and S=="AC": ac+=1 wa+=task[p] task[p]=-1 print(ac,wa)
PYTHON3
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
#include <bits/stdc++.h> using namespace std; int main() { int n,m,p,ansa=0,ansb=0; string s; cin>>n>>m; int ac[n]; int pen[n]; for(int i=0;i<n;i++) ac[i]=pen[i]=0; for(int i=0;i<m;i++){ cin>>p>>s; p--; if(s=="WA"){ pen[p]++; }if(s=="AC"&&!ac[p]){ ac[p]=1; ansa++; ansb+=pen[p]; } } cout<<ansa<<" "<<ansb; }
CPP
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
#include<bits/stdc++.h> using namespace std; int n,m; int p; char s[22]; int cnt[100100][2]; int ac; int pm; int main() { scanf("%d%d",&n,&m); for(int i=1;i<=m;++i) { scanf("%d%s",&p,s); if(s[0]=='A') { cnt[p][1]++; if(cnt[p][1]==1)ac++,pm+=cnt[p][0]; } else cnt[p][0]++; } printf("%d %d\n",ac,pm); return 0; }
CPP
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
import java.util.ArrayList; import java.util.Scanner; public class Main { private static ArrayList<Integer> rightAnswers = new ArrayList<>(); public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); int penalty = 0; int correct = 0; int[] wrong = new int[n + 1]; while (m-- > 0) { int p = sc.nextInt(); String s = sc.next(); if (wrong[p] == -1) continue; if (s.equals("WA")) wrong[p]++; else { correct++; penalty += wrong[p]; wrong[p] = -1; } } System.out.println(correct + " " + penalty); } }
JAVA
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
n,m=map(int,input().split()) l=[0]*n w=0 c=0 ac=set() for i in range(m): p,s=map(str,input().split()) p=int(p) if s=='WA': l[p-1]+=1 else: if p not in ac: c+=1 w+=l[p-1] ac.add(p) print(c,w)
PYTHON3
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
import java.util.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int M = sc.nextInt(); int[] ACcounter = new int[N]; int[] WAcounter = new int[N]; int AC = 0; int WA = 0; for(int i = 0; i < M; i++){ int p = sc.nextInt(); String S = sc.next(); if(S.equals("WA") && ACcounter[p-1] == 0){ WAcounter[p-1]++; } if(S.equals("AC")){ ACcounter[p-1] = 1; } } for(int i = 0; i < N; i++){ AC += ACcounter[i]; if(ACcounter[i] == 1){ WA += WAcounter[i]; } } System.out.println(AC + " " + WA); } }
JAVA
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
[n,m] = [int(x) for x in input().split()] ac=[0]*(n+1) wa=[0]*(n+1) cnt_ac=0 cnt_wa=0 for i in range(m): p,s=input().split() p=int(p) if s=="AC": if ac[p]==0: cnt_ac+=1 cnt_wa+=wa[p] ac[p]=1 else: wa[p]+=1 print(int(cnt_ac),int(cnt_wa))
PYTHON3
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
#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
PYTHON
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); int[] p = new int[m]; String[] s = new String[m]; for (int i = 0; i < m; i++) { p[i] = sc.nextInt(); s[i] = sc.next(); } int ac = 0; int wa = 0; boolean[] solved = new boolean[n]; int[] numOfWa = new int[n]; for (int i = 0; i < m; i++) { if (solved[p[i] - 1]) { continue; } if ("AC".equals(s[i])) { ac++; solved[p[i] - 1] = true; wa += numOfWa[p[i] - 1]; } else { numOfWa[p[i] - 1]++; } } System.out.println(ac + " " + wa); } }
JAVA
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); int[][] data = new int[n][2]; for (int i=0;i<m;i++){ int p = sc.nextInt()-1; String s = sc.next(); if (data[p][0]==0&&s.equals("WA")){ data[p][1]++; }else if (data[p][0]==0&&s.equals("AC")){ data[p][0]++; } } int ac=0; int wa=0; for (int i=0;i<n;i++){ ac+=data[i][0]; if (data[i][0]==1)wa+=data[i][1]; } System.out.println(ac+" "+wa); } }
JAVA
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
import java.util.Scanner; public class Main { public static void main(String[] args) { @SuppressWarnings("resource") Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); int[] p = new int[m]; String[] s = new String[m]; for (int i = 0 ; i < m ; i++) { p[i] = sc.nextInt() - 1; s[i] = sc.next(); } int[][] a = new int[2][n]; for (int i = 0 ; i < m ; i++) { if (s[i].equals("WA") && a[1][p[i]] == 0) { a[0][p[i]]++; } if (s[i].equals("AC") && a[1][p[i]] == 0) { a[1][p[i]]++; } } int ac = 0; int wa = 0; for (int i = 0 ; i < n ; i++) { ac += a[1][i]; if (a[1][i] == 1) { wa += a[0][i]; } } System.out.println(ac + " " + wa); } }
JAVA
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
N,M=map(int,input().split()) res=[0]*N ac,wa=0,0 for i in range(M): p,s=input().split() p=int(p)-1 if res[p]==-1: continue else: if s=="AC": wa+=res[p] res[p]=-1 ac+=1 else: res[p]+=1 print(ac,wa)
PYTHON3
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
N,M = map(int,input().split()) AC = N*[0] WA = N*[0] for m in range(M): P,S = input().split() P = int(P)-1 if AC[P]==1: continue if S=="WA": WA[P]+=1 else: AC[P]=1 wa = 0 for a,w in zip(AC,WA): wa+=w*a print(sum(AC),wa)
PYTHON3
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
n, m = map(int, input().split()) ac = [0] * n wa = [0] * n for i in range(m): p, s = input().split() p = int(p)-1 if not ac[p]: if s=="AC": ac[p] = 1 else: wa[p] += 1 was = 0 for i in range(n): if ac[i]: was += wa[i] print(sum(ac), was)
PYTHON3
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
import java.util.*; public class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(),m=sc.nextInt(); int[] p = new int[m]; String[] q = new String[m]; for(int i = 0;i<m;i++){ p[i] = sc.nextInt(); q[i] = sc.next(); } int[] ac = new int[100000]; int[] wc = new int[100000]; for(int i =0;i<100000;i++){ ac[i]=0; wc[i]=0; } for(int i = 0;i<m;i++){ if(q[i].equals("AC")){ ac[p[i]] = 1; }else if(ac[p[i]]!=1){ wc[p[i]] += 1; } } int acsum = 0,wcsum = 0; for(int i =0;i<100000;i++){ if(wc[i]!=0&&ac[i]==0){ wc[i] = 0; } } for(int i =0;i<100000;i++){ acsum += ac[i]; wcsum += wc[i]; } System.out.println(acsum +" "+wcsum); } }
JAVA
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
import java.util.Scanner; public class Main { static boolean[] acFlag; static int[] waAry; public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); acFlag = new boolean[n]; waAry = new int[n]; int m = sc.nextInt(); for(int i = 0; i < m; i++){ int num = sc.nextInt() - 1; String s = sc.next(); if(! acFlag[num]){ if("AC".equals(s)){ acFlag[num] = true; }else{ waAry[num]++; } } } int acNum = 0; int waNum = 0; for(int i = 0; i < n; i++){ if(acFlag[i]){ acNum++; waNum += waAry[i]; } } System.out.println(acNum + " " + waNum); } }
JAVA
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); final int N = scanner.nextInt(); final int M = scanner.nextInt(); boolean[] isAC = new boolean[N]; int[] penalty = new int[N]; int numAC = 0; int sumPenalty = 0; int p; String resultString; for (int i = 0; i < M; i++) { p = scanner.nextInt() - 1; resultString = scanner.next(); if (!isAC[p]) { if (resultString.equals("AC")) { isAC[p] = true; numAC++; sumPenalty += penalty[p]; } else { penalty[p]++; } } } System.out.println(numAC + " " + sumPenalty); } }
JAVA
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
#include <bits/stdc++.h> using namespace std; int a[100001]; int main(){ int n, m; cin >> n >> m; int p = 0, ac = 0; while(m--){ int x; string s; cin >> x >> s; if(s == "WA"){ if(a[x] == -1)continue; a[x]++; }else{ if(a[x] == -1)continue; p += a[x]; a[x] = -1; ac++; } } cout << ac << " " << p << endl; }
CPP
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
#include<bits/stdc++.h> #define ll long long using namespace std; int N,M,AC=0,WA=0,a; string b; int cnt[100001], condi[100001]; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cin>>N>>M; for(int i=1;i<=M;i++){ cin>>a>>b; if(condi[a]) continue; if(b[0]=='A') condi[a]=1; else cnt[a]++; } for(int i=1;i<=N;i++){ if(condi[i]){ AC++; WA+=cnt[i]; } } cout<<AC<<' '<<WA; }
CPP
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
import java.io.FileNotFoundException; import java.util.Scanner; public class Main { public static void main(String[] args) throws FileNotFoundException { // File file = new File("src/in.txt"); // Scanner sc = new Scanner(file); Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int M = sc.nextInt(); int ac = 0; int[] wa = new int[N]; boolean[] result = new boolean[N]; for (int i = 0; i < N; i++) { result[i] = false; } if (M == 0) { } else { for (int i = 0; i < M; i++) { int p = sc.nextInt(); String S = sc.next(); if (S.equals("AC")) { if (result[p - 1] == false) { result[p - 1] = true; ac++; } } else { if (result[p - 1] == false) { wa[p-1]++; } } } } int WA = 0; for(int i=0;i<N;i++) { if(result[i]==true) { WA += wa[i]; } } System.out.println(ac + " " + WA); } }
JAVA
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
#include<bits/stdc++.h> using namespace std; int main() { int x=0 ,y=0,m,n,i,j,k; cin >> n >> m; string s; map<int,int>mp,mp1; for(i = 0 ;i<m ;i++) { cin >> k >>s; if(s == "AC" && mp1[k]==0) { x++;y+=mp[k]; mp1[k]=1; } else mp[k]++; } cout<<x<<" "<<y<<endl; }
CPP
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
#include<iostream> #include<vector> using namespace std; int main() { int n, m, awa = 0, aac = 0; cin >> n >> m; vector<bool>is_ac(n, false); vector<int>wa(n, 0); for (int i = 0; i < m; i++) { int p; string s; cin >> p >> s; p--; if (!is_ac[p]) { if (s[0] == 'A') { is_ac[p] = true; aac += 1; awa += wa[p]; } else { wa[p]++; } } } cout << aac << " " << awa << endl; }
CPP
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
#include<iostream> using namespace std; int ans,cnt; int N,M; int used[1<<17]; int main() { cin>>N>>M; for(int i=0;i<M;i++) { int p;string s; cin>>p>>s; if(s=="AC") { if(used[p]>=0) { cnt+=used[p]; used[p]=-1; ans++; } } else { if(used[p]>=0) { used[p]++; } } } cout<<ans<<" "<<cnt<<endl; }
CPP
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
import java.io.InputStream; import java.io.PrintStream; import java.util.*; public class Main { public static void main(String[] args) throws Exception { solve(System.in, System.out); } static void solve(InputStream is, PrintStream os) { // Your code here! Scanner scan = new Scanner(is); int N = scan.nextInt(); int M = scan.nextInt(); boolean[] isCorrect = new boolean[N]; int correct = 0; int wa = 0; int wrong[] = new int[N]; for(int i = 0; i < M; i++){ int p = scan.nextInt()-1; String str = scan.next(); if(isCorrect[p]) continue; if(str.equals("AC")){ isCorrect[p] = true; correct++; wa += wrong[p]; } else { wrong[p]++; } } os.println(correct + " " + wa); } }
JAVA
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int M = sc.nextInt(); int a[] = new int[N]; int penality = 0; for (int i=0;i<M;i++) { int temp = sc.nextInt(); String result = sc.next(); if (result.equals("WA")) { if (a[temp-1]<=0) { a[temp-1]--; } } else { if (a[temp-1]<0) { penality +=-a[temp-1]; } a[temp-1]=1; } } int correct=0; for (int i=0;i<N;i++) { if (a[i]>0) { correct++; } } System.out.println(correct+" "+penality); } }
JAVA
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
n,m=map(int,input().split()) acs=[0]*n was=[0]*n WA=0 for i in range(m): p,s=input().split() p=int(p) if acs[p-1]==0: if s=="AC": acs[p-1]=1 WA+=was[p-1] else: was[p-1]+=1 print(sum(acs),WA)
PYTHON3
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
import java.util.Scanner; public class Main { protected static final String CORRECT = "AC"; protected static final String WRONG = "WA"; public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int N = scanner.nextInt(); int M = scanner.nextInt(); int[] missions = new int[N]; int[] scores = new int[N]; int correctRes = 0; int penaltiesRes = 0; for (int i = 0; i < M; i++) { int num = scanner.nextInt() - 1; String score = scanner.next(); if (scores[num] == 1) { }else if (score.equals(CORRECT)) { correctRes ++; scores[num] = 1; }else { missions[num] ++; } } for (int i = 0; i < N; i++) { if (scores[i] == 1) { penaltiesRes += missions[i]; } } System.out.println(correctRes); System.out.println(penaltiesRes); scanner.close(); } }
JAVA
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
#include<bits/stdc++.h> using namespace std; int main(){ long long i,N,M,p,wa,ac; string s; cin>>N>>M; ac=wa=0; vector<long long> vec(N+1,0); vector<long long> vec_wa(N+1,0); for(i=0;i<M;i++){ cin>>p>>s; if(vec.at(p)!=0) continue; if(s=="AC"){ ac++; wa+=vec_wa.at(p); vec.at(p)=1; } else{ vec_wa.at(p)++; } } cout<<ac<<" "<<wa; }
CPP
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
N,M=map(int,input().split()) A=[0]*N B=[0]*N pen=0 for i in range(M): p,S=input().split() if S=="AC": A[int(p)-1]=1 elif S == "WA" and A[int(p)-1] == 0: B[int(p)-1] += 1 penalty=[A[i]*B[i] for i in range(N)] print(sum(A),sum(penalty))
PYTHON3
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder
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. 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. Examples Input 2 5 1 WA 1 AC 2 WA 2 AC 2 WA Output 2 2 Input 100000 3 7777 AC 7777 AC 7777 AC Output 1 0 Input 6 0 Output 0 0
6
0
import java.util.HashSet; import java.util.Scanner; import java.util.Set; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); // problems int M = sc.nextInt(); // submissions Set<Integer> s = new HashSet<>(); int[] a = new int[N+1]; int wa = 0; int ac = 0; for (int i = 0; i < M; i++) { int problemId = sc.nextInt(); String ans = sc.nextLine().trim(); if (!s.contains(problemId)) { if ("AC".equals(ans)) { ac++; wa += a[problemId]; s.add(problemId); } else { a[problemId]++; } } } System.out.println(ac + " " + wa); } }
JAVA