Search is not available for this dataset
name
stringlengths 2
112
| description
stringlengths 29
13k
| source
int64 1
7
| difficulty
int64 0
25
| solution
stringlengths 7
983k
| language
stringclasses 4
values |
---|---|---|---|---|---|
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int M = sc.nextInt();
int ans = 0, pen = 0;
int[] x = new int[100001];
for(int i = 0; i < M; i++) {
int p = sc.nextInt();
if(sc.next().equals("WA")) {
if(x[p] >= 0)
x[p]++;
}
else {
if(x[p] >= 0) {
ans++;
pen += x[p];
x[p] = -1;
}
}
}
System.out.println(ans + " " + 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 | import java.util.Scanner;
class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n=in.nextInt();
int m=in.nextInt();
int[] AC = new int[n];
int[] WA = new int[n];
int acount=0;
int wcount=0;
for (int i = 0; i < m; i++) {
int s=in.nextInt();
String v=in.next();
if(v.equals("WA") && AC[s-1] == 0){
WA[s-1]++;
}
if(v.equals("AC")){
AC[s-1] = 1;
}
}
for(int i = 0; i < n; i++){
acount += AC[i];
if(AC[i] == 1){
wcount += WA[i];
}
}
System.out.println(acount+" "+wcount);
}
} | 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 rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll=long long;
int main() {
int n,m;
cin>>n>>m;
int a=0,w=0;
vector<int> ac(n);//正解の時-1を格納する
rep(i,m){
int p;
string s;
cin>>p>>s;
if(s=="WA"){
ac[p]++;
}else{
if(ac[p]>=0){
w+=ac[p];
a++;
ac[p]=-1000000;
}
}
}
cout<<a<<" "<<w<<endl;
}
| CPP |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | import java.io.*;
import java.util.*;
public class Main extends PrintWriter {
Main() { super(System.out, true); }
Scanner sc = new Scanner(System.in);
public static void main(String[] $) {
Main o = new Main(); o.main(); o.flush();
}
void main() {
int n = sc.nextInt();
int m = sc.nextInt();
int[] wa = new int[n + 1];
int correct = 0, penalty = 0;
while (m-- > 0) {
int p = sc.nextInt();
String s = sc.next();
if (wa[p] == -1)
continue;
if (s.equals("WA"))
wa[p]++;
else {
correct++;
penalty += wa[p];
wa[p] = -1;
}
}
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 | #include<bits/stdc++.h>
using namespace std;
int ar[1000005],cnt[1000005];
int main()
{
int n,k,i,a,c1=0,c2=0;
string s,s1,s2;
s1="AC";s2="WA";
cin>>n>>k;
for(i=0;i<k;i++)
{
cin>>a>>s;
if(ar[a]==0&&s==s1)
{
ar[a]=1;
c1++;
c2+=cnt[a];
}
else
cnt[a]++;
}
cout<<c1<<" "<<c2<<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.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String[] line = sc.nextLine().split(" ");
int n = Integer.parseInt(line[0]);
int m = Integer.parseInt(line[1]);
boolean[] done = new boolean[n];
int ac = 0, penalty = 0;
int[] wa = new int[n];
for(int i = 0; i < m; i++) {
line = sc.nextLine().split(" ");
int p = Integer.parseInt(line[0]);
if(done[p-1]) continue;
if(line[1].equals("AC")) {
ac++;
done[p-1] = true;
penalty+=wa[p-1];
} else if(line[1].equals("WA")) {
wa[p-1]++;
}
}
System.out.println(ac + " " + 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())
ans=[0]*N
pen=[0]*N
AC=[0]*N
for i in range(M):
p,s=input().split()
p=int(p)
if s=="WA":
pen[p-1]+=1
else:
if AC[p-1]==0:
ans[p-1]+=pen[p-1]
AC[p-1]=1
print(AC.count(1),sum(ans))
| PYTHON3 |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | N,M=[int(i) for i in input().split()]
AC,WA=[False]*N,[0]*N
panel=0
for i in range(M):
p,s=input().split()
p=int(p)-1
if AC[p]:
continue
if s=="WA":
WA[p]+=1
else:
AC[p]=True
panel+=WA[p]
ac=sum(AC)
print(ac,panel) | 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 {
static int n;
public static void main(String args[]) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String str[] = br.readLine().split(" ");
int n = Integer.parseInt(str[0]);
int m = Integer.parseInt(str[1]);
int set[] = new int[n];
int wa = 0;
int ac = 0;
for (int i = 0; i < m; i++) {
str = br.readLine().split(" ");
int p = Integer.parseInt(str[0]) - 1;
String s = str[1];
if (s.equals("WA") && set[p] != -1) {
set[p]++;
} else if (set[p] != -1) {
wa += set[p];
ac++;
set[p] = -1;
}
}
System.out.println(ac + " " + wa);
}
} | JAVA |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | #include <bits/stdc++.h>
using namespace std;
long long n, m, p, wa[100005], corr, pena;
string s;
int main() {
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cin >> n >> m;
while (m--) {
cin >> p >> s;
if (s == "WA") {
if (wa[p] >= 0) wa[p]++;
}
else {
if (wa[p] >= 0) {
corr++;
pena += wa[p];
wa[p] = -1;
}
}
}
cout << corr << " " << pena << 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())
li=[0]*n
ans=[0,0]
for i in range(m):
p,s=input().split()
p=int(p)
if li[p-1]>=0:
if s=="WA":
li[p-1]+=1
elif s=="AC":
ans[0]+=1
ans[1]+=li[p-1]
li[p-1]=-1
print(*ans) | PYTHON3 |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n,m;
cin >> n >> m;
vector<int> ac(n),wa(n);
for(int i=0; i<m; i++){
int p;
string s;
cin >> p >> s;
p--;
if(ac[p]) continue;
if(s == "AC") ac[p] = 1;
else wa[p]++;
}
int a=0,w=0;
for(int i=0; i<n; i++) {
a += ac[i];
if(ac[i]) w += wa[i];
}
cout << a << " " << w << endl;
} | CPP |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | import java.util.Scanner;
public class Main {
public static void main(String[] args) throws Exception {
try (Scanner sc = new Scanner(System.in)) {
int N = sc.nextInt();
int M = sc.nextInt();
boolean[] check = new boolean[N];
int[] W = new int[N];
int a = 0;
int w = 0;
for (int i = 0; i < M; i++) {
int p = sc.nextInt() - 1;
String s = sc.next();
if (s.equals("AC")) {
if (!check[p]) {
a++;
w += W[p];
check[p] = true;
}
} else if (s.equals("WA")) {
W[p]++;
}
}
System.out.println(a + " " + w);
}
}
}
| JAVA |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, M;
cin >> N >> M;
vector<int> V(N);
int ac = 0, pn = 0;
for (int i = 0; i < M; i++) {
int p;
string S;
cin >> p >> S;
p--;
if (V.at(p) == -1) continue;
else {
if (S == "AC") ac++, pn += V.at(p), V.at(p) = -1;
else V.at(p)++;
}
}
cout << ac << "\n";
cout << pn << "\n";
} | CPP |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | #include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main(){
int N,M;
cin >>N>>M;
map<int,int> mp;
rep(i,N)mp[i+1]=0;
int p,ac=0,wa=0;
string s;
rep(i,M){
cin >> p >> s;
if(!mp.count(p))continue;
if(s=="WA")mp[p] ++;
else {
wa += mp[p];
ac ++;
mp.erase(p);
}
}
cout << ac <<" " << wa;
} | CPP |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
new Main().run();
}
private void run() {
Scanner scanner = new Scanner(System.in);
int N = scanner.nextInt();
int M = scanner.nextInt();
int[] ans = new int[N];
int[] pena = new int[N];
for(int i = 0; i < M; i++) {
int pi = scanner.nextInt() - 1;
String si = scanner.next();
if(ans[pi] == 0) {
if (si.equals("WA")) {
pena[pi]++;
} else {
ans[pi] = 1;
}
}
}
int totalAns = 0;
int totalPena = 0;
for(int i = 0; i < N; i++) {
if(ans[i] == 1) {
totalAns++;
totalPena += pena[i];
}
}
System.out.println(totalAns);
System.out.println(totalPena);
}
} | 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.List;
import java.util.Objects;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int N = Integer.parseInt(s.next());
int M = Integer.parseInt(s.next());
boolean[] completed = new boolean[N];
int[] wa = new int[N];
int acCount = 0;
int waCount = 0;
for (int i = 0; i < M; i++) {
int p = Integer.parseInt(s.next()) - 1;
if (completed[p]) {
s.next();
continue;
}
String S = s.next();
if (Objects.equals(S, "WA")) {
wa[p]++;
} else {
acCount++;
waCount += wa[p];
completed[p] = true;
}
}
System.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 | import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int M = sc.nextInt();
boolean[] test = new boolean[N];
int count1 = 0;
int count2[] = new int[N];
int count3 = 0;
for(int i=0; i<M; i++){
int p = sc.nextInt();
String str = sc.next();
if(!test[p-1] && str.equals("AC")){
count1++;
test[p-1] = true;
}else if(!test[p-1] && str.equals("WA")){
count2[p-1]++;
}
}
for(int i=0; i<N; i++){
if(!test[i]){
count2[i]=0;
}
count3 += count2[i];
}
System.out.println(count1+" "+count3);
}
} | 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 = [0]*n
AC,WA=0,0
for i in range(m):
x,y = input().split()
x = int(x)
if a[x-1]!=-1 and y=="WA":
a[x-1]+=1
if a[x-1]!=-1 and y=="AC":
WA+=a[x-1]
AC+=1
a[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 | n,m=map(int,input().split())
ac,wa,k,l=0,0,[0]*n,[0]*n
for _ in range(m):
p,s=input().split()
if k[int(p)-1]==0:
if s=='AC':
ac+=1
k[int(p)-1]=1
wa+= l[int(p)-1]
else:
l[int(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;
int a[100005][2];
int main(){
int n,m,cnt1=0,cnt2=0;
scanf("%d%d",&n,&m);
for(int i=0;i<m;i++){
int b;
string str;
cin>>b>>str;
if(a[b][0]==0 && str=="AC" ){
cnt2+=a[b][1];
cnt1++;
a[b][0]=1;
}
else if(a[b][0]==0 && str=="WA"){
a[b][1]++;
}
}
printf("%d %d",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 | #include<bits/stdc++.h>
using namespace std;
int main()
{
int n,m,p,i,cnt=0,cnt1=0;
cin>>n>>m;
int ara[n];
memset(ara,0,sizeof(ara));
string s,s1="AC";
for(i=0;i<m;i++){
cin>>p>>s;
if(ara[p-1]!=-1){
if(s==s1){
cnt1+=ara[p-1];
cnt++;
ara[p-1]=-1;
}
else{
ara[p-1]++;
}
}
}
cout<<cnt<<" "<<cnt1<<endl;
return 0;
} | CPP |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | import java.util.*;
class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = Integer.valueOf(sc.next());
int M = Integer.valueOf(sc.next());
int[] array = new int[N];
int p;
String S;
int ans = 0;
int pena = 0;
for (int i = 0; i < M; i++) {
p = Integer.valueOf(sc.next());
S = sc.next();
if (array[p-1] != -1) {
if (S.equals("WA")) {
array[p-1]++;
} else {
ans++;
pena += array[p-1];
array[p-1] = -1;
}
}
}
System.out.println(ans + " " + 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 | #include <bits/stdc++.h>
using namespace std;
const int MAXN=100010;
int n,m,p,ans1,ans2,pen[MAXN],cor[MAXN];
char c[4];
int main () {
scanf("%d%d",&n,&m);
for (int i=1;i<=m;i++) {
scanf("%d%s",&p,c+1);
if (c[1]=='A') {
if (++cor[p]==1) {ans1++,ans2+=pen[p];}
} else {
pen[p]++;
}
}
printf("%d %d\n",ans1,ans2);
return 0;
} | CPP |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | R = lambda : input().split()
n, m = map(int, R())
a = [False] * n
b = [0] * n
for _ in range(m):
p, s = R()
p = int(p) - 1
if s == 'AC':
a[p] = True
elif not a[p]:
b[p] += 1
b = [y for x, y in zip(a, b) if x]
print(len(b), 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) {
Scanner scan = new Scanner(System.in);
int N = scan.nextInt();
int M= scan.nextInt();
int[][] array = new int[N][2];
for (int i = 0; i < M; i++) {
int mondai = scan.nextInt() - 1;
if ( " AC".equals(scan.nextLine())) {
array[mondai][1] = 1;
} else {
if (array[mondai][1] != 1) {
array[mondai][0] += 1;
}
}
}
int waResultCount = 0;
int acResultCount = 0;
for (int i = 0; i < N; i++) {
if (array[i][1] == 1) {
acResultCount += 1;
waResultCount += array[i][0];
}
}
System.out.println(acResultCount + " " + waResultCount);
}
}
| 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())
s=[0]*n
t=[0]*n
for i in range(m):
a,b=map(str,input().split())
a,
a=int(a)-1
if not s[a]:
if b=="WA":
t[a]+=1
else:
s[a]=1
print(sum(s),sum(t[i] for i in range(n)if s[i])) | 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>
#include <map>
#include <set>
using namespace std;
int main() {
int p, W{};
set<int> s;
map<int,int> m;
string S;
cin >> p >> p;
while (cin >> p >> S) {
if (s.count(p)) continue;
else if (S=="AC") s.insert(p), W += m[p];
else ++m[p];
}
cout << s.size() << " " << W << endl;
}
| CPP |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | 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[N+1];
int ac=0,n,ans=0;
int[] pena=new int[N+1];
String res;
for(int i=0;i<M;i++){
n = sc.nextInt();
res = sc.next();
if(res.equals("AC")){
if(p[n]!=1){
p[n]=1;
ac++;
ans +=pena[n];
}
}else if(res.equals("WA")){
if(p[n]!=1){
pena[n]++;
}
}
}
System.out.print(ac);
System.out.print(" ");
System.out.println(ans);
}
} | JAVA |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | n, m = map(int, input().split())
p = [0]*(n+1)
q = [False]*(n+1)
for _ in range(m) :
v,s = input().split()
v = int(v)
if q[v]:
continue
if s[0] == 'A':
q[v] = True
else :
p[v] += 1
print(sum(q), sum(p[i] for i in range(n+1) if q[i])) | 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 a,b,d,e=0,r=0;
bool q[1000000];
int w[10000000];
signed main (){
string c;
cin>>a>>b;
for(int i=0;i<b;i++){
cin>>d>>c;
if(q[d]==false){
if(c=="WA") w[d]++;
else{
r++;
q[d]=true;
}
}
}
for(int i=0;i<=a;i++){
if(q[i]==true) e+=w[i];
}
cout<<r<<" "<<e<<"\n";
} | 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();
ArrayList<Pair2> atcoder = new ArrayList<Pair2>();
for(int i=0; i<N; i++){
Pair2 pair = new Pair2(false, 0);
atcoder.add(pair);
}
int count=0;
int error=0;
for(int i=0; i<M; i++){
int p = sc.nextInt();
String ans = sc.next();
if(atcoder.get(p-1).ac==false){
if(ans.equals("AC")){
atcoder.get(p-1).ac=true;
count++;
error += atcoder.get(p-1).wa;
}else{
atcoder.get(p-1).wa++;
}
}
}
System.out.println(count+" "+error);
}
}
class Pair2 {
public boolean ac;
public int wa;
Pair2(boolean ac, int wa){
this.ac = ac;
this.wa = 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>
int n,m;
int count[100010],p[100010],cnt,pl;
int main()
{
scanf("%d%d",&n,&m);
while(m--)
{
int id;
char s[4];
scanf("%d%s",&id,s);
if(count[id]) continue;
if(s[0]=='A') count[id]=1,cnt++,pl+=p[id];
else p[id]++;
}
printf("%d %d\n",cnt,pl);
return 0;
}
| CPP |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | import sys
lines = sys.stdin.read().split("\n")
n, m = map(int, lines[0].split())
ac_flags = [0] * (n + 1)
wa_counter = [0] * (n + 1)
ac_count = 0
wa_count = 0
for line in lines[1:-1]:
p, s = line.split()
p = int(p)
if ac_flags[p] == 0:
if s == "AC":
ac_flags[p] = 1
ac_count += 1
wa_count += wa_counter[p]
else:
wa_counter[p] += 1
print ac_count, wa_count
| 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 | N,M = map(int,input().split())
WA = [0] * (N + 1)
AC = [0] * (N + 1)
sum_WA = 0
for _ in range(M):
i,s = input().split()
i = int(i)
if AC[i] == 0:
if s == 'WA':
WA[i] += 1
elif s == 'AC':
AC[i] = 1
sum_WA += WA[i]
print(sum(AC),sum_WA) | PYTHON3 |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | import java.util.Scanner;
import java.util.Arrays;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int M = sc.nextInt();
int count1 = 0;
int count2 = 0;
// int count3 = 0;
boolean[] isAC = new boolean[N];
int[] penaCount = new int[N];
Arrays.fill(isAC,false);
Arrays.fill(penaCount,0);
for(int i=0; i<M; i++){
int index = sc.nextInt()-1;
String s = sc.next();
if(s.equals("AC")&&isAC[index]==false){
isAC[index]=true;
count1++;
count2+=penaCount[index];
}else if(s.equals("WA")&&isAC[index]==false){
penaCount[index]++;
}
}
System.out.print(count1 + " ");
System.out.print(count2);
return;
}
}
| 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
wa = 0
en_li = [[] for i in range(n)]
print
for i in range(m):
a, b = input().split(' ')
en_li[int(a)-1].append(b)
ac = 0
wa = 0
for i in en_li:
if 'AC' in i:
wa += i.index('AC')
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.HashSet;
import java.util.Scanner;
import java.util.Set;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int M = sc.nextInt();
int p[] = new int[M];
String S[] = new String[M];
Set correctSet = new HashSet<Integer>();
Set wrongSet = new HashSet<Integer>();
Set submitAnswer = new HashSet<Integer>();
int correct = 0;
int wrong = 0;
for (int i = 0; i < M; i++) {
p[i] = sc.nextInt();
S[i] = sc.next();
if ("AC".equals(S[i])) submitAnswer.add(p[i]);
}
for (int i = 0; i < M; i++) {
if (submitAnswer.contains(p[i])) {
if ("WA".equals(S[i]) && !correctSet.contains(p[i])) {
wrongSet.add(p[i]);
wrong++;
} else if ("AC".equals(S[i]) && !correctSet.contains(p[i])) {
correctSet.add(p[i]);
correct++;
}
}
}
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 | #include <iostream>
using namespace std;
int main()
{
int n,m,cor=0,pen=0,pe[100002]={0};
cin>>n>>m;
bool f[100001]={false};
string str;
int j;
for(int i=1;i<m+1;i++){
cin>>j>>str;
if(f[j]==false && str=="AC"){
f[j]=true;
cor++;
pen+=pe[j];
}
else if(f[j]==false && str=="WA"){
pe[j]++;
}
}
cout<<cor<<" "<<pen<<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 main(){
int n,m;cin>>n>>m;
int a=0,p=0;
map<int,int> mp;
vector<bool> v(n+1);
for(int i = 0; i < m; i++){
int t;string s;
cin>>t>>s;
if(s == "AC" && !v[t]){
a++;
v[t] = 1;
p+=mp[t];
continue;
}
mp[t]++;
}
cout<<a<<" "<<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.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int N = scan.nextInt();
int M = scan.nextInt();
Map<Integer, List<String>> map = new HashMap<>();
for (int i=0; i < M; i++) {
int p = scan.nextInt();
String S = scan.nextLine();
List<String> tmpL = map.get(p);
if (tmpL == null) {
tmpL = new ArrayList<>();
}
tmpL.add(S);
map.put(p, tmpL);
}
int acCnt = 0;
int waCnt = 0;
for (int p : map.keySet()) {
int tmpWaCnt = 0;
List<String> tmpL = map.get(p);
for (String str : tmpL) {
if (str.trim().equals("AC")) {
acCnt++;
waCnt += tmpWaCnt;
break;
}
else if (str.trim().equals("WA")) {
tmpWaCnt++;
}
}
}
System.out.println(acCnt + " " + waCnt);
}
}
| JAVA |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | import java.util.Scanner;
import java.util.stream.IntStream;
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 < m; i++) {
int p = sc.nextInt();
String s = sc.next();
if (s.equals("AC")) {
ac[p - 1] = true;
} else if (!ac[p - 1]) {
wa[p - 1]++;
}
}
sc.close();
long acc = IntStream.range(0, n).filter(i -> ac[i]).count();
long wac = IntStream.range(0, n).filter(i -> ac[i]).map(i -> wa[i]).sum();
System.out.println(String.format("%d %d", acc, wac));
}
}
| 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.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws Exception {
final Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int M = sc.nextInt();
int[] problems = new int[N];
int[] was = new int[N];
for (int i = 0; i < M; i++) {
final int p = sc.nextInt() - 1;
boolean isAC = sc.next().equals("AC");
if (isAC) {
problems[p] = 1;
} else {
if (problems[p] != 1) {
was[p]++;
}
}
}
int wa = 0;
for (int i = 0; i < N; i++) {
if (problems[i] == 1) {
wa += was[i];
}
}
System.out.println(Arrays.stream(problems).sum() + " " +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 n,m,ac[100010],x[100010],ans,ppen,pos;
string s;
int main()
{
memset(x,0,sizeof(x));
memset(ac,0,sizeof(ac));
scanf("%d%d",&n,&m);
for(int i=1;i<=m;++i) {
scanf("%d",&pos);
cin>>s;
if(!ac[pos]) {
if(s=="WA") x[pos]++;
else ac[pos]=1;
}
}
for(int i=1;i<=n;++i)
if(ac[i])
ppen+=x[i],ans++;
printf("%d %d",ans,ppen);
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())
p = [0]*n
q = [False]*n
for _ in range(m):
v,s = input().split()
v = int(v)-1
if q[v]: continue
if s == 'AC': q[v] = True
else: p[v] += 1
print(sum(q),sum(p[i] for i in range(n) if q[i])) | 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 = Integer.parseInt(sc.next());
int m = Integer.parseInt(sc.next());
boolean[] q = new boolean[n];
int[] q_wa = new int[n];
int ac = 0;
int wa = 0;
for(int i=0 ; i < n ; i++) {
q[i] = false;
q_wa[i] = 0;
}
for(int i=0 ; i < m ; i++) {
int p = Integer.parseInt(sc.next());
String s = sc.next();
if(!q[p-1]) {
if(s.equals("AC")) {
ac++;
wa += q_wa[p-1];
q[p-1] = true;
}else {
q_wa[p-1]++;
}
}
}
System.out.println(ac + " " + wa);
}
} | JAVA |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | #include<iostream>
#include<string>
using namespace std;
int main() {
int n, m, state[100000] = {}, cc = 0, penalty = 0;
cin >> n >> m;
for(int i = 0; i < m; i++) {
int p;
string s;
cin >> p >> s;
if (state[p] == -1) continue;
if (s == "AC") {
penalty += state[p];
cc++;
state[p] = -1;
} else {
state[p]++;
}
}
cout << cc << ' ' << penalty << 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())
s = [[] for _ in [0]*n]
for _ in [0]*m:
p, _s = input().split()
s[int(p)-1] += [_s]
ans = 0
pena = 0
for i in s:
if 'AC' in i:
ans += 1
pena += i[:i.index('AC')].count('WA')
print(ans, 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 | import java.util.*;
class Main{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int m=sc.nextInt();
int ac=0;
int wa=0;
int[] a=new int[n];
for(int i=0;i<m;i++){
int p=sc.nextInt()-1;
String st=sc.next();
if(a[p]==-1){
}else if(st.equals("AC")){
wa+=a[p];
ac++;
a[p]=-1;
}else if(st.equals("WA")){
a[p]++;
}
}
System.out.println(ac+" "+wa);
}
} | JAVA |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | N,M=map(int,input().split())
ac=[0]+[0]*N
wa=[0]+[0]*N
for _ in range(M):
number,ans=input().split()
number=int(number)
if ans=='AC':
ac[number]=1
elif ac[number]==0:
wa[number]+=1
print(sum(ac),sum(c for i,c in enumerate(wa) if ac[i]==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 | N, M = map(int, input().split())
wa=[0]*N
ac=[False]*N
for i in range(M):
p, S = input().split()
p=int(p)-1
if S=="AC":
ac[p]=True
else:#一度ACしたらWAをカウントしない
if not ac[p]:
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 | import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String[] sa = br.readLine().split(" ");
int n = Integer.parseInt(sa[0]);
int m = Integer.parseInt(sa[1]);
boolean[] ac = new boolean[n];
int[] pe = new int[n];
for (int i = 0; i < m; i++) {
sa = br.readLine().split(" ");
int p = Integer.parseInt(sa[0]) - 1;
if (!ac[p]) {
if ("AC".equals(sa[1])) {
ac[p] = true;
} else {
pe[p]++;
}
}
}
br.close();
int ca = 0;
int cp = 0;
for (int i = 0; i < n; i++) {
if (ac[i]) {
ca++;
cp += pe[i];
}
}
System.out.println(ca + " " + cp);
}
}
| JAVA |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int M = sc.nextInt();
int[][] list = new int[N][2];//list[問題番号][0] == AC用//list[問題番号][1] == WA用
int AC =0;//最終的なAC数を収める変数
int WA =0;//最終的なWA数を収める変数
for(int i = 0; i < M; i++){
int num = sc.nextInt();
String s = sc.next();
if(s.equals("AC") && list[num-1][0]!=1){
list[num-1][0] = 1;
AC++;
WA += list[num-1][1];//対象の問題の最終的なWAの数をWAに格納
}else if(s.equals("WA") && list[num-1][0]!=1){
list[num-1][1]++;
}
}
System.out.println(AC+" "+WA);
}
} | JAVA |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | #include <iostream>
#include <string>
typedef long long ll;
using namespace std;
int main(){
ll n,m;cin>>n>>m;
string s;
ll p,pa[n],a=0,w[n],wa=0;fill(pa,pa+n,0);fill(w,w+n,0);
for(int i=0;i<m;i++){
cin>>p>>s;
if(s=="AC"){if(pa[p-1]==0){pa[p-1]=1;a++;wa+=w[p-1];}}
if(s=="WA"){if(pa[p-1]==0){w[p-1]++;}}
}
cout << a<<" "<< wa<<endl;
}
| CPP |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | import java.util.Scanner;
public class Main {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int M = sc.nextInt();
int[][] input = new int[M][2];
for (int i = 0; i < M; i++) {
input[i][0] = sc.nextInt();
String tmp = sc.next();
if (tmp.equals("AC")) {
input[i][1] = 1;
} else {
input[i][1] = 0;
}
}
int resCorr = 0;
int pena = 0;
int[][] qa = new int[N][2];
for (int i = 0; i < M; i++) {
if (qa[input[i][0]-1][1] == 1) {
continue;
}
if (input[i][1] == 0) {
qa[input[i][0]-1][0]++;
} else {
resCorr++;
pena += qa[input[i][0]-1][0];
qa[input[i][0]-1][1] = 1;
}
}
System.out.print(resCorr + " " + pena);
}
} | JAVA |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | import java.util.*;
class Main {
static Scanner sc = new Scanner(System.in);
public static void main(String[] args) {
int N = sc.nextInt(),
M = sc.nextInt(),
count[] = new int[N],
ans1 = 0,
ans2 = 0;
boolean f[] = new boolean[N];
Arrays.fill(f, true);
for (int i = 0; i < M; i++) {
int QN = sc.nextInt()-1;
String result = sc.next();
if (f[QN]) {
if (result.equals("WA")) {
count[QN]++;
}
if (result.equals("AC")) {
ans1 += count[QN];
ans2++;
f[QN] = false;
}
}
}
System.out.println(ans2 + " " + ans1);
}
} | JAVA |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
int N,M,AnsAC=0,AnsWA=0;
cin>>N>>M;
vector<int> AC(N),WA(N);
int p;
string S;
rep(i,M){cin>>p>>S;
if(AC.at(p-1)==0){if(S=="AC"){AC.at(p-1)++;}else{WA.at(p-1)++;}}
}
rep(i,N){AnsAC+=AC.at(i);AnsWA+=AC.at(i)*WA.at(i);}
cout<<AnsAC<<" "<<AnsWA<<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;
vector<int> wa(n+1);
int pe=0;
set<int> a;
for(int i=0; i<m; i++){
int p;
string s;
cin >> p >> s;
if(a.count(p)) continue;
if (s == "AC") {
a.insert(p);
}
else{
wa.at(p)++;
}
}
for(int i=0; i<=n; i++) if(a.count(i)) pe += wa.at(i);
cout << a.size() << " "<< pe << 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())
A = [0] * n
W = [0] * n
w = 0
for i in range(m):
p, s = input().split()
p = int(p) - 1
if s == "AC" and A[p] == 0:
A[p] = 1
w += W[p]
elif s == "WA" and A[p] == 0:
W[p] += 1
print(sum(A), 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
WA=[0]*N
ac=0
wa=0
for i in range(M):
p,s=input().split()
p=int(p)-1
if s=="AC"and AC[p]==0:
AC[p]=1
ac+=1
wa+=WA[p]
elif s=="WA":
WA[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())
done = [0]*(n+1)
wa = [0]*(n+1)
pen = 0
for i in range(m):
p,q = input().split()
p = int(p)
if q == "WA":
if done[p] == 0:
wa[p] += 1
else:
if done[p] == 0:
done[p] = 1
pen += wa[p]
print(sum(done),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 | #include <bits/stdc++.h>
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef pair<int,int> pii;
int n,m,check[1010101],ac,wa;
int main()
{
cin>>n>>m;
for(int i=0;i<m;i++)
{
int t; char arr[30];
scanf("%d %s",&t,arr);
if(check[t]<0) continue;
if(arr[0]=='W') check[t]++;
else if(arr[0]=='A') ac++, wa+=check[t], check[t]=-1;
} printf("%d %d",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<cstdio>
#include<cstring>
using namespace std;
const int maxn=100010;
int n,m,a[maxn],b[maxn],ac,pe;
char c[5];
int main()
{
int i,p;
scanf("%d%d",&n,&m);
for (i=1;i<=m;i++)
{
scanf("%d%s",&p,c+1);
if (a[p])
continue;
if (c[1]=='A')
{
ac++;
pe+=b[p];
a[p]=1;
}
else
b[p]++;
}
printf("%d %d\n",ac,pe);
}
| CPP |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | #include <bits/stdc++.h>
using namespace std;
int w[100100], a[100100];
long long nr,n,m,wa,ac;
char ans[3];
int main()
{
cin>>n>>m;
for(int i=1; i<=m; ++i)
{
cin>>nr;
cin.get();
cin>>ans;
if(ans[0]=='W')
w[nr]++;
else wa+=(w[nr]*(w[nr] && a[nr]==0)), ac+=(a[nr]==0),a[nr]=1;
}
cout<<ac<<' '<<wa<<'\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<bits/stdc++.h>
using namespace std;
int a[100005],n,m,ans1,ans2,num,f[100005];
string s;
int main(){
cin>>n>>m;
if(m==0) {cout<<0<<" "<<0;return 0;}
for(int i=1;i<=m;i++)
{
cin>>num>>s;
if(f[num]!=0) continue;
if(s=="AC") {ans2+=a[num],ans1++,f[num]=1;continue;}
a[num]++;
}
cout<<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 | f=lambda:input().split()
n,m=map(int,f())
n+=1
a,w=[0]*n,[0]*n
for _ in range(m):
p,s=f()
p=int(p)
if s=='AC': a[p]=1
elif a[p]<1: w[p]+=1
print(sum(a),sum(i*j for i,j in zip(a,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
wa = [0]*n
a = 0
w = 0
for i in range(m):
p, s = input().split()
p = int(p)-1
if ac[p] == 0 and s == "AC":
ac[p] += 1
a += 1
w += wa[p]
elif ac[p] == 0 and s == "WA":
wa[p] += 1
print(a,w) | PYTHON3 |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | import java.util.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[] ac = new int[N];
//ACしたならばWAを数えてもよい退避場所
int[] wa = new int[N];
//答えカウンター
int ok = 0;
int ng = 0;
for (int i = 0; i < M; i++) {
//問題番号は配列のキーにあたる
int indx = sc.nextInt();
String acWa = sc.next();
if (acWa.equals("AC")) {
if (ac[indx - 1] == 1) {
} else {
ok++;
ac[indx - 1] = 1;
}
} else {
if (ac[indx - 1] == 1) {
} else {
wa[indx - 1]++;
}
}
}
//ACしたならばWAを数えてもよい
for (int i = 0; i < N; i++) {
if (ac[i] == 1) {
ng = ng + wa[i];
} else {
}
}
System.out.println(ok + " " + ng);
}
}
| JAVA |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | #include<bits/stdc++.h>
using namespace std;
int a[100005],ans1,ans2;
int b[100005];
int main(){
int n,m;
cin>>n>>m;
for(int i=1;i<=m;i++){
int x;
string s;
cin>>x>>s;
if(s=="WA"){
a[x]+=!b[x];
}else{
ans1+=!b[x];
b[x]=1;
}
}
for(int i=1;i<=n;i++){
if(b[i]) ans2+=a[i];
}
cout<<ans1<<" "<<ans2<<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 <iostream>
#include <string>
#include <numeric>
int main(){
int n,m,wa[100001]={},i,ac[100001]={},p,a,b=0;
std::string s;
std::cin>>n>>m;
for(i=0;i<m;++i){
std::cin>>p>>s;
if(s=="AC")ac[p-1]=1;
else (ac[p-1]?0:++wa[p-1]);
}
a = std::accumulate(ac, ac+n, 0);
for(i=0;i<n;++i)b+=ac[i]*wa[i];
std::cout<<a<<' '<<b<<"\n";
}
| 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.LinkedHashMap;
import java.util.Map;
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();
Map<Integer,Boolean> ac = new LinkedHashMap<>();
Map<Integer,Integer> wa = new LinkedHashMap<>();
for(int i = 1; i <= n; i++) {
ac.put(i,true);
wa.put(i,0);
}
for(int i = 1; i <= m; i++) {
int sub = sc.nextInt();
String result = sc.next();
if(result.equals("AC")) {
ac.put(sub,false);
}
else {
if(ac.get(sub)) {
int temp = wa.get(sub)+1;
wa.put(sub, temp);
}
}
}
int ac_result = 0;
int wa_result = 0;
for(int i = 1; i <= n; i++) {
if(!ac.get(i)) {
ac_result++;
wa_result += wa.get(i);
}
}
System.out.print(ac_result + " ");
System.out.println(wa_result);
}
} | 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) throws Exception {
Scanner sc = new Scanner(System.in);
// 入力値
int n = sc.nextInt();
int m = sc.nextInt();
int ok = 0;
int ng = 0;
int[] ac = new int[n];
int[] wa = new int[n];
for(int i=0;i<m;i++){
int idx = sc.nextInt();
String s = sc.next();
if("AC".equals(s)){
if(ac[idx-1]==0){
ok++;
ng+=wa[idx-1];
}
ac[idx-1] = 1;
}else if("WA".equals(s)){
if(ac[idx-1]==0) wa[idx-1]++;
}
}
sc.close();
System.out.println(ok+" "+ng);
}
} | JAVA |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | N,M=map(int,input().split(' '))
AC=[0]*N
WA=[0]*N
for i in range(M):
p,s=input().split(' ')
p=int(p)
if s=='AC':
AC[p-1]=1
elif not AC[p-1]:
WA[p-1]+=1
print(sum(AC),sum([i if j==1 else 0 for i,j 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 | import java.util.*;
import java.io.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
PrintWriter ou = new PrintWriter(System.out);
int n = Integer.parseInt(sc.next());
int m = Integer.parseInt(sc.next());
boolean[] c = new boolean[n];
long ac = 0 , wa = 0;
int[] q = new int[n];
Arrays.fill(q , 0);
Arrays.fill(c , true);
int p;
String s;
for(int i = 0 ; i < m ; i++){
p = Integer.parseInt(sc.next()) - 1;
s = sc.next();
if(s.equals("WA") && c[p]) q[p]++;
if(s.equals("AC") && c[p]){
c[p] = false;
wa += q[p];
ac++;
}
}
sc.close();
ou.print(ac + " " + wa + "\n");
ou.flush();
}
} | 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> a(n,0),b(n,0);
int c=0,w=0;
for(int i=0;i<m;i++){
int p;
string s;
cin>>p>>s;
p--;
if(a[p]==1) continue;
if(s=="WA") b[p]++;
if(s=="AC") {c++; w+=b[p]; a[p]=1;}
}
cout<<c<<" "<<w<<endl;
} | CPP |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | n, m = map(int, input().split())
d = {}
for i in range(m):
p, s = input().split()
d.setdefault(p, [])
d[p].append(s)
cnt = 0; correct = 0
for v in d.values():
if "AC" not in v:
continue
correct += 1
cnt += v.index("AC")
print(correct, cnt)
| 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[] a = new int[n];
boolean[] s = new boolean[n];
for (int i = 0; i < n; i++) {
a[i] = 0;
s[i] = false;
}
for (int i = 0; i < m; i++) {
int p = sc.nextInt()-1;
String S = sc.next();
if(S.equals("WA")) {
if(!s[p]) a[p]++;
}else {
s[p] = true;
}
}
int count = 0;
int count2 = 0;
for (int i = 0; i < n; i++) {
if(s[i]) {
count++;
count2 += a[i];
}
}
System.out.printf("%d %d",count, count2);
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 | // In the name of god
#include <bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
long long int n,m,x,ac[maxn],wa[maxn],p,ans;
string s;
int main(){
cin>>n>>m;
for(int i=0;i<m;i++){
cin>>x>>s;
if(s=="AC"){
if(ac[x]==0){
ans++;
p+=wa[x];
}
ac[x]=1;
}
else{
wa[x]++;
}
}
cout<<ans<<' '<<p;
}
| CPP |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | #include <iostream>
#include <cstdio>
using namespace std;
int n, m, p, x, y, ac[100005], wa[100005];
char s[5];
int main() {
cin>> n>> m;
while(m--) {
scanf("%d %s", &p, s);
if(s[0]=='A' && !ac[p]) ac[p] = 1;
else if(s[0]=='W' && !ac[p]) wa[p]++;
}
for(int i=1; i<=n; i++) {
x += ac[i]==1;
if(ac[i]) y += wa[i];
}
cout<< x<< ' '<< y;
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() {
ios::sync_with_stdio(false);
int N, M;
cin >> N >> M;
vector<int> wa(N);
int ac = 0, pe = 0;
for (int i = 0; i < M; i++) {
int p;
string S;
cin >> p >> S;
p--;
if (wa.at(p) == -1) continue;
else if (S == "AC") ac++, pe += wa.at(p), wa.at(p) = -1;
else wa.at(p)++;
}
cout << ac << " " << pe << "\n";
} | 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 wa=0,ac=0;
vector<int> data(n,0);
vector<int> wacnt(n,0);
while(m){
int p;cin>>p;
string s;cin>>s;
if(!data.at(p-1)){
if(s=="WA")wacnt.at(p-1)++;
else {data.at(p-1)=1;ac++;wa+=wacnt.at(p-1);}
}
m--;
}
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>
#define int long long
using namespace std;
int n,q,temp,p=0,c=0;
int a[100005],b[100005];
signed main()
{
cin>>n>>q;
for (int i=1;i<=q;i++)
{
string s;
cin>>temp>>s;
if (s=="AC") a[temp]=1;
else
{
if (a[temp]==0) b[temp]++;
}
}
for (int i=1;i<=n;i++)
{
if (a[i])
{
c++;
p+=b[i];
}
}
cout<<c<<' '<<p<<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;
signed main(){
int n,m;
cin>>n>>m;
vector<int> pe(n,0);
for(int i=0;i<m;++i){
int p;
string s;
cin>>p>>s;
--p;
if(pe[p]<=0){
--pe[p];
if(s=="AC")pe[p]*=-1;
}
}
int r=0,pen=0;
for(int i=0;i<n;++i){
if(pe[i]>0){
++r;
pen+=pe[i]-1;
}
}
cout<<r<<" "<<pen;
} | 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
ac=[False]*n
for _ in range(m):
p,s=input().split()
p=int(p)
if ac[p-1]: continue
elif s=="WA": wa[p-1]+=1
else: ac[p-1]=True
print(ac.count(True),end=" ")
w=0
for i in range(n):
if ac[i]: w+=wa[i]
print(w) | PYTHON3 |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scn = new Scanner(System.in);
int N = scn.nextInt(), M = scn.nextInt();
boolean AC[] = new boolean[N];
int WA[] = new int[N];
int ac = 0;
int wa = 0;
for(int i = 0;i < M;i++) {
int p = scn.nextInt();
char[] s = scn.next().toCharArray();
if(s[0] == 'A') {
AC[p-1] = true;
}else {
if(!AC[p-1]) {
WA[p-1]++;
}
}
}
for(int i = 0;i < N;i++) {
if(AC[i]) {
ac++;
wa += WA[i];
}
}
System.out.println(ac + " " + wa);
}
}
| JAVA |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | n,m=map(int,input().split())
judge=["WA"]*n
count=[0]*n
ac=0
pena=0
for i in range(m):
p,s=input().split()
p=int(p)-1
if s=="AC" and judge[p]=="WA":
judge[p]="AC"
ac+=1
pena+=count[p]
elif s=="WA":
count[p]+=1
print(ac,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 | import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
// 入力
int n = sc.nextInt();
int[] a = new int[n+1];
int m = sc.nextInt();
int c = 0;
int[] d = new int[n+1];
for ( int i=0; i<m; i++ ) {
int p = sc.nextInt();
String s = sc.next();
if ( a[p] == 0 ) {
if ( s.equals("AC") ) {
c++;
a[p]++;
} else {
d[p]++;
}
}
}
int e = 0;
for ( int i=1; i<=n; i++ ) {
e = e + d[i] * a[i];
}
// 出力
System.out.println(c + " " + e);
}
} | 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[] arrayp = new int[100000];
String[] arrays = new String[100000];
int[] arrayA = new int[100000];
int[] arrayW = new int[100000];
for(int i=0;i<m;i++) {
arrayp[i] = sc.nextInt();
arrays[i] = sc.next();
}
for(int i=0;i<m;i++) {
if(arrays[i].equals("AC")){
arrayA[arrayp[i]]=1;
}else if(arrayA[arrayp[i]]!=1){
arrayW[arrayp[i]]+=1;
}
}
long counta=0,countw=0;
for(int i=0;i<100000;i++) {
if(arrayA[i]==1) {
counta+=1;
if(arrayW[i]>0) {
countw+=arrayW[i];
}
}
}
System.out.println(counta+" "+countw);
}
}
| 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> cnt (N);
vector<bool> ac (N);
int fail = 0;
int success = 0;
for(int i = 0; i < M; i++){
int p; string s; cin >> p >> s;
p--;
if(ac[p]) continue;
if(s == "AC"){
ac[p] = true;
fail += cnt[p];
success++;
}else{
cnt[p]++;
}
}
cout << success << " " << fail << 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.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int N = scan.nextInt();
int M = scan.nextInt();
int[] p = new int[M];
String[] S = new String[M];
for(int i=0; i<M; i++) {
p[i] = scan.nextInt();
S[i] = scan.next();
}
scan.close();
int ok[] = new int[N];
int pe[] = new int[N];
for(int i=0; i<M; i++) {
if(ok[p[i]-1] == 0) {
if(S[i].equals("AC")) {
ok[p[i]-1] = 1;
}
else if(S[i].equals("WA")) {
pe[p[i]-1]++;
}
}
}
int okSum = 0;
int peSum = 0;
for(int i=0; i<N; i++) {
okSum += ok[i];
if(ok[i] == 1) {
peSum += pe[i];
}
}
System.out.println(okSum + " " + peSum);
}
} | 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())
r = [False] * n
w = [0] * n
ok = 0
ng = 0
for i in range(m):
p, s = input().split()
p = int(p)
p -= 1
if s == 'AC':
if r[p] == False:
ok += 1
ng += w[p]
r[p] = True
else:
w[p] += 1
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 | n,m=map(int,input().split())
ac=[0]*(n+1)
wa=0
for i in range(m):
p,c=input().split()
if c=='WA' and ac[int(p)]!=1:
ac[int(p)]-=1
elif c=='AC' and ac[int(p)]!=1:
wa+=abs(ac[int(p)])
ac[int(p)]=1
print(ac.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 | #include <stdio.h>
int n,m,c[200200];
int main()
{
scanf ("%d %d",&n,&m);
int s=0,p=0;
while (m--){
int x; char S[10]; scanf ("%d %s",&x,S);
if (S[0] == 'A'){
if (c[x] >= 0){
s++; p += c[x];
c[x] = -1;
}
}
else{
if (c[x] >= 0) c[x]++;
}
}
printf ("%d %d\n",s,p);
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,i,j,p,ac=0,wa=0;
string s;
cin>>n>>m;
//string s[m];
bool f[n+1];
int sum[n+1];
for(i=1;i<=n;i++){f[i]=0;sum[i]=0;}
for(i=0;i<m;i++){
cin>>p>>s;
if(f[p])continue;
if(s=="AC"){ac++;f[p]=1;wa+=sum[p];}
else sum[p]++;
}
if(ac==0)wa=0;
cout<<ac<<" "<<wa;
return 0;
}
| CPP |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | import java.util.Arrays;
import java.util.Scanner;
public class Main {
static int[] p;
static int[] q;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = sc.nextInt();
boolean[] s = new boolean[n];
int count1 = 0;
int count2 = 0;
int[] array = new int[n];
for (int i = 0; i < m; i++) {
int tmp = sc.nextInt() - 1;
if (sc.next().charAt(0) == 'A') {
if (!s[tmp]) {
++count1;
s[tmp] = true;
}
} else {
if (!s[tmp]) {
++array[tmp];
}
}
}
for (int i = 0; i < n; i++) {
if (s[i]) {
count2 += array[i];
}
}
System.out.println(count1 + " " + count2);
}
}
| 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;
map<int, int> M;
map<int, int> ACM;
int p;
string s;
int WA = 0, AC = 0;
for (int i = 0; i < m; ++i)
{
cin >> p >> s;
if (s == "WA")
{
++M[p];
}
else if (s == "AC")
{
if (ACM[p] == 0)
{
ACM[p] = 1;
WA += M[p];
++AC;
}
}
}
cout << AC << " " << WA << endl;
return 0;
} | CPP |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | import java.util.*;
class Main{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int m=sc.nextInt();
int[] b=new int[n];
int ac=0;
int wa=0;
for(int i=0;i<m;i++){
int mon=sc.nextInt()-1;
String st=sc.next();
if(b[mon]==-1){
}else if(st.equals("AC")){
ac++;
wa+=b[mon];
b[mon]=-1;
}else if(st.equals("WA")){
b[mon]++;
}
}
System.out.println(ac+" "+wa);
}
} | JAVA |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
// 整数の入力
int n = sc.nextInt();
int m = sc.nextInt();
int miss = 0, count = 0;
int tmp;String tmp2;
int ans[] = new int[n];
boolean ans2[] = new boolean[n];
for(int i = 0;i < n;i++){
ans[i] = 0;
ans2[i] = false;
}
for(int i = 0;i < m;i++){
tmp = sc.nextInt();
tmp2 = sc.next();
if(ans2[tmp - 1] == false){
if(tmp2.equals("AC")){
count +=1;
ans2[tmp - 1] = true;
miss += ans[tmp - 1];
}else{
ans[tmp - 1] += 1;
}
}
}
System.out.println(count + " " + miss);
}
} | 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>
using namespace std;
const int mxN = 1e5 + 5;
bool done[mxN];
int WA[mxN];
int main() {
int n, m;
cin >> n >> m;
int ac = 0, wa = 0;
for(int i = 1; i <= m; ++i) {
int p;
cin >> p;
string s;
cin >> s;
if(done[p])
continue;
if(s == "AC") {
wa += WA[p];
++ac;
done[p] = true;
}
else
++WA[p];
}
cout << ac << ' ' << wa;
}
| CPP |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | n,m = map(int,input().split())
r = [False]*n
q = [0]*n
res = 0
for _ in [0]*m:
p,s = map(str,input().split())
p = int(p)-1
if s == 'AC':
if not r[p]:
r[p] = True
res += q[p]
else:
q[p] += 1
print(sum(r),res) | PYTHON3 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.