prompt
string | response
string |
|---|---|
Problem: There are N people (with different names) and K clubs. For each club you know the list of members (so you have K unordered lists). Each person can be a member of many clubs (and also 0 clubs) and two different clubs might have exactly the same members. The value of the number K is the minimum possible such that the following property can be true for at least one configuration of clubs. If every person changes her name (maintaining the property that all names are different) and you know the new K lists of members of the clubs (but you don't know which list corresponds to which club), you are sure that you would be able to match the old names with the new ones.
Count the number of such configurations of clubs (or say that there are more than 1000). Two configurations of clubs that can be obtained one from the other if the N people change their names are considered equal.
Formal statement: A club is a (possibly empty) subset of \\{1,\dots, N\\} (the subset identifies the members, assuming that the people are indexed by the numbers 1, 2,\dots, N). A configuration of clubs is an unordered collection of K clubs (not necessarily distinct). Given a permutation \sigma(1), \dots, \sigma(N) of \\{1,\dots, N\\} and a configuration of clubs L=\\{C_1, C_2, \dots, C_K\\}, we denote with \sigma(L) the configuration of clubs \\{\sigma(C_1), \sigma(C_2), \dots, \sigma(C_K)\\} (if C is a club, \sigma(C)=\\{\sigma(x):\, x\in C\\}). A configuration of clubs L is name-preserving if for any pair of distinct permutations \sigma\not=\tau, it holds \sigma(L)\not=\tau(L).
You have to count the number of name-preserving configurations of clubs with the minimum possible number of clubs (so K is minimum). Two configurations L_1, L_2 such that L_2=\sigma(L_1) (for some permutation \sigma) are considered equal. If there are more than 1000 such configurations, print -1.
Constraints
* 2 \le N \le 2\cdot10^{18}
Input
The input is given from Standard Input in the format
N
Output
If ans is the number of configurations with the properties described in the statement, you should print on Standard Output
ans
If there are more than 1000 such configurations, print -1.
Examples
Input
2
Output
1
Input
3
Output
1
Input
4
Output
7
Input
13
Output
6
Input
26
Output
-1
Input
123456789123456789
Output
-1
Solution (in CPP):
|
#include <bits/stdc++.h>
using namespace std;
/*
#include <bits/stdc++.h>
using namespace std;
const int Nmx = 5;
const int fac[6] = {1, 1, 2, 6, 24, 120};
int shuf[Nmx + 1][120][1 << Nmx];
void prepare() {
auto arrange = [&] (int v, int l, const vector<int>& p) {
int rt = 0;
for (auto x : p) {
if (v & 1) {
rt |= 1 << x;
}
v >>= 1;
}
return rt;
};
for (int l = 1; l <= Nmx; l++) {
vector<int> p (l);
for (int i = 0; i < l; i++) {
p[i] = i;
}
for (int id = 0; next_permutation(p.begin(), p.end()); id++) {
for (int i = 0; i < (1 << l); i++) {
shuf[l][id][i] = arrange(i, l, p);
}
}
}
}
bool check(int n, const vector<int>& tb) {
static int vis[1 << Nmx], dfc = 0;
++dfc;
for (auto x : tb) {
vis[x] = dfc;
}
for (int i = 0; i < fac[n] - 1; i++) {
bool flag = true;
for (int j = 0; j < (signed) tb.size() && flag; j++) {
flag = vis[shuf[n][i][tb[j]]] == dfc;
}
if (flag) {
return false;
}
}
return true;
}
int ans = 0;
vector<int> stk;
void dfs(int l, int d, int k, int ls) {
if (d == k) {
ans += check(l, stk);
if (ans > 1000 * fac[l]) {
throw 1;
}
return;
}
for (int s = ls + 1; s < (1 << l); s++) {
stk[d] = s;
dfs(l, d + 1, k, s);
}
}
int n, k;
int table[6][20];
int main() {
prepare();
for (int k = 1; k <= 5; k++) {
for (int n = k; n <= (1 << (k - 1)); n++) {
::k = k;
::n = n;
::ans = 0;
stk.resize(n);
try {
dfs(k, 0, n, -1);
} catch(int) {
ans = 1001 * fac[k];
}
cout << k << " " << n << '\n';
ans /= fac[k];
table[k][n] = ans;
}
}
cout << "{{}";
for (int i = 1; i <= 5; i++) {
cout << ",\n {";
cout << table[i][0];
for (int j = 1; j <= 16; j++) {
cout << ", " << table[i][j];
}
cout << "}";
}
cout << "};\n";
return 0;
}
*/
const int table[6][20] = {{},
{1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 4, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 36, 108, 220, 334, 384, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 976, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001}};
#define ll long long
vector<int> G (105);
void prepare() {
G[1] = 0;
for (int n = 2; n <= 100; n++) {
for (int k = 1; k < n; k++) {
if ((1 << k) >= n && ((1 << k) - n) >= G[k]) {
G[n] = k;
break;
}
}
}
}
int g(ll n) {
if (n <= 100) {
return G[n];
}
for (int k = 1; ; k++) {
if ((1ll << k) >= n && ((1ll << k) - n) >= g(k)) {
return k;
}
}
assert(false);
return -1;
}
int solve(ll n, ll k) {
if (n < k) {
swap(n, k);
}
if (k < 63 && (1ll << k) - n < n) {
return solve((1ll << k) - n, k);
}
if (k > 5) {
return 1001;
}
return k == 0 ? 1 : table[k][n];
}
int main() {
ll n;
prepare();
scanf("%lld", &n);
int ans = solve(n, g(n));
ans += (n == 4);
ans += (n == 7) * 2;
printf("%d\n", (ans > 1000) ? -1 : ans);
return 0;
}
|
Problem: There are N people (with different names) and K clubs. For each club you know the list of members (so you have K unordered lists). Each person can be a member of many clubs (and also 0 clubs) and two different clubs might have exactly the same members. The value of the number K is the minimum possible such that the following property can be true for at least one configuration of clubs. If every person changes her name (maintaining the property that all names are different) and you know the new K lists of members of the clubs (but you don't know which list corresponds to which club), you are sure that you would be able to match the old names with the new ones.
Count the number of such configurations of clubs (or say that there are more than 1000). Two configurations of clubs that can be obtained one from the other if the N people change their names are considered equal.
Formal statement: A club is a (possibly empty) subset of \\{1,\dots, N\\} (the subset identifies the members, assuming that the people are indexed by the numbers 1, 2,\dots, N). A configuration of clubs is an unordered collection of K clubs (not necessarily distinct). Given a permutation \sigma(1), \dots, \sigma(N) of \\{1,\dots, N\\} and a configuration of clubs L=\\{C_1, C_2, \dots, C_K\\}, we denote with \sigma(L) the configuration of clubs \\{\sigma(C_1), \sigma(C_2), \dots, \sigma(C_K)\\} (if C is a club, \sigma(C)=\\{\sigma(x):\, x\in C\\}). A configuration of clubs L is name-preserving if for any pair of distinct permutations \sigma\not=\tau, it holds \sigma(L)\not=\tau(L).
You have to count the number of name-preserving configurations of clubs with the minimum possible number of clubs (so K is minimum). Two configurations L_1, L_2 such that L_2=\sigma(L_1) (for some permutation \sigma) are considered equal. If there are more than 1000 such configurations, print -1.
Constraints
* 2 \le N \le 2\cdot10^{18}
Input
The input is given from Standard Input in the format
N
Output
If ans is the number of configurations with the properties described in the statement, you should print on Standard Output
ans
If there are more than 1000 such configurations, print -1.
Examples
Input
2
Output
1
Input
3
Output
1
Input
4
Output
7
Input
13
Output
6
Input
26
Output
-1
Input
123456789123456789
Output
-1
Solution (in PYTHON3):
|
#
# File : F.py
# Author : Kazune Takahashi
# Created : 5/24/2020, 3:07:25 AM
# Powered by Visual Studio Code
#
dic = {
1: 1,
2: 1,
3: 1,
4: 7,
5: 4,
6: 1,
7: 336,
8: 384,
9: 334,
10: 220,
11: 108,
12: 36,
13: 6,
27: 976,
28: 108,
29: 4,
60: 220,
61: 1,
124: 334,
252: 384,
508: 334,
1020: 220,
2044: 108,
4092: 36,
8188: 6,
134217723: 976,
268435451: 108,
536870907: 4,
1152921504606846970: 220,
2305843009213693946: 1,
}
n = int(input())
if n in dic:
print(dic[n])
else:
print(-1)
|
Problem: There are N people (with different names) and K clubs. For each club you know the list of members (so you have K unordered lists). Each person can be a member of many clubs (and also 0 clubs) and two different clubs might have exactly the same members. The value of the number K is the minimum possible such that the following property can be true for at least one configuration of clubs. If every person changes her name (maintaining the property that all names are different) and you know the new K lists of members of the clubs (but you don't know which list corresponds to which club), you are sure that you would be able to match the old names with the new ones.
Count the number of such configurations of clubs (or say that there are more than 1000). Two configurations of clubs that can be obtained one from the other if the N people change their names are considered equal.
Formal statement: A club is a (possibly empty) subset of \\{1,\dots, N\\} (the subset identifies the members, assuming that the people are indexed by the numbers 1, 2,\dots, N). A configuration of clubs is an unordered collection of K clubs (not necessarily distinct). Given a permutation \sigma(1), \dots, \sigma(N) of \\{1,\dots, N\\} and a configuration of clubs L=\\{C_1, C_2, \dots, C_K\\}, we denote with \sigma(L) the configuration of clubs \\{\sigma(C_1), \sigma(C_2), \dots, \sigma(C_K)\\} (if C is a club, \sigma(C)=\\{\sigma(x):\, x\in C\\}). A configuration of clubs L is name-preserving if for any pair of distinct permutations \sigma\not=\tau, it holds \sigma(L)\not=\tau(L).
You have to count the number of name-preserving configurations of clubs with the minimum possible number of clubs (so K is minimum). Two configurations L_1, L_2 such that L_2=\sigma(L_1) (for some permutation \sigma) are considered equal. If there are more than 1000 such configurations, print -1.
Constraints
* 2 \le N \le 2\cdot10^{18}
Input
The input is given from Standard Input in the format
N
Output
If ans is the number of configurations with the properties described in the statement, you should print on Standard Output
ans
If there are more than 1000 such configurations, print -1.
Examples
Input
2
Output
1
Input
3
Output
1
Input
4
Output
7
Input
13
Output
6
Input
26
Output
-1
Input
123456789123456789
Output
-1
Solution (in CPP):
|
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
typedef string str;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef pair<db,db> pd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<db> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<pd> vpd;
#define mp make_pair
#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define pf push_front
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)
const int MOD = 1e9+7; // 998244353;
const int MX = 2e5+5;
const ll INF = 1e18;
const ld PI = acos((ld)-1);
const int xd[4] = {1,0,-1,0}, yd[4] = {0,1,0,-1};
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());
template<class T> bool ckmin(T& a, const T& b) {
return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) {
return a < b ? a = b, 1 : 0; }
int pct(int x) { return __builtin_popcount(x); }
int bits(int x) { return 31-__builtin_clz(x); } // floor(log2(x))
int cdiv(int a, int b) { return a/b+!(a<0||a%b == 0); } // division of a by b rounded up, assumes b > 0
int fstTrue(function<bool(int)> f, int lo, int hi) {
hi ++; assert(lo <= hi); // assuming f is increasing
while (lo < hi) { // find first index such that f is true
int mid = (lo+hi)/2;
f(mid) ? hi = mid : lo = mid+1;
}
return lo;
}
// INPUT
template<class A> void re(complex<A>& c);
template<class A, class B> void re(pair<A,B>& p);
template<class A> void re(vector<A>& v);
template<class A, size_t SZ> void re(array<A,SZ>& a);
template<class T> void re(T& x) { cin >> x; }
void re(db& d) { str t; re(t); d = stod(t); }
void re(ld& d) { str t; re(t); d = stold(t); }
template<class H, class... T> void re(H& h, T&... t) { re(h); re(t...); }
template<class A> void re(complex<A>& c) { A a,b; re(a,b); c = {a,b}; }
template<class A, class B> void re(pair<A,B>& p) { re(p.f,p.s); }
template<class A> void re(vector<A>& x) { trav(a,x) re(a); }
template<class A, size_t SZ> void re(array<A,SZ>& x) { trav(a,x) re(a); }
// TO_STRING
#define ts to_string
str ts(char c) { return str(1,c); }
str ts(bool b) { return b ? "true" : "false"; }
str ts(const char* s) { return (str)s; }
str ts(str s) { return s; }
template<class A> str ts(complex<A> c) {
stringstream ss; ss << c; return ss.str(); }
str ts(vector<bool> v) {
str res = "{"; F0R(i,sz(v)) res += char('0'+v[i]);
res += "}"; return res; }
template<size_t SZ> str ts(bitset<SZ> b) {
str res = ""; F0R(i,SZ) res += char('0'+b[i]);
return res; }
template<class A, class B> str ts(pair<A,B> p);
template<class T> str ts(T v) { // containers with begin(), end()
bool fst = 1; str res = "{";
for (const auto& x: v) {
if (!fst) res += ", ";
fst = 0; res += ts(x);
}
res += "}"; return res;
}
template<class A, class B> str ts(pair<A,B> p) {
return "("+ts(p.f)+", "+ts(p.s)+")"; }
// OUTPUT
template<class A> void pr(A x) { cout << ts(x); }
template<class H, class... T> void pr(const H& h, const T&... t) {
pr(h); pr(t...); }
void ps() { pr("\n"); } // print w/ spaces
template<class H, class... T> void ps(const H& h, const T&... t) {
pr(h); if (sizeof...(t)) pr(" "); ps(t...); }
// DEBUG
void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) {
cerr << ts(h); if (sizeof...(t)) cerr << ", ";
DBG(t...); }
#ifdef LOCAL // compile with -DLOCAL
#define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
#else
#define dbg(...) 0
#endif
// FILE I/O
void setIn(string s) { freopen(s.c_str(),"r",stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
void setIO(string s = "") {
unsyncIO();
// cin.exceptions(cin.failbit);
// throws exception when do smth illegal
// ex. try to read letter into int
if (sz(s)) { setIn(s+".in"), setOut(s+".out"); } // for USACO
}
int g(ll n) {
if (n == 1) return 0;
for (int k = 1;;++k) if ((1LL<<k) >= n && (1LL<<k)-g(k) >= n) return k;
}
int res = 0, fac[6];
ll K;
int memo[6][120][1<<5];
vi st;
bool ok() {
vector<bool> present(1<<K);
trav(t,st) present[t] = 1;
FOR(i,1,fac[K]) {
bool works = 1;
trav(t,st) works &= present[memo[K][i][t]];
if (works) return 0;
}
return 1;
}
void dfs(int num, int ind) {
if (res/fac[K] > 1000) return;
if (sz(st) == num) {
res += ok();
return;
}
if (ind == (1<<K)) return;
dfs(num,ind+1);
st.pb(ind);
dfs(num,ind+1);
st.pop_back();
}
int solve(ll k, ll n) {
if (k > n) return solve(n,k);
if (k <= 61 && n > (1LL<<k)-n) return solve(k,(1LL<<k)-n);
if (k > 5) return -1;
dbg("HA",k,n);
K = k; dfs(n,0);
if (res/fac[k] > 1000) return -1;
assert(res%fac[k] == 0);
return res/fac[k];
}
int main() {
fac[0] = 1; FOR(i,1,6) fac[i] = i*fac[i-1];
FOR(len,1,6) {
vi v; F0R(i,len) v.pb(i);
int cnt = 0;
do {
F0R(i,1<<len) {
int mask = 0;
F0R(j,len) if (i&(1<<j)) mask ^= 1<<v[j];
memo[len][cnt][i] = mask;
}
cnt ++;
} while (next_permutation(all(v)));
}
dbg("OK");
setIO(); ll n; re(n);
int _g = g(n); dbg("HUH",n,_g);
int tmp = solve(_g,n);
if (n == 4) tmp ++;
if (n == 7) tmp += 2;
ps(tmp);
// you should actually read the stuff at the bottom
}
/* stuff you should look for
* int overflow, array bounds
* special cases (n=1?)
* do smth instead of nothing and stay organized
* WRITE STUFF DOWN
*/
|
Problem: There are N people (with different names) and K clubs. For each club you know the list of members (so you have K unordered lists). Each person can be a member of many clubs (and also 0 clubs) and two different clubs might have exactly the same members. The value of the number K is the minimum possible such that the following property can be true for at least one configuration of clubs. If every person changes her name (maintaining the property that all names are different) and you know the new K lists of members of the clubs (but you don't know which list corresponds to which club), you are sure that you would be able to match the old names with the new ones.
Count the number of such configurations of clubs (or say that there are more than 1000). Two configurations of clubs that can be obtained one from the other if the N people change their names are considered equal.
Formal statement: A club is a (possibly empty) subset of \\{1,\dots, N\\} (the subset identifies the members, assuming that the people are indexed by the numbers 1, 2,\dots, N). A configuration of clubs is an unordered collection of K clubs (not necessarily distinct). Given a permutation \sigma(1), \dots, \sigma(N) of \\{1,\dots, N\\} and a configuration of clubs L=\\{C_1, C_2, \dots, C_K\\}, we denote with \sigma(L) the configuration of clubs \\{\sigma(C_1), \sigma(C_2), \dots, \sigma(C_K)\\} (if C is a club, \sigma(C)=\\{\sigma(x):\, x\in C\\}). A configuration of clubs L is name-preserving if for any pair of distinct permutations \sigma\not=\tau, it holds \sigma(L)\not=\tau(L).
You have to count the number of name-preserving configurations of clubs with the minimum possible number of clubs (so K is minimum). Two configurations L_1, L_2 such that L_2=\sigma(L_1) (for some permutation \sigma) are considered equal. If there are more than 1000 such configurations, print -1.
Constraints
* 2 \le N \le 2\cdot10^{18}
Input
The input is given from Standard Input in the format
N
Output
If ans is the number of configurations with the properties described in the statement, you should print on Standard Output
ans
If there are more than 1000 such configurations, print -1.
Examples
Input
2
Output
1
Input
3
Output
1
Input
4
Output
7
Input
13
Output
6
Input
26
Output
-1
Input
123456789123456789
Output
-1
Solution (in CPP):
|
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
const int inf=2333;
inline ll read(){
ll x=0,f=1;
char c=getchar();
while(c<'0'||c>'9'){
if(c=='-')f=-1;
c=getchar();
}
while(c>='0'&&c<='9'){
x=(x<<1)+(x<<3)+c-'0';
c=getchar();
}
return x*f;
}
ll n;
int g[233];
void init(){
g[1]=0;
for(int i=2;i<=80;++i){
for(int k=1;;++k){
if((1LL<<k)-i>=g[k]){
g[i]=k;break;
}
}
}
}
const int table[6][23] = {
{},
{1,2},
{0,0,2},
{0,0,0,4,6},
{0,0,0,0,36,108,220,334,384},
{0,0,0,0,0,976,inf,inf,inf,inf,inf,inf,inf,inf,inf,inf,inf}
};
int Get_g(ll n){
if(n<=80)return g[n];
for(int k=1;;++k){
if((1LL<<k)-n>=g[k])return k;
}
return 114514;
}
int Solve(ll n,ll k){
if(n<k)swap(n,k);
if(!k)return 1;
if(k<63&&(1LL<<(k-1))<n){
return Solve((1LL<<k)-n,k);
}
if(k<=5)return table[k][n];
return inf;
}
int main(){
init();
n=read();
int ans=Solve(n,Get_g(n))+(n==4)+(n==7)*2;
printf("%d\n",ans>1000?-1:ans);
return 0;
}
|
Problem: There are N people (with different names) and K clubs. For each club you know the list of members (so you have K unordered lists). Each person can be a member of many clubs (and also 0 clubs) and two different clubs might have exactly the same members. The value of the number K is the minimum possible such that the following property can be true for at least one configuration of clubs. If every person changes her name (maintaining the property that all names are different) and you know the new K lists of members of the clubs (but you don't know which list corresponds to which club), you are sure that you would be able to match the old names with the new ones.
Count the number of such configurations of clubs (or say that there are more than 1000). Two configurations of clubs that can be obtained one from the other if the N people change their names are considered equal.
Formal statement: A club is a (possibly empty) subset of \\{1,\dots, N\\} (the subset identifies the members, assuming that the people are indexed by the numbers 1, 2,\dots, N). A configuration of clubs is an unordered collection of K clubs (not necessarily distinct). Given a permutation \sigma(1), \dots, \sigma(N) of \\{1,\dots, N\\} and a configuration of clubs L=\\{C_1, C_2, \dots, C_K\\}, we denote with \sigma(L) the configuration of clubs \\{\sigma(C_1), \sigma(C_2), \dots, \sigma(C_K)\\} (if C is a club, \sigma(C)=\\{\sigma(x):\, x\in C\\}). A configuration of clubs L is name-preserving if for any pair of distinct permutations \sigma\not=\tau, it holds \sigma(L)\not=\tau(L).
You have to count the number of name-preserving configurations of clubs with the minimum possible number of clubs (so K is minimum). Two configurations L_1, L_2 such that L_2=\sigma(L_1) (for some permutation \sigma) are considered equal. If there are more than 1000 such configurations, print -1.
Constraints
* 2 \le N \le 2\cdot10^{18}
Input
The input is given from Standard Input in the format
N
Output
If ans is the number of configurations with the properties described in the statement, you should print on Standard Output
ans
If there are more than 1000 such configurations, print -1.
Examples
Input
2
Output
1
Input
3
Output
1
Input
4
Output
7
Input
13
Output
6
Input
26
Output
-1
Input
123456789123456789
Output
-1
Solution (in CPP):
|
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int INF = 1000;
// Applies the permutation perm on the bits of x.
int shuffle_bitmask(int len, const vector<int>& perm, int x) {
int y = 0;
for (int i = 0; i < len; i++) if (x&(1<<i)) y ^= 1<<perm[i];
return y;
}
const int MAXLEN = 5;
int memo_shuffle_bitmask[MAXLEN+1][120][1<<MAXLEN];
int factorial[MAXLEN+1];
// Precompute the factorials and shuffle_bitmask.
// The precomputation of shuffle_bitmask is not necessary, but it makes the code
// much faster.
void preprocessing() {
factorial[0] = factorial[1] = 1;
for (int n = 2; n <= MAXLEN; n++) {
int z = 0;
factorial[n] = n * factorial[n-1];
vector<int> perm(n);
for (int i = 0; i < n; i++) perm[i] = i;
while (next_permutation(perm.begin(), perm.end())) {
for (int bb = 0; bb < (1<<n); bb++) {
memo_shuffle_bitmask[n][z][bb] = shuffle_bitmask(n, perm, bb);
}
z++;
}
}
}
// Returns whether conf is name-preserving.
bool is_name_preserving(int len, const vector<int>& conf) {
static bool arr[1<<MAXLEN];
for (int bb = 0; bb < (1<<len); bb++) arr[bb] = false;
for (int x: conf) arr[x] = true;
for (int i = 0; i < factorial[len]-1; i++) {
bool works = true;
for (int x: conf) works &= arr[memo_shuffle_bitmask[len][i][x]];
if (works) return false;
}
return true;
}
// Enumerate configurations of q distinct subsets of {0, ..., len-1}; counting how many are name-preserving.
// A configuration is identified with a q-subset of {0, 1, ..., (2^len)-1}.
int count_name_preserving(int len, int q, int last, vector<int>& curr) {
if (q == 0) return is_name_preserving(len, curr);
int res = 0;
for (int i = last+1; i < (1<<len) and res/factorial[len] <= INF; i++) {
curr.push_back(i);
res += count_name_preserving(len, q-1, i, curr);
curr.pop_back();
}
return res;
}
int solve(LL k, LL n) {
if (k > n) swap(k, n);
if (n > (1ll<<k)-n) return solve(k, (1ll<<k)-n);
if (k > MAXLEN) return -1;
vector<int> curr = {};
int res = count_name_preserving(k, n, -1, curr) / factorial[k];
return (res > INF)?-1:res;
}
int g(LL n) {
if (n == 1) return 0;
for (int k = 0; k <= n; k++) if ((1ll<<k) >= n and (1ll<<k)-g(k) >= n) return k;
return -1;
}
int main() {
preprocessing();
LL N;
cin >> N;
LL res = solve(g(N), N);
if (N == 4) res++;
if (N == 7) res += 2;
cout << res << "\n";
}
|
Problem: There are N people (with different names) and K clubs. For each club you know the list of members (so you have K unordered lists). Each person can be a member of many clubs (and also 0 clubs) and two different clubs might have exactly the same members. The value of the number K is the minimum possible such that the following property can be true for at least one configuration of clubs. If every person changes her name (maintaining the property that all names are different) and you know the new K lists of members of the clubs (but you don't know which list corresponds to which club), you are sure that you would be able to match the old names with the new ones.
Count the number of such configurations of clubs (or say that there are more than 1000). Two configurations of clubs that can be obtained one from the other if the N people change their names are considered equal.
Formal statement: A club is a (possibly empty) subset of \\{1,\dots, N\\} (the subset identifies the members, assuming that the people are indexed by the numbers 1, 2,\dots, N). A configuration of clubs is an unordered collection of K clubs (not necessarily distinct). Given a permutation \sigma(1), \dots, \sigma(N) of \\{1,\dots, N\\} and a configuration of clubs L=\\{C_1, C_2, \dots, C_K\\}, we denote with \sigma(L) the configuration of clubs \\{\sigma(C_1), \sigma(C_2), \dots, \sigma(C_K)\\} (if C is a club, \sigma(C)=\\{\sigma(x):\, x\in C\\}). A configuration of clubs L is name-preserving if for any pair of distinct permutations \sigma\not=\tau, it holds \sigma(L)\not=\tau(L).
You have to count the number of name-preserving configurations of clubs with the minimum possible number of clubs (so K is minimum). Two configurations L_1, L_2 such that L_2=\sigma(L_1) (for some permutation \sigma) are considered equal. If there are more than 1000 such configurations, print -1.
Constraints
* 2 \le N \le 2\cdot10^{18}
Input
The input is given from Standard Input in the format
N
Output
If ans is the number of configurations with the properties described in the statement, you should print on Standard Output
ans
If there are more than 1000 such configurations, print -1.
Examples
Input
2
Output
1
Input
3
Output
1
Input
4
Output
7
Input
13
Output
6
Input
26
Output
-1
Input
123456789123456789
Output
-1
Solution (in CPP):
|
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#ifndef LOCAL
#define cerr if(0)cout
#endif
typedef long long ll;
//My i/o stream
struct fastio
{
char s[100000];
int it, len;
fastio() {it=len=0;}
inline char get()
{
if (it<len) return s[it++]; it=0;
len=fread(s, 1, 100000, stdin);
if (len==0) return EOF; else return s[it++];
}
bool notend()
{
char c=get();
while (c==' '||c=='\n') c=get();
if (it>0) it--;
return c!=EOF;
}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
ll r=0; bool ng=0; char c; c=_buff.get();
while (c!='-'&&(c<'0'||c>'9')) c=_buff.get();
if (c=='-') ng=1, c=_buff.get();
while (c>='0'&&c<='9') r=r*10+c-'0', c=_buff.get();
return ng?-r:r;
}
template <class T> inline void putnum(T x)
{
if (x<0) putchar('-'), x=-x;
register short a[20]={}, sz=0;
while (x) a[sz++]=x%10, x/=10;
if(sz==0) putchar('0');
for (int i=sz-1; i>=0; i--) putchar('0'+a[i]);
}
inline char getreal() {char c=_buff.get(); while (c<=32) c=_buff.get(); return c;}
const int mod = 1e9+7;
ll qpow(ll x, ll k) {return k==0? 1: 1ll*qpow(1ll*x*x%mod,k>>1)*(k&1?x:1)%mod;}
/*
generator 1
generate all situations with distinctive rows for K<=5 (in less than 1 min)
const int maxk = 5;
const int maxkf = 120;
int K, F;
int pm[1<<maxk][maxkf];
typedef unsigned long long ull;
ull f[maxkf];
void init_pm()
{
int p[maxk];
for (int i=0; i<K; i++) p[i] = i;
int t = 0;
do
{
for (int i=0; i<1<<K; i++)
{
int ni = 0;
for (int j=0; j<K; j++) ni |= ((i>>j)&1)<<p[j];
pm[i][t] = ni;
}
t++;
}while(next_permutation(p, p+K));
F = t;
}
int ans[1111];
bool check_diff()
{
for (int i=1; i<F; i++) if (f[i]<=f[0]) return false;
return true;
}
bool check_diff2()
{
for (int i=1; i<F; i++)
{
f[i] = 0;
for (int j=0; j<(1<<K); j++) f[i] |= (ull((f[0]>>j)&1))<<pm[j][i];
if (f[i]<=f[0]) return false;
}
return true;
}
void dfs(int x, int cnt)
{
if (cnt>(1<<(K-1))) return;
// if (x<=4) cerr<<x<<endl;
if (x==(1<<K))
{
if (ans[cnt]<=1000&&check_diff2())
{
ans[cnt]++;
}
return;
}
dfs(x+1, cnt);
// for (int i=0; i<F; i++) f[i] |= 1ull<<pm[x][i];
f[0] |= 1ull<<x;
dfs(x+1, cnt+1);
f[0] -= 1ull<<x;
// for (int i=0; i<F; i++) f[i] -= 1ull<<pm[x][i];
}
int main()
{
for (K=1; K<=5; K++)
{
memset(ans, 0, sizeof(ans));
init_pm();
dfs(0, 0);
for (int i=0; i<=(1<<K-1); i++)
{
if (i==0) cerr<<"{"; else cerr<<",";
cerr<<ans[i];
}
cerr<<"},"<<endl;
}
return 0;
}
*/
/*
generator 2
generate all situations with some identical rows for K<=5
const int tab[6][20] =
{{},
{1,2},
{0,1,2},
{0,0,1,4,6},
{0,0,0,6,36,108,220,334,384},
{0,0,0,4,108,976,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001}};
const int maxn[6] =
{0, 1, 2, 4, 8, 5};
const int maxk = 5;
const int maxkf = 120;
int K, F;
int pm[1<<maxk][maxkf];
typedef unsigned long long ull;
ull f[maxkf];
void init_pm()
{
int p[maxk];
for (int i=0; i<K; i++) p[i] = i;
int t = 0;
do
{
for (int i=0; i<1<<K; i++)
{
int ni = 0;
for (int j=0; j<K; j++) ni |= ((i>>j)&1)<<p[j];
pm[i][t] = ni;
}
t++;
}while(next_permutation(p, p+K));
F = t;
}
int ans[1111];
bool check_special()
{
bool sp = false;
for (int i=1; i<F; i++)
{
f[i] = 0;
bool flag = true;
for (int j=0; j<(1<<K); j++)
{
if ((f[0]>>j)&1)
{
f[i] |= 1ull<<pm[j][i];
if (pm[j][i]!=j) flag = false;
}
}
if (flag) sp = true;
else if (f[i]<=f[0]) return false;
}
return sp;
}
void dfs(int x, int cnt)
{
if (cnt>maxn[K]) return;
if (x==(1<<K))
{
if (check_special())
{
ans[cnt]++;
}
return;
}
dfs(x+1, cnt);
// for (int i=0; i<F; i++) f[i] |= 1ull<<pm[x][i];
f[0] |= 1ull<<x;
dfs(x+1, cnt+1);
f[0] -= 1ull<<x;
// for (int i=0; i<F; i++) f[i] -= 1ull<<pm[x][i];
}
int main()
{
for (K=1; K<=5; K++)
{
memset(ans, 0, sizeof(ans));
init_pm();
dfs(0, 0);
for (int i=0; i<=(1<<K-1); i++)
{
if (i==0) cerr<<"{"; else cerr<<",";
cerr<<ans[i];
}
cerr<<"},"<<endl;
}
return 0;
}
*/
const int tab[6][20] =
{{},
{1,2},
{0,1,2},
{0,0,1,4,6},
{0,0,0,6,36,108,220,334,384},
{0,0,0,4,108,976,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001}};
const int tab_sp[6][20] =
{{},
{0,0},
{1,2,1},
{1,4,6,4,1},
{1,5,13,23,28,22,10,2,0},
{1,6,22,78,244,594,0,0,0,0,0,0,0,0,0,0,0}};
ll solve(ll K, ll N)
{
assert(K>=1&&N>=0);
if (N>(1ll<<K)) return 0;
if (N>(1ll<<K-1)) return solve(K, (1ll<<K)-N);
if (N==0) return K==1;
if (N<K) return solve(N, K);
if (K>5) return 1001;
return tab[K][N];
}
ll solve_sp(ll K, ll N)
{
if (K>5||N>(1ll<<K-1)) return 0;
else return tab_sp[K][N];
}
int main()
{
ll N;
cin>>N;
int K = 1;
while (true)
{
// cerr<<"K="<<K<<endl;
ll ans = solve(K, N)+solve_sp(K, N);
if (ans==0) K++;
else
{
if (ans>1000) puts("-1");
else cout<<ans<<endl;
return 0;
}
}
}
|
Problem: There are N people (with different names) and K clubs. For each club you know the list of members (so you have K unordered lists). Each person can be a member of many clubs (and also 0 clubs) and two different clubs might have exactly the same members. The value of the number K is the minimum possible such that the following property can be true for at least one configuration of clubs. If every person changes her name (maintaining the property that all names are different) and you know the new K lists of members of the clubs (but you don't know which list corresponds to which club), you are sure that you would be able to match the old names with the new ones.
Count the number of such configurations of clubs (or say that there are more than 1000). Two configurations of clubs that can be obtained one from the other if the N people change their names are considered equal.
Formal statement: A club is a (possibly empty) subset of \\{1,\dots, N\\} (the subset identifies the members, assuming that the people are indexed by the numbers 1, 2,\dots, N). A configuration of clubs is an unordered collection of K clubs (not necessarily distinct). Given a permutation \sigma(1), \dots, \sigma(N) of \\{1,\dots, N\\} and a configuration of clubs L=\\{C_1, C_2, \dots, C_K\\}, we denote with \sigma(L) the configuration of clubs \\{\sigma(C_1), \sigma(C_2), \dots, \sigma(C_K)\\} (if C is a club, \sigma(C)=\\{\sigma(x):\, x\in C\\}). A configuration of clubs L is name-preserving if for any pair of distinct permutations \sigma\not=\tau, it holds \sigma(L)\not=\tau(L).
You have to count the number of name-preserving configurations of clubs with the minimum possible number of clubs (so K is minimum). Two configurations L_1, L_2 such that L_2=\sigma(L_1) (for some permutation \sigma) are considered equal. If there are more than 1000 such configurations, print -1.
Constraints
* 2 \le N \le 2\cdot10^{18}
Input
The input is given from Standard Input in the format
N
Output
If ans is the number of configurations with the properties described in the statement, you should print on Standard Output
ans
If there are more than 1000 such configurations, print -1.
Examples
Input
2
Output
1
Input
3
Output
1
Input
4
Output
7
Input
13
Output
6
Input
26
Output
-1
Input
123456789123456789
Output
-1
Solution (in CPP):
|
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
const int inf=2333;
inline ll read(){
ll x=0,f=1;
char c=getchar();
while(c<'0'||c>'9'){
if(c=='-')f=-1;
c=getchar();
}
while(c>='0'&&c<='9'){
x=(x<<1)+(x<<3)+c-'0';
c=getchar();
}
return x*f;
}
ll n;
int g[233];
void init(){
g[1]=0;
for(int i=2;i<=80;++i){
for(int k=1;;++k){
if((1LL<<k)-i>=g[k]){
g[i]=k;break;
}
}
}
}
const int table[6][23] = {
{},
{1,2},
{0,0,2},
{0,0,0,4,6},
{0,0,0,0,36,108,220,334,384},
{0,0,0,0,0,976,inf,inf,inf,inf,inf,inf,inf,inf,inf,inf,inf}
};
int Get_g(ll n){
if(n<=80)return g[n];
for(int k=1;;++k){
if((1LL<<k)-n>=g[k])return k;
}
return 114514;
}
int Solve(ll n,ll k){
if(n<k)swap(n,k);
if(k<63&&(1LL<<k)-n<n){
return Solve((1LL<<k)-n,k);
}
if(!k)return 1;
if(k<=5)return table[k][n];
return inf;
}
int main(){
init();
n=read();
int ans=Solve(n,Get_g(n))+(n==4)+(n==7)*2;
printf("%d\n",ans>1000?-1:ans);
return 0;
}
|
Problem: There are N people (with different names) and K clubs. For each club you know the list of members (so you have K unordered lists). Each person can be a member of many clubs (and also 0 clubs) and two different clubs might have exactly the same members. The value of the number K is the minimum possible such that the following property can be true for at least one configuration of clubs. If every person changes her name (maintaining the property that all names are different) and you know the new K lists of members of the clubs (but you don't know which list corresponds to which club), you are sure that you would be able to match the old names with the new ones.
Count the number of such configurations of clubs (or say that there are more than 1000). Two configurations of clubs that can be obtained one from the other if the N people change their names are considered equal.
Formal statement: A club is a (possibly empty) subset of \\{1,\dots, N\\} (the subset identifies the members, assuming that the people are indexed by the numbers 1, 2,\dots, N). A configuration of clubs is an unordered collection of K clubs (not necessarily distinct). Given a permutation \sigma(1), \dots, \sigma(N) of \\{1,\dots, N\\} and a configuration of clubs L=\\{C_1, C_2, \dots, C_K\\}, we denote with \sigma(L) the configuration of clubs \\{\sigma(C_1), \sigma(C_2), \dots, \sigma(C_K)\\} (if C is a club, \sigma(C)=\\{\sigma(x):\, x\in C\\}). A configuration of clubs L is name-preserving if for any pair of distinct permutations \sigma\not=\tau, it holds \sigma(L)\not=\tau(L).
You have to count the number of name-preserving configurations of clubs with the minimum possible number of clubs (so K is minimum). Two configurations L_1, L_2 such that L_2=\sigma(L_1) (for some permutation \sigma) are considered equal. If there are more than 1000 such configurations, print -1.
Constraints
* 2 \le N \le 2\cdot10^{18}
Input
The input is given from Standard Input in the format
N
Output
If ans is the number of configurations with the properties described in the statement, you should print on Standard Output
ans
If there are more than 1000 such configurations, print -1.
Examples
Input
2
Output
1
Input
3
Output
1
Input
4
Output
7
Input
13
Output
6
Input
26
Output
-1
Input
123456789123456789
Output
-1
Solution (in CPP):
|
#include<iostream>
#include<cstdio>
using namespace std;
const int res[6][20]={{},
{1,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,4,6,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,36,108,220,334,384,0,0,0,0,0,0,0,0},
{0,0,0,0,0,976,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001}};
const int N=1005;
int G[N];
void init()
{
G[1]=0;
for(int n=2;n<=1000;n++)
{
for(int k=1;k<n;k++)
if((1LL<<k)>=n&&((1LL<<k)-n)>=G[k])
{
G[n]=k;
break;
}
if(G[n]==0) G[n]=-1;
}
return;
}
int g(long long n)
{
if(n<=1000) return G[n];
for(int k=1;;k++)
if((1LL<<k)>=n&&((1LL<<k)-n)>=g(k)) return k;
return -1;
}
int solve(long long n,long long k)
{
if(n<k) swap(n,k);
if(k<63&&(1LL<<k)-n<n) return solve((1LL<<k)-n,k);
if(k>5) return 1001;
if(k==0) return 1;
return res[k][n];
}
long long n;
int main()
{
init();
scanf("%lld",&n);
int ans=solve(n,g(n));
if(n==4) ans++;
if(n==7) ans+=2;
if(ans>1000) printf("-1");
else printf("%d",ans);
return 0;
}
|
Problem: There are N people (with different names) and K clubs. For each club you know the list of members (so you have K unordered lists). Each person can be a member of many clubs (and also 0 clubs) and two different clubs might have exactly the same members. The value of the number K is the minimum possible such that the following property can be true for at least one configuration of clubs. If every person changes her name (maintaining the property that all names are different) and you know the new K lists of members of the clubs (but you don't know which list corresponds to which club), you are sure that you would be able to match the old names with the new ones.
Count the number of such configurations of clubs (or say that there are more than 1000). Two configurations of clubs that can be obtained one from the other if the N people change their names are considered equal.
Formal statement: A club is a (possibly empty) subset of \\{1,\dots, N\\} (the subset identifies the members, assuming that the people are indexed by the numbers 1, 2,\dots, N). A configuration of clubs is an unordered collection of K clubs (not necessarily distinct). Given a permutation \sigma(1), \dots, \sigma(N) of \\{1,\dots, N\\} and a configuration of clubs L=\\{C_1, C_2, \dots, C_K\\}, we denote with \sigma(L) the configuration of clubs \\{\sigma(C_1), \sigma(C_2), \dots, \sigma(C_K)\\} (if C is a club, \sigma(C)=\\{\sigma(x):\, x\in C\\}). A configuration of clubs L is name-preserving if for any pair of distinct permutations \sigma\not=\tau, it holds \sigma(L)\not=\tau(L).
You have to count the number of name-preserving configurations of clubs with the minimum possible number of clubs (so K is minimum). Two configurations L_1, L_2 such that L_2=\sigma(L_1) (for some permutation \sigma) are considered equal. If there are more than 1000 such configurations, print -1.
Constraints
* 2 \le N \le 2\cdot10^{18}
Input
The input is given from Standard Input in the format
N
Output
If ans is the number of configurations with the properties described in the statement, you should print on Standard Output
ans
If there are more than 1000 such configurations, print -1.
Examples
Input
2
Output
1
Input
3
Output
1
Input
4
Output
7
Input
13
Output
6
Input
26
Output
-1
Input
123456789123456789
Output
-1
Solution (in CPP):
|
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxm = 6, maxd = 1 << 5 | 1, maxs = (int)1e3 + 1;
int dfs(int n, int tot, int upp, int sta, vector<int> &msk) {
if((int)msk.size() == tot) {
bool chk = 1;
vector<int> perm(n);
iota(perm.begin(), perm.end(), 0);
static int tim = 0, vis[maxd] = {};
++tim;
for(int x : msk)
vis[x] = tim;
while(chk && next_permutation(perm.begin(), perm.end())) {
bool same = 1;
for(int x : msk) {
int y = 0;
for(int i = 0; i < n; ++i, x >>= 1)
if(x & 1)
y |= 1 << perm[i];
if(vis[y] != tim) {
same = 0;
break;
}
}
chk &= !same;
}
if(chk) {
// for(int x : best) {
// for(int j = 0; j < n; ++j, x >>= 1)
// printf("%d", x & 1);
// puts("");
// }
// puts("");
}
return chk;
}
int ret = 0;
msk.push_back(0);
for( ; sta < (1 << n) && ret < upp; ++sta) {
msk.back() = sta;
ret += dfs(n, tot, upp, sta + 1, msk);
}
msk.pop_back();
return ret < upp ? ret : upp;
}
int solve1(LL n, int m) {
if(n < m)
return solve1(m, n);
if(n > (1LL << m) - n)
return solve1((1LL << m) - n, m);
if(m > 5)
return maxs;
int prd = 1;
for(int i = 1; i <= m; ++i)
prd *= i;
int upp = (maxs - 1) * prd + 1;
vector<int> msk;
int ret = dfs(m, n, upp, 0, msk);
return ret < upp ? ret / prd : maxs;
}
set<vector<int> > Hash;
int dfs2(int n, int tot, int sta, vector<int> &msk, bool sp) {
if((int)msk.size() == tot) {
if(!sp)
return 0;
bool chk = 1;
vector<int> perm(n), best = msk;
iota(perm.begin(), perm.end(), 0);
while(chk && next_permutation(perm.begin(), perm.end())) {
vector<int> tmp;
for(int x : msk) {
int y = 0;
for(int i = 0; i < n; ++i, x >>= 1)
if(x & 1)
y |= 1 << perm[i];
tmp.push_back(y);
}
sort(tmp.begin(), tmp.end());
chk &= msk != tmp;
best = min(best, tmp);
}
chk &= !Hash.count(best);
if(chk) {
Hash.insert(best);
// for(int x : best) {
// for(int j = 0; j < n; ++j, x >>= 1)
// printf("%d", x & 1);
// puts("");
// }
// puts("");
}
return chk;
}
int ret = 0;
msk.push_back(0);
for( ; sta < (1 << n) && ret < maxs; ++sta) {
msk.back() = sta;
ret += dfs2(n, tot, sta, msk, sp || ((int)msk.size() > 2 && msk[msk.size() - 2] == sta));
}
msk.pop_back();
return ret < maxs ? ret : maxs;
}
int solve2(int n, int m) {
// printf("dangerous (%d, %d)\n", n, m);
if(n == 4) {
/*
1100
1100
1010
*/
return 1;
}
if(n == 7) {
/*
1110000
1110000
1001100
1101010
1110000
1101100
1101100
1011010
*/
return 2;
}
if(n == 8) {
return 0;
}
// unreachable
Hash.clear();
vector<int> msk;
return dfs2(n, m, 0, msk, 0);
}
int main() {
LL n;
int m = 0;
scanf("%lld", &n);
vector<int> dp = {0};
for(int i = 1; i < n; ++i) {
for(int j = 0; j < i; ++j)
if((1 << j) - i >= dp[j]) {
dp.push_back(j);
break;
}
// assert((int)dp.size() == i + 1);
if((1LL << i) - n >= dp.back()) {
m = i;
break;
}
}
int ans = solve1(n, m);
if(ans < maxs && n * 2 <= (1LL << m))
ans += solve2(n, m);
printf("%d\n", ans < maxs ? ans : -1);
return 0;
}
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in CPP):
|
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n, m; cin >> n >> m;
vector<bool> flag(n);
vector<int> cnt(n);
int ac = 0, wa = 0;
for (int i = 0; i < m; ++i) {
int p; cin >> p;
--p;
string s; cin >> s;
if (flag[p]) continue;
if (s == "WA") ++cnt[p];
else {
wa += cnt[p];
++ac;flag[p] = true;
}
}
cout << ac << " " << wa << endl;
return 0;
}
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in JAVA):
|
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();
Integer Array[] = new Integer[N];
boolean AC[] = new boolean[N];
for(int i=0;i<N;i++){
Array[i] = 0;
AC[i] = false;
}
for (int i=0;i<M;i++){
int p = sc.nextInt();
String s = sc.next();
if (s.equals("WA")){
if (AC[p-1] == false){
Array[p-1] += 1;
}
}else{
AC[p-1] = true;
}
}
int one = 0;
int two = 0;
for (int i=0;i<N;i++){
if (AC[i]){
one += 1;
two += Array[i];
}
}
System.out.print(one);
System.out.print(" ");
System.out.print(two);
}
}
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in CPP):
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long N,M,A,B,Tac,Tp;
string S;
cin >> N >> M;
Tac=Tp=0;
vector<int> seen(N,0);
for (long long i=0;i<M;i++) {
cin >> A >> S;
if (seen.at(A-1)>=0 && S=="WA") {seen.at(A-1)++;}
else if (seen.at(A-1)>=0 && S=="AC") {Tac+=1;Tp+=seen.at(A-1);seen.at(A-1)=-1;}
}
cout << Tac << " " << Tp << endl;
}
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in CPP):
|
#include <iostream>
using namespace std;
int main() {
int n, m, p, ac[1000000] = { 0 }, ac_num = 0, wa_num = 0, wa[1000000] = { 0 };
string s;
cin >> n >> m;
for (int i = 0; i < m; i++) {
cin >> p >> s;
if (ac[p - 1] == 0) {
if (s == "AC") {
ac_num++;
ac[p - 1] = 1;
wa_num += wa[p - 1];
}
else {
wa[p - 1]++;
}
}
}
cout << ac_num << " " << wa_num << endl;
}
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in JAVA):
|
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 wa[] = new int[N+1];
int correct=0,penalties=0;
while (M-- > 0){
int p = sc.nextInt();
String s = sc.next();
if(wa[p]==-1){
continue;
}
if(s.equals("WA")){
wa[p]++;
}
else {
correct++;
penalties += wa[p];
wa[p] = -1;
}
}
System.out.println(correct+" "+penalties);
}
}
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in JAVA):
|
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[][] b = new int[n][3];
for (int i = 0; i < m; i++) {
int p = sc.nextInt();
String s = sc.next();
if (b[p - 1][0] == 0) {
if ("AC".equals(s)) {
b[p - 1][0] = i + 1;
} else {
b[p - 1][1]++;
}
}
}
int ok = 0;
int ng = 0;
for (int i = 0; i < n; i++) {
if (b[i][0] > 0) {
ok++;
ng += b[i][1];
}
}
System.out.println(ok + " " + ng);
}
}
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in PYTHON):
|
input = raw_input
n, m = map(int, input().split(" "))
num_penals = [0 for _ in range(n+1)]
seikai = 0
ayamari = 0
for _ in range(m):
nn, res = input().split(" ")
nn = int(nn)
if num_penals[nn] is not None:
if res == "AC":
seikai += 1
ayamari += num_penals[nn]
num_penals[nn] = None
else:
num_penals[nn] += 1
out = "%d %d" % (seikai, ayamari)
print(out)
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in PYTHON3):
|
N,M=map(int,input().split())
PS=[input().split() for i in range(M)]
wa,ac=[0]*N,[0]*N
for p,s in PS:
p=int(p)-1
if s=='WA' and ac[p]==0:
wa[p]+=1
elif s=='AC':
ac[p]=1
for i in range(N):
if ac[i]==0:
wa[i]=0
print(sum(ac),sum(wa))
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in JAVA):
|
import java.util.Scanner;
public class Main {
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int m = in.nextInt();
int p;
int correctAns = 0;
int penalties = 0;
String s;
int[] Problems = new int[n];
//initialize array
for(int i = 0; i < n; i++) {
Problems[i] = 0;
}
for(int i = 0; i < m; i++) {
p = in.nextInt();
s = in.nextLine();
//String wa = new String("WA");
if(s.equals(" WA")) {
if(Problems[p-1] != -1) {
Problems[p-1]++;
}
} else if (Problems[p-1] != -1) {
correctAns++;
penalties += Problems[p-1];
//if visited set to -1
Problems[p-1] = -1;
}
}
System.out.println(correctAns + " " + penalties);
}
}
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in CPP):
|
#include <bits/stdc++.h>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n,m;
cin>>n>>m;
int ac=0,wa=0;
int p;
string a;
int list[100001][2]={};
while(m)
{
cin>>p>>a;
if(a=="AC"&&list[p][0]==0)
{
list[p][0]=1;
ac++;
wa+=list[p][1];
}
else
{
list[p][1]++;
}
m--;
}
cout<<ac<<" "<<wa;
return 0;
}
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in JAVA):
|
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = sc.nextInt();
int[] ac = new int[n];
int[] wa = new int[n];
for(int i = 0; i < m; i++) {
int p = sc.nextInt() - 1;
String s = sc.next();
if(s.equals("AC")) {
ac[p] = 1;
} else {
if(ac[p] == 0) wa[p]++;
}
}
int ans1 = 0;
int ans2 = 0;
for(int i = 0; i < n; i++) {
if(ac[i] == 1) {
ans1++;
ans2 += wa[i];
}
}
System.out.println(ans1 + " " + ans2);
}
}
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in CPP):
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int N,M;
cin >>N >> M;
vector<bool> K(N,false);
vector<int> A(N,0);
int ac =0;
int wa = 0;
for(int i=0;i<M;i++){
int P;
string S;
cin >> P >>S;
if(K[P] == false && S =="WA") A[P]++;
else if(K[P] == false && S == "AC"){
ac++;
wa += A[P];
K[P] = true;
}
}
printf("%d %d",ac,wa);
}
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in PYTHON3):
|
n, m = map(int, input().split())
ans = [0, 0]
ac = [0 for _ in range(n)]
for _ in range(m):
p, s = input().split()
p = int(p) - 1
if ac[p] == -1:
continue
elif s == "AC":
ans[0] += 1
ans[1] += ac[p]
ac[p] = -1
else:
ac[p] += 1
print(*ans)
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in CPP):
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int N, M, p, A=0, W=0;
string S;
cin >> N >> M;
vector<int> cA(N);
vector<int> cW(N);
for(int i=0; i<M; i++){
cin >> p >> S;
if(S=="AC" && cA.at(p-1)==0){
A++;
W += cW.at(p-1);
cA.at(p-1) = 1;
}else if(cA.at(p-1)==0)
cW.at(p-1)++;
}
cout << A << " " << W << endl;
}
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in JAVA):
|
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt(), m = sc.nextInt();
int[] ac = new int[n], wa = new int[n];
int acc = 0, wac = 0;
for (int i = 0; i < m; i++){
int p = sc.nextInt() - 1;
String s = sc.next();
if (ac[p] == 1) continue;
if (s.equals("AC")) {
ac[p] = 1;
} else {
wa[p]++;
}
}
for (int i = 0; i < n; i++) {
acc += ac[i];
if (ac[i] == 1) wac += wa[i];
}
System.out.println("" + acc + " " + wac);
}
}
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in JAVA):
|
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int M = sc.nextInt();
int[] p = new int[M];
String[] S = new String[M];
for(int i = 0;i < M;i++){
p[i] = sc.nextInt();
S[i] = sc.next();
}
sc.close();
int[] WA = new int[105000];
boolean[] AC = new boolean[105000];
int WAnum = 0;
int ACnum = 0;
for(int i = 0;i < N;i++){
WA[i+1] = 0;
AC[i+1] = false;
}
for(int i = 0;i < M;i++){
if(AC[p[i]])continue;
if(S[i].equals("AC")){
AC[p[i]] = true;
ACnum++;
WAnum += WA[p[i]];
}else if(S[i].equals("WA")){
WA[p[i]]++;
}
}
System.out.println(ACnum + " " + WAnum);
}
}
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in JAVA):
|
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[] was = new int[n];
boolean[] accepted = new boolean[n];
int ac = 0;
int wa = 0;
for (int i = 0; i < m; i++) {
int x = sc.nextInt() - 1;
String s = sc.nextLine();
if (accepted[x]) continue;
if (s.contains("AC")) {
accepted[x] = true;
wa += was[x];
ac++;
} else {
was[x]++;
}
}
System.out.println(ac + " " + wa);
}
}
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in PYTHON3):
|
n,m=map(int,input().split())
cnt=0
l=[0 for i in range(n)]
for i in range(m):
p,s=input().split()
p=int(p)
p-=1
if l[p]!=-1:
if s=='AC':
cnt+=l[p]
l[p]=-1
else:
l[p]+=1
ac_cnt=l.count(-1)
print(ac_cnt,cnt)
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in JAVA):
|
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Main main = new Main();
main.run();
}
public void run() {
Scanner sc = new Scanner(System.in);
int n=sc.nextInt();
int m=sc.nextInt();
boolean ac[] = new boolean[n+1];
long wa[] = new long[n+1];
for(int i=0; i<m; i++) {
int p = sc.nextInt();
String s = sc.next();
if(ac[p]) continue;
if(s.equals("AC")) {
ac[p]=true;
} else {
wa[p]++;
}
}
long sum1=0;
long sum2=0;
for(int i=1; i<=n; i++) {
if(ac[i]) {
sum1++;
sum2 += wa[i];
}
}
System.out.println(sum1 + " " + sum2);
sc.close();
}
}
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in JAVA):
|
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = sc.nextInt();
int ac = 0;
long wa = 0l;
long[] problems = new long[n+2];
boolean[] end = new boolean[n+2];
for(int i = 0;i<m;i++){
int p = sc.nextInt();
String s = sc.next();
if(end[p]){
continue;
}else if(s.equals("AC")){
end[p] = true;
ac++;
}else{
problems[p]++;
}
}
for(int i = 1;i<n+1;i++){
if(end[i]){
wa += problems[i];
}
}
System.out.println(ac);
System.out.println(wa);
}
}
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in PYTHON3):
|
n,m = map(int,input().split())
acwa=[[] for _ in range(n)]
for i in range(m):
pp,ss = input().split()
acwa[int(pp)-1].append(ss)
n_ac=0
n_wa=0
for i in range(n):
if "AC" in acwa[i]:
n_ac +=1
n_wa +=acwa[i].index("AC")
print(n_ac,n_wa)
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in CPP):
|
#include<bits/stdc++.h>
using namespace std;
int main()
{
char a[10];
int c[100005]={0},d[100005]={0};
int m,n,b,x=0,y=0,z=0,i;
scanf("%d%d",&m,&n);
for(i=1;i<=n;i++)
{
scanf("%d%s",&b,a);
if(d[b]==-1)
continue;
if(a[0]=='A')
{
d[b]=-1;
x++;
z+=c[b];
//printf("%d ",z);
}
if(a[0]=='W')
{
c[b]++;
}
}
if(n==0)
printf("0 0");
else
printf("%d %d",x,z);
}
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in PYTHON3):
|
n,m=map(int,input().split())
ac=[0]*n
wa=[0]*n
for i in range(m):
p,s=map(str,input().split())
p=int(p)-1
if ac[p]==0:
if s=='AC':
ac[p]=1
else:
wa[p]+=1
w=0
for i in range (n):
w+=ac[i]*wa[i]
print(sum(ac),w)
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in PYTHON3):
|
N,M = map(int,input().split())
AC = 0
WA = 0
was = [0]*(N+1)
acs = [0]*(N+1)
for i in range(M):
p,s = input().split()
p = int(p)
if s == "AC":
if acs[p] == 0:
AC += 1
WA += was[p]
acs[p] = 1
else:
was[p] += 1
print(AC,WA)
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in CPP):
|
#include<bits/stdc++.h>
using namespace std;
int memo[100001];
int main(){
int n,m; cin>>n>>m;
int WA=0,AC=0;
for(int i=0;i<m;i++){
int p; cin>>p;
string s; cin>>s;
if(s=="WA"){
if(memo[p]!=-1)memo[p]++;
else continue;
}else{
if(memo[p]>=0){
AC++;
WA+=memo[p];
memo[p]=-1;
}
}
}
cout<<AC<<" "<<WA<<endl;
return 0;
}
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in PYTHON3):
|
n,m=map(int,input().split())
L=[0]*n
W=[0]*n
cnt=0
for i in range(m):
p,s=input().split()
p=int(p)
if L[p-1]==0:
if s=="AC":
L[p-1]=1
else:
W[p-1]+=1
for i in range(n):
if L[i]==1:
cnt += W[i]
print(sum(L),cnt)
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in CPP):
|
#include <bits/stdc++.h>
using namespace std;
int n,m,pen[100010];
bool solved[100010];
int main() {
cin>>n>>m;
int penalty=0, correct=0;
for (int i=1; i<=m; ++i) {
int p; string s; cin>>p>>s;
if (s=="AC") {
if (!solved[p]) {
correct++;
solved[p]=true;
penalty+=pen[p];
}
}
else {
pen[p]++;
}
}
cout<<correct<<" "<<penalty<<endl;
}
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in JAVA):
|
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.List;
import java.util.Queue;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
execute3();
}
private static void execute3() {
try (Scanner sc = new Scanner(System.in)) {
int M = sc.nextInt();
int N = sc.nextInt();
int[] tryN = new int[M];
boolean[] ac = new boolean[M];
for(int j=0;j<M;j++) {
tryN[j]=0;
ac[j]=false;
}
for(int i=0;i<N;i++) {
int p = sc.nextInt()-1;
String r = sc.next();
if(r.equals("AC")) {
if(!ac[p]) {
ac[p]=true;
}
} else {
if(!ac[p]) {
tryN[p]++;
}
}
}
int ansAc=0;
int wa=0;
for(int i=0;i<M;i++) {
if(ac[i]) {
ansAc++;
wa+=tryN[i];
}
}
System.out.println(ansAc+" "+wa);
}
}
}
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in JAVA):
|
import java.util.*;
class Main{
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = sc.nextInt();
int[] accept = new int[n+1];
int[] fail = new int[n+1];
int ACsum = 0;
int WAsum = 0;
for(int i =0;i<m;i++){
Integer p = sc.nextInt();
String acwa = sc.next();
if(accept[p]==1)continue;
if(acwa.equals("AC")){
accept[p] = 1;
ACsum++;
WAsum+=fail[p];
}
else{
fail[p]++;
}
}
System.out.println(ACsum + " " + WAsum);
}
}
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in CPP):
|
//HovalHaq!
#include <bits/stdc++.h>
using namespace std;
const int maxN = 1 << 20;
int A[maxN];
int main() {
int n, m, c = 0, s = 0; cin >> n >> m;
for(int i = 0; i < m; i++) {
int x; cin >> x;
string v; cin >> v;
if(A[x] == -2) continue;
if(v == "AC") c++, s += A[x], A[x] = -2;
else A[x]++;
}
cout << c << " " << s;
}
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in JAVA):
|
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
boolean ju[] = new boolean[100001];
int pe[] = new int[100001];
int wa=0;
int ac=0;
for(int i=0; i<b; i++){
int n = sc.nextInt();
String res = sc.next();
if(res.equals("WA") && ju[n-1] != true){
pe[n-1]++;
}
if(res.equals("AC")){
ju[n-1] = true;
}
}
for(int i=0; i<a ; i++){
if(ju[i]){
ac++;
wa += pe[i];
}
}
System.out.println(""+ac+" "+wa);
}
}
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in PYTHON3):
|
N,M=map(int,input().split())
import sys
S=sys.stdin.readlines()
A=set()
WA=[0]*N
B=[0]*N
for i in range(M):
p,t=S[i].split()
p=int(p)
if p not in A and t=="AC":
A.add(p)
B[p-1]+=WA[p-1]
elif p not in A and t=="WA":
WA[p-1]+=1
print(len(A))
print(sum(B))
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in CPP):
|
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int wa=0,ac=0,n,m,a,b,p[1000005];
bool ha[1000005];
string s;
int main(){
scanf("%d%d",&n,&m);
for(int i=0;i<m;i++){
scanf("%d",&a);
cin>>s;
if(s=="AC"&&!ha[a]){
ha[a]=1;
ac++;
wa+=p[a];
}
if(s=="WA"&&!ha[a]){
p[a]++;
}
}
printf("%d %d",ac,wa);
return 0;
}
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in CPP):
|
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,m,i,j,p,ac=0,wa=0;
string s;
cin>>n>>m;
//string s[m];
bool f[n+1];
int sum[n+1];
for(i=1;i<=n;i++){f[i]=0;sum[i]=0;}
for(i=0;i<m;i++){
cin>>p>>s;
if(f[p])continue;
if(s=="AC"){ac++;f[p]=1;wa+=sum[p];}
else sum[p]++;
}
//if(ac==0)wa=0;
cout<<ac<<" "<<wa;
return 0;
}
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in JAVA):
|
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[] cleared = new boolean[n];
int[] penalties = new int[n];
int clearedQuestions = 0;
boolean ac; int q;
for(int i=0; i<m; i++){
q = sc.nextInt()-1;
ac = sc.next().equals("AC");
if(cleared[q]) continue;
if(ac){
cleared[q] = true;
clearedQuestions++;
}else{
penalties[q]++;
}
}
int penalty = 0;
for(int i=0; i<n; i++){
penalty += cleared[i] ? penalties[i] : 0;
}
System.out.println(clearedQuestions+" "+penalty);
}
}
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in PYTHON3):
|
N,M=map(int,input().split())
ac=[0]*N
wa=[0]*N
for i in range(M):
p,s=input().split()
p=int(p)-1
if not ac[p]:
if s>"AC":
wa[p]+=1
else:
ac[p]=1
a=0
w=0
for i in range(N):
if ac[i]:
a+=1
w+=wa[i]
print(a,w)
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in PYTHON3):
|
n,m=map(int,input().split())
ac_count=[0]*n
wa_count=[0]*n
ac=0
wa=0
for i in range(m):
p,s=input().split()
p=int(p)-1
if s=="AC" and ac_count[p]==0:
ac_count[p]=1
ac+=1
wa+=wa_count[p]
elif s[0]=="W":
wa_count[p]+=1
print(ac,wa)
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in CPP):
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n,m,p; cin>>n>>m;
string s;
vector<int> ac(n,0);
vector<int> wa(n,0);
int sumAC=0,sumWA=0;
for(;m--;){
cin>>p>>s;
p--;
if(s=="AC") ac[p]=1;
else if(s=="WA"&&!ac[p]) wa[p]++;
}
for(int i=0;i<n;i++){
sumAC+=ac[i];
if(ac[i]) sumWA+=wa[i];
}
cout<<sumAC<<" "<<sumWA;
}
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in JAVA):
|
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);
}
}
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in CPP):
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n,m,pp,wa=0,ac=0;
string ss;
cin >> n >> m;
vector<long int> p(n+1);
vector<long int> s(n+1);
for (int i = 0; i < m; i++) {
cin >> pp >> ss;
if(s[pp]==0){
if(ss=="WA"){
p[pp]++;
}else{
ac++;
s[pp]=1;
wa+=p[pp];
}
}
}
cout << ac << " " << wa << endl;
}
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in PYTHON3):
|
n,m= map(int,input().split())
r = 0
p = 0
li = [0]*n
for i in range(m):
a,b = input().split()
if li[int(a)-1]==-1:
pass
elif b=='WA':
li[int(a)-1]+=1
elif b=='AC':
r += 1
p += li[int(a)-1]
li[int(a)-1]=-1
print(r,p)
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in CPP):
|
#include<bits/stdc++.h>
using namespace std;
int n,m,s[100003],ton[100003],s1,s2,p[100003];
string t[100003];
int main()
{
scanf("%d%d",&n,&m);
for(int i=1;i<=m;i++)
{
cin>>s[i]>>t[i];
if(t[i]=="AC")
if(ton[s[i]]==0)
s1++,ton[s[i]]=1,s2+=p[s[i]];
if(t[i]=="WA")
if(ton[s[i]]==0)
p[s[i]]++;
}
cout<<s1<<" "<<s2;
return 0;
}
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in PYTHON3):
|
a,b=map(int, input().split())
c=[0]*a
d=[0]*a
e=0
for i in range(b):
p, s=input().split()
p=int(p)-1
if c[p]==0 and s=='AC':
c[p]=1
e+=d[p]
d[p]+=1
print(sum(c),e)
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in PYTHON3):
|
n,m=map(int,input().split())
li=[0]*(n+1)
cn=[0]*(n+1)
ac=wa=0
for _ in range(m):
x,y=input().split()
x=int(x)
if y=="AC":
if li[x]!=1:
li[x]=1
ac+=1
wa+=cn[x]
else:
cn[x]+=1
print(ac,wa)
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in JAVA):
|
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[] isClear = new boolean[N];
for (int i = 0; i < N; i++)
isClear[i] = false;
int[] cntWrong = new int[N];
for (int i = 0; i < N; i++)
cntWrong[i] = 0;
int cntCorrect = 0;
sc.nextLine();
for (int j = 0; j < M; j++) {
int num = sc.nextInt() - 1;
String result = sc.nextLine();
if (!isClear[num]) {
if (result.equals(" AC")) {
isClear[num] = true;
cntCorrect++;
} else {
cntWrong[num]++;
}
}
}
int sumCorrect = 0;
for (int i = 0; i < N; i++) {
if (isClear[i])
sumCorrect += cntWrong[i];
}
System.out.println(cntCorrect + " " + sumCorrect);
sc.close();
}
}
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in PYTHON3):
|
n,m=map(int,input().split())
a=[0]*n
b=[0]*n
ac=0
pe=0
for i in range(m):
p,s=input().split()
if a[int(p)-1]==0:
if s=="AC":
a[int(p)-1]=1
ac+=1
pe+=b[int(p)-1]
else:
b[int(p)-1]+=1
print(ac,pe)
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in JAVA):
|
import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
PrintWriter out = new PrintWriter(System.out);
final int N = Integer.parseInt(sc.next());
final int M = Integer.parseInt(sc.next());
int[] ac = new int[N];
int[] wa = new int[N];
for (int i = 0; i < M; i++) {
int p = Integer.parseInt(sc.next());
String s = sc.next();
p--;
if (ac[p] == 1) {
} else if (s.equals("AC")) {
ac[p]++;
} else {
wa[p]++;
}
}
int asum = 0;
int wsum = 0;
for (int i = 0; i < N; i++) {
asum += ac[i];
if (ac[i] == 1) wsum += wa[i];
}
out.println(asum + " " + wsum);
out.flush();
}
}
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in CPP):
|
# include<iostream>
using namespace std;
int a[100005];
int mp[100005];
int main ()
{
int N,M;
cin>>N>>M;
int win_num =0;
int wrong_num=0;
for(int i=0;i<M;i++)
{
int id;
cin>>id;
string s;
cin>>s;
if(s=="WA")
{
a[id]++;
}
else if(mp[id]==0)
{
mp[id]=1;
win_num++;
wrong_num +=a[id];
}
}
cout<<win_num<<" "<<wrong_num<<endl;
}
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in JAVA):
|
import java.util.Scanner;
import java.util.TreeMap;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = sc.nextInt();
int ac = 0;
int[] wa = new int[n];
int wawa = 0;
TreeMap<Integer, String> ans = new TreeMap<>();
for (int i = 0; i < m; i++) {
int p = sc.nextInt();
String s = sc.next();
if (ans.containsKey(p)) {
if (ans.get(p).equals("AC")) {
continue;
} else {
ans.put(p, s);
if (s.equals("AC")) {
ac++;
continue;
} else if(s.equals("WA")){
wa[p-1]++;
continue;
}
}
}
ans.put(p, s);
if (s.equals("AC")) {
ac++;
} else if(s.equals("WA")){
wa[p-1]++;
}
}
System.out.println(ac);
for(Integer key : ans.keySet()) {
if(ans.get(key).equals("AC")) {
wawa = wawa + wa[key-1];
}
}
System.out.println(wawa);
}
}
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in CPP):
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int N, M;
cin >> N >> M;
vector<int> V(N);
int ac = 0, pe = 0;
for (int i = 0; i < M; i++) {
int p;
string S;
cin >> p >> S;
if (V.at(--p) == -1) continue;
if (S == "WA") V.at(p)++;
else ac++, pe += V.at(p), V.at(p) = -1;
}
cout << ac << " " << pe << "\n";
}
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in JAVA):
|
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[] = new int[n];
int sum = 0;
int counter = 0;
for(int i = 0; i < m; i++) {
int p = sc.nextInt()-1;
String s = sc.next();
if(c[p] != -1) {
if(s.equals("WA")) {
c[p]++;
}else {
sum += c[p];
counter++;
c[p] = -1;
}
}
}
System.out.println(counter + " " + sum);
return;
}
}
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in CPP):
|
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int num[N];
bool vis[N];
char s[5];
int main() {
int n,m,id,a=0,b=0;
scanf("%d%d",&n,&m);
for(int i=0;i<m;i++) {
scanf("%d%s",&id,s);
if(vis[id]) continue;
if(s[0]=='A') a++,b+=num[id],vis[id]=true;
else num[id]++;
}
printf("%d %d\n",a,b);
return 0;
}
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in JAVA):
|
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int M = sc.nextInt();
int[] AC = new int[N];
int[] penalty = new int[N];
int ACCnt = 0;
int penaltyCnt = 0;
for(int i = 0; i < M; i++){
int p = sc.nextInt() - 1;
String s = sc.next();
if(AC[p] == 1) continue;
if(s.equals("AC")){
AC[p] = 1;
ACCnt++;
penaltyCnt += penalty[p];
}else{
penalty[p]++;
}
}
System.out.println(ACCnt + " " + penaltyCnt);
}
}
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in PYTHON3):
|
N, M = map(int, input().split())
P = [0] * N
wa = 0
for _ in range(M):
p, s = input().split()
index = int(p)-1
if s == 'WA' and P[index] != -1:
P[index] += 1
elif P[index] > -1:
wa += P[index]
P[index] = -1
print(P.count(-1), wa)
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in PYTHON3):
|
N,M = map(int,input().split())
a = 0
w = 0
lis = [[] for _ in range(N)]
for i in range(M):
p,s = map(str,input().split())
p = int(p)
lis[p - 1].append(s)
for j in range(N):
if lis[j].count("AC") > 0:
a += 1
w += lis[j].index("AC")
print(a,w)
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in JAVA):
|
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[] wa = new int[n + 1];
boolean[] ac = new boolean[n + 1];
for(int i = 0; i < n + 1; i++) {
wa[i] = 0;
ac[i] = true;
}
for(int i = 0; i < m; i++) {
int p = sc.nextInt();
String s = sc.next();
if(s.equals("AC")) {
ac[p] = false;
} else if(ac[p]) {
wa[p]++;
}
}
int ansac = 0;
int answa = 0;
for(int i = 1; i < n + 1; i++) {
if(ac[i] == false) {
ansac++;
answa += wa[i];
}
}
System.out.println(ansac + " " + answa);
}
}
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in JAVA):
|
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 ju[] = new boolean[100001];
int pe[] = new int[100001];
for(int i = 0 ; i < m ; ++i){
int no = sc.nextInt();
String res = sc.next();
no--;
if(res.equals("WA") && ju[no] != true){
pe[no]++;
}
if(res.equals("AC")){
ju[no] = true;
}
}
int ac = 0;
int wa = 0;
for(int i = 0 ; i < n ; ++i){
if(ju[i]){
ac++;
wa += pe[i];
}
}
System.out.println(ac + " " + wa);
}
}
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in CPP):
|
#include<bits/stdc++.h>
using namespace std;
bool pan[1000010];
int f[1000010];
char a[3];
int n,m,ai,aj,kl;
int main() {
scanf("%d%d",&n,&m);
for(int i=1;i<=m;i++)
{
scanf("%d %s",&kl,a);
if(a[0]=='W')
if(!pan[kl])
++f[kl];
if(a[0]=='A')
if(!pan[kl])
pan[kl]=1;
}
for(int i=1;i<=n;i++)
if(pan[i])
{
++ai;
aj+=f[i];
}
printf("%d %d",ai,aj);
}
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in JAVA):
|
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[] problem = new int[n+1];
int[] wa = new int[n+1];
for (int i = 0; i < m; i++) {
int p = sc.nextInt();
String s = sc.next();
if ("AC".equals(s)) {
problem[p] = 1;
} else {
if (problem[p] != 1) {
wa[p]++;
}
}
}
int sumWA = 0;
int sumAC = 0;
for (int i = 0; i < n+1; i++) {
if (problem[i] == 1) {
sumAC++;
sumWA += wa[i];
}
}
System.out.println(sumAC +" "+sumWA);
}
}
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in JAVA):
|
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[] clear = new boolean[N];
int[] wa = new int[N];
long waCnt = 0;
int ac = 0;
for (int i=0; i<M; i++) {
int p = sc.nextInt() - 1;
String S = sc.next();
if (!clear[p]) {
if (S.equals("AC")) {
clear[p] = true;
ac++;
waCnt += wa[p];
}
else {
wa[p]++;
}
}
}
System.out.println(ac + " " + waCnt);
}
}
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in PYTHON3):
|
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)
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in JAVA):
|
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 [] list = new int [N+1];
int [] list2 = new int [N+1];
for(int i=0;i<N+1;i++){
list[i]=0;
list2[i]=0;
}
for(int i=0;i<M;i++){
int p = sc.nextInt();
String S = sc.next();
if(S.charAt(0)=='A'&&list[p]==0)list[p]=1;
else if(S.charAt(0)=='W'&&list[p]==0) list2[p]++;
}
int A_sum =0, W_sum=0;
for(int i=1;i<N+1;i++){
if(list[i]==1){
W_sum+=list2[i];
A_sum++;
}
}
System.out.println(A_sum+" "+W_sum);
}
}
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in PYTHON):
|
N, M = map(int, raw_input().split())
A = [False]*N
C = [0]*N
for i in range(M):
p, S = raw_input().split()
p = int(p)-1
if S=="AC":
A[p] = True
else:
if not A[p]:
C[p] += 1
print sum(A), sum(C[i] for i in range(N) if A[i])
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in JAVA):
|
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();
Set<Integer> ACset = new HashSet<>();
//Set<Integer> WAset = new HashSet<>();
Map<Integer, Integer> waMap = new HashMap<>();
int ac = 0;
int wa = 0;
int waCount = 0;
for(int i = 0; i < M; i++) {
int num = sc.nextInt();
String value = sc.next();
if(value.equals("AC")) {
if(!ACset.contains(num)) {
ac++;
ACset.add(num);
if(waMap.containsKey(num)) {
wa += waMap.get(num);
}
}
}else {
if(waMap.containsKey(num)) {
waCount = waMap.get(num);
waMap.put(num, ++waCount);
}else {
waCount = 1;
waMap.put(num, waCount);
}
}
}
System.out.println(ac + " " + wa);
sc.close();
}
}
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in JAVA):
|
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int N = scanner.nextInt();
int M = scanner.nextInt();
int[] numWA = new int[N];
boolean[] AC = new boolean[N];
for (int i = 0; i < M; i++) {
int p = scanner.nextInt() - 1;
boolean s = scanner.next().equals("AC");
if (s) {
AC[p] = true;
} else if (!AC[p]) {
numWA[p]++;
}
}
int numAC = 0;
int penalty = 0;
for (int i = 0; i < N; i++) if (AC[i]) numAC++;
for (int i = 0; i < N; i++) if (AC[i]) penalty += numWA[i];
System.out.printf("%d %d\n", numAC, penalty);
}
}
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in PYTHON3):
|
N,M=map(int,input().split())
fin=set()
AC=0
WA=0
WAL=[0]*N
for i in range(M):
p,s=input().split()
p=int(p)
if not p in fin:
if s=="AC":
AC+=1
fin.add(p)
if s=="WA":
WAL[p-1]+=1
for k in fin:
WA+=WAL[k-1]
print(AC,WA)
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in CPP):
|
#include <bits/stdc++.h>
using namespace std;
int main(){
int n,m,i,p,pena=0,seikai=0;
string s;
cin>>n>>m;
int wa[n],ac[n];
for(i=0;i<n;i++){
wa[i]=0;
ac[i]=0;
}
for(i=0;i<m;i++){
cin>>p>>s;
if(s=="WA"){
wa[p-1]++;
}else{
if(ac[p-1]==0){
pena+=wa[p-1];
ac[p-1]=1;
seikai++;
}
}
}
cout<<seikai<<" "<<pena;
}
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in JAVA):
|
import java.util.Arrays;
import java.util.Scanner;
public class Main{
public static void main(String[] args){
// ๆบๅ
int ac = 0;
int pena = 0;
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[] submit = new int[n+1];
int[] wa = new int[n+1];
Arrays.fill(submit, 0);
Arrays.fill(wa, 0);
for(int i=0; i<m; ++i) {
p[i] = sc.nextInt();
s[i] = sc.next();
}
for(int i=0; i<m; ++i) {
if(submit[p[i]] == 0 && s[i].equals("WA")) {
++wa[p[i]];
}
if(submit[p[i]] == 0 && s[i].equals("AC")) {
submit[p[i]] = 1;
++ac;
pena += wa[p[i]];
}
}
System.out.println(ac +" "+pena);
}
}
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in JAVA):
|
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[100010];
int[] wacnt = new int[100010];
int ans =0;
int wa =0;
for(int i=0;i<M;i++)
{
if(s[i].equals("WA"))
{
if(!ac[p[i]])
{
wacnt[p[i]]++;
}
}
else if(s[i].equals("AC"))
{
if(!ac[p[i]])
{
ans++;
wa+= wacnt[p[i]];
ac[p[i]]=true;
}
}
}
System.out.println(ans+ " " + wa);
}
}
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in PYTHON3):
|
n,m=map(int,input().split())
j=[0]*n
c=[0]*n
pe=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
pe+=c[p]
elif s[0]=="W":c[p]+=1
print(ac,pe)
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in CPP):
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n,k,m,i,cur;
string s;
cin >> n >> m;
vector<int> ans(n);
int res1=0,res2=0;
for(i=0; i<m; i++){
cin >> cur >> s;
cur--;
if(ans[cur]<100000){
if(s=="AC"){
res2+=ans[cur];
ans[cur]+=100000;
res1++;
}else{
ans[cur]+=1;
}
}
}
printf("%d %d\n",res1,res2);
return 0;
}
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in CPP):
|
#include <bits/stdc++.h>
#define N 110000
using namespace std;
int a[N],i,j,n,m,k,l,ans,sum;
bool t[N];
int main()
{
scanf("%d%d",&n,&m);
for (i=1;i<=m;i++)
{
int x;char c,s;
scanf("%d %c%c\n",&x,&c,&s);
if (c=='A') t[x]=1;else
{
if (!t[x]) a[x]++;
}
}
for (i=1;i<=n;i++)
if (t[i]) ans++,sum+=a[i];
printf("%d %d",ans,sum);
}
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in PYTHON3):
|
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([[0,wa[x]][ac[x]] for x in range(N)]),sep=" ")
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in CPP):
|
#include <bits/stdc++.h>
using namespace std;
int cnt[100005];
string s;
int main (){
int n,m;scanf ("%d%d",&n,&m);
int ac=0,wa=0;
for (int i=1,id;i<=m;i++){
cin>>id>>s;
if (cnt[id]==-1) continue;
if (s=="AC") ac++,wa+=cnt[id],cnt[id]=-1;
else cnt[id]++;
}
printf ("%d %d",ac,wa);
return 0;
}
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in CPP):
|
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
using P = pair<int,int>;
int main(){
int n,m,ac=0,wa=0,w;
string s;
cin >> n >> m;
vector<int> a(n),b(n);
rep(i,m){
cin >> w >> s;
if(a[w]==0) {
if(s=="AC"){
wa+=b[w];
a[w]=1;
ac++;
}else b[w]++;
}
}
cout << ac <<" "<<wa<<endl;
}
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in JAVA):
|
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[] ans = new boolean[n];
int p;
String s;
int countAC = 0;
int countWA = 0;
int[] cw = new int[n];
for (int i=0; i<m; i++) {
p = sc.nextInt() - 1;
s = sc.next();
if (s.equals("AC")) {
if (ans[p] == false) {
countAC++;
ans[p] = true;
countWA += cw[p];
}
} else {
cw[p]++;
}
}
System.out.print(countAC + " " + countWA);
}
}
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in PYTHON3):
|
n,m=map(int,input().split())
ac=[0]*(n+1)
wa=[0]*(n+1)
for _ in range(m):
i,j=input().split()
i=int(i)
if j=="AC":
ac[i]=1
elif ac[i]==0 and j=="WA":
wa[i]+=1
print(sum(ac),sum(wa[i] for i in range(n+1) if ac[i]==1))
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in PYTHON):
|
from collections import defaultdict
n, m = map(int, raw_input().split())
aced = set()
d = defaultdict(int)
pen = 0
for i in xrange(m):
p, s = raw_input().split()
p = int(p)
s = s.strip()
if p in aced:
continue
if s == 'WA':
d[p] += 1
elif s == 'AC':
aced.add(p)
pen += d[p]
else:
assert False
print len(aced), pen
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in PYTHON3):
|
n,m=map(int,input().split())
ans=[0]*n
pen=[0]*n
res_pen=0
for i in range(m):
p,s=list(input().split())
if ans[int(p)-1]!=1:
if s=="AC":
ans[int(p)-1]=1
res_pen+=pen[int(p)-1]
else:
pen[int(p)-1]+=1
print(str(sum(ans))+" "+str(res_pen))
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in JAVA):
|
import java.util.Scanner;
//
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
//โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
int n=sc.nextInt();
int m=sc.nextInt();
int[] ACs =new int[n+1];
int[] WAs =new int[n+1];
for (int i=0;i<n+1;i++) {
ACs[i]=0;
WAs[i]=0;
}
for (int i=1;i<=m;i++) {
int p=sc.nextInt();
String s=sc.next();
if (s.equals("AC")&&ACs[p]==0) {
ACs[p] ++;
} else if (s.equals("WA")&&ACs[p]==0){
WAs[p] ++;
}
}
int sumAC =0;
int sumWA =0;
for (int i=1;i<=n;i++) {
sumAC += ACs[i];
if (ACs[i]==1){
sumWA += WAs[i];
}
}
System.out.println(sumAC);
System.out.println(sumWA);
//โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
}
//----------------------------------------
//ใกใฝใใ็ฝฎใๅ ด
//----------------------------------------
}
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in JAVA):
|
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n=sc.nextInt();
int m=sc.nextInt();
int ac=0;
int wa=0;
int[][] p = new int[n][2];
for(int i=0;i<m;i++) {
int k = sc.nextInt()-1;
String t = sc.next();
if(p[k][0]==0&&t.equals("AC")) {
p[k][0]++;
}
if(p[k][0]==0&&t.equals("WA")) {
p[k][1]++;
}
}
for(int i=0;i<n;i++) {
if(p[i][0]==1) {
ac++;
wa+=p[i][1];
}
}
System.out.println(ac+" "+wa);
sc.close();
}
}
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in PYTHON3):
|
N,M=map(int,input().split())
c=[0]*(N+1)
w=[0]*(N+1)
AC=0
WA=0
for i in range(M):
p,s=input().split()
p=int(p)
if(c[p]==0 and s=="AC"):
c[p]+=1
AC+=1
WA+=w[p]
elif(c[p]==0 and s=="WA"):
w[p]+=1
print(AC,WA)
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in CPP):
|
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
int n,m;
cin >> n >> m;
vector<int> cnt(n),isac(n);
ll ac=0,wa=0;
for(int i = 0;i<m;i++)
{
int p;
string s;
cin >> p >> s;
p--;
if(isac[p])continue;
else
{
if(s=="AC")
{
ac++;
wa += cnt[p];
isac[p]=1;
}
else
{
cnt[p]++;
}
}
}
cout << ac << ' '<< wa << endl;
}
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in CPP):
|
#include<bits/stdc++.h>
using namespace std;
int i,j,n,a,m,c1,c2,wa[105000];
bool ac[105000];
string s;
// map<long long,string> r;
int main(){
for(cin>>n>>m;i<n;i++){
ac[i]=false;
}
while(m--){
int p;
cin>>p>>s;
if(ac[p])continue;
if(s=="AC"){
ac[p]=true;
c1++;
c2+=wa[p];
}else{
wa[p]++;
}
}
cout<<c1<<" "<<c2;
}
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in CPP):
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int N, M;
cin >> N >> M;
vector<int> V(N + 1);
int P;
string S;
int ac = 0, wa = 0;
while (cin >> P >> S) {
if (S == "AC") {
if (V.at(P) != -1) ac++, wa += V.at(P), V.at(P) = -1;
else continue;
} else {
if (V.at(P) != -1) V.at(P)++;
else continue;
}
}
cout << ac << " " << wa << "\n";
}
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in CPP):
|
#include "bits/stdc++.h"
using namespace std ;
int h(string x){return x=="AC";}
int main()
{
int n , m ;
cin >> n >> m ;
int sol = 0 , pen = 0 ;
map<int , int > mp ;
for(int i = 0 ; i < m ; i++)
{
string res ;
int pro ;
cin >> pro >> res ;
if(mp[pro]==int(1e8)) continue ;
if(h(res)){ sol++; pen += mp[pro] ;mp[pro] = 1e8 ;}
else mp[pro] += 1 ;
}
cout << sol << " " << pen << '\n' ;
}
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in CPP):
|
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int main(){
int n,m; cin>>n>>m;
int ans1=0,ans2=0;
vector<bool> ac(n);
vector<int> cnt(n);
rep(i,m){
int p;
string s; cin>>p>>s; p--;
if(s=="AC"){
if(!ac[p]) ans1++, ans2+=cnt[p], ac[p]=true;
}
else cnt[p]++;
}
cout<<ans1<<' '<<ans2<<'\n';
return 0;
}
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in PYTHON3):
|
n,m=map(int,input().split())
l=[0]*n
s=set([])
for i in range(m):
p,q=map(str,input().split())
if int(p) in s:
continue
elif q=='AC':
s.add(int(p))
else:
l[(int(p))-1]+=1
s_l=list(s)
an=len(s_l)
c=0
for i in range(an):
c+=l[s_l[i]-1]
print(an,c)
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in PYTHON3):
|
n,m=map(int,input().split())
acf,waf=[0]*n,[0]*n
ac,wa=0,0
for i in range(m):
x,y=input().split()
x=int(x)
if y=='AC':
if acf[x-1]==0:
ac+=1
wa+=waf[x-1]
acf[x-1]+=1
else:
waf[x-1]+=1
print(ac,wa)
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in CPP):
|
#include<iostream>
using namespace std;
int main()
{
int n,m,i,p,t[100000]={0},ac=0,wa=0;
string s;
cin >> n >> m;
for(i=0;i<m;i++){
cin >> p >> s;
if(s=="WA" && t[p]!=-1) t[p]+=1;
else if(t[p]!=-1){
ac++;
wa+=t[p];
t[p]=-1;
}
}
cout << ac << ' ' << wa;
return 0;
}
|
Problem: Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
* N, M, and p_i are integers.
* 1 \leq N \leq 10^5
* 0 \leq M \leq 10^5
* 1 \leq p_i \leq N
* S_i is `AC` or `WA`.
Input
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Examples
Input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
Output
2 2
Input
100000 3
7777 AC
7777 AC
7777 AC
Output
1 0
Input
6 0
Output
0 0
Solution (in PYTHON3):
|
n,m = map(int,input().split())
AC = [0]*n
WA = [0]*n
ans = 0
for i in range(m):
p,s = input().split()
p = int(p)-1
if s == "AC" and AC[p] == 0:
AC[p] = 1
ans += WA[p]
WA[p] += 1
print(sum(AC),ans)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.