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())
ac=[0]*n
pn=[0]*n
for i in range(m):
ps=input().split()
p=int(ps[0])-1
s=ps[1]
if ac[p]:
continue
if s=='AC':
ac[p]=1
else:
pn[p]+=1
acs=sum(ac)
pns=sum([x for i,x in enumerate(pn) if ac[i]])
print(acs, pns) | PYTHON3 |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | N,M = map(int,input().split())
AC = (N+1)*[0]
WA = (N+1)*[0]
wa=0
for m in range(M):
p,s = input().split()
p = int(p)
if AC[p]==0 and s=="AC":
AC[p]=1
wa+=WA[p]
WA[p]+=1
print(sum(AC),wa) | PYTHON3 |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | from sys import stdin as s
n,m=map(int,s.readline().split())
l=[0]*n
wa=[0]*n
cor,pen=0,0
for i in range(m):
x,y=s.readline().split()
x=int(x)-1
if y=="AC":
l[x]=1
elif not l[x]:
wa[x]+=1
for i in range(n):
if l[i]:
cor+=1
pen+=wa[i]
print(cor,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 | d=dict()
wa=ans=0
N,M=map(int,input().split())
for i in range(M):
p,s=input().split()
if p not in d:
d[p]=0
if d[p]>=0 and s=="AC":
ans+=1
wa+=d[p]
d[p]=-float("inf")
else:
d[p]+=1
print(ans,wa) | PYTHON3 |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = sc.nextInt();
int[] p =new int[m];
String[] s = new String[m];
int[] ac = new int[n+1];
int[] wa = new int[n+1];
for(int i=0;i<m;i++) {
p[i] = sc.nextInt();
s[i] = sc.next();
}
for(int i=0;i<m;i++) {
if(s[i].equals("AC")&&!(ac[p[i]]>=1)) {
ac[p[i]] = 1;
}
if(s[i].equals("WA")&&!(ac[p[i]]>=1)) {
wa[p[i]]++;
}
}
int acnum = 0;
int penanum = 0;
for(int i=1;i<=n;i++) {
acnum += ac[i];
if(ac[i]>0) {
penanum += wa[i];
}
}
System.out.println(acnum+" "+penanum);
}
}
| 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.io.*;
import java.util.*;
public class Main{
public static void main(String[] args)throws Exception{
Scanner sc=new Scanner(System.in);
int n=sc.nextInt(),m=sc.nextInt();
boolean[] aw=new boolean[n];
int[] ary=new int[n];
int ac_c=0,wa_c=0;
Arrays.fill(aw,false);
Arrays.fill(ary,0);
for(int i=0;i<m;i++){
int p=sc.nextInt();
String s=sc.next();
if(s.equals("AC")){
if(!aw[p-1]){
ac_c++;
}
aw[p-1]=true;
}
if(s.equals("WA")&&!aw[p-1]){
ary[p-1]++;
}
}
for(int i=0;i<n;i++){
if(aw[i]){
wa_c+=ary[i];
}
}
System.out.println(ac_c +" "+ wa_c);
}
} | 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 | w,*d=[0]*10**6
a={0}
for t in open(0):
p,s=t.split()
p=int(p)
if'AC'==s*(not p in a):w+=d[p];a|={p}
d[p]+=s>'V'
print(len(a)-1,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<stdio.h>
#include<iostream>
using namespace std;
int a[100010]={0};
int main()
{
int n,m,i;
cin>>n>>m;
int x=0,y=0;
for(i=0;i<m;i++)
{
int s;string ss;
cin>>s>>ss;
if(a[s]>=0)
{
if(ss=="WA")
{
a[s]++;
}
else
{
x+=a[s];
a[s]=-1;
y++;
}
}
}
printf("%d %d\n",y,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 | n, m = map(int, input().split())
l = [0]*(n + 1)
ac = 0
wa = 0
for i in range(m):
p, s = input().split()
p = int(p)
if l[p] == -1:
continue
if s == "AC":
ac += 1
wa += l[p]
l[p] = -1
else:
l[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 = list(map(int, input().split()))
AC = [0] * N
WA = [0] * N
for i in range(M):
p, S = input().split()
p = int(p)
if(S == "AC"):
AC[p-1] = 1
elif(AC[p-1] == 0):
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.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = sc.nextInt();
int array[] = new int[n + 1];
int ans = 0;
int wa = 0;
for (int i = 0; i < m; i++) {
int prb = sc.nextInt();
String res = sc.next();
if (array[prb] == -1) continue;
if (res.equals("AC")) {
wa += array[prb];
ans++;
array[prb] = -1;
} else {
array[prb]++;
}
}
System.out.println(ans + " " + 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 java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = sc.nextInt();
int p[] = new int[m];
String s[] = new String[m];
for(int i = 0; i < m; i++){
p[i] = sc.nextInt();
s[i] = sc.next();
}
boolean ac[] = new boolean[n];
int wa[] = new int[n];
int ac_count = 0;
int wa_count = 0;
for(int i = 0; i < m; i++){
int count = 0;
if(ac[p[i] - 1]){
continue;
}
if(s[i].equals("WA")){
wa[p[i] - 1]++;
}else{
ac_count++;
wa_count += wa[p[i] - 1];
ac[p[i] - 1] = true;
}
}
System.out.println(ac_count + " " + wa_count);
}
} | JAVA |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | import java.util.Scanner;
public class Main{
public static void main(String[]args) {
try(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();
}
long seitou = 0;
long pena = 0;
String[]res = new String[N];
int[]pe = new int[N];
for(int i = 0;i<M;i++) {
if(res[p[i]-1]==null) {//まだ一回も回答されてない
if(S[i].equals("WA")) {
res[p[i]-1] = "WA";
pe[p[i]-1]++;
}else {
res[p[i]-1] = "AC";
seitou++;
}
}else{//一回回答した問題。ACなら無視
if(res[p[i]-1].equals("WA")) {
if(S[i].equals("WA")) {
pe[p[i]-1]++;
}else{
res[p[i]-1] = "AC";
pena+=pe[p[i]-1];
seitou++;
}
}
}
}
System.out.println(seitou);
System.out.println(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;
long long n, m, cnt[100001], sc=0, pen=0;
bool ac[100001];
int main(){
memset(ac,0,sizeof ac);
memset(cnt,0,sizeof cnt);
cin >> n >> m;
for (int i=0;i<m;i++){
long long p;
string s;
cin >> p >> s;
if (ac[p]) continue;
if (s=="WA") cnt[p]++;
else if (s=="AC"){
ac[p]=1;
sc++;
pen+=cnt[p];
}
}
cout << sc << " " << pen << "\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())
ac_=[0]*n
wa_=[0]*n
ac=0
wa=0
for i in range(m):
q,r=input().split()
q=int(q)-1
if ac_[q]==0:
if r=='WA':
wa_[q]+=1
if r=='AC':
ac+=1
wa+=wa_[q]
ac_[q]=1
print(ac,wa) | PYTHON3 |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | n,m=map(int,input().split())
f=[0]*n
ac=0
w=[0]*n
wa=0
for i in range(m):
p,q=map(str,input().split())
p=int(p)-1
if f[p]==0:
if q=='AC':
f[p]=1
ac+=1
wa+=w[p]
else:
w[p]+=1
print(ac,wa)
| PYTHON3 |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | import java.util.*;
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[] pn = new int[n];
for (int i = 0; i < m; i++) {
int p = sc.nextInt();
String s = sc.next();
if (s.equals("AC")) ac[p - 1] = true;
else if (!ac[p - 1]) pn[p - 1]++;
}
int ans1 = 0, ans2 = 0;
for (int i = 0; i < n; i++) {
if (ac[i]) {
ans1++;
ans2 += pn[i];
}
}
System.out.println(ans1 + " " + ans2);
}
} | JAVA |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | 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;
String S;
int ac = 0;
int wa = 0;
int score[] = new int[n];
for(int i = 0; i < n; i++){
score[i] = 0;
}
for(int i = 0; i < m; i++){
p = scan.nextInt()-1;
S = scan.next();
if(score[p] >= 0){
if(S.equals("AC")){
ac++;
wa += score[p];
score[p] = -1;
}
else{
score[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())
acs = [0]*n
was = [0]*n
ac = 0
wa = 0
for i in range(m):
p, s = input().split()
p = int(p) - 1
if s == "AC" and acs[p]==0:
acs[p] += 1
ac += 1
wa += was[p]
elif s == "WA":
was[p] += 1
print(ac, wa) | PYTHON3 |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | N, M = map(int, input().split())
ac = [0] * N
wa = [0] * N
WA = 0
for i in range(M):
p, s = input().split()
p = int(p) - 1
if ac[p] == 0 and s == 'AC':
ac[p] = 1
WA += wa[p]
wa[p] += 1
print(sum(ac), WA) | PYTHON3 |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = sc.nextInt();
int[] b = new int[n];//間違え
boolean[] c = new boolean[n];//正答
String a = "";
for (int i = m; i > 0; i--) {
int d = sc.nextInt() - 1;
a = sc.next();
if (a.equals("WA") && !c[d]) {
b[d]++;
} else if (a.equals("AC")) {
if (!c[d]) {
c[d] = true;
}
}
}
int e = 0;
int pena = 0;
for (int j = 0; j < b.length; j++) {
if (c[j]) {
pena = pena + b[j];
}
}
for (boolean f: c) {
if (f) {
e++;
}
}
System.out.println(e + " " + 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;
#define int long long
#define N 666666
int arr[N];
map<string,int> mp,vis;
signed main(){
int n,m;
int ans1=0;int ans2=0;
cin>>n>>m;
string s1,s2;
for(int i=1;i<=m;i++){
cin>>s1>>s2;
if(vis[s1]) continue;
if(s2=="AC"){
ans1++;
ans2+=mp[s1];
vis[s1]=1;
}else if(s2=="WA"){
mp[s1]++;
}
}cout<<ans1<<" "<<ans2;
return 0;
} | CPP |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | n,m = map(int, input().split())
ac = [0] * n
wa = [0] * n
a = 0
w = 0
for i in range(m):
p, s = input().split()
p = int(p) - 1
if ac[p] == 0 and s == 'AC':
ac[p] += 1
a += 1
w += wa[p]
elif ac[p] == 0 and s == 'WA':
wa[p] += 1
print(a, w)
| PYTHON3 |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = Integer.parseInt(scan.next());
int m = Integer.parseInt(scan.next());
List<Integer> ac = Arrays.asList(new Integer[n]);
List<Integer> pena = Arrays.asList(new Integer[n]);
Collections.fill(ac, 0);
Collections.fill(pena, 0);
for(int i=0; i<m; ++i) {
int p = Integer.parseInt(scan.next());
String s = scan.next();
--p;
if(ac.get(p) == 1) continue;
if(s.equals("AC")) {
ac.set(p, 1);
} else {
pena.set(p, (pena.get(p)+1));
}
}
scan.close();
int AC = 0, PENA = 0;
for(int i=0; i<n; ++i) {
AC += ac.get(i);
if(ac.get(i) == 1) PENA += pena.get(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 | N,M=map(int,input().split())
AC=[0] * (N + 1)
WA=[0] * (N + 1)
cnt_AC=0
cnt_WA=0
for _ in range(M):
i,s=input().split()
i=int(i)
if AC[i]==0:
if s=='WA':
WA[i]+=1
if s=='AC':
AC[i]=1
cnt_WA+=WA[i]
cnt_AC=sum(AC)
print(cnt_AC,cnt_WA) | PYTHON3 |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | import java.util.*;
import java.math.RoundingMode;
import java.math.BigDecimal;
public class Main{
public static void main (String[] args){
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int M = sc.nextInt();
String p[][] = new String[M][2];
for(int i = 0; i < M; i++) {
p[i][0] = sc.next();
p[i][1] = sc.next();
}
int AC = 0;
int WA = 0;
boolean ac [] = new boolean[N];
int wa [] = new int[N];
for(int i = 0; i < M; i++) {
int a = Integer.parseInt(p[i][0])-1;
if(ac[a]){
continue;
}
if(p[i][1].equals("WA")){
wa[a]++;
} else {
AC++;
WA += wa[a];
ac[a] = true;
}
}
System.out.println(AC + " " + WA);
}
} | JAVA |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | #include<bits/stdc++.h>
using namespace std;
int main(){
long N,M;cin>>N>>M;
vector<int>AC(N,0),WA(N,0);
for(int i=0;i<M;i++){
long p;string s;cin>>p>>s;
if(AC[p-1]==0 && s=="WA")WA[p-1]++;
if(s=="AC")AC[p-1]=1;
}
long a=0,b=0;
for(int i=0;i<N;i++){
a+=AC[i];
if(AC[i])b+=WA[i];
}
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 | n,m=map(int,input().split())
w,l=0,[0]*n
for i in range(m):
p,s=input().split()
p=int(p)-1
if s=='AC':
w+=l[p]*(l[p]>=0)
l[p]=-1
else:
l[p]+=(l[p]>=0)
print(l.count(-1),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.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// 入力値の取得
int N = sc.nextInt();
int M = sc.nextInt();
// ACとWAの集計
Set<Integer> ACset = new HashSet<>();
Map<Integer, Integer> WAmap = new HashMap<>();
for (int i = 0; i < M; i++) {
int pi = sc.nextInt();
String Si = sc.next();
if (Si.equals("AC")) {
ACset.add(pi);
}
else if (!ACset.contains(pi)){
if (WAmap.containsKey(pi)) {
int count = WAmap.get(pi) + 1;
WAmap.put(pi, count);
}
else {
WAmap.put(pi, 1);
}
}
}
// WAmapのうちACが一度でも出たものだけ集計
int WAcount = 0;
for (int key : WAmap.keySet()) {
if (ACset.contains(key)) {
WAcount += WAmap.get(key);
}
}
// 結果の出力
System.out.println(ACset.size() + " " + WAcount);
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 java.util.ArrayList;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N=sc.nextInt();
int M=sc.nextInt();
boolean[] isAc = new boolean[N];
for(int i=0;i<N;i++) {
isAc[i]=false;
}
int[] waCount = new int[N];
for(int i=0;i<N;i++) {
waCount[i]=0;
}
for(int i=0;i<M;i++) {
int p = sc.nextInt();
String S = sc.next();
if(S.equals("AC")) {
isAc[p-1]=true;
}else if(!isAc[p-1]) {
waCount[p-1]+=1;
}
}
int watotal=0;
int actotal=0;
for(int i=0;i<N;i++) {
if(isAc[i]) {
actotal++;
watotal+=waCount[i];
}
}
System.out.println(actotal+" "+watotal);
}
} | 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) {
// write your code here
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = sc.nextInt();
boolean[] ac = new boolean[n];
int[] wa = new int[n];
int acSum = 0;
int waSum = 0;
for (int i = 0; i < m; i++) {
int index = sc.nextInt() - 1;
boolean isAc = sc.next().equals("AC");
if (ac[index]) {
continue;
}
if (isAc) {
acSum++;
ac[index] = true;
waSum += wa[index];
} else {
wa[index]++;
}
}
System.out.println(acSum + " " + waSum);
}
} | 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
A=0
W=0
tmp=[0]*N
for i in range(M):
x,y=input().split()
t=int(x)
if L[t-1]==0:
if y=="WA":
tmp[t-1]+=1
else:
A+=1
W+=tmp[t-1]
L[t-1]=1
print(A,W) | PYTHON3 |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | #!/usr/bin/env python3
# Submit as pypy2
from __future__ import print_function, division, unicode_literals
__metaclass__ = type
try:
input = raw_input
range = xrange
except NameError:
pass
import sys
# Test code requires python3
# from hypothesis import given
# from hypothesis import strategies as st
#
#
# def debug(*args, **kwargs):
# print(*args, *('{}={}'.format(k, v) for k, v in kwargs.items()),
from collections import Counter
def main():
N, M = map(int, input().split())
AC = set()
WA = Counter()
for i in range(M):
p, S = input().split()
p = int(p) - 1
S = S == 'AC'
if S:
AC.add(p)
elif p not in AC:
WA[p] += 1
print(len(AC), sum(v for k, v in WA.items() if k in AC))
if __name__ == "__main__":
main()
| PYTHON |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | n,m = map(int,input().split())
ac,wa = 0,0
number=[0]*n
for i in range(m):
p,s = input().split()
p = int(p) - 1
if number[p]!=-1:
if s == "WA":
number[p]+=1
elif s == "AC":
ac+=1
wa+=number[p]
number[p]=-1
print(ac,wa) | PYTHON3 |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
int m = scan.nextInt();
boolean[] ac = new boolean[n];
long[] wrong = new long[n];
for (int i = 0; i < m; i++) {
int p = scan.nextInt();
String s = scan.next();
if (!ac[p-1]) {
if (s.equals("WA")) wrong[p-1]++;
else ac[p-1] = true;
}
}
int wr = 0;
int acc = 0;
for (int i = 0; i < ac.length; i++) {
if (ac[i]) {
acc++;
wr += wrong[i];
}
}
System.out.println(acc + " " + wr);
}
}
| JAVA |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | #include<bits/stdc++.h>
using namespace std;
int n,m,c[100005],p,a,b;
string s;
int main()
{
cin>>n>>m;
for(int i=1;i<=m;i++){
cin>>p>>s;
if(c[p]==-1)continue;
else if(s=="AC"){a++;b+=c[p];c[p]=-1;}
else c[p]++;
}
cout<<a<<" "<<b;
return 0;
} | CPP |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | #include<bits/stdc++.h>
using namespace std;
int main()
{
int n,M;
cin>>n>>M;
vector<int>r(n+1);
vector<int>w(n+1);
for(int i=0;i<M;i++){
int p;string s;
cin>>p>>s;
if(s=="AC"&&r[p]==0)r[p]+=1;
else if(s=="WA"&&r[p]==0)w[p]+=1;
}
int R=0,W=0;
for(int i=1;i<=n;i++){
R+=r[i];
if(r[i]>0)W+=w[i];
}
cout<<R<<' '<<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>
#define ll long long
using namespace std;
const int N=1e5+5;
int a[N],v[N],f[N];
int main(){
ios::sync_with_stdio(false);
int n,k,m,c=0,pe=0;
cin>>n>>m;
for(int i=1;i<=m;i++){
int p;
char s[3];
cin>>p>>s;
if(v[p])continue;
if(s[0]=='W')++f[p];
else c++,pe+=f[p],v[p]=1;
}
cout<<c<<' '<<pe;
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;
bool vis[100010];
int ans[100010];
int main(){
memset(ans,0,sizeof(ans));
int n,m;
cin>>n>>m;
int ac=0;
int wa=0;
for(int i=0;i<m;i++){
int a;
string s;
cin>>a>>s;
if(s=="AC"&&!vis[a]){
ac++;
wa+=ans[a];
vis[a]=1;
}
else if(s=="WA"&&!vis[a]){
ans[a]++;
}
}
cout<<ac<<" "<<wa<<endl;
return 0;
} | CPP |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | n, m = map(int, input().split())
AC = [0] * n
WA = [0] * n
w = 0
for i in range(m):
p, s = input().split()
p = int(p) - 1
if s == 'AC' and AC[p] == 0:
AC[p] += 1
w += WA[p]
elif s == 'WA' and AC[p] == 0:
WA[p] += 1
print(sum(AC), w) | PYTHON3 |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int M = sc.nextInt();
int p;
String S;
int AC[] = new int[N];
int WA[] = new int[N];
for(int i=0; i<N; i++){
AC[i]=0;
WA[i]=0;
}
int penalty = 0;
for(int i=0; i<M; i++){
p=sc.nextInt()-1;
S=sc.next();
if(S.equals("WA")){
WA[p]++;
}else if(S.equals("AC")){
if(AC[p]==0){
penalty = penalty + WA[p];
}
AC[p]=1;
}
}
int clear = 0;
for(int i=0; i<N; i++){
clear = clear + AC[i];
}
System.out.print(clear + " " + penalty);
}
}
| JAVA |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | n, m = [int(s) for s in input().split()]
a = [0 for _ in range(n)]
for i in range(m):
p, res = input().split()
p = int(p) - 1
if a[p]%2==0:
a[p] += 2 if res=='WA' else 1
print(sum([tmp%2 for tmp in a]), sum([tmp//2 if tmp%2==1 else 0 for tmp in a])) | PYTHON3 |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | N, M = map(int, input().split())
l = [0 for _ in range(N)]
AC = 0
WA = 0
for _ in range(M):
p, S = input().split()
p = int(p) - 1
if l[p] != None and S == "WA":
l[p] += 1
if l[p] != None and S == "AC":
AC += 1
WA += l[p]
l[p] = None
print(AC, WA) | PYTHON3 |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | #include<bits/stdc++.h>
using namespace std;
map<int,int> mp;
map<int,int> watimes;
int main()
{
int n,m;
cin>>n>>m;
int sum = 0;
for(int i = 0;i<m;i++)
{
int ad;
string as;
cin>>ad>>as;
if(as == "AC")
{
if(mp[ad]!=1)
{
sum+=watimes[ad];
}
mp[ad] = 1;
}
else
{
watimes[ad]++;
}
}
cout<<mp.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 | n, m = map(int, input().split())
s = [[] for i in range(n)]
for i in range(m):
p, S = input().split()
s[int(p) - 1] += [S]
print(sum('AC' in si for si in s), sum(si[:si.index('AC')].count('WA') if 'AC' in si else 0 for si in s)) | PYTHON3 |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | 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[] isAc = new boolean[N+1];
Arrays.fill(isAc, false);
int[] was = new int[N+1];
Arrays.fill(was, 0);
int ac = 0;
int wa = 0;
for (int i = 0; i < M; i++) {
int p = sc.nextInt();
String s = sc.next();
if (isAc[p]) continue;
if (s.equals("WA")) was[p]++;
else {
ac++;
isAc[p] = true;
wa += was[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 | import java.util.*;
class Main {
Scanner sc;
int N, M;
int[] stat;
int[] penalty;
private void calc() {
sc = new Scanner(System.in);
int N = sc.nextInt();
int M = sc.nextInt();
stat = new int[N];
penalty = new int[N];
for (int i = 0; i < M; i++) {
int p = sc.nextInt() - 1;
String S = sc.next();
switch (S) {
case "WA":
if (stat[p] == 0) penalty[p]++;
break;
case "AC":
stat[p] = 1;
break;
default:
}
}
int ac = 0;
int pe = 0;
for (int i = 0; i < N; i++) {
if (stat[i] == 1) {
ac++;
pe += penalty[i];
}
}
System.out.println(ac+" "+pe);
}
public static void main(String[] args) {
new Main().calc();
}
} | JAVA |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | n,m= map(int, input().split())
judge=[0]*n
cor=0
pen=0
inf=10**6
for i in range(m):
a,s = input().split()
a=int(a)
if s=='WA':
judge[a-1]+=1
else:
if judge[a-1]>-1:
cor+=1
pen+=judge[a-1]
judge[a-1]=-inf
print(cor,pen) | PYTHON3 |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | n,m = map(int,input().split())
l = [1]*n
a = 0
w = 0
for i in range(m):
p,s = map(str,input().split())
p = int(p)
if l[p-1]>0:
if s == "AC":
w+=l[p-1]-1
l[p-1] = 0
a+=1
else:
l[p-1]+=1
print(a,w) | PYTHON3 |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | n,m = map(int,input().split())
d = {}
for _ in range(m):
p,s = input().split()
try:
d[int(p)].append(s)
except:
d[int(p)] = [s]
T = 0
pe = 0
for key in d:
if "AC" in d[key]:
T += 1
pe += d[key].index("AC")
print(T,pe)
| PYTHON3 |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | N, M = map(int, input().split())
a = [False] * N
w = [0] * N
for i in range(M):
p, S = input().split()
if S == 'AC':
a[int(p)-1] = True
elif not a[int(p)-1]:
w[int(p)-1] += 1
print(a.count(True), sum([w[i] if a[i] else 0 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 <iostream>
#include <map>
#include <string>
using namespace std;
int main()
{
int i,x,m,n,c,w;
string s;
c=w=0;
map<int,int> wa;
map<int,int> ac;
cin >> n >> m;
while(m--)
{
cin >> x >> s;
if(s=="AC")
{
if(ac.find(x)==ac.end())
{
c++;
if(wa.find(x)!=wa.end())
w+=wa[x];
}
ac[x]=1;
}
else
wa[x]++;
}
cout << c << " " << w;
return 0;
} | CPP |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | n,m=map(int,input().split())
l=[]
for _ in range(n):l.append(0)
wa=0
for i in range(m):
p,s=map(str,input().split())
if l[int(p)-1]==-1:continue
elif s=="AC":
wa+=l[int(p)-1]
l[int(p)-1]=-1
else: l[int(p)-1]+=1
print(l.count(-1),wa)
| PYTHON3 |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | n,m=map(int,input().split())
a=[0]*(n+1)
b=[0]*(n+1)
for i in range(m):
p,s=input().split()
p=int(p)
if a[p]==0:
if s=="AC":
a[p]=1
else:
b[p]+=1
for i in range(n+1):
if a[i]==0:
b[i]=0
print(sum(a),sum(b)) | PYTHON3 |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | #include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
using namespace std;
int main() {
int N, M;
cin >> N >> M;
set<int> S;
map<int, int> T;
rep(i,0,M-1) {
int p; string s;
cin >> p >> s;
if (S.count(p) == 0)
if (s == "WA") T[p]++;
else S.insert(p);
}
int wa = 0;
for (int i:S) wa += T[i];
cout << S.size() << " " << wa << endl;
return 0;
}
| CPP |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int M = sc.nextInt();
boolean[] solved = new boolean[N];
int[] wa = new int[N];
Arrays.fill(solved, false);
int penalty = 0;
for (int i=0;i<M;i++) {
int p = sc.nextInt()-1;
String S = sc.next();
if (S.equals("AC")) {
if (!solved[p]) penalty+=wa[p];
solved[p] = true;
} else { // S.equals("WA")
if (!solved[p]) wa[p]++;
}
}
int accepted = 0;
for (int i=0;i<N;i++) {
if (solved[i]) accepted++;
}
System.out.println(accepted+" "+penalty);
}
}
| JAVA |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | N,M = map(int,input().split())
AC = 0
WA = 0
lis = [0] * N
for i in range(M):
a,b = input().split()
if lis[int(a)-1] < 0:
pass
elif b == 'AC':
WA += lis[int(a)-1]
AC += 1
lis[int(a)-1] = -1
else:
lis[int(a)-1] += 1
print(AC, WA)
| PYTHON3 |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int M = sc.nextInt();
boolean[] po=new boolean[N+1];
int[] pena=new int[N+1];
Arrays.fill(pena,0);
for(int i=0; i<M; i++){
int p=sc.nextInt();
String s=sc.next();
if(s.equals("WA")){
if(!po[p]){
pena[p]++;
}
else{}
}
else if(s.equals("AC")){
if(!po[p]){
po[p]=true;
}
}
}
int penasum=0;
int ans=0;
for(int i=0; i<=N; i++){
if(po[i]) {
ans++;
penasum+=pena[i];
}
}
System.out.println(ans+" "+penasum);
}
}
| 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())
j=[0]*n
c=[0]*n
wa=0
ac=0
for i in range(m):
p,s=input().split()
p=int(p)-1
if s[0]=="A" and j[p]==0:
j[p]=1
ac+=1
wa+=c[p]
elif s[0]=="W":c[p]+=1
print(ac,wa) | PYTHON3 |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | n,m=map(int,input().split())
a=[0]*n
w=[0]*n
ac=0
wc=0
for _ in range(m):
p,s=input().split()
p=int(p)-1
if a[p]==0:
if s=='AC':
a[p]=1
ac+=1
wc+=w[p]
else:
w[p]+=1
print(ac,wc)
| PYTHON3 |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | #include <bits/stdc++.h>
using namespace std;
signed main(){
int n,m;cin>>n>>m;
vector<int> v(n,0);
int ans=0,cnt=0;
while(m--){
int a;string t;cin>>a>>t;a--;
if(v[a]<0)continue;
if(t=="AC")ans+=v[a],v[a]=-1,cnt++;
else v[a]++;
}
cout<<cnt<<" "<<ans<<endl;
}
| CPP |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | N,M=map(int,input().split())
ACL=[0]*N
PL=[0]*N
AC=0
P=0
for i in range(M):
p,S=input().split()
p=int(p)
p-=1
if S =='AC':
if ACL[p]==0:
AC+=1
P+=PL[p]
ACL[p]=1
else:
PL[p]+=1
print(AC,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;
int n,m;
int ac=0,per=0;
int p[100010],ad[100010];
string s[100010];
bool t[100010];
int main() {
ios::sync_with_stdio(false);
memset(t,0,sizeof(t));
cin>>n>>m;
for(int i=1;i<=m;i++)
cin>>p[i]>>s[i];
for(int i=1;i<=m;i++) {
if(t[p[i]]) continue;
if(s[i]=="AC") ac++,t[p[i]]=true,per+=ad[p[i]];
else ad[p[i]]++;
}
cout<<ac<<' '<<per;
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(); //回答数
boolean[] bool = new boolean[N];
int[] miss= new int[N]; //間違った回数
for(int i=0; i<N; i++) {
bool[i] = false;
miss[i] = 0;
}
for(int i = 0; i<M; i++) {
//添え字を選択させる。
int no = sc.nextInt()-1;
String anser = sc.next();
if(bool[no]) {
continue;
}else {
if(anser.equals("AC")) {
bool[no] = true;
}else {
miss[no]++;
}
}
}
int win = 0;
int lose = 0;
for(int i = 0; i<N; i++) {
if(bool[i]) {
win++;
lose += miss[i];
}
}
System.out.println(win + " " + lose);
}
}
| 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 sca = new Scanner(System.in);
// 入力
int n = sca.nextInt(); // n問出題される
int m = sca.nextInt(); // m回提出
int[] pi = new int[m]; // i番目の問題番号
String[] si = new String[m]; // i番目の提出の結果ACかWA
for(int i = 0; i < m; i++) {
pi[i] = sca.nextInt();
si[i] = sca.next();
}
boolean[] flg = new boolean[n+1];
for(int i = 0; i <= n; i++) {
flg[i] = false;
}
int seito = 0;
int penal = 0;
int[] penal_loop = new int[n+1];
for(int j = 0; j < m; j++) {
// i番目の問題がまだ正解していないとき
if(flg[pi[j]] == false) {
if(si[j].equals("AC")) {
seito++;
flg[pi[j]] = true;
}
else if(si[j].equals("WA")) {
penal_loop[pi[j]]++;
}
}
}
for(int i = 1; i <= n; i++) {
if(flg[i] == true) {
penal = penal + penal_loop[i];
}
}
System.out.print(seito);
System.out.print(" ");
System.out.println(penal);
// 後始末
sca.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 | d = dict()
wa = ac = 0
N, M= map(int,input().split())
for i in range(M):
a, b = input().split()
if a not in d:
d[a] = 0
if d[a] >= 0 and b == "AC":
ac += 1
wa += d[a]
d[a] = -1
elif d[a] >= 0:
d[a] += 1
print(ac,wa) | PYTHON3 |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | #include<iostream>
using namespace std;
int main(){
bool ac[100001]={};
int pc[100001]={};
int n,m;
cin>>n>>m;
int a=0,pe=0;
while(m--){
int p;
char s[9];
cin>>p>>s;
if(s[0]=='A'){
a+=!ac[p];
ac[p]=true;
}else{
pc[p]+=!ac[p];
}
}
int p=0;
for(int i=1;i<=n;i++){
if(ac[i]){
p+=pc[i];
}
}
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;
typedef long long ll;
int z[100005];
int main()
{
int a,b,c,d,e,f;
string wa="WA",ac="AC",now;
memset(z,0,sizeof(z));
scanf("%d%d",&a,&b);
c=0;d=0;
while(b--)
{
scanf("%d",&e);
cin>>now;
if(z[e]==-1)continue;//AC-1
if(now==wa)z[e]++;
else if(now==ac)
{
d+=z[e];
c++;
z[e]=-1;
}
}
printf("%d %d",c,d);
} | CPP |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | #include<bits/stdc++.h>
using namespace std;
int main(){
int n,k,m,a,ans1=0,d=0,c[100000]={};
int ans2[1000000]={};
string b;
cin>>n>>m;
for(int i=0;i<m;i++){
cin>>a>>b;
if(c[a]==0 && b=="AC"){
c[a]++;
d+=ans2[a];
ans1++;
}
if(c[a]==0 && b=="WA"){
ans2[a]++;
}
}
cout<<ans1<<" "<<d<<endl;
return(0);
} | CPP |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | n, m = (int(x) for x in input().split())
sub = [0] * (n+1)
ok = ng = 0
for i in range(m):
p, s = input().split()
p = int(p)
if sub[p] == -1:
continue
if s == 'WA':
sub[p] += 1
if s == 'AC':
ok += 1
ng += sub[p]
sub[p] = -1
print(ok, ng) | PYTHON3 |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | import sys
input()
d={}
nc=np=0
for ln in sys.stdin:
p,S=ln.split()
if p not in d:
d[p]=[0,0]
if not d[p][0]:
if S=='AC':
d[p][0]=1
nc+=1
np+=d[p][1]
else:
d[p][1]+=1
print(nc,np)
| PYTHON3 |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | N,M = map(int, input().split())
s,p = [False]*N, [0]*N
for i in range(M):
tmp = input().split()
pi,Si = int(tmp[0])-1, tmp[1]
s[pi] |= Si == "AC"
p[pi] += 1 if not s[pi] else 0
print(sum(s), sum([pi for si,pi in zip(s,p) if si]))
| PYTHON3 |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | N, M = map(int, input().split())
AC = [0] * N
WA = [0] * N
for i in range(M):
p, S = input().split()
p = int(p) - 1
if S == 'AC':
AC[p] = 1
elif 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 | import java.util.*;
class Main{
//150a
static final long DIV = 100000007L;
static final int MAX = 2000000000;
//static long[] fac = new long[MAX];
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = sc.nextInt();
boolean[] collect = new boolean[n];
int ans = 0;
int penans = 0;
int[] pen = new int[n];
for(int i = 0;i < m;i++){
int pi = sc.nextInt();
String s = sc.next();
if(!collect[pi-1]){
if(s.equals("WA")){
pen[pi-1]++;
}else if(s.equals("AC")){
collect[pi-1] = true;
ans++;
}
}
}
for(int i = 0;i < n;i++){
if(collect[i])penans += pen[i];
}
System.out.println(ans + " " + penans);
}
} | JAVA |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | #include<iostream>
using namespace std;
int a[100005];
int main()
{
int n,m,wa=0,ac=0,x;
cin>>n>>m;
string s;
for(int i=0;i<m;i++)
{
cin>>x>>s;
if(x>n)
continue;
if(s=="AC"&&a[x]>=0)
{
wa+=a[x];
a[x]=-1;
ac++;
}
else if(s=="WA"&&a[x]>=0)
{
a[x]++;
}
}
cout<<ac<<" "<<wa;
} | CPP |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | import 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':
if cc['AC'][i] == 0:
cc['WA'][i] += 1
s = 0
for p in cc['AC']:
s += cc['WA'][p]
print len(cc['AC']), s #len(penalties) | PYTHON |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | n,m=map(int,input().split())
a=[0]*n
b=[0]*n
ac=wa=0
for i in range(m):
p,s=input().split()
p=int(p)-1
if s[0]=='A' and a[p]==0:
a[p]=1
ac+=1
wa+=b[p]
elif s[0]=='W':
b[p]+=1
print(ac, wa) | PYTHON3 |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | #include<iostream>
#include<vector>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
int main(){
int n,m;
cin>>n>>m;
vector<int>p(n,0),wa(n,0);
int q,ac=0,w;
string tmp;
rep(i,m){
cin>>q>>tmp;
if(p[q-1]==0){
if(tmp[0]=='W')wa[q-1]+=1;
else {ac++;w+= wa[q-1];p[q-1]=1;}
}
}
cout<<ac<<' '<<w<<endl;
return 0;
} | CPP |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | n,m=map(int,input().split())
sgn=[0 for i in range(n)]
penal=[0 for i in range(n)]
pp=0
for i in range(m):
p,s=map(str,input().split())
p=int(p)-1
if s=='AC':
if sgn[p]==0: pp+=penal[p]
sgn[p]=1
else:
penal[p]+=1
print(sum(sgn),pp) | PYTHON3 |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | N,M = [int(i) for i in input().split(" ")]
pS = [0]*N
ac,wa = 0,0
for _ in range(M):
p,S = input().split(" ")
p = int(p)-1
if pS[p] != -1 and S == "WA":
pS[p]+=1
if pS[p] != -1 and S=="AC":
ac+=1
wa+=pS[p]
pS[p]=-1
print(ac,wa) | PYTHON3 |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | import java.util.Scanner;
public class Main {
public static void main(String[] args)throws Exception{
Scanner stdIn=new Scanner(System.in);
int N=stdIn.nextInt();
int M=stdIn.nextInt();
boolean AC[]=new boolean[N];
int WA[]=new int[N];
int ac=0,wa=0;
for(int i=0;i<M;i++){
int p=stdIn.nextInt()-1;
String S=stdIn.next();
if(S.equals("AC"))
AC[p]=true;
if(AC[p]==false&&S.equals("WA"))
WA[p]++;
}
for(int i=0;i<N;i++){
if(AC[i]){
ac++;
wa+=WA[i];
}
}
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 | import java.util.Scanner;
class Main
{
public static void main(String[] agh)
{
Scanner sc=new Scanner(System.in);
int n,m;
n=sc.nextInt();
m=sc.nextInt();
int[] w=new int[n+1];
int cor=0,inc=0;
int[] x=new int[n+1];
// for(int i=0;i<n;i++)
// System.out.println(x[i]);
for(int i=0;i<m;i++)
{
int que=sc.nextInt();
String sta=sc.nextLine();
if(x[que]==1)
continue;
if(sta.equals(" AC"))
{
x[que]=1;
cor++;
inc+=w[que];
}
else
{
if(x[que]==0 && sta.equals( " WA"))
{
w[que]++;
}
}
}
System.out.println(cor+" "+inc);
}
} | 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[] num = new int[m];
String[] s = new String[m];
for (int i = 0; i < m; i++) {
num[i] = sc.nextInt();
s[i] = sc.next();
}
int[] cnt = new int[n];
int[] wa = new int[n];
for (int i = 0; i < m; i++) {
if (s[i].equals("AC") && cnt[num[i] - 1] == 0) {
cnt[num[i] - 1]++;
continue;
}
if (s[i].equals("WA") && cnt[num[i] - 1] == 0) {
wa[num[i] - 1]++;
}
}
int a = 0;
int w = 0;
for (int i = 0; i < n; i++) {
a += cnt[i];
if (cnt[i] > 0) {
w += wa[i];
}
}
System.out.println(a + " " + w);
}
} | JAVA |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
int main(){
int n,m;cin>>n>>m;
int ac=0,pin=0;
map<int,pair<int,int> >mp;
for(int i=0;i<m;i++){
int p;string s;cin>>p>>s;
if(s=="AC")mp[p].first++;
else if(mp[p].first==0) mp[p].second++;
}
for(auto u:mp){
if(u.second.first){
ac++;pin+=u.second.second;
}
}
cout<<ac<<' '<<pin;
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.Collections;
import java.util.List;
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 temp = sc.nextInt() - 1;
String s = sc.next();
// まだACが出ていないなら
if (ac[temp] == 0) {
if (s.equals("AC")) {
ac[temp]++;
} else {
wa[temp]++;
}
}
}
int ans1 = 0;
int ans2 = 0;
for (int i = 0; i < n; i++) {
// ACが出ている問題のみカウント
if (ac[i] == 1) {
ans1 += ac[i];
ans2 += wa[i];
}
}
System.out.println(ans1 + " " + ans2);
}
} | JAVA |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | N, M = map(int, input().split())
penas = [0] * N
acs, pena = set(), 0
for _ in range(M):
p, stat = input().split()
p = int(p) - 1
if stat == "AC" and p not in acs:
acs.add(p)
pena += penas[p]
else:
penas[p] += 1
print(len(acs), 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 | n, m = map(int, input().split())
account=0
wacount=0
a=[0]*n
for i in range(m):
p,s=input().split()
p=int(p)
p-=1
if a[p]==-1:
continue
if s=="AC":
account+=1
wacount+=a[p]
a[p]=-1
else:
a[p]+=1
print(account, wacount)
| 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;
map<pair<int,string >,int>m1;
int penaltis = 0;
int ac = 0;
while(m--){
int x;
string s;
cin>>x>>s;
if(s == "WA"){
if(m1[{x,"AC"}] == 0)
m1[{x,s}]++;
}else{
if(m1[{x,s}] == 0){
ac++;
penaltis += m1[{x,"WA"}];
m1[{x,s}] = 1;
}
}
}
cout<<ac<<" "<<penaltis<<endl;
return 0;
}
| CPP |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | #include <bits/stdc++.h>
int A[200005];
int con[200005];
using namespace std;
int main(){
string s;
int n,m,i,sum=0,d,k,dog=0,pen=0;
scanf("%d %d",&n,&m);
for(i=0;i<m;i++){scanf("%d",&d); cin>>s;
if(s[0]=='W' ){
if(con[d]==0 ){A[d]++; }
else{continue;}
}
else{
con[d]=1;
}
}
for(i=1;i<=n;i++){dog+=con[i]; pen+=con[i]*A[i]; }
printf("%d %d\n",dog,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 | import java.util.*;
class Main {
public static void main(String args[]){
Main main = new Main();
}
public Main(){
Scanner SC = new Scanner(System.in);
int N = Integer.parseInt(SC.next());
int M = Integer.parseInt(SC.next());
int[] NUM = new int[N];
boolean[] T = new boolean[N];
for(int i=0;i<N;i++) T[i] = false;
int A = 0;
int P = 0;
for(int i=0;i<M;i++){
int p = Integer.parseInt(SC.next())-1;
boolean S = SC.next().equals("AC");
if(T[p]) continue;
if(S){
A++;
P += NUM[p];
}
else {
NUM[p]++;
}
T[p] = S;
}
System.out.println(A + " " + P);
}
}
| JAVA |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int M = sc.nextInt();
boolean[] ACcon =new boolean[N + 1];
int[] WAcon =new int[N + 1];
int ACans =0;
int WAans =0;
for (int i = 0; i < M; i++) {
int Q = sc.nextInt();
String result = sc.next();
if (ACcon[Q] == false && result.equals("WA")) {
WAcon[Q]++;
}
if (ACcon[Q] == false && result.equals("AC")) {
ACcon[Q] = true;
}
}
for (int i = 1; i < N+1; i++) {
if (ACcon[i]) {
ACans++;
WAans += WAcon[i];
}
}
System.out.println(ACans + " " + WAans);
}
} | JAVA |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | n,m = map(int, input().split())
ac = [0]*(n+1)
wa = [0]*(n+1)
for i in range(m):
p, s = input().split()
p = int(p)
if s== "AC":
ac[p] = 1
else:
if ac[p]==0:
wa[p]+=1
for i in range(n+1):
if ac[i]==0:
wa[i]=0
print(sum(ac),sum(wa))
| PYTHON3 |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | 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 c=0;
int d=0;
boolean[] f=new boolean[n];
int x[]=new int[n];
for(int i=0;i<n;i++)
x[i]=0;
for(int i=0;i<m;i++) {
int p=sc.nextInt();
String s=sc.next();
if(!(f[p-1])&&s.equals("AC")) {
f[p-1]=true;
c++;
d+=x[p-1];
}
if(!(f[p-1])&&s.equals("WA")) {
x[p-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.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int problemCount = sc.nextInt();
int teisyutuCount = sc.nextInt();
int seitoCount = 0;
int penaltyCountTotal = 0;
boolean[] seitoList = new boolean[problemCount];
int[] penaltyCount = new int[problemCount];
for(int i =0;i < problemCount; i++) {
seitoList[i] = false;
penaltyCount[i] = 0;
}
for(int i = 0;i < teisyutuCount; i++) {
int problemNo = sc.nextInt();
String result = sc.next();
if(seitoList[problemNo -1]) {
// すでに正解している場合は何もしない
continue;
}else if(result.equals("AC")) {
// 初めて正解した場合
seitoCount++;
seitoList[problemNo-1] = true;
// これまでの不正解数を加える
penaltyCountTotal += penaltyCount[problemNo-1];
}else {
// 不正解の場合
penaltyCount[problemNo-1]++;
}
}
System.out.println(seitoCount + " " + penaltyCountTotal);
}
}
| JAVA |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int main()
{
int n,m,a,b[100005]={},sum[2]={};
string s;
bool flag[100005]={};
cin>>n>>m;
for(int i=0;i<m;i++)
{
cin>>a>>s;
if(!flag[a]&&s=="AC")
{
sum[0]++;
sum[1]+=b[a];
flag[a]=true;
}
else if(!flag[a]&&s=="WA")b[a]++;
}
cout<<sum[0]<<" "<<sum[1]<<endl;
return 0;
} | CPP |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | import java.util.*;
class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = sc.nextInt();
HashSet<Integer> rightAnswer = new HashSet<Integer>();
List<Integer> wrongAnswers = new ArrayList<Integer>();
for (int i=0; i<n; i++) {
wrongAnswers.add(0);
}
int right = 0;
int wrongs = 0;
for (int i=0; i<m; i++) {
int p = sc.nextInt();
String answer = sc.next();
if (rightAnswer.contains(p)) {
continue;
}
if (answer.equals("WA")) {
int wrongNum = wrongAnswers.get(p-1);
wrongNum++;
wrongAnswers.set(p-1, wrongNum);
}
else {
rightAnswer.add(p);
}
}
for (int answer: rightAnswer) {
wrongs += wrongAnswers.get(answer-1);
}
System.out.println(rightAnswer.size() + " " + String.valueOf(wrongs));
}
} | 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())
ps=[list(input().split()) for _ in range(m)]
wa=[0]*n
w=0
ac=0
d=[0]*n
for p,s in ps:
if s=='WA':
if d[int(p)-1]==0:
wa[int(p)-1]+=1
else:
if d[int(p)-1]==0:
ac+=1
d[int(p)-1]=1
w+=wa[int(p)-1]
print(ac,w) | PYTHON3 |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0 | 6 | 0 | n,m=map(int,input().split())
l=[0]*n
ac=[False]*n
cnt=0;acnt=0
for i in range(m):
a,b=input().split()
a=int(a)
if ac[a-1]:continue
if b=="AC":
cnt+=l[a-1]
acnt+=1
ac[a-1]=True
if b=="WA":
l[a-1]+=1
print(acnt,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 | #include<iostream>
using namespace std;
int main(){
int n,m;
cin>>n>>m;
bool ac[n+1];
int wa[n+1];
for(int i=1;i<=n;++i)
ac[i]=false,wa[i]=0;
int actot=0,watot=0;
for(int i=0;i<m;++i){
int ti;
string sub;
cin>>ti>>sub;
if(ac[ti])
continue;
if(sub=="AC"){
ac[ti]=true;
++actot;
watot+=wa[ti];
}
else
++wa[ti];
}
cout<<actot<<' '<<watot;
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())
x=[0]*n
y=[0]*n
for i in range(m):
P,s=input().split()
p=int(P)
if x[p-1]==0:
if s=="WA":
y[p-1]+=1
if s=="AC":
x[p-1]+=1
sx=0
sy=0
for i in range(n):
sx+=x[i]
if x[i]==1:
sy+=y[i]
print(str(sx),str(sy)) | PYTHON3 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.