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 | N, M=map(int, input().split())
solved=[False]*N
wal=[0]*N
ac=0
wa=0
for _ in range(M):
p, s=input().split()
p=int(p)-1
if solved[p]:
continue
if s=="AC":
solved[p]=True
ac+=1
wa+=wal[p]
else:
wal[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())
sac = set()
lwa = [0] * n
for i in range(m):
p, s = input().split()
p = int(p) - 1
if p in sac:
continue
elif s == 'AC':
sac.add(p)
else:
lwa[p] += 1
print(len(sac), sum(lwa[p] for p in sac)) | 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_cnt = 0
wa_cnt = 0
d = {}
for _ in range(m):
p, s = input().split()
if p not in d:
d[p] = [s]
else:
d[p].append(s)
for i in d:
if 'AC' in d[i]:
ac_cnt += 1
wa_cnt += d[i].index('AC')
print(ac_cnt, wa_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 | n,m=map(int,input().split())
wa=[0]*(n+1)
ac=[0]*(n+1)
for _ in range(m):
p,s=input().split()
p=int(p)
if s=='AC':
ac[p]=1
if s=='WA' and ac[p]==0:
wa[p]+=1
wa=[wa[i]*ac[i] for i in range(n+1)]
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.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws NumberFormatException, IOException {
// TODO Auto-generated method stub
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String[] tmpArray = br.readLine().split(" ");
int n = Integer.parseInt(tmpArray[0]);
int m = Integer.parseInt(tmpArray[1]);
boolean[] ac = new boolean[n + 1];
int[] wa = new int[n + 1];
int acCount = 0;
int penalty = 0;
for(int i = 0; i < m; i++) {
tmpArray = br.readLine().split(" ");
int p = Integer.parseInt(tmpArray[0]);
String str = tmpArray[1];
if(!ac[p]) {
if(str.equals("AC")) {
ac[p] = true;
acCount++;
penalty += wa[p];
}
else {
wa[p]++;
}
}
}
System.out.println(acCount+" "+penalty);
}
}
| JAVA |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 |
import java.util.*;
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, List<String>> result = new HashMap<>();
for (int i = 0; i < m; i++) {
int p = sc.nextInt();
String s = sc.next();
if (!result.containsKey(p)) {
result.put(p, new ArrayList<>());
}
result.get(p).add(s);
}
int ok = 0;
int ng = 0;
for (Map.Entry<Integer, List<String>> entry : result.entrySet()) {
int acIndex = entry.getValue().indexOf("AC");
if (acIndex == -1) {
continue;
}
ok++;
ng += acIndex;
}
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())
a=0
p=0
L=[0 for _ in range(n)]
for _ in range(m):
num,s = input().split()
num=int(num)-1
if not L[num] == -1:
if s == "AC":
a+=1
p+=L[num]
L[num]=-1
else:
L[num]+=1
print(a,p) | PYTHON3 |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | #include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll n,m,i,pr,sol[100005]={0},p[100005]={0},pen=0,ans=0;
string s;
cin>>n>>m;
for(i=0;i<m;i++) {
cin>>pr>>s;
if(sol[pr]==0) {
if(s=="WA" ) p[pr]++;
else {
sol[pr]=1;
pen+=p[pr];
}
}
}
for(i=1;i<=n;i++) ans+=sol[i];
cout<<ans<<" "<<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 | #include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
bool ok[N];
char s[5];
int c[N];
int main (void) {
int n, m, ans = 0;
long long per = 0;
scanf("%d%d", &n, &m);
for (int i = 1, x; i <= m; i++) {
scanf("%d%s", &x, s);
if (s[0] == 'A') {
if (ok[x] == false) {
ok[x] = true;
ans ++;
per += c[x];
}
} else c[x] ++;
}
printf("%d %lld\n", ans, per);
} | 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 = [0] * N
r,w = 0,0
for i in range(M):
p, s = input().split()
if S[int(p)-1] >= 0:
if s == 'AC':
r+=1
w+=S[int(p)-1]
S[int(p)-1] = -1
else:
S[int(p)-1] = S[int(p)-1] + 1
print(r,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.*;
import java.io.*;
// This file is a "Hello, world!" in Java language by OpenJDK for wandbox.
class Main
{
public static void main(String[] args)
{
new Main().run();
}
void run(){
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();
--p;
String s=sc.next();
if(s.equals("AC")){
AC[p]=true;
}else{
if(!AC[p])++WA[p];
}
}
int ok=0;int ng=0;
for(int i=0;i<AC.length;++i){
if(AC[i]){
++ok;
ng+=WA[i];
}
}
System.out.println(ok+" "+ng);
}
void tr(Object...o){System.out.println(Arrays.deepToString(o));}
}
// OpenJDK reference:
// http://openjdk.java.net/
// Java language references:
// http://docs.oracle.com/javase
| 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 | mon,sub=map(int,input().split())
sei,pen=0,0
f=0
l=[0 for i in range(mon)]#ACで1
ll=[0 for i in range(mon)]
for i in range(sub):
n,re=input().split()
n=int(n)
if l[n-1]==1:f%=2
elif re=="WA":ll[n-1]+=1
else:
l[n-1]=1
sei+=1
pen+=ll[n-1]
print(sei,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 | import java.util.*;
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());
Set<Integer> ac = new HashSet<>();
Map<Integer, Integer> wa = new HashMap<>();
for (int i = 0; i < m; i++) {
int p = Integer.parseInt(sc.next());
String s = sc.next();
if("AC".equals(s)) {
ac.add(p);
}else {
if(!ac.contains(p)) {
int w = wa.getOrDefault(p, 0);
w++;
wa.put(p, w);
}
}
}
int res = 0;
for(int i:ac) {
res += wa.getOrDefault(i, 0);
}
System.out.println(ac.size() + " " + res);
}
}
| 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 account=0;
boolean[] accepted=new boolean[n];
int[] wacount=new int[n];
int tmpnum;
boolean ac;
for(int i=0;i<m;i++){
tmpnum=sc.nextInt()-1;
ac=sc.next().equals("AC");
if(!ac){
if(!accepted[tmpnum]){
wacount[tmpnum]++;
}
}else{
if(!accepted[tmpnum])account++;
accepted[tmpnum]=true;
}
}
int sum=0;
for(int i=0;i<n;i++){
if(accepted[i])sum+=wacount[i];
}
System.out.println(account+" "+sum);
}
}
| JAVA |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | n,m=map(int,input().split())
ac=0
wa=0
boac=[0]*n
bowa=[0]*n
for i in range(m):
p,s=map(str,input().split())
p=int(p)-1
if s=="WA":
bowa[p]+=1
if s=="AC" and boac[p]==0:
boac[p]=1
ac+=1
wa+=bowa[p]
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())
acl=["WA"]*n
wal=[0]*n
ans=0
for i in range(m):
p,s=input().split()
p=int(p)-1
if(acl[p]=="WA"):
if s=="WA":
wal[p]+=1
else:
ans+=wal[p]
acl[p]="AC"
print(acl.count("AC"),ans)
| PYTHON3 |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | d = [0]*10**5
a = set()
w = 0
for t in open(0):
p, s = t.split()
p = int(p)
if "AC" == s and p not in a:
w += d[p]
a.add(p)
if "WA" == s:
d[p] += 1
print(len(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 | #include<bits/stdc++.h>
using namespace std;
long long w[1000000],c[1000000];
int main()
{
long long n,k,m,i,j,x,y,p;
x=0;
y=0;
string s;
cin>>n>>m;
for (i=0;i<m;i++)
{
cin>>p;
cin>>s;
if (c[p]!=1)
{
if (s[0]=='W')
{
w[p]++;
}
else
{
c[p]=1;
}
}
}
for (i=0;i<=n;i++)
{
if (c[i]==1)
{
x++;
y=y+w[i];
}
}
cout<<x<<" "<<y<<endl;
} | CPP |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | #include <bits/stdc++.h>
using namespace std;
int N, M, ac, pe, p;
string S;
int main() {
cin >> N >> M;
vector<int> wa(N);
while (M-- && 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 | n,m=map(int,input().split())
p=[0]
p*=n
ac=set()
wa=0
for i in range(m):
pi,si=input().split()
pi=int(pi)
if si=='AC' and not pi in ac:
ac.add(pi)
wa+=p[pi-1]
else:
p[pi-1]+=1
ans=len(ac)
print(ans,wa,end=' ')
| 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.lang.*;
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 wanum[] = new int[n];
for(int i = 0;i<n;i++){
ac[i] = false;
wanum[i] = 0;
}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(s.equals("WA") && ac[p-1] == false){
wanum[p-1]++;
}
}
int acResult = 0;
int waResult = 0;
for(int i = 0;i<n;i++){
if(ac[i]){
acResult++;
waResult += wanum[i];
}
}
System.out.print(acResult + " ");
System.out.println(waResult);
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 | N,M=map(int,input().split())
AC=[0]*(N+1)
WA=[0]*(N+1)
ans=0
for _ in range(M):
p,s=input().split()
p=int(p)
if AC[p]==0:
if s=='AC':
AC[p]=1
ans+=WA[p]
else:
WA[p]+=1
print(sum(AC),ans)
| PYTHON3 |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | #include<bits/stdc++.h>
#include<math.h>
using namespace std;
int main(){
int n,m,i;
long long x;
cin>>n>>m;
string s;
vector<int> v(n,0),c(n,0);
for(i=0;i<m;i++) {
cin>>x;
cin>>s;
x--;
if(s=="AC") v[x]=1;
if(v[x]==0 && s=="WA") c[x]++;
}
x=0;
m=0;
for(i=0;i<n;i++) if(v[i]==1) x+=c[i],m++;
cout<<m<<" "<<x;
}
| CPP |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 |
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int N = scanner.nextInt();
int M = scanner.nextInt();
Map<Integer, Boolean> isAc = new HashMap<>();
Map<Integer, Integer> penalties = new HashMap<>();
for (int i = 1 ; i <= M ; i++) {
int p = scanner.nextInt();
String S = scanner.next();
if (S.equals("WA") && !isAc.getOrDefault(p, false)) {
penalties.put(p, penalties.getOrDefault(p, 0) + 1);
} else {
isAc.put(p ,true);
}
}
int acCount = 0;
int pCount = 0;
for (int p : isAc.keySet()) {
acCount++;
pCount += penalties.getOrDefault(p, 0);
}
System.out.printf("%d %d%n", acCount, pCount);
}
}
| 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]*M
S=["a"]*M
x=[0]*N
y=[0]*N
for i in range(M):
p[i],S[i]=input().split()
k=int(p[i])-1
if x[k]==0:
if S[i]=="WA":
y[k]+=1
else:
x[k]=1
z=sum(x)
w=0
for i in range(N):
if x[i]==1:
w+=y[i]
print(z,w) | PYTHON3 |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
int c = 0;
int d = 0;
if(b>0){int [] in = new int [b];
String [] str = new String [b];
int [] in2 = new int [a];
for(int i=0;i<b;i++){in[i] = sc.nextInt();str[i] = sc.next();
}
for(int i=0;i<b;i++){if("AC".equals(str[i]) && in2[in[i]-1]>=0)
{
c++;d+=in2[in[i]-1];in2[in[i]-1]=-1000000;
}
else {in2[in[i]-1]++;}
}
}
System.out.println(c + " " + d);
}
} | JAVA |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int M = sc.nextInt();
int correct=0;
int penality=0;
int[] a = new int[N+1];
while(M-->0)
{
int i = sc.nextInt();
String j = sc.next();
if(j.contentEquals("AC")&&a[i]!=-1)
{
correct++;
penality+=a[i];
a[i]=-1;
}
else if(a[i]!=-1) {
a[i]++;
}
}
System.out.println(correct+" "+penality);
}
}
| JAVA |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | n,m=map(int,input().split())
l=[0]*(n+1)
p=0
for _ in range(m):
a,b=list(input().split())
if str(b)=="AC" and l[int(a)]!=-1:
p+=l[int(a)]
l[int(a)]=-1
elif str(b)=="WA" and l[int(a)]!=-1:
l[int(a)]+=1
print(l.count(-1),p) | PYTHON3 |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 |
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[] arr = new int[n];
int[] nums = new int[n];
int countA = 0;
int countW = 0;
for(int i = 0; i < m; i++){
int index = sc.nextInt();
String res = sc.next();
if(arr[index-1] == 0 && res.equals("WA")) {
nums[index - 1]+=1;
}else if(arr[index-1] == 0 && res.equals("AC")){
countA += 1;
arr[index-1] = 1;
countW+=nums[index-1];
}
}
System.out.println(countA);
System.out.println(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 | n,m=map(int,input().split())
d,c,wa=[0]*n,0,0
for _ in range(m):
p,a=input().split()
p=int(p)-1
if d[p]!=-1:
if 'W' in a:
d[p]+=1
else:
wa+=d[p]
d[p]=-1
c+=1
print(c,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())
di = [[] for _ in range(n)]
ac = 0
wa = 0
for i in range(m):
a,b = map(str,input().split())
di[int(a)-1].append(b)
for j in range(n):
if "AC" in di[j]:
wa += di[j].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 | // C - Welcome to AtCoder
#include <bits/stdc++.h>
using namespace std;
int wa_count[100000];
int main(){
int n,m,p,ac=0,wa=0;
char s[3];
scanf("%d%d",&n,&m);
while(m--){
scanf("%d%s",&p,s); --p;
if(wa_count[p] < 0) continue;// ac
if(s[0] == 'W') wa_count[p]++;
else{
ac++;
wa += wa_count[p];
wa_count[p] = -1;// ac flag on
}
}
printf("%d %d\n",ac,wa);
} | CPP |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | import java.util.Scanner;
public class Main {
public static void main(String[] args){
try(Scanner sc = new Scanner(System.in)) {
int n = sc.nextInt();
int m = sc.nextInt();
int[] wrongCounts = new int[n];
boolean[] corrects = new boolean[n];
int totalAC = 0;
for( int i = 0 ; i < m ; i++ ) {
int index = sc.nextInt() - 1;
String ans = sc.next();
if ( corrects[index]) {
// no count
}
else if ( ans.equals("WA")) {
wrongCounts[index]++;
}
else if ( ans.equals("AC")) {
corrects[index] = true;
totalAC++;
}
}
//calc total Wrong count
// int totalWrong = Arrays.stream(wrongCounts).sum();
int totalWrong = 0;
for(int i = 0 ; i < n ; i++ ) {
if ( corrects[i]) {
totalWrong += wrongCounts[i];
}
}
System.out.println(String.format("%d %d", totalAC, totalWrong));
}
}
} | JAVA |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | N, M = map(int, input().split())
ac = [0] * N
wa = [0] * N
for i in range(M):
p, S = input().split()
p = int(p) - 1
if S == 'AC':
ac[p] = 1
if S == 'WA' and ac[p] == 0:
wa[p] += 1
print(sum(ac), sum(ac[i] * wa[i] for i in range(N)))
| 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;
unordered_map <int, int> umap;
unordered_set <int> done;
int suc = 0, pen = 0;
for(int i=0; i<m; i++) {
int a; string s;
cin>>a>>s;
if(done.find(a) == done.end()){
if(s == "WA")
umap[a]++;
else {
pen += umap[a];
suc++;
done.insert(a);
}
}
}
cout<<suc<<" "<<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 | 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];
int correct=0;
int penalty=0;
for(int i=0;i<m;i++){
int p = sc.nextInt();
String s = sc.next();
if(s.equals("AC") && list[p-1][0]!=1){
list[p-1][0]=1;
correct++;
penalty+=list[p-1][1];
}else if(s.equals("WA") && list[p-1][0]!=1){
list[p-1][1]++;
}
}
System.out.println(correct+" "+penalty);
}
}
| JAVA |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | from collections import defaultdict
n,m = list(map(int, input().split()))
wa = defaultdict(int)
ac = set()
for _ in range(m):
p, s = input().split()
if(s == "AC"):
ac.add(p)
if (p not in ac and s=="WA"):
wa[p] += 1
print(len(ac), sum([wa[i] for i in ac])) | PYTHON3 |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | n,m=map(int,input().split())
A=[0]*n
W=[0]*n
wa=0
ac=0
for _ in range(m):
p,s=input().split()
if s=="AC":
A[int(p)-1]=1
if s=="WA" and A[int(p)-1]!=1:
W[int(p)-1]+=1
for i in range(n):
if A[int(i)]==0:
W[int(i)]=0
print(sum(A),sum(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 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
ios::sync_with_stdio(0);
cin >> n >> m;
int cnt[100005] = {};
int a = 0, b = 0;
for (int i = 1; i <= m; i++) {
int x; string s;
cin >> x >> s;
if (s[0] == 'A') {if (cnt[x]>= 0) b += cnt[x], a++, cnt[x] = -1000000;}
else cnt[x] ++;
}
cout << a << " " << b << endl;
} | CPP |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | from collections import *
r = set()
c = defaultdict(int)
n, m = map(int, input().split())
for _ in range(m):
l = input().split()
i = int(l[0])
if l[1] == 'AC':
r.add(i)
elif i not in r:
c[i] += 1
print(len(r), sum(v for k, v in c.items() if k in r)) | PYTHON3 |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int M = sc.nextInt();
int[] ac = new int[N];
int[] pena = new int[N];
for(int i=0; i<M; i++){
int p = sc.nextInt();
String S = sc.next();
p--;
if(ac[p] == 1) continue;
if(S.equals("AC")){
ac[p] = 1;
} else {
pena[p]++;
}
}
int AC=0, PENA = 0;
for (int i = 0; i < N; i++) {
AC += ac[i];
if(ac[i] == 1) PENA += pena[i];
}
System.out.println(AC + " " + PENA);
}
}
| JAVA |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | #include <bits/stdc++.h>
using namespace std;
int main()
{
//while(true)
{
int m,n;
cin>>m>>n;
map<int,int> was;
map<int,int> acs;
int sum = 0;
for( int i=0; i<n; i++ )
{
int a;
string b;
cin>>a>>b;
if( b == "WA")
was[a]++;
else
{
if(!acs.count(a))
sum += was[a];
acs[a] = 1;
}
}
cout << acs.size() << " " << sum << 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<cstdio>
#include<algorithm>
using namespace std;
#define N 100001
bool ok[N];
int sum[N];
int main()
{
int n,m,x,a=0,b=0;
char c;
scanf("%d%d",&n,&m);
for(int i=1;i<=m;++i)
{
scanf("%d",&x);
scanf("%*c%c%*c",&c);
if(ok[x]) continue;
if(c=='A') ok[x]=true;
else sum[x]++;
}
for(int i=1;i<=n;++i)
if(ok[i]) a++,b+=sum[i];
printf("%d %d",a,b);
} | 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, ac = [0]*n, [0]*n
for i in range(m):
p, s = input().split()
p = int(p)
if s=="AC": ac[p-1] = 1
else:
if ac[p-1]==0: wa[p-1] += 1
wac = 0
for i in range(n): wac += wa[i] * ac[i]
print(sum(ac), wac)
| 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,c=0,p=0; cin >>n >>m;
vector<bool>v(n,0); vector<int>sum(n,0);
for(int i=0; i<m; i++){
int p; string s; cin >>p >>s;
if(!v[p-1]){
if(s=="WA") sum[p-1]++;
else{v[p-1]=1; c++;}
}
}
for(int i=0; i<n; i++) if(v[i]) p+=sum[i];
cout <<c<<" "<<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 | N,M = map(int,input().split())
AC=[0]*N
WA=[0]*N
WAtimes=0
ACtimes=0
for i in range(M):
p,S=map(str,input().split())
p=int(p)-1
if 'AC'==S:
if 0==AC[p]:
ACtimes+=1
WAtimes+=WA[p]
AC[p]+=1
if 'WA'==S:
WA[p]+=1
print(ACtimes,WAtimes) | PYTHON3 |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | #include<bits/stdc++.h>
using namespace std;
int n,m,ans,ans2;
const int N=1e5+5;
int x[N];bool f[N];
int main()
{
cin>>n>>m;
for(int i=0;i<m;i++)
{
string s;
int a;
cin>>a>>s;
if(s=="WA"&&!f[a])
x[a]++;
else
if(s=="AC"&&!f[a])
{
ans+=x[a];
f[a]=true;
ans2++;
}
}
cout<<ans2<<' '<<ans<<endl;
return 0;
} | CPP |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = sc.nextInt();
int ac = 0;
int wa = 0;
int[] sub = new int[n];
for(int i = 0; i < m; i++){
int p = sc.nextInt() - 1;
boolean s = sc.next().equals("AC");
if(s && sub[p] > -1){
wa += sub[p];
sub[p] = -1;
ac++;
}else if(!s && sub[p] > -1){
sub[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())
a=[[] for ii in range(n)]
for ii in range(m):
p,s=input().split()
p=int(p)-1
a[p].append(s)
r=0
q=0
for ii in range(n):
#print(a[ii])
if "AC" in a[ii]:
r+=1
q+=a[ii].index("AC")
print(r,q) | PYTHON3 |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | n,m = map(int,input().split())
toi=[0 for i in range(n)]
ac=0
wa=0
for i in range(m):
p,s=map(str,input().split())
p=int(p)
if s=="AC":
if toi[p-1]!=-1:
wa+=toi[p-1]
ac+=1
toi[p-1]=-1
else:
if toi[p-1]!=-1:
toi[p-1]+=1
print(ac,wa)
| PYTHON3 |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | n,m=map(int,input().split())
ac = [0]*(n+1)
wa = [0]*(n+1)
for _ in range(m):
p,s = tuple(input().split())
p = int(p)
if ac[p]==1: continue
if s == 'WA': wa[p]+=1
else: ac[p] = 1
pena = 0
for a,w in zip(ac,wa):
pena += a*w
print(sum(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 | #include <bits/stdc++.h>
using namespace std;
int n, m, hsh[100001];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n >> m;
int pen = 0, ac = 0;
for(int i = 0; i < m; i++){
int p;
string s;
cin >> p >> s;
if(s == "AC" && hsh[p] != -1) ac++, pen += hsh[p], hsh[p] = -1;
else if(hsh[p] != -1) hsh[p]++;
}
cout << ac << " " << pen << "\n";
return 0;
} | CPP |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | import java.util.*;
import java.lang.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int M = sc.nextInt();
String[] ac = new String[N+1];
int[] wa = new int[N+1];
for( int i=0; i<N+1; i++ ){
ac[i] = "Q";
}
int count1 = 0;
for( int i=0; i<M; i++ ){
int a = sc.nextInt();
String ss = sc.next();
if( ss.equals("AC") ){
ac[a] = "AC";
}else{
if( ac[a].equals("Q") ){
wa[a]++;
}
}
}
int count2 = 0;
for( int i=0; i<N+1; i++ ){
if( ac[i].equals("AC") ){
count1++;
}else{
wa[i] = 0;
}
count2 += wa[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 | n,m=map(int,input().split())
AC=[0]*n
cnt=[0]*n
ans=0
for i in range(m):
p,s=input().split()
p=int(p)
s=str(s)
if s=='WA' and AC[p-1]==0:
cnt[p-1]+=1
if s=='AC' and AC[p-1]==0:
AC[p-1]=1
ans+=cnt[p-1]
print(sum(AC),ans) | PYTHON3 |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | // C - Welcome to AtCoder
#include <bits/stdc++.h>
using namespace std;
int wa_count[100000];
int main(){
int n,m,p,ac=0,wa=0;
char s[3];
scanf("%d%d",&n,&m);
while(m--){
scanf("%d%s",&p,s); --p;
if(wa_count[p] >= 0)// not ac
if(s[0] == 'W') wa_count[p]++;
else{
ac++;
wa += wa_count[p];
wa_count[p] = -1;// ac flag on
}
}
printf("%d %d\n",ac,wa);
} | CPP |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | #include <bits/stdc++.h>
using namespace std;
#define N 100005
int n,m,ans[2],vs[N][2];
int main()
{
scanf("%d %d",&n,&m);
for(int i=1,x;i<=m;++i)
{
char a[5];scanf("%d %s",&x,a);
if(a[0]=='A') vs[x][0]=1;
else if(!vs[x][0]) ++vs[x][1];
}
for(int i=1;i<=n;++i) if(vs[i][0])
ans[0]+=vs[i][0],ans[1]+=vs[i][1];
printf("%d %d\n",ans[0],ans[1]);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;
const int N = 1e5;
bool uda[N+5];
int cnt[N+5];
int n,m;
int main(){
scanf("%d%d",&n,&m);
int ac = 0;
int pen = 0;
for(int i=1;i<=m;i++){
int x;
string s;
cin >> x >> s;
if(s[0] == 'A'){
if(uda[x]) continue;
uda[x] = 1;
ac++;
pen+=cnt[x];
} else {
cnt[x]++;
}
}
printf("%d %d\n",ac,pen);
return 0;
}
| CPP |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | n,m=map(int,input().split())
ac=[0]*n
wa=[0]*n
for i in range(m):
p,s=input().split()
p=int(p)-1
if ac[p]==0:
if s=='AC':
ac[p]=1
else:
wa[p]+=1
wasum=0
for i in range(n):
if ac[i]==1:
wasum+=wa[i]
print(sum(ac),wasum) | 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<bool>V(N,true);vector<int>F(N);int P=0;int A=0;
for(int X=0;X<M;X++){
int L;string S;cin>>L>>S;
if(V[L-1]&&S=="WA"){
P++;F[L-1]++;
}
if(V[L-1]&&S=="AC"){
A++;V[L-1]=false;
}
}
for(int X=0;X<N;X++){
if(V[X])P-=F[X];
}
cout<<A<<" "<<P<<endl;
}
| CPP |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | #include <bits/stdc++.h>
using namespace std;
int N, M, ac, pe, p;
string S;
int main() {
cin >> N >> M;
vector<int> wa(N + 1, 1);
while (M-- && cin >> p >> S) if (wa.at(p)) {
if (S == "AC") ac++, pe += --wa.at(p), wa.at(p) = 0;
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 | 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 acc = 0;
int pc = 0;
int[] wa = new int[n];
boolean[] ac = new boolean[n];
for(int i=0; i<m; i++) {
int a = sc.nextInt() - 1;
String res = sc.next();
if(ac[a]) {
continue;
}
if(res.equals("AC")) {
acc++;
pc+=wa[a];
ac[a] = true;
} else {
wa[a]++;
}
}
System.out.println(String.format("%d %d", acc, pc));
}
}
| JAVA |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | #include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string.h>
#include<vector>
using namespace std;
int n,m,x,y,k[100009];
bool f[100009];
int main(void){
cin>>n>>m;
for(int i=0;i<m;i++){
int a;
cin>>a;
string s;
cin>>s;
if(f[a])
continue;
if(s=="AC"){
x++;
y+=k[a];
f[a]=1;
}
else{
k[a]++;
}
}
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 | n,m=map(int,input().split())
ans=0
l=[0] * n
d={}
for i in range(m):
p,s=input().split()
q=int(p)-1
if q in d:
continue
if s=="AC":
ans+=l[q]
d[q]=s
else:
l[q]+=1
print(len(d),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 | n1,m1 = map(int,input().split())
dic = [0 for i in range(n1)]
se = set()
for i in range(m1):
n,m = input().split()
if n not in se and m == "WA":
dic[int(n)-1] += 1
else:
se.add(n)
print(len(se),sum([dic[int(i)-1] for i in se]))
| PYTHON3 |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | import java.util.*;
public class Main {
public static void main(String args[]) throws Exception {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = sc.nextInt();
Set<Integer> finished = new HashSet<>();
Map<Integer, Integer> map = new HashMap<>();
int cnt = 0;
for(int i = 0; i < m; i++) {
int p = sc.nextInt();
String res = sc.next();
if(finished.contains(p))
continue;
if(res.equals("AC")) {
finished.add(p);
cnt += map.getOrDefault(p, 0);
} else {
map.put(p, map.getOrDefault(p, 0) + 1);
}
}
System.out.println(finished.size() + " " + cnt);
}
}
| JAVA |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | import java.util.*;
class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt(),m=sc.nextInt();
int[] p = new int[m];
String[] q = new String[m];
boolean[] check = new boolean[n+1];
int[] count = new int[n+1];
int countAC = 0;
int countWA = 0;
for(int i = 0 ; i<m;i++){
p[i] = sc.nextInt();
q[i] = sc.next();
if(q[i].equals("AC")){
check[p[i]] = true;
} else {
if(!check[p[i]]){
count[p[i]] ++;
}
}
}
for(int i = 1;i<=n;i++){
if(check[i]){
countAC ++;
countWA += count[i];
}
}
System.out.println(countAC+" "+countWA);
}
} | 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<stdio.h>
#include<map>
using namespace std;
char a[10];
int main()
{
map<int,int>mp;
int n,m,i,p,ac=0,wa=0;scanf("%d%d",&n,&m);
while(m--)
{
scanf("%d%s",&p,a);
if(mp[p]==-1)continue;
if(a[0]=='A')
{
wa+=mp[p];
ac++;
mp[p]=-1;
continue;
}
mp[p]++;
}
printf("%d %d\n",ac,wa);
} | CPP |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int m=sc.nextInt();
boolean[] x=new boolean[n+1];
Arrays.fill(x,false);
int[] y=new int[n+1];
int sum=0,num=0;
for(int i=0;i<m;i++) {
int a=sc.nextInt();
String s=sc.next();
if(s.equals("AC")) {
x[a]=true;
}else {
if(!x[a])
y[a]++;
}
}
for(int i=0;i<n+1;i++) {
if(x[i]&&y[i]>0)
num+=y[i];
if(x[i])
sum++;
}
System.out.print(sum+" "+num);
}
} | JAVA |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | 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[] ac = new boolean[n+1];
int[] wa = new int[n+1];
int a = 0;
for(int i = 0; i < m; i++){
int p = Integer.parseInt(sc.next());
String s = sc.next();
if(!ac[p]){
if(s.equals("AC")){
a++;
ac[p] = true;
}else{
wa[p]++;
}
}
}
int penalty = 0;
for(int i = 1; i <= n; i++){
if(ac[i]){
penalty += wa[i];
}
}
System.out.println(a + " " + penalty);
}
} | JAVA |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | N,M = map(int,input().split())
A = [0]*(N+1)
ac = 0
pe = 0
for i in range(M):
p,S = input().split()
if A[int(p)] == -1:
continue
if S == "AC":
ac += 1
pe += A[int(p)]
A[int(p)] = -1
else:
A[int(p)] += 1
print(ac,pe) | PYTHON3 |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | #include <bits/stdc++.h>
using namespace std;
int main(){
int N,M,j=0,k=0;
cin>>N>>M;
vector<int> A(N,0);
vector<bool> B(N,true);
for(int i=0;i<M;i++){
int p;
string S;
cin>>p>>S;
if(S=="AC"){
if(B[p-1]){
j++;
k+=A[p-1];
B[p-1]=false;
}
}else
A[p-1]++;
}
cout<<j<<' '<<k<<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 ans_array[]= new int[n];
int wrong_array[]= new int[n];
for(int i=0;i<n;i++) {
ans_array[i]=0;
wrong_array[i]=0;
}
int wrong=0,ans=0;
for(int i=0;i<m;i++) {
if(ans_array[p[i]-1]==0 ) {
if(s[i].equals("AC")) {
ans++;
ans_array[p[i]-1]=1;
wrong+=wrong_array[p[i]-1];
} else {
wrong_array[p[i]-1]++;
}
}
}
System.out.println(ans+" "+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 <cstdio>
using namespace std;
int N, M, cnt[2][100001], AC, WA;
int main() {
scanf("%d %d", &N, &M);
int p; char S[2];
for(int i = 0; i < M; ++i) {
scanf("%d %s", &p, &S);
if(S[0] == 'A') ++cnt[0][p];
else if(cnt[0][p] == 0) ++cnt[1][p];
}
for(int i = 1; i <= N; ++i) {
if(cnt[0][i] > 0) ++AC, WA+=cnt[1][i];
}
printf("%d %d\n", AC, WA);
} | CPP |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | n,m=map(int,input().split())
a=[0]*n
ans=0
for i in range(m):
p,s=input().split()
p=int(p)-1
if a[p]!=1:
if s=='WA':a[p]-=1
else:
ans-=a[p]
a[p]=1
for i in range(n):
a[i]=max(a[i],0)
print(sum(a),ans) | PYTHON3 |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | N,M=map(int,input().split())
AC=[0]*N; WA=[0]*N;
for i in range(M):
p,S=map(str,input().split())
p=int(p)
if AC[p-1]==0:
if S=="AC":
AC[p-1]+=1
else:
WA[p-1]+=1
for i in range(N):
if AC[i]==0:
WA[i]=0
print(sum(AC),sum(WA)) | PYTHON3 |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | import java.util.*;
class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int mondai = sc.nextInt();
int teisyutu = sc.nextInt();
int[] seitou = new int[mondai];
int[] pena = new int[mondai];
int ansOK = 0;
int ansNG = 0;
for ( int i = 0; i < teisyutu; i++){
int number = sc.nextInt() - 1;
String ret = sc.next();
if ( seitou[number] == 0){
if (ret.equals("AC")){
seitou[number]++;
} else {
pena[number]++;
}
}
}
for ( int i = 0; i < seitou.length; i++){
if ( seitou[i] == 1){
ansOK += seitou[i];
ansNG += pena[i];
}
}
System.out.println(ansOK + " " + ansNG);
}
}
| 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>
const int maxn=1e5+9;
using namespace std;
int main()
{
int i,ac=0,wa=0,vis[maxn]={0},x,n,m,sum[maxn]={0};
char s[10];
scanf("%d%d",&n,&m);
while(m--)
{
scanf("%d%s",&x,s);
if(vis[x])continue;
if(s[0]=='A')vis[x]=1,ac++,wa+=sum[x];
else sum[x]++;
}
printf("%d %d\n",ac,wa);
} | CPP |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | n,m = map(int,input().split())
qaw = [[0,0] for i in range(n)]
x = 0
y = 0
for i in range(m):
p,s = input().split()
p = int(p)-1
if s == "AC":
qaw[p][0] = 1
elif qaw[p][0] == 0:
qaw[p][1] += 1
for q in qaw:
if q[0] == 1:
x += 1
y += q[1]
print(x,y) | PYTHON3 |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | import java.util.Scanner;
public class Main{
public static void main(String[] args) {
// TODO 自動生成されたメソッド・スタブ
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int m=sc.nextInt();
boolean[] ac=new boolean[n];
int[] wa=new int[n];
for(int i=0;i<n;i++) {
ac[i]=false;
wa[i]=0;
}
for(int i=0;i<m;i++) {
int sub=sc.nextInt()-1;
String result=sc.next();
if(ac[sub]){
continue;
}else if(result.equals("AC")) {
ac[sub]=true;
}else {
wa[sub]++;
}
}
int acnum=0;
int wanum=0;
for(int i=0;i<n;i++){
if(ac[i]){
acnum++;
wanum+=wa[i];
}
}
System.out.println(acnum+" "+wanum);
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 | N,M=map(int, input().split())
ansY = [0]*N
ansWA = [0]*N
for i in range(M):
id,ans = input().split()
idr = int(id)-1
if ans=='AC':
ansY[idr]=1
elif ans=='WA' and ansY[idr]==0:
ansWA[idr]+=1
WA = sum([x * y for (x, y) in zip(ansY, ansWA)])
print(sum(ansY),WA) | PYTHON3 |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | #include <bits/stdc++.h>
using namespace std;
int main()
{
int n,m;cin>>n>>m;
vector<int>ac(n),pena(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{
pena[p]++;
}
}
int AC=0,PENA=0;
for(int i=0;i<n;i++){
AC+=ac[i];
if(ac[i])PENA+=pena[i];
}
cout<<AC<<" "<<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 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
bool f[114514];
ll cnt[114514];
int main(){
ll n,m;
cin>>n>>m;
ll ansac=0,answa=0;
for(int i=0;i<m;i++){
ll x;
string s;
cin>>x>>s;
if(!f[x]){
if(s=="WA")cnt[x]++;
else {
f[x]=1;
ansac++;
answa+=cnt[x];
}
}
}
cout<<ansac<<' '<<answa;
return 0;
}
| CPP |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 |
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
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(); // 提出回数
int[] ac = new int[n];
int[] wa = new int[n];
for (int i = 0; i < m; i++) {
int a = sc.nextInt();
String s = sc.next();
if (s.equals("AC") && ac[a - 1] == 0) {
ac[a - 1]++;
continue;
}
if (s.equals("WA") && ac[a - 1] == 0) {
wa[a - 1]++;
}
}
int sumA = 0;
int sumB = 0;
for (int i = 0; i < n; i++) {
sumA += ac[i];
if (ac[i] > 0) {
sumB += wa[i];
}
}
System.out.println(sumA);
System.out.println(sumB);
}
}
| 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;
int c[100010];
bool b[100010];
string s;
int n,m;
int ans1,ans2;
int main()
{
scanf("%d%d",&n,&m);
for(int i=1;i<=m;i++)
{
scanf("%d",&a);
cin>>s;
if(b[a]==true)
{
continue;
}
else
{
if(s=="WA")
{
c[a]++;
}
else
{
ans1+=c[a];
ans2++;
b[a]=1;
}
}
}
printf("%d %d\n",ans2,ans1);
return 0;
}
| CPP |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | 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[] p=new int[m];
String[] s=new String[m];
for(int a=0;a<m;a++){
p[a]=sc.nextInt();
s[a]=sc.next();
}
int ac=0;
int wa=0;
int[] w=new int[n];
int[] a=new int[n];
for(int c=0;c<m;c++){
if(s[c].equals("WA")&&a[p[c]-1]==0){
w[p[c]-1]++;
}else if(s[c].equals("AC")&&a[p[c]-1]==0){
a[p[c]-1]++;
}
}
for(int d=0;d<n;d++){
ac+=a[d];
if(a[d]==1){
wa+=w[d];
}
}
System.out.println(ac);
System.out.println(wa);
}
} | JAVA |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | n,m = map(int,input().split())
ac = [0 for _ in range(n)]
wa = [0 for _ in range(n)]
for _ in range(m):
a,b = input().split()
a = int(a) - 1
if b == 'AC':
ac[a] = 1
elif ac[a] == 0:
wa[a] += 1
for i in range(n):
wa[i] *= ac[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 | N, M=map(int,input().split())
if M==0:
print("0 0")
else:
ac=0
pe=0
ch=[0]*N
Ch=[0]*N
for i in range(M):
a, b=input().split()
a=int(a)-1
if ch[a]==1:
continue
elif b=="WA":
Ch[a]+=1
else:
ch[a]=1
ac+=1
pe+=Ch[a]
print(ac,pe)
| PYTHON3 |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | import java.util.*;
import java.math.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = sc.nextInt();
int right = 0;
int penalty = 0;
HashMap<Integer, Integer> map = new HashMap<>();
HashSet<Integer> set = new HashSet<>();
for(int i = 0; i < m; ++i) {
int index = sc.nextInt();
String s = sc.next();
if(set.contains(index)) continue;
if(s.equals("AC")) {
penalty += map.getOrDefault(index, 0);
++right;
set.add(index);
} else {
if(!map.containsKey(index)) {
map.put(index, 1);
} else {
map.put(index, map.get(index) + 1);
}
}
}
System.out.println(right + " " + 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 a[100001];
int ans,cnt,n,m;
int main(){
scanf("%d%d",&n,&m);
while(m--){
int x;
char s[5];
scanf("%d%s",&x,s);
if(a[x]==-1)continue;
if(s[0]=='A'){
cnt++;
ans+=a[x];
a[x]=-1;
}
else a[x]++;
}
printf("%d %d\n",cnt,ans);
return 0;
} | CPP |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | 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[] acs = new int[n + 1];
int[] was = new int[n + 1];
for(int i = 0; i < m; i++) {
int p = Integer.parseInt(sc.next());
String r = sc.next();
if(r.equals("AC") && acs[p] == 0) {
acs[p]++;
}
else {
if(acs[p] == 0) {
was[p]++;
}
}
}
long ans = 0;
long pen = 0;
for(int i = 0; i < n; i++) {
ans += acs[i + 1];
pen += (acs[i + 1] == 1 ? was[i + 1] : 0);
}
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 collections
k,n = map(int, raw_input().split(' '))
cc = {'AC': collections.Counter(), 'WA': collections.Counter()}
for _ in range(n):
i,res = raw_input().split(' ')
i = int(i)
if res == 'AC':
cc['AC'][i] += 1
elif res == 'WA' and cc['AC'][i] == 0:
cc['WA'][i] += 1
print len(cc['AC']), sum([cc['WA'][p] for p in cc['AC']] or [0]) | PYTHON |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;
public class Main {
public static final int MOD = 1000000007;
public static ArrayList<Integer> list = new ArrayList<>();
public static void main(String[] args) {
int i,j;
Scanner sc = new Scanner(in);
int n = parseInt(sc.next());
int m = parseInt(sc.next());
int[] p = new int[m];
String[] s = new String[m];
for(i=0;i<m;i++) {
p[i] = parseInt(sc.next());
s[i] = sc.next();
}
sc.close();
boolean[] acf = new boolean[n+1];
int[] wac = new int[n+1];
int ac = 0;
int wa = 0;
for(i=0;i<m;i++) {
if(s[i].equals("WA")) {
if(!acf[p[i]]) {
wac[p[i]]++;
}
} else {
if(!acf[p[i]]) {
ac++;
wa+=wac[p[i]];
acf[p[i]]=true;
}
}
}
out.printf("%d %d%n", ac, wa);
}
}
| JAVA |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = Integer.parseInt(sc.next());
int m = Integer.parseInt(sc.next());
int[] p = new int[n];
long wa = 0;
long ac = 0;
for (int i = 0; i < m; i++) {
int pi = Integer.parseInt(sc.next());
String s = sc.next();
if ("WA".equals(s) && p[pi - 1] != -1) {
p[pi - 1]++;
} else if ("AC".equals(s) && p[pi - 1] >= 0) {
ac++;
wa += p[pi - 1];
p[pi - 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 | n,m=map(int,input().split())
ac=[0]*n
wa=[0]*n
for i in range(m):
p,s=input().split()
if s=='AC' and ac[int(p)-1]==0:
ac[int(p)-1]+=1
elif s=='WA' and ac[int(p)-1]==0:
wa[int(p)-1]+=1
ans=0
for i,j in zip(ac,wa):
ans+=i*j
print(sum(ac),ans) | PYTHON3 |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | import 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 = 0;
int wa = 0;
int[] isAC = new int[n + 1];
int[] cntWA = new int[n + 1];
for (int i = 0; i < m; i++) {
int p = sc.nextInt();
String s = sc.next();
if ("WA".equals(s)) {
if (isAC[p] == 0) {
cntWA[p]++;
}
} else {
isAC[p] = 1;
}
}
for (int i = 1; i <= n; i++) {
ac += isAC[i];
if (isAC[i] == 1) {
wa += cntWA[i];
}
}
System.out.println(ac + " " + wa);
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 | import sys
input=sys.stdin.readline
n,m=map(int,input().split())
sa,lw=set(),[0]*n
for _ in range(m):
p,s=input().split()
if p in sa: continue
if s=='AC': sa.add(p)
else: lw[int(p)-1]+=1
print(len(sa),sum(lw[int(p)-1] for p in sa)) | PYTHON3 |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | import java.util.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 ques[] = new int[N];
int correct = 0;
int penalties = 0;
for(int i=0; i<M; i++){
int prob= sc.nextInt();
String verdict= sc.next();
if(ques[prob-1]==-1){
continue;
}
if(verdict.equals("AC")){
correct++;
penalties += ques[prob-1];
ques[prob-1] = -1;
}
else{
ques[prob-1] += 1;
}
}
System.out.println(correct);
System.out.println(penalties);
}
} | JAVA |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | #include<bits/stdc++.h>
using namespace std;
int main() {
static int wa[100001];
static bool ac[100001];
int n, m;
cin >> n >> m;
int p, a = 0, w = 0;
string s;
for (int i = 0; i < m; i++) {
cin >> p >> s;
if (ac[p]) continue;
if (s == "WA") wa[p]++;
else {
ac[p] = true;
a++;
w+=wa[p];
}
}
cout << a << " " << w << endl;
}
| CPP |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | #include<bits/stdc++.h>
using namespace std;
int c[1<<17],n,m,ac,wa,i,p;
string s;
int main(){
scanf("%d%d",&n,&m);
while(m--){
cin>>p>>s;
if(c[p]==-1)continue;
if(s=="AC")ac++,wa+=c[p],c[p]=-1;
else c[p]++;
}
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<iostream>
#include<string>
const int N = 1e5+1;
using namespace std;
int a[N];
bool o[N];
int main() {
int n, m;
cin >> n >> m;
int ans, cnt;
ans = cnt = 0;
for (int i = 0;i < m;i++) {
string s;
int x;
cin >> x >> s;
if (o[x])continue;
if (s == "WA") a[x]++;
else if (s == "AC") {
ans++;
o[x] = true;
cnt+=a[x];
}
}
cout << ans << " " << cnt << endl;
return 0;
} | CPP |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.