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.Scanner; public class Main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); boolean[] ac = new boolean[n]; int[] wa = new int[n]; for(int i= 0; i < n; i++) { ac[i] = false; wa[i] = 0; } for(int i = 0; i < m; i++) { int sub = sc.nextInt()-1; String result = sc.next(); if(ac[sub]) { continue; } else { if(result.equals("AC")) { ac[sub]=true; } else { wa[sub]++; } } } int ac_count=0; int wa_count = 0; for(int i = 0; i < n; i++) { if(ac[i]) { ac_count++; wa_count+=wa[i]; } } System.out.println(ac_count+" "+wa_count); } }
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 WA = [0]*N wa = 0 for i in range(M): j, res = input().split() j = int(j)-1 if AC[j] == 0 and res == "AC": AC[j] = 1 wa += WA[j] WA[j] += 1 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
import java.util.Scanner; public class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); int numberOfProblems = sc.nextInt(); int numberOfSubmissions = sc.nextInt(); int[] wa = new int[numberOfProblems+1]; int correct =0, penalties = 0; while (numberOfSubmissions-->0){ int indexOfQuestion = sc.nextInt(); String result = sc.next(); if(wa[indexOfQuestion]==-1){ continue; } if(result.equals("WA")){ wa[indexOfQuestion]++; }else { correct++; penalties += wa[indexOfQuestion]; wa[indexOfQuestion] = -1; } } System.out.println(correct+ " "+penalties); } }
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; typedef long long ll; const int maxn = 1e5+5; set<int> st; string s; int n,m,p[maxn],re1,re2; bool vis[maxn]; int main() { cin>>n>>m; for(int i=0;i<m;i++) { int x; cin>>x>>s; if(s=="AC")if(!vis[x]) { vis[x]=1; re1++; re2+=p[x]; } if(s=="WA"&&!vis[x]) { p[x]++; } } cout<<re1<<' '<<re2; 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=[0]*n, [0]*n ac, wa=0, 0 for _ in range(m): p, s=list(map(str, input().split())) p=int(p)-1 if AC[p]==0 and s=='WA': WA[p]+=1 elif AC[p]==0 and s=='AC': AC[p]=1 wa+=WA[p] 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; class Main { public static void main(String... args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); int m = scan.nextInt(); int acCnt = 0; int ngCnt = 0; int[] ng = new int[n + 1]; boolean[] ok = new boolean[n + 1]; for(int i = 0; i < m; i++) { int p = scan.nextInt(); String s = scan.next(); if(!ok[p] && s.equals("AC")) { ok[p] = true; }else if(!ok[p] && s.equals("WA")) { ng[p]++; } } for(int i = 1; i <= n; i++) { if(ok[i]) { acCnt++; ngCnt += ng[i]; } } System.out.println(acCnt + " " + ngCnt); } }
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); //List<String> list=new ArrayList<String>(Arrays.asList(s.split(""))); //List<Integer> list_ac=new ArrayList<Integer>(); //List<Integer> list_wa=new ArrayList<Integer>(); //int[] array_k = new int[100000]; int n = sc.nextInt(); int m = sc.nextInt(); int[] array_ac = new int[n+1]; int[] array_wa = new int[n+1]; for(int i=0;m>i;i++) { int p = sc.nextInt(); String s = sc.next(); if(s.equals("AC")){ array_ac[p] = 1; } else { if(array_ac[p] != 1) { array_wa[p]++; } } } int ac =0; int wa =0; for(int i=0;n+1>i;i++) { if(array_ac[i]==1) ac++; if(array_wa[i]>=1) if(array_ac[i]==1) wa=wa+array_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
n,m = map(int,input().split()) ac = [0 for _ in range(n)] wa = [0 for _ in range(n)] for _ in range(m): a,b = input().split() a = int(a) - 1 if b == 'AC': ac[a] = 1 elif ac[a] == 0: wa[a] += 1 w = 0 for i in range(n): w += ac[i] * wa[i] print(sum(ac),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
n,m=map(int,input().split()) AC=[0]*(n+1) pen=[0]*(n+1) for i in range(m): p,s=input().split() p=int(p) if s=="AC": AC[p]=1 else: if AC[p]==0: pen[p]+=1 print(sum(AC),sum([AC[i]*pen[i] for i in range(n+1)]))
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 sc = new Scanner(System.in); int N = sc.nextInt(); int M = sc.nextInt(); int[] p = new int[M]; int[] c = new int[N]; int[] b = new int[N]; int s = 0; int n = 0; for(int i=0; i<M; i++) { p[i] = (sc.nextInt()-1); String a = sc.next(); if(b[p[i]] == 0) { if(a.equals("WA") ){ c[p[i]]++; }else{ b[p[i]]=1; } } } sc.close(); for(int i=0; i<N; i++) { if(b[i]==1) { s++; n += c[i]; } } if(n<0) n=0; System.out.println(s + " " + n); } }
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.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.Map; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long N = sc.nextLong(), M = sc.nextLong(); Map<Long,ArrayList<String>> map = new HashMap<>(); if(M == 0) System.out.println(0 +" " + 0); else { for(int i = 0; i < M; i ++) { long c = sc.nextLong(); String str = sc.next(); if(map.containsKey(c)) { map.get(c).add(str); }else { map.put(c, new ArrayList<String>(Arrays.asList(str))); } } long ac = 0, wa = 0; for(long l : map.keySet()) { ArrayList<String> ar = map.get(l); if(ar.contains("AC")) { long a = ar.indexOf("AC"); wa += a; ac++; } } 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 N , M; cin >> N >> M; vector<int>wakaisuu(N,0); vector<int>ackaisuu(N,0); int ac,pen; ac = 0; pen = 0; for (int i=0; i < M; i++){ int p; string s; cin >> p >> s; if (s == "AC"){ if (ackaisuu.at(p-1)==0){ac++; ackaisuu.at(p-1) ++; pen += wakaisuu.at(p-1);} } else{wakaisuu.at(p-1) ++;} } cout << ac << ' ' << 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; typedef long long ll; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) ll ans = 0; ll anss = 0; int main() { ll n , m ; cin >> n >> m ; vector<ll> v(n+1); rep(i,m){ ll a ; string b ; cin >> a >> b ; if(v[a]>=0&&b=="WA")v[a]++; if(v[a]>=0&&b=="AC"){anss+=v[a];ans++;v[a]=-1;} } cout << ans<<' '<<anss << 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
n,m = map(int, input().split()) ac = [0]*n wa = [0]*n ans = 0 for i in range(m): p, s = input().split() p = int(p) - 1 if s == 'AC' and ac[p] == 0: ac[p] = 1 ans += wa[p] wa[p] += 1 print(sum(ac), 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
import sys input=sys.stdin.readline a=b=0 n,m=map(int,input().split()) ans=[0]*n for i in range(m): p,s=input().rstrip().split() p=int(p) if ans[p-1]<=0: if s=="AC": a+=1 b+=-ans[p-1] ans[p-1]=1 else: ans[p-1]-=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
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 Q[]=new String[M]; int R[] =new int[N]; int S[] =new int[N]; int x=0;int y=0; for(int i=0;i<M;i++){ P[i]=sc.nextInt(); Q[i]=sc.next(); if(R[P[i]-1]==1){continue;} if(Q[i].equals("AC")){ R[P[i]-1]=1;x=x+1;y=y+S[P[i]-1];} else{S[P[i]-1]=S[P[i]-1]+1;}} System.out.println (x+" "+y); } }
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 = (N+1)*[0] wa = (N+1)*[0] pt = 0 for i in range(M): p,s = input().split() p = int(p) if ac[p] == 0 and s == "AC": ac[p] = 1 pt += wa[p] wa[p] += 1 print(sum(ac),pt)
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<cstring> #include<cmath> #include<algorithm> using namespace std; int n,m,c[100005],i,ans1,ans2; char s[10]; bool ok[100005]; int main() { scanf("%d%d",&n,&m); while(m--) { scanf("%d%s",&i,s); if(s[0]=='A') ok[i]=true; else if(!ok[i]) ++c[i]; } for(i=1;i<=n;++i) if(ok[i]) ++ans1,ans2+=c[i]; printf("%d %d",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; #define LL long long #define MN 100005 int n,m; LL sum; char ch[5]; int vis[MN],WA[MN],cnt1,cnt2; int main(){ scanf("%d%d",&n,&m); for(int i=1;i<=m;++i){ char ch[5]; int a; scanf("%d%s",&a,ch); if(ch[0]=='A'&&!vis[a])cnt1++,cnt2+=WA[a],vis[a]=1; else if(ch[0]=='W')WA[a]++; } printf("%d %d\n",cnt1,cnt2); 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.Scanner; import java.util.Arrays; 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[m]; String[] s=new String[m]; int i=0; for(i=0;i<m;i++){ p[i]=scan.nextInt(); s[i]=scan.next(); } int[] a=new int[n]; int[] b=new int[n]; for(i=0;i<n;i++){ a[i]=0; b[i]=0; } for(i=0;i<m;i++){ if(s[i].equals("WA")&&b[p[i]-1]==0){ a[p[i]-1]=a[p[i]-1]+1; } if(s[i].equals("AC")&&b[p[i]-1]==0){ b[p[i]-1]=b[p[i]-1]+1; } } int sum=0; int summ=0; for(i=0;i<n;i++){ if(b[i]==1){ sum=sum+a[i]; } summ=summ+b[i]; } System.out.println(summ+" "+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
n,m=map(int,input().split()) ok=[0]*(n+1) pe=[0]*(n+1) for _ in range(m): q,s=input().split() q=int(q) if s=="WA" and ok[q]==0: pe[q]+=1 else: ok[q]=1 for i in range(n+1): if ok[i]==0: pe[i]=0 print(sum(ok),sum(pe))
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 _ in range(M): p,S=input().split() p=int(p)-1 if S=='AC': ac[p]=1 else: if ac[p]==0: wa[p]+=1 a=0 b=0 for i in range(N): if ac[i]: a+=1 b+=wa[i] 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
#include<iostream> using namespace std; int main(){ int N,M; cin>>N>>M; int C=0,P=0,w[N],p; string S; bool a[N]; for(int i=0;i<N;i++){ a[i]=false; w[i]=0; } for(int i=0;i<M;i++){ cin>>p>>S; if(S=="WA"&&a[p-1]==false){ w[p-1]++; } if(S=="AC"&&a[p-1]==false){ C++; P+=w[p-1]; a[p-1]=true; } } 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
import java.util.HashMap; 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 wa=0; int ac=0; // int a=0; for (int i=0; i<M; i++){ int P = sc.nextInt()-1; String S=sc.next(); if(a[P]==-1){ } else if(S.equals("AC")){ wa=wa+a[P]; ac++; a[P]=-1; } else if(S.equals("WA")){ a[P]++; } } //for (int i=0;i<M;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.Scanner; class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); int c = 0, pen = 0; int[] r = new int[n + 1]; for(int i = 0; i < m; i++){ int p = sc.nextInt(); if(sc.next().equals("WA")){ if(r[p] >= 0)r[p]++; }else{ if(r[p] >= 0){ pen += r[p]; c++; r[p] = -1; } } } System.out.println(c+" "+pen); } }
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=["false"]*N WA=[0]*N wa=0 ac=0 for i in range(M): p,s=input().split() p=int(p) if s=="AC": if AC[p-1]=="false": AC[p-1]="True" ac+=1 wa+=WA[p-1] else: WA[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
import java.util.Scanner; public class Main { public static void main(String[] args) { //input Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); int[] t = new int[n]; int[] f = new int[n]; for (int i = 0; i < m; i++) { int v = sc.nextInt() - 1; String s = sc.next(); if (s.contains("AC")) { t[v] = 1; } else if (t[v] != 1){ f[v] += 1; } } //解析 long ct_t = 0; long ct_f = 0; for (int i = 0; i < n; i++) { ct_t += (t[i] == 0)? 0 : 1; ct_f += (t[i] == 0)? 0 : f[i]; } System.out.println(ct_t + " " + ct_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 = map(int,input().split()) x = [0]*(n+1) t = [0]*(n+1) p=q=0 for i in range(m): k,l = input().split() y=int(k)-1 if x[y]==0: if l=='WA': t[y]+=1 else: q+=t[y] p+=1 x[y]=1 print(p,q)
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; vector <bool> a; vector <int> s; int main() { int n,m; cin >> n >> m; a.assign(n,false); s.assign(n,0); int ac=0,wa=0; int id; string now; for (int i=0; i<m; i++) { cin >> id >> now; id--; if (now=="WA") if (!a[id]) s[id]++; if (now=="AC") if (!a[id]){ ac++; a[id] = true; wa+=s[id];} } 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
#include<iostream> using namespace std; int main(){ int N,M,p,ac=0,wa[100001]={0},sum=0; bool acF[100001]={0}; string S; cin>>N>>M; for(int i=0;i<M;i++){ cin>>p>>S; if(S=="WA"&&acF[p]==false){wa[p]++;} else if(S=="AC"&&acF[p]==false){acF[p]=true;ac++;} } for(int i=1;i<=N;i++){ if(acF[i])sum+=wa[i]; } cout<<ac<<" "<<sum; 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(); Set<Integer> ac = new HashSet<>(); int[] penalty = new int[N]; int total = 0; for (int i = 0; i < M; i++) { int p = sc.nextInt(); String result = sc.next(); if (result.equals("AC")) { if (!ac.contains(p)) { ac.add(p); total+=penalty[p-1]; } } else { if (!ac.contains(p)) { penalty[p-1]++; } } } System.out.println(ac.size() + " " + total); } }
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 s = new Scanner(System.in); int n = s.nextInt(); int m = s.nextInt(); int correct = 0; int penalty = 0; int [] a = new int[n+1]; for(int i = 0; i<m; i++){ int problem = s.nextInt(); String status = s.next(); if(a[problem] == -1){ continue; } if(status.equals("WA")){ a[problem]++; }else{ correct++; penalty = penalty + a[problem]; a[problem] = -1; } } System.out.println(correct); System.out.println(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()) a=[-1]*n for i in range(m): p,s=input().split() p=int(p)-1 if s=="AC" and a[p]<0: a[p] = a[p]*(-1) if s=="WA" and a[p]<0: a[p] -= 1 ac=0 wa=0 for i in range(n): if a[i] > 0: ac += 1 wa += a[i] - 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; const int N=1e5+10; int flag[N],w[N]; int main() { int n,m; cin>>n>>m; string s; int ac=0,wa=0,X; for(int i=0;i<m;i++) { cin>>X; cin>>s; if(flag[X]==0)//û��AC�� { if(s=="AC") { flag[X]=1; ac++; wa+=w[X]; } else w[X]++; } } 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
n,m = map(int,input().split()) L = [0]*n AC = 0 WA = 0 tmp = [0]*n for i in range(m): x,y = input().split() x = int(x) if L[x-1] == 0: if y == "WA": tmp[x-1] += 1 else: AC += 1 WA += tmp[x-1] L[x-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
#include<bits/stdc++.h> using namespace std; int n; int a[100005]; string s; int k; int ans,times; int main() { cin>>n>>n; for(int i=1;i<=n;i++) { cin>>k>>s; if(s[0]=='W'&&a[k]!=-1) a[k]++; if(s[0]=='W'&&a[k]==-1) continue; if(s[0]=='A'&&a[k]!=-1) ans++,times+=a[k],a[k]=-1; if(s[0]=='A'&&a[k]==-1) continue; } cout<<ans<<" "<<times; 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 s=new Scanner(System.in); int n=s.nextInt(),q=s.nextInt(); int[]a=new int[n]; boolean[]b=new boolean[n]; int r=0,p=0; for(int Q=0;Q<q;++Q){ int i=s.nextInt()-1; if(s.next().equals("WA")) ++a[i]; else if(!b[i]){ ++p; r+=a[i]; a[i]=0; b[i]=true; } } System.out.println(p+" "+r); } }
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> #define re register using namespace std; bool v[100002]; char c[1002]; int num[100002]; signed main(){ int n,m,k,a,sum,ans1=0,ans2=0; cin>>n>>m; for(re int i=1;i<=m;++i){ cin>>a>>c; if(v[a])continue; if(c[0]=='W')++num[a]; else ++ans1,v[a]=1; } for(re int i=1;i<=n;++i)if(v[i])ans2+=num[i]; cout<<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
N,M = map(int,input().split()) ac = 0 wa = 0 acs = [0]*(N+1) was = [0]*(N+1) for i in range(M): p,s = input().split() p = int(p) if s == "AC": if acs[p]==0: ac += 1 wa += was[p] acs[p] = 1 else: was[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()) acs=[0]*N was=[0]*N for i in range(M): p,s=input().split() if s=='AC': acs[int(p)-1]=1 else: was[int(p)-1]+=(acs[int(p)-1]!=1) was=[was[i] for i in range(N) if acs[i]==1] print(sum(acs),sum(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
#include <bits/stdc++.h> using namespace std; int main(){ int n, m, ans1=0, ans2=0; cin >> n >> m; vector<int> a(n+1), b(n+1); for(int i = 0; i < m; i++){ int p; cin >> p; string s; cin >> s; if(s=="AC" && !a[p]){ ans1++; a[p]++; ans2 += b[p]; } if(s=="WA" && !a[p]){ b[p]++; } } cout << ans1 << " " << ans2 << 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[] x=new int[n+1]; 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(y[a]==-1) continue; if(s.equals("AC")) { x[a]=1; num+=y[a]; y[a]=-1; }else { y[a]++; } } for(int i=0;i<n+1;i++) { if(x[i]>0) 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
import java.util.Scanner; public class Main { @SuppressWarnings("resource") public static void main(String[] args) { Scanner sc =new Scanner(System.in); int N=sc.nextInt(); int M=sc.nextInt(); int pena=0; int AC=0; boolean flag[]=new boolean[N]; int pena2[]=new int[N]; for(int i=0;i<M;i++) { int p=sc.nextInt(); String S=sc.next(); if(S.equals("WA")) { if(!flag[p-1]) { pena2[p-1]++; } }else { if(!flag[p-1]) { flag[p-1]=true; pena+=pena2[p-1]; AC++;} } } System.out.println(AC+" "+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.Scanner; class Main{ public static void main(String[] args){ Scanner scan=new Scanner(System.in); int pro=scan.nextInt(); int sub=scan.nextInt(); int pronum[]=new int[sub]; String rate[]=new String[sub]; int ACans=0, WAans=0; int WA[]=new int[pro]; boolean flag[]=new boolean[pro]; for(int x=0; x<pro; x++){ flag[x]=true; } if(sub>0){ for(int x=0; x<sub; x++){ pronum[x]=scan.nextInt(); rate[x]=scan.next(); if(flag[pronum[x]-1]){ if(rate[x].equals("AC")){ flag[pronum[x]-1]=false; ACans++; WAans+=WA[pronum[x]-1]; }else { WA[pronum[x]-1]++; } } } } System.out.println(ACans+" "+WAans); } }
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 wa=[0]*N pena=0 acsum=0 for i in range(M): p,S=input().split() p=int(p)-1 if S == 'AC': if ac[p]==0: ac[p]=1 pena+=wa[p] acsum+=1 else: wa[p]+=1 print(acsum,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> using namespace std; int n,m; int ans1,ans2; int pen[100005]; bool ok[100005]; int main(){ scanf("%d%d",&n,&m); for (int i=1;i<=m;i++){ int p; char ch[2]; scanf("%d%s",&p,ch); if (ok[p]) continue; if (ch[0]=='A'){ ok[p]=true; ++ans1; ans2+=pen[p]; } else{ ++pen[p]; } } printf("%d %d",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
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(); if(m == 0) { System.out.println("0 0"); return; } String[][] p = new String[m][2]; for(int i=0; i<m; i++) { p[i][0] = sc.next(); p[i][1] = sc.next(); } boolean[] acA = new boolean[n+1]; int [] waA = new int[n+1]; int wa = 0; int ac = 0; for(int i=0; i<m; i++) { int a = Integer.parseInt(p[i][0]); if(acA[a]) continue; if("WA".equals(p[i][1])) { waA[a]++; }else { ac++; wa += waA[a]; acA[a] = true; } } 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()) ac=[0]*N pn=[0]*N for i in range(M): p,s=input().split() p=int(p) if ac[p-1]==0: if s=="AC": ac[p-1]=1 else: pn[p-1]+=1 pna=0 for i in range(N): if ac[i]==1: pna+=pn[i] print(sum(ac),pna)
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() if(s=="AC"): ac[int(p)-1]=1 else: if(ac[int(p)-1]==0): wa[int(p)-1]+=1 x=sum(ac) y=0 for i in range(n): y+=ac[i]*wa[i] print(x,y)
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,wa; signed main(){ cin>>n>>m; vector<int> v(n,0); for(int i=0;i<m;i++){ int p;string s;cin>>p>>s;p--; if(~v[p]){ if(s=="AC"){ ac++; wa+=v[p]; v[p]=-1; } else v[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
n,m = map(int,input().split()) ls = [0 for _ in range(n+1)] ans = 0 pen = 0 for _ in range(m): p,s = input().split() p = int(p) if ls[p] == None: pass elif s == "WA": ls[p] += 1 else: pen += ls[p] ls[p] = None ans +=1 print(ans,pen)
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 b=[0]*n for i in range(m): p,s=input().split() p=int(p)-1 if a[p]==0: if s=="AC": a[p]=1 else: b[p]+=1 for i in range(n): if a[i]==0: b[i]=0 print(sum(a),sum(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
import java.util.Scanner; public class Main { public static void main(String[] args) { // TODO 自動生成されたメソッド・スタブ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); String p[] = new String[10000000]; int w[] = new int[10000000]; int setsumon[] = new int[10000000]; String answer[] = new String[10000000]; for (int i = 0; i < m; i++) { setsumon[i] = sc.nextInt(); answer[i] = sc.next(); } int seikai = 0; int wrong = 0; for (int i = 0; i < m; i++) { if ("AC".equals(p[setsumon[i] - 1])) { continue; } if (answer[i].equals("AC")) { p[setsumon[i] - 1] = "AC"; seikai++; if (w[setsumon[i] - 1] > 0) { wrong += w[setsumon[i] - 1]; } } else { w[setsumon[i] - 1]++; } } System.out.println(seikai + " " + 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
n,m = map(int, input().split()) ac = [0]*n wa = [0]*n x=0 y=0 for i in range(m): p , s = input().split() p = int(p) if s=='WA' and ac[p-1]==0: wa[p-1]+=1 elif s=='AC' and ac[p-1]==0: ac[p-1]=1 y+=wa[p-1] x+=1 print(x,y)
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 wa=0 for i in range(m): p,s=input().split() p=int(p) if s=="WA" and a[p-1]!=1: a[p-1]-=1 elif s=="AC" and a[p-1]!=1: wa-=a[p-1] a[p-1]=1 print(a.count(1),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.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws NumberFormatException, IOException { // TODO Auto-generated method stub BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String [] s = br.readLine().split(" "); int n = Integer.parseInt(s[0]); int m = Integer.parseInt(s[1]); boolean[] probFlag = new boolean[n]; int[] probWa = new int[n]; int correct = 0 ,wa = 0 ; for(int i = 0 ; i < m ; i++) { s = br.readLine().split(" "); int p = Integer.parseInt(s[0]); String res = s[1]; if(res.equals("WA") && !probFlag[p-1]) { probWa[p-1]++; }else if(res.equals("AC") && !probFlag[p-1]) { probFlag[p-1] = true; correct ++; wa += probWa[p-1]; } } System.out.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 =Integer.parseInt(sc.next()); int m =Integer.parseInt(sc.next()); int [][]ac = new int [n][2]; boolean []flag = new boolean [n]; for(int i = 0 ;i < m ;i++) { int p = Integer.parseInt(sc.next()); String s = sc.next(); if(s.equals("WA")) { if(flag[p-1]) { continue; } ac[p-1][0]++; } else if(s.equals("AC")) { flag[p-1] = true; ac[p-1][1] = 1; } } int ans1 = 0; int ans2 = 0; for(int i = 0 ;i < n ;i++) { ans1 += ac[i][1]; if(ac[i][1] ==1) { ans2 += ac[i][0]; } } 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; int main(){ int n,m; cin >> n >> m; vector<int>wa(n+1); vector<int>ac(n+1); int ca = 0 , p = 0; for(int i = 0; i < m; ++i){ int tmp; cin >> tmp; string ver; cin >> ver; if(ver == "AC"){ if(ac[tmp]){ continue; } else{ p+=wa[tmp]; ca+=1; ac[tmp]++; } } else{ wa[tmp]++; } } cout << ca <<" " << p <<"\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 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 ac_count = 0; int wa_count = 0; int[] ac_list = new int[n];//正解の数 int[] wa_list = new int[n];//不正解の数 int p=0 ; String s ; for(int i=0; i<m; i++){ p = sc.nextInt() -1; s = sc.next(); if(ac_list[p]<1){//問題が正解になっていない if(s.equals("AC")){ ac_list[p] += 1; }else if(s.equals("WA")){ wa_list[p] += 1; } } } for (int i = 0; i < n; i++) { if (ac_list[i] < 1) { wa_list[i] = 0; } } int ac_sum = 0; int wa_sum = 0; for(int i=0; i<n; i++){ ac_sum += ac_list[i]; wa_sum += wa_list[i]; } System.out.println(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
#include <bits/stdc++.h> using namespace std; int main() { int N,M,p,ac=0,wa=0; cin>>N>>M; vector<int> C(N,0),W(N,0); string S; for(int i=0;i<M;i++) { cin>>p>>S; if(S=="WA"){if(C.at(p-1)==0) W.at(p-1)++;} else C.at(p-1)=1; } for(int i=0;i<N;i++) { ac+=C.at(i); if(C.at(i)==1) wa+=W.at(i); } 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
#include<bits/stdc++.h> using namespace std; int main(){ int n,m; cin>>n>>m; int arr[105000]; bool bll[105000]; int wc=0; int ac=0; for(int i=1;i<=n;i++){ arr[i]=0; bll[i]=false; } while(m--){ int p; string s; cin>>p>>s; if(bll[p])continue; if(s=="AC"){ bll[p]=true; ac++; wc+=arr[p]; }else if(s=="WA"){ arr[p]++; } } cout<<ac<<" "<<wc<<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
n,m=map(int,input().split()) li=[0]*n ok=0 ng=0 pro=set() for i in range(m): p,s=map(str,input().split()) p=int(p) if s=="WA": li[p-1]+=1 else: if not p in pro: ok+=1 ng+=li[p-1] pro.add(p) print(ok,ng)
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
// C - Welcome to AtCoder #include <bits/stdc++.h> using namespace std; int wa_count[100000]; int main(){ int n,m,p,ac=0,wa=0; char s[3]; scanf("%d%d",&n,&m); while(m--){ scanf("%d%s",&p,s); if(wa_count[p] < 0) continue;// ac else{//not ac if(s[0] == 'W') wa_count[p]++; else{ ac++; wa += wa_count[p]; wa_count[p] = -1;// ac flag on } } } printf("%d %d\n",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
#include<bits/stdc++.h> using namespace std; bitset<200000>md; int arr[200000]; int main() { int n,m,c=0,p=0; string s; int a; cin>>n>>m; for(int i=0;i<m;i++) { cin>>a>>s; if(md[a]==0){ if(s=="WA")arr[a]++; else {c++; md[a]=1;p+=arr[a];} } } cout<<c<<" "<<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
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[] arr = new int[n]; int cntAC = 0; int cntWA = 0; int[] cntWAs = new int[n]; for(int i = 0; i < m; i++){ int num = sc.nextInt(); String res = sc.nextLine(); //System.out.println(res); if(arr[num - 1] == 0){ if(res.equals(" AC")){ cntAC++; cntWA += cntWAs[num - 1]; arr[num - 1] = 1; }else{ cntWAs[num - 1]++; } } } System.out.println(cntAC + " " + cntWA); } }
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 <vector> using namespace std; int main(){ int N,M,p,cntAC=0,cntPen=0; string S; cin >> N >> M; vector<int> WA(N,0); for(int i=0;i<M;i++){ cin >> p >> S; if(S=="AC" && WA[p-1]>=0){ cntAC++; cntPen+=WA[p-1]; WA[p-1]=-1; } if(S=="WA" && WA[p-1]>=0)WA[p-1]++; } cout << cntAC << " " << cntPen << 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 p[100005]; string s[100005]; int wa[100005]; int ans; int used[100005]; int anss; int main(){ int n,m; cin>>n>>m; for(int i=0;i<m;i++){ cin>>p[i]; cin>>s[i]; if(used[p[i]]){ continue; } if(s[i]=="AC"){ used[p[i]]=1; anss++; ans+=wa[p[i]]; }else{ wa[p[i]]++; } } cout<<anss<<" "<<ans; 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 a[100005],c[100005],s,cnt; char st[5]; int main(){ int n,m; scanf("%d %d",&n,&m); for(int i=0;i<m;i++){ int x; scanf("\n%d %s",&x,st); if(st[0]=='W')a[x]++; else if(!c[x]){ c[x]=1; s+=a[x]; cnt++; } } printf("%d %d",cnt,s); }
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 <string> using namespace std; int main() { int n, m; cin >> n >> m; int a[100005] = {}; int x = 0, y = 0; while (m--) { int p; string s; cin >> p >> s; if (a[p] == -1) continue; if (s == "AC") {++x; y += a[p]; a[p] = -1;} else ++a[p]; } cout << x << ' ' << y << 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 scan = new Scanner(System.in); int n = scan.nextInt(); int m = scan.nextInt(); int c = 0; int d = 0; boolean [] a = new boolean[n]; int [] t = new int[n]; for (int p=0;p<n;p++){ a[p] = false; t[p] = 0; } for (int i=0;i<m;i++){ int g = scan.nextInt(); String check = scan.next(); if (a[g-1] == true){ continue; } if (check.equals("AC") == true){ c += 1; a[g-1] = true; d += t[g-1]; } else{ t[g-1] += 1; } } System.out.print(c+" "); System.out.println(d); } }
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 static java.lang.Math.*; import java.math.BigInteger; public class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); // 入力 int n = sc.nextInt(); int m = sc.nextInt(); int[] ac = new int[n]; int[] penalty = new int[n]; int acCnt = 0; int penaltyCnt = 0; for(int i = 0; i < m; i++){ int p = sc.nextInt() - 1; String s = sc.next(); if(ac[p] == 1) continue; if(s.equals("AC")){ ac[p] = 1; acCnt++; penaltyCnt += penalty[p]; }else{ penalty[p]++; } } // 計算 // 出力 System.out.println(acCnt + " " + penaltyCnt); } }
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, raw_input().split()) l = [] ac = set() wa = {} for i in range(m): a, b = raw_input().split() a = int(a) if a not in ac: if b == 'WA': if a in wa: wa[a] += 1 else: wa[a] = 1 else: ac.add(a) ans = 0 for i in list(ac): if i in wa: ans += wa[i] print len(ac), ans
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 main(){ int N,M,a; string b; cin>>N>>M; vector<int>A(N+1,0); vector<bool>C(N+1,false); int ac=0, wa=0; for(int i=0; i<M; i++){ cin>>a>>b; if(C[a]==false){ if(b=="WA") A[a]++; else if(b=="AC"){ ac++; C[a]=true; wa+=A[a]; } } } 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
N,M=map(int,input().split()) wa=[0]*N pen=[0]*N ac=[0]*N for x in range(M): P,S=input().split() if S=="WA" and ac[int(P)-1]==0: wa[int(P)-1] += 1 elif S=="AC" and ac[int(P)-1]==0: ac[int(P)-1] += 1 pen[int(P)-1] = wa[int(P)-1] print(f"{sum(ac)} {sum(pen)}")
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()) #print N, M state = [-1 for i in range(N)] pena = [0 for i in range(N)] WA = [0 for i in range(N)] for i in range(M): s = raw_input().split() p = int(s[0]) sc = s[1] #print p, sc p -= 1 if (state[p] == 0): continue if sc == 'WA': pena[p] += 1 else: state[p] = 0 ok = 0 pn = 0 for i in range(N): if state[i] == 0: ok += 1 pn += pena[i] print ok, pn
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.*; public class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(),m=sc.nextInt(); boolean[] ac=new boolean[n+1]; int[] wa=new int[n+1]; Arrays.fill(ac, false); int acn = 0,wan = 0; while(m-->0) { int a=sc.nextInt(); String s=sc.nextLine(); if(s.equals(" AC")) { ac[a] = true; }else { if(!ac[a]) { wa[a]++; } } } for(int i=1;i<n+1;i++) { if(ac[i]) acn++; if(wa[i]>0&&ac[i]) { wan+=wa[i]; } } System.out.print(acn+" "+wan); } }
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.lang.Math; public class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); List acList = new ArrayList<String>(); boolean acs[] = new boolean[n]; int was[] = new int[n]; int istack; String sstack; String sstack2; int ac = 0; int wa = 0; Arrays.fill(acs,false); Arrays.fill(was,0); for(int i = 0;i < m;i++){ istack = sc.nextInt() - 1; sstack = sc.next(); if(sstack.equals("AC") && !acs[istack]){ ac++; acs[istack] = true; wa += was[istack]; } else was[istack]++; } System.out.print(ac + " "); System.out.println(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.*; import static java.lang.System.*; public class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int N = sc.nextInt(); //問題数 int M = sc.nextInt(); //解答した回数 int ACcount=0; int WAcount = 0; Set<Integer> corrected = new HashSet<>(); //既に正解した問題番号 int[] WA = new int[N+10]; for(int i=0; i<M; i++) { int p = sc.nextInt(); String s = sc.next(); if(corrected.contains(p)) continue; if( s.equals("AC")) { ACcount++; corrected.add(p); WAcount += WA[p]; } else if (s.equals("WA")) { WA[p]++; } } out.println(ACcount + " " + WAcount); } }
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
//package atcoder; import java.util.*; //import java.math.BigDecimal; public class Main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int M = sc.nextInt(); int ac = 0; int wa[] = new int [N]; int wawa = 0; TreeMap<Integer,String> map = new TreeMap<Integer,String>(); for(int i=0;i<M;i++) { int p = sc.nextInt(); String s = sc.next(); if(map.containsKey(p)) { if(map.get(p).equals("AC")) { continue; }else { map.put(p,s); if(s.contentEquals("AC")) { ac ++; continue; }else if(s.contentEquals("WA")) { wa[p-1] ++; continue; } } } map.put(p,s); if(s.equals("AC")) { ac ++; }else if(s.equals("WA")){ wa[p-1]++; } } for(Integer key:map.keySet()) { if(map.get(key).equals("AC")) { wawa += wa[key-1]; } } System.out.print(ac+" "+wawa); } }
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 n,m,x,ans,ans1,f[100001],e[100001]; char y[10]; int main(){ ios::sync_with_stdio(false); cin>>n>>m; for(int i=1;i<=m;i++){ cin>>x>>y; if(y[0]+y[1]=='A'+'C'){ if(!f[x])ans++,f[x]=1,ans1+=e[x]; } else e[x]++; } printf("%d %d\n",ans,ans1); 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; cin >> n>>m; vector<int> wa(n,0); int a; string s; int pen=0, ac=0; for(int i=0; i<m; i++){ cin >> a >> s; if(s=="WA" && wa[a-1]!=-1){ wa[a-1]++; } else if(s=="AC" && wa[a-1]!=-1){ ac++; pen += wa[a-1]; wa[a-1]= -1; } } cout << ac << " " << 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
/* * ID: juryc * PROG: Welcome to Atcoder * LANG: C++ */ #include<bits/stdc++.h> using namespace std; int main(){ int n,m; cin>>n>>m; vector<int> ac(n,0); vector<int> wa(n,0); int aw,ca; aw=ca=0; int p; string s; for(int i=0;i<m;i++){ cin>>p>>s; --p; if(s=="AC") ac[p]=1; else{ if(ac[p]) continue; else wa[p]++; } } for(int i=0;i<n;i++) if(ac[i]) aw+=wa[i],ca++; cout<<ca<<" "<<aw<<"\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
#include <stdio.h> int n, m, x, y; int ac[100000]; int wa[100000]; char s[10]; int main() { scanf("%d%d", &n, &m); for (int i = 0; i < m; i++) { scanf("%d", &x); x--; scanf(" %s", s); if (s[0] == 'A') { ac[x] = 1; } if (s[1] == 'A' && ac[x] == 0) { wa[x]++; } } x = 0; for (int i = 0; i < n; i++) { x += ac[i]; if (ac[i])y += wa[i]; } printf("%d %d\n", x, y); }
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<cstdio> int n,m,cnta,cntw;char s[2]; int ac[233333],tries[233333]; int main(){ scanf("%d%d",&n,&m); while(m--){ int k;scanf("%d%s",&k,s); if(!ac[k]){ if(s[0]=='W')tries[k]++; else cnta++,ac[k]=1; } } for(int i=1;i<=n;i++) if(ac[i])cntw+=tries[i]; printf("%d %d\n",cnta,cntw); }
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=[list(input().split()) for _ in range(m)] ac=[True]*n d=[0]*n tw=0 ta=0 for i in a: j=int(i[0])-1 if (ac[j]): if (i[1]=="WA"): d[j]+=1 else : tw+=d[j] ta+=1 ac[j]=False print(ta,tw)
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,j=0,k=0; cin>>N>>M; vector<bool> A(N,true); vector<int> B(N,0); for(int i=0;i<M;i++){ int p; string S; cin>>p>>S; if(S=="AC"){ if(A[p-1]){ k++; j+=B[p-1]; A[p-1]=false; } }else{ B[p-1]++; } } cout<<k<<' '<<j<<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.ArrayDeque; import java.util.Arrays; import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Queue; import java.util.Scanner; import java.util.Set; public class Main { public static void main(String[] args) { execute10_1(); } private static void execute10_2() { } private static void execute10_1() { try (Scanner sc = new Scanner(System.in)) { int n = sc.nextInt(); int m = sc.nextInt(); int[] sub = new int[n]; boolean[] comp = new boolean[n]; int c = 0; int w = 0; for (int i = 0; i < m; i++) { int p = sc.nextInt() -1; String s = sc.next(); if(comp[p]) continue; if ("AC".equals(s)) { comp[p]=true; c++; w+=sub[p]; } else { sub[p]++; } } System.out.println(c + " " + 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
d=dict() wa=ans=0 N,M=map(int,input().split()) for i in range(M): p,s=input().split() if p not in d: d[p]=0 if d[p]>=0 and s=="AC": ans+=1 wa+=d[p] d[p]=-1 elif d[p]>=0: d[p]+=1 print(ans,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.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Scanner; import java.util.Set; public class Main { static Scanner sc = new Scanner(System.in); public static void main(String[] args){ solve_abc151_c(); } public static void solve_abc151_c(){ Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int M = sc.nextInt(); int[] pi = new int[M]; boolean[] p_ac = new boolean[N]; int ans_correct = 0; int ans_penalty = 0; int[] p_penalty = new int[N]; for(int i=0;i<M;i++){ pi[i] = sc.nextInt() - 1; String s = sc.next(); if(!p_ac[pi[i]]){ if(s.equals("AC")){ ans_correct++; p_ac[pi[i]] = true; ans_penalty += p_penalty[pi[i]]; } else{ p_penalty[pi[i]]++; } } } System.out.println(ans_correct + " " + ans_penalty); sc.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
// C - Welcome to AtCoder #include <bits/stdc++.h> using namespace std; int wa_count[100000]; int main(){ int n,m,p,ac=0,wa=0; string s; cin>>n>>m; while(m--){ cin>>p>>s; --p; if(wa_count[p] < 0) continue;// ac else{//not ac if(s[0] == 'W') wa_count[p]++; else{ ac++; wa += wa_count[p]; wa_count[p] = -1;// ac flag on } } } 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
n,m=map(int,input().split()) A=[0]*n ac,wa=0,0 for i in range(m): p,s=map(str,input().split()) p=int(p) if s=="AC" and A[p-1]!=-1: ac+=1 wa+=A[p-1] A[p-1]=-1 elif s=="WA" and A[p-1]!=-1: A[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
#include<bits/stdc++.h> using namespace std; typedef long long ll; int main(){ ll N,M,p,res=0; string str; cin>>N>>M; set<ll> liste; vector<ll>vect(N+1,0); for (ll i=0;i<M;i++){ cin>>p>>str; if(str=="AC")liste.insert(p); if(liste.find(p)==liste.end()&&str=="WA")vect[p]++; } for(auto&&i:liste)res+=vect[i]; cout<<liste.size()<<" "<<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 s = new Scanner(System.in); int probs = s.nextInt(); int verdicts = s.nextInt(); HashSet<Integer> ac = new HashSet<>(); HashMap<Integer, Integer> map = new HashMap<>(); int correct = 0; int penalty = 0; for (int i = 0; i < verdicts; i++) { int n = s.nextInt(); String str = s.next(); if(str.equals("AC")) { if (!ac.contains(n)) { correct++; ac.add(n); penalty += map.getOrDefault(n, 0); } } else { if (!ac.contains(n)) { map.put(n, map.getOrDefault(n, 0) + 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()) AC=[0]*n WA=[0]*n for i in range(m): p,s=input().split() p=int(p)-1 if s=="WA": if AC[p]==0: WA[p]+=1 else: AC[p]=1 ac=sum(AC) wa=0 for i in range(n): if AC[i]==1: wa+=WA[i] 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 = (int(i) for i in input().split()) ac=0 pe=0 p = [0]*(n+1) a = [0]*(n+1) for i in range(m): x,y = input().split() x = int(x) if y=="AC": a[x]=1 elif not a[x]: p[x]+=1 ac = sum(a) pe = sum(p[i] for i in range(n+1) if a[i]) print(ac, pe)
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.HashMap; import java.util.Map; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); // 問題数 int a = sc.nextInt(); // 提出数 int b = sc.nextInt(); int[] w = new int[a]; Map<Integer, Boolean> map = new HashMap<>(); for (int i = 0; i < a; i++) { map.put(i + 1, false); w[i] = 0; } int wrong = 0; int correct = 0; int problemNum; String result; for (int i = 1; i <= b; i++) { problemNum = sc.nextInt(); result = sc.next(); if (!map.get(problemNum)) { if (result.equals("WA")) { w[problemNum - 1]++; } if (result.equals("AC")) { correct++; wrong += w[problemNum - 1]; map.put(problemNum, true); } } } System.out.println(correct + " " + 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.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); boolean[] isAc = new boolean[n]; int[] waCounter = new int[n]; for (int i = 0; i < m; i++) { int nOrder = sc.nextInt() - 1; String result = sc.next(); if (!isAc[nOrder]){ if (result.equals("AC")) isAc[nOrder]=true; else waCounter[nOrder]++; } } int ac = 0; int wa = 0; for (int i = 0; i < n; i++) { if (isAc[i]){ ac++; 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 = map(int, input().split()) AC = [0]*N WA = [0]*N for _ in range(M): p,s = input().split() if AC[int(p)-1] == 0: if s == "WA": WA[int(p)-1] += 1 elif s == "AC": AC[int(p)-1] = 1 print(sum(AC),sum(w*a for w,a in zip(WA,AC)))
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() if s == "AC": ac[int(p)-1] = 1 elif ac[int(p)-1] != 1: wa[int(p)-1] += 1 for i in range(n): 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
n,m=map(int,input().split()) a=[0]*n w=[0]*n ac=0 wa=0 for i in range(m): p,s=map(str,input().split()) p=int(p) if a[p-1]==0: if s=="AC": ac+=1 wa+=w[p-1] a[p-1]=1 else: w[p-1]+=1 print(ac,wa)
PYTHON3