submission_id stringlengths 10 10 | problem_id stringlengths 6 6 | language stringclasses 3
values | code stringlengths 1 522k | compiler_output stringlengths 43 10.2k |
|---|---|---|---|---|
s471162688 | p03665 | C++ | #include <iostream>
using namespace std;
typedef long long ll;
ll n, p, k, a;
ll pow(ll x, ll y){
if (y == 0) {
return 1;
} else {
return x * pow(x, y - 1);
}
}
int main(void){
// Your code here!
cin >> n >> p;
for (ll i = 0; i < n; i++) {
cin >> a;
if (a % 2) k++;
}
cout << (k ? pow(2, n - 1) : (p ? 0 : pow(2, n)) << endl;
}
| a.cc: In function 'int main()':
a.cc:21:54: error: invalid operands of types 'long long int' and '<unresolved overloaded function type>' to binary 'operator<<'
21 | cout << (k ? pow(2, n - 1) : (p ? 0 : pow(2, n)) << endl;
| ~~~~~~~~~~~~~~~~~~~~^~~~~~~
a.cc:21:61: error: expected ')' before ';' token
21 | cout << (k ? pow(2, n - 1) : (p ? 0 : pow(2, n)) << endl;
| ~ ^
| )
|
s283099585 | p03665 | C++ | #include <iostream>
#include <algorithm>
using namespace std;
long comb(int n, int r) {
long ans = 1;
for (int i = n; i > n - r; --i) {
ans = ans * i;
}
for (int i = 1; i < r + 1; ++i) {
ans = ans / i;
}
return ans;
}
int main() {
int n, p;
cin >> n >> p;
int num[3];
for (int i = 0;i < n;i++) {
int q;
cin >> q;
num[q % 2] ++;
}
int ans = 0;
ans += pow(2, num[0] + 1);
int anss = ans;
if (p == 0) {
for (int i = 0;i <= num[1];i += 2) {
ans += comb(num[1], i)*anss;
}
}
else {
for (int i = 1;i <= num[1];i += 2) {
ans += comb(num[1], i)*anss;
}
}
cout << ans << endl;
} | a.cc: In function 'int main()':
a.cc:26:16: error: 'pow' was not declared in this scope
26 | ans += pow(2, num[0] + 1);
| ^~~
|
s394167479 | p03665 | C++ | #include <iostream>
#include <vector>
using namespace std;
int N, P;
const int MAX_C = 100;
long long Com[MAX_C][MAX_C];
void calc_com() {
memset(Com, 0, sizeof(Com));
Com[0][0] = 1;
for (int i = 1; i < MAX_C; ++i) {
Com[i][0] = 1;
for (int j = 1; j < MAX_C; ++j) {
Com[i][j] = (Com[i-1][j-1] + Com[i-1][j]);
}
}
}
int main() {
calc_com();
while (cin >> N >> P) {
long long even = 0, odd = 0;
for (int i = 0; i < N; ++i) {
int a; cin >> a;
if (a & 1) ++odd;
else ++even;
}
long long evenbit = 1LL<<even;
long long oddbit = 0;
for (int i = 0; i <= odd; ++i) {
if (i % 2 == P) {
oddbit += Com[odd][i];
}
}
cout << evenbit * oddbit << endl;
}
}
| a.cc: In function 'void calc_com()':
a.cc:11:5: error: 'memset' was not declared in this scope
11 | memset(Com, 0, sizeof(Com));
| ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
2 | #include <vector>
+++ |+#include <cstring>
3 | using namespace std;
|
s900688352 | p03665 | C++ | #include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;
int main(){
int N, P;
cin >>N>>P;
int t;
int even=1,odd=1;
ll ans=0;
for(int i=1;i<=N;i++){
cin >> t;
if(t%2==0){
even++;
}
else{
odd++;
}
}
if(P==1 && odd==1){
cout << ans;
return 0;
}
if(P==0 && odd==2 && even=1){
cout << ans;
return 0;
}
ans=pow(2,even)/2*pow(2,odd)/4;
cout << ans;
} | a.cc: In function 'int main()':
a.cc:34:21: error: lvalue required as left operand of assignment
34 | if(P==0 && odd==2 && even=1){
| ~~~~~~~~~~~~~~~^~~~~~~
|
s023555432 | p03665 | C++ | #include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
using namespace std;
using ll =int long long;
map <int ,int> mpa,mpb;
int main (void){
int N;
int P;
int odd=0;
int even=0;
cin >> N >> P;
int A[N];
int x=0;
int ans=0;
for(int i=0;i<N;i++){
cin >> x;
A[i]=x%2;
if(A[i]==1){
odd++;
}
else{
even++;
}
}
if(odd==0 || even==0){
ans=max({ans,pow(2,odd-1),pow(2,even)});
cout << ans;
return 0;
}
if(P){
ans=2*even*(pow(2,odd-1));
}
else{
if(odd>=2){
ans=pow(2,even)*(1+pow(2,odd-1));
}
cout << ans;
} | a.cc: In function 'int main()':
a.cc:35:12: error: no matching function for call to 'max(<brace-enclosed initializer list>)'
35 | ans=max({ans,pow(2,odd-1),pow(2,even)});
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 1 provided
In file included from /usr/include/c++/14/algorithm:61,
from a.cc:2:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: template argument deduction/substitution failed:
a.cc:35:12: note: deduced conflicting types for parameter '_Tp' ('int' and 'double')
35 | ans=max({ans,pow(2,odd-1),pow(2,even)});
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate expects 2 arguments, 1 provided
a.cc:47:2: error: expected '}' at end of input
47 | }
| ^
a.cc:15:16: note: to match this '{'
15 | int main (void){
| ^
|
s955442126 | p03665 | C++ | #include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
using namespace std;
using ll =int long long;
map <int ,int> mpa,mpb;
int main (void){
int N;
int P;
int odd=0;
int even=0;
cin >> N >> P;
int A[N];
int x=0;
int ans=0;
for(int i=0;i<N;i++){
cin >> x;
A[i]=x%2;
if(A[i]==1){
odd++;
}
else{
even++;
}
}
if(P==0){
ans=2**even*(1+odd*(odd-1)/2);
}
else{
int sum=0;
int i=1;
while(true){
if(odd%i) break;
sum+=odd%i;
i=i+2;
}
ans=2*even*(sum);
}
cout << ans;
} | a.cc: In function 'int main()':
a.cc:35:11: error: invalid type argument of unary '*' (have 'int')
35 | ans=2**even*(1+odd*(odd-1)/2);
| ^~~~~
|
s739923888 | p03665 | C++ | #include <iostream>
using namespace std;
int main(){
int n,p;
cin >> n;
long long int ans = 1 << (n-1);
ans << ans << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:8:14: error: invalid operands of types 'long long int' and '<unresolved overloaded function type>' to binary 'operator<<'
8 | ans << ans << endl;
| ~~~~~~~~~~~^~~~~~~
|
s435774648 | p03665 | C++ | #include <iostream>
using namespace std;
int main(){
int n,p;
cin >> n;
long long int ans = 1 << (n-1)
ans << ans << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:8:3: error: expected ',' or ';' before 'ans'
8 | ans << ans << endl;
| ^~~
|
s061129376 | p03665 | C++ | #include<iostream>
#include<algorithm>
using namespace std;
int main() {
int n, p;
cin >> n >> p;
int a[1000];
for (int i = 0;i < n;i++) {
int b;
cin >> b;
a[i] = b % 2;
}
int num[2];
for (int i = 0;i < n;i++)num[a[i]]++;
if (num[1] == 0) {
cout << pow(2, n - 1) << endl;
}
else {
if (p == 0)cout << pow(2, n) << endl;
else cout << 0 << endl;
}
} | a.cc: In function 'int main()':
a.cc:18:25: error: 'pow' was not declared in this scope
18 | cout << pow(2, n - 1) << endl;
| ^~~
a.cc:21:36: error: 'pow' was not declared in this scope
21 | if (p == 0)cout << pow(2, n) << endl;
| ^~~
|
s005761883 | p03665 | C++ | #include<iostream>
#include<algorithm>
using namespace std;
int main() {
int n, p;
cin >> n >> p;
int a[n];
for (int i = 0;i < n;i++) {
int b;
cin >> b;
a[i] = b % 2;
}
int num[2];
for (int i = 0;i < n;i++)num[a[i]]++;
if (num[1] == 0) {
cout << pow(2, n - 1) << endl;
}
else {
if (p == 0)cout << pow(2, n) << endl;
else cout << 0 << endl;
}
} | a.cc: In function 'int main()':
a.cc:18:25: error: 'pow' was not declared in this scope
18 | cout << pow(2, n - 1) << endl;
| ^~~
a.cc:21:36: error: 'pow' was not declared in this scope
21 | if (p == 0)cout << pow(2, n) << endl;
| ^~~
|
s908597340 | p03665 | C++ | #include<iostream>
#include<algorithm>
using namespace std;
long dp[max][max];
long nCr(int n, int r)
{
if (n == r) return dp[n][r] = 1;
if (r == 0) return dp[n][r] = 1;
if (r == 1) return dp[n][r] = n;
if (dp[n][r]) return dp[n][r];
return dp[n][r] = nCr(n - 1, r) + nCr(n - 1, r - 1);
}
int main() {
int n, p;
cin >> n >> p;
int a[n];
for (int i = 0;i < n;i++) {
int b;
cin >> b;
a[i] = b % 2;
}
int num[2];
for (int i = 0;i < n;i++)num[a[i]]++;
int res = num[0];
for (int i = 2;i < num[1];i += 2) {
res += num[0] * nCr(num[1], i);
}
cout << res << endl;
}
| a.cc:5:17: error: cannot resolve overloaded function 'max' based on conversion to type 'long unsigned int'
5 | long dp[max][max];
| ^
a.cc:5:6: error: size of array 'dp' has non-integral type '<unresolved overloaded function type>'
5 | long dp[max][max];
| ^~
a.cc:5:17: error: cannot resolve overloaded function 'max' based on conversion to type 'long unsigned int'
5 | long dp[max][max];
| ^
a.cc:5:6: error: size of array 'dp' has non-integral type '<unresolved overloaded function type>'
5 | long dp[max][max];
| ^~
|
s902598903 | p03665 | C++ | #include<cmath>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define ROF(i,b,a) for (int i=(b);i>(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,n-1,-1)
typedef long long int int64;
typedef unsigned long long int uint64;
int64 combination(int n,int k){
int64 nck[n+1][n+1];
REP(i,n+1){
REP(j,n+1){
nck[i][j]=0;
}
}
REP(i,n+1){
nck[i][0]=1;
nck[i][i]=1;
}
FOR(i,2,n+1){
FOR(j,1,i){
if(nck[i][j]!=1){
nck[i][j] = nck[i-1][j-1]+nck[i-1][j];
}
}
}
return nck[n][k];
}
int main(){
int N,P;
cin >> N >> P;
int A[N];
int cnt=0;
REP(i,N){
cin >> A[i];
A[i] %= 2;
if(A[i]==0){
cnt++;
}
}
int64 ans=0;
REP(i,N-cnt+1){
if(i%2==P){
cout << N-cnt << "C" << i << " " << combination(N-cnt,i) << "\n";
ans += combination(N-cnt,i);
}
}
ans *= pow(2,cnt);
cout << ans;
} | a.cc: In function 'int main()':
a.cc:36:5: error: 'cin' was not declared in this scope
36 | cin >> N >> P;
| ^~~
a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
1 | #include<cmath>
+++ |+#include <iostream>
2 | using namespace std;
a.cc:49:13: error: 'cout' was not declared in this scope
49 | cout << N-cnt << "C" << i << " " << combination(N-cnt,i) << "\n";
| ^~~~
a.cc:49:13: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:54:5: error: 'cout' was not declared in this scope
54 | cout << ans;
| ^~~~
a.cc:54:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
|
s532041219 | p03665 | C | #include<stdio.h>
#include<math.h>
int main(void) {
int N, P;
scanf("%d %d", &N, &P);
int A[N];
for (int i = 0; i < N; i++) {
scanf("%d", &A[i]);
A[i] = A[i]%2;
}
int cnt0 = 0;
int cnt1 = 0;
for (int i = 0; i < N; i++) {
if (A[i] == 0) cnt0++;
else cnt1++;
}
long long int ans = 0;
if (P == 1) {
if (cnt1 == 0) printf("%d", 0);
else {
ans = pow(2, cnt0 +(cnt1-1) )*1;
printf("%lld", ans);
}
} else {
if (cnt0 == 0) {
ans = pow(2, cnt1-1)*1;
printf("%lld", ans);
} else if (cnt1 == 0){
ans = pow(2, N);
printf("%lld", ans);
}else {
ans = pow(2, cnt0 + (cnt1-1) )*1;
printf("%lld", ans);
}
}
| main.c: In function 'main':
main.c:39:3: error: expected declaration or statement at end of input
39 | }
| ^
|
s482999343 | p03665 | C | #include<stdio.h>
#include<math.h>
int main(void) {
int N, P;
scanf("%d %d", &N, &P);
int A[N];
for (int i = 0; i < N; i++) {
scanf("%d", &A[i]);
A[i] = A[i]%2;
}
int cnt0 = 0;
int cnt1 = 0;
for (int i = 0; i < N; i++) {
if (A[i] == 0) cnt0++;
else cnt1++;
}
long long int ans = 0;
if (P == 1) {
if (cnt1 == 0) printf("%d", 0);
else {
ans = pow(2, cnt0 +(cnt1-1) )*1;
printf("%lld", ans);
}
} else {
if (cnt0 == 0) {
ans = pow(2, cnt1-1)*1;
printf("%lld", ans);
} else if (cnt1 == 0){
ans = pow(2, N);
printf("%lld", ans);
}
else {
ans = pow(2, cnt0 + (cnt1-1) )*1;
printf("%lld", ans);
}
}
| main.c: In function 'main':
main.c:40:3: error: expected declaration or statement at end of input
40 | }
| ^
|
s097766394 | p03665 | C | #include<stdio.h>
#include<math.h>
int main(void) {
int N, P;
scanf("%d %d", &N, &P);
int A[N];
for (int i = 0; i < N; i++) {
scanf("%d", &A[i]);
A[i] = A[i]%2;
}
int cnt0 = 0;
int cnt1 = 0;
for (int i = 0; i < N; i++) {
if (A[i] == 0) cnt0++;
else cnt1++;
}
long long int ans = 0;
if (P == 1) {
if (cnt1 == 0) printf("%d", 0);
else {
ans = pow(2, cnt0 +(cnt1-1) )*1;
printf("%lld", ans);
}
} else {
if (cnt0 == 0) {
ans = pow(2, cnt1-1)*1;
printf("%lld", ans);
} else if (cnt1 == 0){
printf("%lld", pow(2, N));
}
else {
ans = pow(2, cnt0 + (cnt1-1) )*1;
printf("%lld", ans);
}
}
| main.c: In function 'main':
main.c:39:3: error: expected declaration or statement at end of input
39 | }
| ^
|
s364713013 | p03665 | C++ | #define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])
#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl
#define ALL(obj) (obj).begin(),(obj).end()
#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
cin>>head;
CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision; // cpp_int
#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define L list<int>
#define pb(a) push_back(a)
#define mp make_pair
ll Kai(ll t){
int tt=1;
FOR(i,2,t+1)tt*=i;
return tt;
}
int main(){
CIN(n,p);V a(n);VECCIN(a);
V cou(2,0);REP(i,n)(a[i]%2==1?cou[1]:cou[0])++;
if(cou[1]==0){
COUT(p==0?1LL<<n:0);
return 0;
}
COUT(1LL<<(n - 1));
return 0;
}
| a.cc: In function 'void CINT(Head&&, Tail&& ...)':
a.cc:23:5: error: 'cin' was not declared in this scope
23 | cin>>head;
| ^~~
a.cc: At global scope:
a.cc:41:1: error: 'll' does not name a type
41 | ll Kai(ll t){
| ^~
a.cc: In function 'int main()':
a.cc:33:11: error: 'vector' was not declared in this scope
33 | #define V vector<int>
| ^~~~~~
a.cc:48:12: note: in expansion of macro 'V'
48 | CIN(n,p);V a(n);VECCIN(a);
| ^
a.cc:33:18: error: expected primary-expression before 'int'
33 | #define V vector<int>
| ^~~
a.cc:48:12: note: in expansion of macro 'V'
48 | CIN(n,p);V a(n);VECCIN(a);
| ^
a.cc:48:26: error: 'a' was not declared in this scope
48 | CIN(n,p);V a(n);VECCIN(a);
| ^
a.cc:11:37: note: in definition of macro 'VECCIN'
11 | #define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
| ^
a.cc:11:41: error: 'cin' was not declared in this scope
11 | #define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
| ^~~
a.cc:48:19: note: in expansion of macro 'VECCIN'
48 | CIN(n,p);V a(n);VECCIN(a);
| ^~~~~~
a.cc:33:18: error: expected primary-expression before 'int'
33 | #define V vector<int>
| ^~~
a.cc:49:3: note: in expansion of macro 'V'
49 | V cou(2,0);REP(i,n)(a[i]%2==1?cou[1]:cou[0])++;
| ^
a.cc:49:23: error: 'a' was not declared in this scope
49 | V cou(2,0);REP(i,n)(a[i]%2==1?cou[1]:cou[0])++;
| ^
a.cc:49:33: error: 'cou' was not declared in this scope
49 | V cou(2,0);REP(i,n)(a[i]%2==1?cou[1]:cou[0])++;
| ^~~
a.cc:50:6: error: 'cou' was not declared in this scope
50 | if(cou[1]==0){
| ^~~
a.cc:19:17: error: 'cout' was not declared in this scope
19 | #define COUT(x) cout<<(x)<<endl
| ^~~~
a.cc:51:5: note: in expansion of macro 'COUT'
51 | COUT(p==0?1LL<<n:0);
| ^~~~
a.cc:19:28: error: 'endl' was not declared in this scope
19 | #define COUT(x) cout<<(x)<<endl
| ^~~~
a.cc:51:5: note: in expansion of macro 'COUT'
51 | COUT(p==0?1LL<<n:0);
| ^~~~
a.cc:19:17: error: 'cout' was not declared in this scope
19 | #define COUT(x) cout<<(x)<<endl
| ^~~~
a.cc:54:3: note: in expansion of macro 'COUT'
54 | COUT(1LL<<(n - 1));
| ^~~~
a.cc:19:28: error: 'endl' was not declared in this scope
19 | #define COUT(x) cout<<(x)<<endl
| ^~~~
a.cc:54:3: note: in expansion of macro 'COUT'
54 | COUT(1LL<<(n - 1));
| ^~~~
a.cc: In instantiation of 'void CINT(Head&&, Tail&& ...) [with Head = int&; Tail = {int&}]':
a.cc:48:3: required from here
26 | #define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
| ~~~~^~~~~~~~~~~~~
a.cc:24:14: error: 'move' was not declared in this scope
24 | CINT(move(tail)...);
| ~~~~^~~~~~
|
s723432889 | p03665 | C++ | #include <iostream>
using namespace std;
typedef long long ll;
int main() {
static ll C[51][51];
for (int i = 0; i <= 50; i++) {
c[i][0] = c[i][i] = 1;
for (int j = 1; j < i; j++) {
c[i][j] = c[i - 1][j - 1] + c[i - 1][j];
}
}
int n, p;
cin >> n >> p;
int b[2] = {};
for (int i = 0; i < n; i++) {
int a;
cin >> a;
b[a % 2]++;
}
ll m = 0;
for (int i = 0; i <= b[0]; i++) {
for (int j = p; j <= b[1]; j += 2) {
m += C[b[0]][i] * C[b[1]][j];
}
}
cout << m << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:8:17: error: 'c' was not declared in this scope
8 | c[i][0] = c[i][i] = 1;
| ^
|
s452113002 | p03665 | C++ | /**
* Author: houtaru
* Create: 29.01.2018 21:51:20
*/
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
int n, p, cnt;
int main() {
scanf("%d%d", &n, &p);
for (int i = 0; i < n; ++i) {
int x; scanf("%d", &x);
cnt += x % 2;
}
if (cnt > 0) n--;
long long answer = 0;
if (!p) {
answer = 1ll << n);
} else if (cnt) {
answer = 1ll << n;
}
printf("%lld\n", answer);
return 0;
} | a.cc: In function 'int main()':
a.cc:22:26: error: expected ';' before ')' token
22 | answer = 1ll << n);
| ^
| ;
|
s317264151 | p03665 | C++ | #include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
int n, p;
long long int ans;
cin >> n >> p;
int odd = 0;
for(int i = 0; i < n; i++){
int x;
cin >> x;
if(x % 2 == 0) odd++;
}
long long int comb[odd+1];
comb[0] = 1;
for(int i = 1; i <= odd; i++){
comb[i] = comb[i-1] * (n - i + 1) / i;
}
int ans = 0;
for(int i = p; i <= odd; i += 2){
ans += comb[i];
}
ans *= (long long int)pow(2, n - odd);
cout << ans << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:22:13: error: conflicting declaration 'int ans'
22 | int ans = 0;
| ^~~
a.cc:9:23: note: previous declaration as 'long long int ans'
9 | long long int ans;
| ^~~
|
s599294763 | p03665 | C++ | #include <bits/stdc++.h>
using namespace std;
int32_t main(){
int n, p, odd = 0, even = 0, a;
cin >> n >> p;
for(int i=0; i<n; i++){
cin >> a;
if( a % 2 ) odd++;
else even++;
}
long long ans = 1LL << even;
if( odd == 0 && p == 1 ) ans = 0;a
else if( odd != 0 ) ans <<= ( odd-1 );
cout << ans << "\n";
return 0;
}
| a.cc: In function 'int32_t main()':
a.cc:13:39: error: expected ';' before 'else'
13 | if( odd == 0 && p == 1 ) ans = 0;a
| ^
| ;
14 | else if( odd != 0 ) ans <<= ( odd-1 );
| ~~~~
|
s374016565 | p03665 | C++ | // A - Biscuits: https://beta.atcoder.jp/contests/agc017/tasks/agc017_a
// P=0とP=1で場合分け。P=0の場合、奇数個のビスケット袋から偶数個、P-1の場合奇数個のビスケット袋から奇数個とる。
// N>=50なのでintではだめ。
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
const int INF=1<<29;
const double EPS=1e-9;
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};
long long dp[51][51];
long long comb(int n, int r) {
if (dp[n][r] != -1) return dp[n][r];
if (r == 0) return dp[n][r] = 1;
if (n == r) return dp[n][r] = 1;
return dp[n][r] = comb(n - 1, r - 1) + comb(n - 1, r);
}
int main() {
for (int i = 0; i < 51; i++) {
for (int j = 0; j < 51; j++) {
dp[i][j] = -1;
}
}
int N, P;
cin >> N >> P;
vector<int> A(N);
int sum = 0;
for (int i = 0; i < N; i++) {
cin >> A[i];
A[i] %= 2;
sum += A[i];
}
int rest = N - sum;
if (P == 0) {
long long ret = 0;
for(int i = 0; i <= sum; i+=2) {
ret += comb(sum, i) * (1LL << rest);
}
} else {
long long ret = 0;
for(int i = 1; i <= sum; i+=2) {
ret += comb(sum, i) * (1LL << rest);
}
}
cout << ret << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:81:13: error: 'ret' was not declared in this scope; did you mean 'rest'?
81 | cout << ret << endl;
| ^~~
| rest
|
s403811006 | p03665 | C++ | #include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <climits>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define INF INT_MAX/3
#define REP(i,n) for(int i=0;i<n;i++)
int main(){
ll N,P;
vector<ll> arr;
cin>>N>>P;
REP(i,N){
ll a;
cin>>a;
arr.push_back(a);
}
ll i = 0;
while(i < N){
if(arr[i++] % 2 == 1)break;
}
if(i != N){
cout<<pow(2,N-1)<<endl;
}
else{
cout<<(P == 1 ? 0 : pow(2,N-1))<<endl;
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:34:23: error: 'pow' was not declared in this scope
34 | cout<<pow(2,N-1)<<endl;
| ^~~
a.cc:37:37: error: 'pow' was not declared in this scope
37 | cout<<(P == 1 ? 0 : pow(2,N-1))<<endl;
| ^~~
|
s306082386 | p03665 | C++ | #include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <climits>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define INF INT_MAX/3
#define REP(i,n) for(int i=0;i<n;i++)
int main(){
ll N,P;
vector<ll> arr;
cin>>N>>P;
REP(i,N){
ll a;
cin>>a;
arr.push_back(a);
}
ll i = 0;
while(i < N){
if(arr[i++] % 2 == 1)break;
}
if(i != N){
cout<<pow(2,N-1)<<endl;
}
else{
cout<<(P == 1 ? 0 : pow(2,N-1))<<endl;
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:34:23: error: 'pow' was not declared in this scope
34 | cout<<pow(2,N-1)<<endl;
| ^~~
a.cc:37:37: error: 'pow' was not declared in this scope
37 | cout<<(P == 1 ? 0 : pow(2,N-1))<<endl;
| ^~~
|
s731089041 | p03665 | C++ | #include <cstdin>
int main(){
int a,b
scanf("%d\n%d",&a,&b);
printf("%d\n",a+b)
return 0;
} | a.cc:1:10: fatal error: cstdin: No such file or directory
1 | #include <cstdin>
| ^~~~~~~~
compilation terminated.
|
s180951911 | p03665 | C++ | #include <iostream>
#include <vector>
using namespace std;
typedef unsigned long long u64;
u64 binpow(u64 n, u64 x, u64 mod)
{
u64 tgt = 1;
u64 dig = n;
while (x > 0) {
if (x%2) {
tgt = (tgt * dig) % mod;
}
dig = (dig * dig) % mod;
x /= 2;
}
return tgt;
}
class Comb
{
public:
u64 mod;
vector< u64 > fact;
vector< u64 > factf;
void init(u64 size, u64 imod) {
mod = imod;
fact.resize(size+1);
factf.resize(size+1);
fact[0] = 1;
factf[0] = 1;
for (u64 i = 1; i <= size; ++i) {
fact[i] = fact[i-1]*i%mod;
factf[i] = binpow(fact[i], mod-2, mod);
}
}
u64 comb(u64 n, u64 k) {
if (n<k) return 0;
if (k==0 || n==k) return 1;
return ((fact[n] * factf[k]) % mod * factf[n-k]) % mod;
}
};
int main(void)
{
cin.tie(0);
ios::sync_with_stdio(false);
Comb comb;
comb.init(50, 1e9+7);
int n, p;
cin >> n >> p;
int isodd = 0;
for (int i = 0; i < n; ++i) {
int a;
cin >> a;
if (a%2==1) isodd++;
}
u64 ret_odd = 0;
for (int i = p; i <= isodd; i+=2) {
ret_odd += comb.comb(isodd, i);
}
for (int i = 0; i <= iseven; ++i) {
ret_odd *= 2;
}
cout << ret_odd << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:62:24: error: 'iseven' was not declared in this scope; did you mean 'sigevent'?
62 | for (int i = 0; i <= iseven; ++i) {
| ^~~~~~
| sigevent
|
s099636977 | p03665 | C++ | // 11.07.2017
//# include <stdio.h>
//# include <iostream>
# include <cstdio>
//# include <conio.h>
//using namespace std;
int main ()
{
//
freopen ("A.TXT", "r", stdin);
freopen ("A.OUT", "w", stdout);
//
int a, i, n, p, m=0, k=0;
__int64 sum = 0, t;
scanf ("%d%d\n", &n, &p);
for ( i=0; i < n; i++ )
{
scanf ("%d", &a);
if ( a % 2 == 0 )
k++;
else
m++;
}
//
//printf ("n=%d p=%d m=%d k=%d\n", n, p, m, k);
//
if ( p == 0 )
{
t = 1;
sum = t;
for ( i=2; i <= m; i+=2 )
{
t = t*(m-i+1)*(m-i+2)/i/(i-1);
sum += t;
//printf ("== sum=%I64d t=%I64d\n", sum, t);
}
for ( i=0; i < k; i++ )
sum *= 2;
}
else
{
t = m;
if ( m > 0 )
sum = m;
for ( i=3; i <= m; i+=2 )
{
t = t*(m-i+1)*(m-i+2)/i/(i-1);
sum += t;
//printf ("= sum=%I64d t=%I64d\n", sum, t);
}
for ( i=0; i < k; i++ )
sum *= 2;
}
printf ("%I64d", sum);
// printf ("%I64d", sum);
return 0;
}
| a.cc: In function 'int main()':
a.cc:22:4: error: '__int64' was not declared in this scope; did you mean '__int64_t'?
22 | __int64 sum = 0, t;
| ^~~~~~~
| __int64_t
a.cc:38:7: error: 't' was not declared in this scope
38 | t = 1;
| ^
a.cc:39:7: error: 'sum' was not declared in this scope
39 | sum = t;
| ^~~
a.cc:51:17: error: 't' was not declared in this scope
51 | t = m;
| ^
a.cc:53:20: error: 'sum' was not declared in this scope
53 | sum = m;
| ^~~
a.cc:57:20: error: 'sum' was not declared in this scope
57 | sum += t;
| ^~~
a.cc:61:20: error: 'sum' was not declared in this scope
61 | sum *= 2;
| ^~~
a.cc:64:21: error: 'sum' was not declared in this scope
64 | printf ("%I64d", sum);
| ^~~
|
s288755509 | p03665 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll quick_pow(ll a, ll b) {
ll ans = 1;
while(b) {
if(b & 1) ans *= a;
a *= a;
b >>= 1;
}
return ans;
}
int main(void) {
int n, p;
while(~scanf("%d%d", &n, &p)) {
bool flag = 0;
int cnt1 = 0, cnt2 = 0;
for(int i = 0; i < n; ++i) {
int x; scanf("%d", &x);
if(x & 1) cnt1++;
else cnt2++;
}
if(p) {
if(cnt1) printf("%lld\n", quick_pow(2, n - 1));
else puts("0");
} else {
printf("%lld\n", cnt1 ? quick_pow(2, n - 1) : quick_pow(2, n)
}
}
}
| a.cc: In function 'int main()':
a.cc:28:74: error: expected ')' before '}' token
28 | printf("%lld\n", cnt1 ? quick_pow(2, n - 1) : quick_pow(2, n)
| ~ ^
| )
29 | }
| ~
|
s386068585 | p03665 | Java | import java.io.*;
import java.util.*;
public class grand {
public static void main(String[] args)
{
InputReader in = new InputReader(System.in);
PrintWriter w = new PrintWriter(System.out);
Scanner sc = new Scanner(System.in);
int n = in.nextInt();
int p=in.nextInt();
int arr[] = new int[100001];
arr=in.nextIntArray(n);
int flagodd=0;
for(int i=0;i<n;i++)
{
if(arr[i]%2==1)
{
flagodd=1;
break;
}
}
if(flagodd==0)
{
if(p==0)
{
w.println((int)Math.pow(2, n));
}
else
{
w.println("0");
}
}
else
{
w.println((int)Math.pow(2, (n-1)));
}
//w.println(n);
w.close();
}
static class InputReader {
private final InputStream stream;
private final byte[] buf = new byte[8192];
private int curChar, snumChars;
public InputReader(InputStream st) {
this.stream = st;
}
public int read() {
if (snumChars == -1)
throw new InputMismatchException();
if (curChar >= snumChars) {
curChar = 0;
try {
snumChars = stream.read(buf);
} catch (IOException e) {
throw new InputMismatchException();
}
if (snumChars <= 0)
return -1;
}
return buf[curChar++];
}
public int nextInt() {
int c = read();
while (isSpaceChar(c)) {
c = read();
}
int sgn = 1;
if (c == '-') {
sgn = -1;
c = read();
}
int res = 0;
do {
res *= 10;
res += c - '0';
c = read();
} while (!isSpaceChar(c));
return res * sgn;
}
public long nextLong() {
int c = read();
while (isSpaceChar(c)) {
c = read();
}
int sgn = 1;
if (c == '-') {
sgn = -1;
c = read();
}
long res = 0;
do {
res *= 10;
res += c - '0';
c = read();
} while (!isSpaceChar(c));
return res * sgn;
}
public int[] nextIntArray(int n) {
int a[] = new int[n];
for (int i = 0; i < n; i++) {
a[i] = nextInt();
}
return a;
}
public String readString() {
int c = read();
while (isSpaceChar(c)) {
c = read();
}
StringBuilder res = new StringBuilder();
do {
res.appendCodePoint(c);
c = read();
} while (!isSpaceChar(c));
return res.toString();
}
public String nextLine() {
int c = read();
while (isSpaceChar(c))
c = read();
StringBuilder res = new StringBuilder();
do {
res.appendCodePoint(c);
c = read();
} while (!isEndOfLine(c));
return res.toString();
}
public boolean isSpaceChar(int c) {
return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
}
private boolean isEndOfLine(int c) {
return c == '\n' || c == '\r' || c == -1;
}
}
} | Main.java:3: error: class grand is public, should be declared in a file named grand.java
public class grand {
^
1 error
|
s534600178 | p03665 | C++ | #include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
long long cau[100][100];
int main()
{ int n,m;
cin>>n>>m;
long long J=0;
long long O=0;
memset(cau,0,sizeof(cau));
int i=0;
int b;
while(n--)
{
cin>>b;
if(b%2)
J++;
else
O++;
}
memset(cau,0,sizeof(cau));
cau[0][0]=1;
for(int i=0;i<=50;i++)
for(int is=0;is<=i;is++)
{
cau[is][i]=cau[is-1][i-1]+cau[is][i-1];
}
long long fd=1;
for(int i=0;i<O;i++)
{
fd=fd*2;
}
long long num=0;
if(m%2)
{
for(int i=1;i<=J;i=i+2)
{ long long t=cau[i][J];
num=num+(t*fd);
}
cout<<num;
}
else
{ for(int i=0;i<=J;i=i+2)
{ long long t=cau[i][J];
num=num+t*fd;
}
cout<<num;
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:26:17: error: unable to find numeric literal operator 'operator""\U0000ff1b'
26 | cau[0][0]=1;
| ^~~
a.cc:27:28: error: expected ';' before ')' token
27 | for(int i=0;i<=50;i++)
| ^
| ;
a.cc:28:22: error: 'is' was not declared in this scope; did you mean 'i'?
28 | for(int is=0;is<=i;is++)
| ^~
| i
|
s282271772 | p03665 | C++ | #include <iostream>
#include <cmath>
using namespace std;
int main()
{
int N, P;
cin >> N >> P;
int t, ar[2] = { 0 };
for( int i = 0; i < N; ++i ){
cin >> t;
++ar[t%2];
}
long long int ans = 0;
if( ar[1] == 0 ){
if( P == 0 ) ans = pow(2, N);
else if( P == 1 ) ans = 0;
} else if( 0 < ar[1] ){
long long int others = pow(2, N-1);
for( int i = 0; i < ar[1]; ++i ){
S = ar[0] + ar[1] - 1;
if( S%2 == 1 ) ;
else if( S%2 == 0 ) ;
}
ans = others;
}
cout << ans << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:26:13: error: 'S' was not declared in this scope
26 | S = ar[0] + ar[1] - 1;
| ^
|
s527287356 | p03665 | C++ | #include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
#define MX 54
typedef long long LL;
int a[MX];
int n,p;
LL C[MX][MX];
void getAC()
{
C[1][0] = C[1][1] = 1LL;
C[0][0] = C[0][1] = 1LL;
for(int i = 1;i <= MX;i++)
{
C[i][0] = C[i][i] = 1LL;
}
for(int i = 2;i <= MX;i++)
{
for(int j = 1;j < i;j++)
C[i][j] = C[i - 1][j] + C[i - 1][j - 1] ;
}
}
int main()
{
scanf("%d%d",&n,&p);
int cnt1 = 0,cnt2 = 0;
getAC();
for(int i = 1; i <= n;i++){
scanf("%d",&a[i]);
if(a[i]%2==0)
cnt1++;
else
cnt2++;
}
LL cnt = 1LL<<cnt1;
LL ans = 0;
for(int i = p;i<= cnt2;i++){
ans += C[cnt2][i];
LL res = ans*cnt;
printf("%lld\n",res);
return 0;
}
| a.cc: In function 'int main()':
a.cc:46:2: error: expected '}' at end of input
46 | }
| ^
a.cc:26:1: note: to match this '{'
26 | {
| ^
|
s219688576 | p03665 | C++ | #include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <set>
#include <queue>
#define INTFY 10000000
using namespace std;
int N, P;
long long cnt;
long long fct[51];
int main() {
cin >> N >> P;
int g = 0, k = 0;
fct[0] = 1;
for (int i = 1; i < 51; ++i) {
fct[i] = fct[i - 1] * 2;
//printf("fct[%d]:", i);
//cout << fct[i] << endl;
}
fct[0] = 0;
for (int i = 0; i < N; ++i) {
int t;
cin >> t;
if (t % 2 == 0)
g++;
else
k++;
}
if (k == 0)
P == 0 ? cout << fct[N] << endl : printf("0\n");
else
cout << fct[k+g-1] << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:42:24: error: operands to '?:' have different types 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} and 'int'
42 | P == 0 ? cout << fct[N] << endl : printf("0\n");
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
s700857789 | p03665 | C++ | #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,px,y;
int main(){
cin>>n>>p;
for(int i=1;i<=n;i++){
cin>>x;
if(x&1)y=1;
}
if(y)cout<<(1LL<<(n-1));
else if(p==0)cout<<(1LL<<n);
else cout<<0;
} | a.cc: In function 'int main()':
a.cc:6:17: error: 'p' was not declared in this scope
6 | cin>>n>>p;
| ^
a.cc:8:22: error: 'x' was not declared in this scope
8 | cin>>x;
| ^
|
s855941924 | p03665 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int freq[210000];
int balls[210000];
int main(){
int n, m;
cin >> n >> m;
for(int i = 1; i <= n; i++){
freq[i] = 0;
}
for(int i = 0; i < n; i++){
cin >> balls[i];
freq[balls[i]]++;
}
for(int i = 0; i < m; i++){
int c, d;
cin >> c >> d;
c--;
freq[balls[c]]--;
balls[c] = d;
freq[balls[c]]++;
int ans = 0;
int fl[n+1];
int fr[n+1];
int f = 0;
for(int j = 1; j <= n; j++){
f += freq[j];
fl[j] = f;
}
f = 0;
for(int j = n; j >= 1; j--){
f += freq[j];
fr[j] = f;
}
for(int i = 1; i <= n; i++){
for(int j = i+1; j <= n; j++){
ans = max(max(0,freq[i]-i)+max(0,freq[j]-j));
}
cout << ans << endl;
}
}
| a.cc: In function 'int main()':
a.cc:38:42: error: no matching function for call to 'max(int)'
38 | ans = max(max(0,freq[i]-i)+max(0,freq[j]-j));
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 1 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: template argument deduction/substitution failed:
a.cc:38:42: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
38 | ans = max(max(0,freq[i]-i)+max(0,freq[j]-j));
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate expects 2 arguments, 1 provided
a.cc:42:2: error: expected '}' at end of input
42 | }
| ^
a.cc:6:11: note: to match this '{'
6 | int main(){
| ^
|
s632598168 | p03665 | Java | public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int bagNumber = scan.nextInt();
int remainder = scan.nextInt();
int[] intArray = new int[bagNumber];
int counter = 0;
for (int i =0;i<bagNumber;i++){
intArray[i] = scan.nextInt();
}
int mc=1<<bagNumber; // 全組み合わせ総数
for(int i=0; i<mc; ++i){
int ttl=0;
for(int j=0; j<bagNumber; ++j){
if(0<(i&1<<j)){
ttl+=intArray[j];
}
}
if(ttl%2==remainder){
counter = counter + 1;
}
if(i == mc -1) {
System.out.println(remainder);
}
}
}
} | Main.java:3: error: cannot find symbol
Scanner scan = new Scanner(System.in);
^
symbol: class Scanner
location: class Main
Main.java:3: error: cannot find symbol
Scanner scan = new Scanner(System.in);
^
symbol: class Scanner
location: class Main
2 errors
|
s093759432 | p03665 | C | #include <stdio.h>
long long comb(long long n, long long r){
static long long c[50][50]={};
if(r==0 || r==n) return c[n][r] = 1;
if(r==1 || r==n-1) return c[n][r] = n;
if(c[n][r] != 0) return c[n][r];
if(c[n][n-r] != 0) return c[n][r] = c[n][n-r];
return c[n][r] = comb(n-1, r) + comb(n-1, r-1);
}
int main()
{
long long i, a, b, ans=0;
int n, p, t;
char s[100];
scanf(" %d %d", &n, &p);
a=b=0;
for(i=0; i<n; i++){
scanf(" %d", &t);
t%2 ? a++ : b++;
//printf("[%d (%lld,%lld)] ", t, a, b);
}
if(p){
for(i=1; i<=a; i+=2){
ans += comb(a, i);
//printf("comb(%lld,%lld):%lld ", a, i, comb(a, i));
}
}else{
for(I=0; i<=a; i+=2){
ans += comb(a, i);
//printf("comb(%lld,%lld):%lld ", a, i, comb(a, i));
}
}
//printf("ans: %lld (%lld, %lld) ", ans, a, b);
ans *= 1<<b;
sprintf(s, "%lld", ans);
puts(s);
return 0;
} | main.c: In function 'main':
main.c:34:9: error: 'I' undeclared (first use in this function)
34 | for(I=0; i<=a; i+=2){
| ^
main.c:34:9: note: each undeclared identifier is reported only once for each function it appears in
|
s784385591 | p03665 | Java | import java.util.Scanner;
public class Biscuits {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int bagNumber = scan.nextInt();
int remainder = scan.nextInt();
int[] intArray = new int[bagNumber];
int counter = 0;
for (int i =0;i<bagNumber;i++){
intArray[i] = scan.nextInt();
}
int mc=1<<bagNumber; // 全組み合わせ総数
for(int i=0; i<mc; ++i){
int ttl=0;
for(int j=0; j<bagNumber; ++j){
if(0<(i&1<<j)){
ttl+=intArray[j];
}
}
if(ttl%2==remainder){
counter = counter + 1;
}
if(i == mc -1) {
System.out.println(remainder);
}
}
}
} | Main.java:3: error: class Biscuits is public, should be declared in a file named Biscuits.java
public class Biscuits {
^
1 error
|
s455131203 | p03665 | C++ | #include <bits/stdc++.h>
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define SORTR(v,n) sort(v, v+n, greater<int>());
#define SORTPairSecond(v, n) sort(v, v+n, pairCompareSecond);
#define int long long // %d=>%lld
#define pb push_back
#define INF 1000000007
#define llINF 1e17
#define EPS 1e-9
#define pi acos(-1)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> piii;
typedef pair<ll, pll> plll;
bool pairCompareSecond(const pii& firstEl, const pii& secondEl) {
return firstEl.second > secondEl.second;
}
const int MAX_n = 50;
int n,p,a[MAX_n];
int odd, even;
int ans;
int odd_n,even_n;
int comb(int n, int r) {
if(n < 0 || r < 0 || n < r) return 0;
if(!r) return 1;
return conb(n - 1, r - 1) + conb(n - 1, r);
}
signed main(){
cin >> n >> p;
for(int i = 0;i < n;i++){
cin >> a[i];
if(a[i]%2 == 0)
even++;
else {
odd++;
}
}
if(p == 0){
for(int i = 0;i <= odd/2;i++){
odd_n += comb(odd , i*2);
}
even_n = 1 << even;
cout<< odd_n*even_n<<endl;
}else{
for(int i = 0;i <= odd/2;i++){
odd_n += comb(odd , i*2+1);
}
even_n = 1 << even;
cout<< odd_n*even_n<<endl;
}
return 0;
} | a.cc: In function 'long long int comb(long long int, long long int)':
a.cc:35:12: error: 'conb' was not declared in this scope; did you mean 'comb'?
35 | return conb(n - 1, r - 1) + conb(n - 1, r);
| ^~~~
| comb
|
s245340263 | p03665 | Java | import java.util.*;
public class Main {
// 変数宣言
static int N;
static int P;
static int[] biscuits;
// main
public static void main(String[] args) {
// 準備
Scanner sc = new Scanner(System.in);
// ロード
String[] line = sc.nextLine().split(" ");
N = Integer.parseInt(line[0]);
P = Integer.parseInt(line[1]);
line = sc.nextLine().split(" ");
biscuits = new int[N];
for (int i = 0; i < N; i++) {
biscuits[i] = Integer.parseInt(line[i]);
}
// 処理
int count = 0;
for (int i = 0; i < N; i++) {
count += calcMatchP(i);
}
// 出力
System.out.println(count);
}
// 一致するPの数を計算する
public static int calcMatchP(int num) {
if (num == 0) {
return (P == 0);
}
int match = 0;
int[] total = calcAllBiscuits(num);
for (int i = 0; i < total.length; i++) {
match += (P == (total[i] % 2));
}
return match;
}
// 特定の組み合わせ数の組み合わせの合計数を計算するメソッド
public static int[] calcAllBiscuits(int num) {
int[][] inds = getCombn(num);
int len = inds.length;
int[] res = new int[len];
for (int i = 0; i < len; i++) {
res[i] = calcBiscuits(inds[i]);
}
return res;
}
// ビスケットの合計数を計算するメソッド
public static int calcBiscuits(int[] inds) {
int total = 0;
for (int ind : inds) {
total += biscuits[ind];
}
return total;
}
// ビスケットの組み合わせを計算するメソッド
public static int[][] getCombn(int num) {
// 組み合わせ数
int combnN = calcCombnN(N, num);
int[][] combn = new int[num][combnN];
// 1つ目
int start = 0;
int combnN;
for (int i = 0; i < (N - num + 1); i++) {
combnN = calcCombnN(N - i - 1, num - 1);
for (int j = start; j < (start + combnN); j++) {
combn[0][j] = i;
}
start += combnN;
}
if (num > 1) {
int[] combnList;
intn start = 0;
for (int k = 1; k < num; k++) {
for(int i=(k-1); i<N; i++) {
combnList = calcCombnList(combn[k-1][start], num-k);
}
}
for (int k = 1; k < num; k++) {
for (int i = combn[k - 1]; i < (N - num + 1); i++) {
combnN = calcCombnN(N - i - 1, num - 1);
for (int j = start; j < (start + combnN); j++) {
combn[0][j] = i;
}
start += combnN;
}
}
}
return combn;
}
// (選択済数+1)個目の各indexの選択予定数を計算するメソッド
public static int[] calcCombnList(int no, int num) {
int[] res = new int[N];
for (int i = no; i < (N-num+1); i++) {
res[i] = calcCombnN(N - i - 1, num - 1);
}
return res;
}
// 組み合わせ数を計算するメソッド
public static int calcCombnN(int A, int B) {
// 組み合わせ数 A Combination B
int combnN = 1;
for (int i = 0; i < B; i++) {
combnN *= (A - i);
}
for (int i = 0; i < B; i++) {
combnN /= (B - i);
}
return combnN;
}
}
| Main.java:37: error: incompatible types: boolean cannot be converted to int
return (P == 0);
^
Main.java:43: error: bad operand types for binary operator '+'
match += (P == (total[i] % 2));
^
first type: int
second type: boolean
Main.java:76: error: variable combnN is already defined in method getCombn(int)
int combnN;
^
Main.java:87: error: cannot find symbol
intn start = 0;
^
symbol: class intn
location: class Main
Main.java:87: error: variable start is already defined in method getCombn(int)
intn start = 0;
^
Main.java:95: error: incompatible types: int[] cannot be converted to int
for (int i = combn[k - 1]; i < (N - num + 1); i++) {
^
6 errors
|
s052174255 | p03665 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7
__attribute__((constructor))
void initial() {
cin.tie(0);
ios::sync_with_stdio(false);
}
int n, p, a[50], ans = 0;
int saiki(int g, int s) {
if(g == n) ans += return s % 2 == p ? 1 : 0;
saiki(g + 1, s + a[g]);
saiki(g + 1, s);
return 0;
}
int main() {
cin >> n >> p;
rep(i, 0, n) cin >> a[i];
cout << ans << endl;
}
| a.cc: In function 'int saiki(int, int)':
a.cc:21:21: error: expected primary-expression before 'return'
21 | if(g == n) ans += return s % 2 == p ? 1 : 0;
| ^~~~~~
|
s955653172 | p03665 | C++ | #include<bits/stdc++.h>
typedef long long ll;
using namespace std;
ll sum;
int a[2],n,p;
ll D[60][60];
ll jiecheng(int x)
{
ll s=1;
for(int i=1;i<=x;i++)
{
s*=i;
}
return s;
}
ll C(int n,int m){return jiecheng(n)/jiecheng(m)/jiecheng(n-m);}
int main()
{
scanf("%d%d",&n,&p);
for(int i=0;i<n;i++)
{
int x;
scanf("%d",&x);
a[x%2]++;
}
if (!p%2) sum++;
D[0][1]=a[1];
D[1][0]=a[0];
if (p%2 )sum+=a[1];
else sum+=a[0];
for(int i=2;i<=n;i++)
for(int j=0;j<=i;j++)
{
int k=i-j;
if (j>a[0]||k>a[1])
continue;
D[j][k]=C(a[0],j)*C(a[1],k);
if ((j*0+k*1)%2==p)
{
sum+=(ll)D[j][k];
}
}
for(int i=1;i<=n;i++)
{
for(int j=0;j<=i;j++)
{
int k=i-j;
cout<<D[j][k]<<" ";
}
cout<<endl;
}
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
ll sum;
int a[2],n,p;
ll D[60][60];
ll jiecheng(int x)
{
ll s=1;
for(int i=1;i<=x;i++)
{
s*=i;
}
return s;
}
ll C(int n,int m){return jiecheng(n)/jiecheng(m)/jiecheng(n-m);}
int main()
{
scanf("%d%d",&n,&p);
for(int i=0;i<n;i++)
{
int x;
scanf("%d",&x);
a[x%2]++;
}
if (!p%2) sum++;
D[0][1]=a[1];
D[1][0]=a[0];
if (p%2 )sum+=a[1];
else sum+=a[0];
for(int i=2;i<=n;i++)
for(int j=0;j<=i;j++)
{
int k=i-j;
if (j>a[0]||k>a[1])
continue;
D[j][k]=C(a[0],j)*C(a[1],k);
if ((j*0+k*1)%2==p)
{
sum+=(ll)D[j][k];
}
}
for(int i=1;i<=n;i++)
{
for(int j=0;j<=i;j++)
{
int k=i-j;
cout<<D[j][k]<<" ";
}
cout<<endl;
}
cout<<sum<<endl;
return 0;
}
cout<<sum<<endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:71:1: error: a function-definition is not allowed here before '{' token
71 | {
| ^
a.cc:81:18: error: a function-definition is not allowed here before '{' token
81 | ll C(int n,int m){return jiecheng(n)/jiecheng(m)/jiecheng(n-m);}
| ^
a.cc:83:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
83 | int main()
| ^~
a.cc:83:9: note: remove parentheses to default-initialize a variable
83 | int main()
| ^~
| --
a.cc:83:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:84:1: error: a function-definition is not allowed here before '{' token
84 | {
| ^
|
s801537823 | p03665 | C++ | #include <algorithm>
#include <iostream>
using namespace std;
int main(){
long long int N,P,a[50],x,y,z,l,m,e,f;
cin>>N>>P;
if(P==0){
for(int i=0;i<N;i++){
cin>>a[i];
if(a[i]%2==0){
x+=1;
}else{
y+=1;
} }
for(int j=1;j<=x;j++){
for(int k=x;k>=j;k=k-1){
l*=k;
l=l/(x-k+1);
}
m+=l;
}
if(y%2==0){
for(int c=2;c<=y;c+=2){
for(int d=y;d>=c;d-=1){
e*=d;
e=e/(y-c+1);
}
f+=e;
}
}else{
for(int c=2;c<=y-1;c+=2){
for(int d=y;d>=c;d-=1){
e*=d;
e=e/(y-c+1);
}
f+=e;
}}
cout<<m*f<<endl;
}else{
for(int i=0;i<N;i++){
if(a[i]%2==0){
x+=1;
}else{
y+=1;
} }
for(int j=1;j<=x;j++){
for(int k=x;k>=j;k=k-1){
l*=k;
l=l/(x-k+1);
}
m+=l;
}
if(y%2==1){
for(int c=1;c<=y;c+=2){
for(int d=y;d>=c;d=d-1){
e*=d;
e=e/(y-c+1);
}
f+=e;
}
}else{
for(int c=1;c<=y-1;c+=2){
for(int d=y;d>=c;d=d-1){
e*=d;
e=e/(y-c+1);
}
f+=e;
}
}
cout<<m*f<<endl;
}
}
} | a.cc:76:1: error: expected declaration before '}' token
76 | }
| ^
|
s303547001 | p03665 | C++ | #include <algorithm>
#include <iostream>
using namespace std;
int main(){
long long int N,P,a[50],x,y,z,l,m,e,f;
cin>>N>>P;
if(P==0){
for(int i=0;i<N;i++){
cin>>a[i];
if(a[i]%2==0){
x+=1;
}else{
y+=1;
} }
for(int j=1;j<=x;j++){
for(int k=x;k>=j;k=k-1){
l*=k;
l=l/(x-k+1);
}
m+=l;
}
if(y%2==0){
for(int c=2;c<=y;c+=2){
for(int d=y;d>=c;d-=1){
e*=d;
e=e/(y-c+1);
}
f+=e;
}
}else{
for(int c=2;c<=y-1;c+=2){
for(int d=y;d>=c;d-=1){
e*=d;
e=e/(y-c+1);
}
f+=e;
}}
cout<<m*f<<endl;
}else{
if(a[i]%2==0){
x+=1;
}else{
y+=1;
}
for(int j=1;j<=x;j++){
for(int k=x;k>=j;k=k-1){
l*=k;
l=l/(x-k+1);
}
m+=l;
}
if(y%2==1){
for(int c=1;c<=y;c+=2){
for(int d=y;d>=c;d=d-1){
e*=d;
e=e/(y-c+1);
}
f+=e;
}
}else{
for(int c=1;c<=y-1;c+=2){
for(int d=y;d>=c;d=d-1){
e*=d;
e=e/(y-c+1);
}
f+=e;
}
}
cout<<m*f<<endl;
}
}
} | a.cc: In function 'int main()':
a.cc:42:13: error: 'i' was not declared in this scope
42 | if(a[i]%2==0){
| ^
a.cc: At global scope:
a.cc:75:1: error: expected declaration before '}' token
75 | }
| ^
|
s812873264 | p03665 | C++ | #include <algorithm>
#include <iostream>
using namespace std;
int main(){
long long int N,P,a[50],x,y,z,l,m,e,f;
cin>>N>>P;
if(P==0){
for(int i=0;i<N;i++){
cin>>a[i];
if(a[i]%2==0){
x+=1;
}else{
y+=1;
} }
for(int j=1;j<=x;j++){
for(int k=x;k>=j;k=k-1){
l*=k;
l=l/(x-k+1);
}
m+=l;
}
if(y%2==0){
for(int c=2;c<=y;c+=2){
for(int d=y;d>=c;d-=1){
e*=d;
e=e/(y-c+1);
}
f+=e;
}
}else{
for(int c=2;c<=y-1;c+=2){
for(int d=y;d>=c;d-=1){
e*=d;
e=e/(y-c+1);
}
f+=e;
}}
cout<<m*f<<endl;
}else{
if(a[i]%2==0){
x+=1;
}else{
y+=1;
}
for(int j=1;j<=x;j++){
for(int k=x;k>=j;k=k-1){
l*=k;
l=l/(x-k+1);
}
m+=l;
}
if(y%2==1){
for(int c=1;c<=y;c+=2){
for(int d=y;d>=c;d=d-1){
e*=d;
e=e/(y-c+1);
}
f+=e;
}
}else{
for(int c=1;c<=y-1;c+=2){
for(int d=y;d>=c;d=d-1){
e*=d;
e=e/(y-c+1);
}
f+=e;
}
}
cout<<m*f<<endl;
}
}
} | a.cc: In function 'int main()':
a.cc:42:13: error: 'i' was not declared in this scope
42 | if(a[i]%2==0){
| ^
a.cc: At global scope:
a.cc:75:1: error: expected declaration before '}' token
75 | }
| ^
|
s385446869 | p03665 | C++ | #include<iostream>
#include<string>
#include<algorithm>
using namespace std;
long long c(int a,int b) {
if (b == 0)return 1;
return a*c(a - 1, b - 1) / b;
}
int main() {
int n, p; cin >> n >> p;
long long s0 = 1, s1 = 0;
for (int i = 0; i < n; i++){
int a; cin >> a;
if (a % 2 == 0)s0 *= 2; else s1++;
}
long long sum = 0;
for (int i = p; i <= s1; i += 2)
sum += c(s1, min(i, s1 - i));
cout << sum*s0 << endl;
} | a.cc: In function 'int main()':
a.cc:18:33: error: no matching function for call to 'min(int&, long long int)'
18 | sum += c(s1, min(i, s1 - i));
| ~~~^~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed:
a.cc:18:33: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
18 | sum += c(s1, min(i, s1 - i));
| ~~~^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
from a.cc:3:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
5686 | min(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
5696 | min(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed:
a.cc:18:33: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
18 | sum += c(s1, min(i, s1 - i));
| ~~~^~~~~~~~~~~
|
s312383370 | p03665 | C++ | #include <algorithm>
#include <iostream>
using namespace std;
int main(){
long long int N,P,a[50],x,y,z,l,m,e,f;
cin>>N>>P;
for(int i=0;i<N;i++){
cin>>a[i];
if(P==0){
if(a[i]%2==0){
x+=1;
}else{
y+=1;
}
}
for(int j=1;j<=x;j++){
for(int k=x;k>=j;k=k-1){
l*=k;
l=l/(x-k+1);
}
m+=l;
}
if(y%2==0){
for(int c=2;c<=y;c+=2){
for(int d=y;d>=c;d-=1){
e*=d;
e=e/(y-c+1);
}
f+=e;
}
}else{
for(int c=2;c<=y-1;c+=2){
for(int d=y;d>=c;d-=1){
e*=d;
e=e/(y-c+1);
}
f+=e;
}
cout<<m*f<<endl;
}else{
if(a[i]%2==0){
x+=1;
}else{
y+=1;
}
}
for(int j=1;j<=x;j++){
for(int k=x;k>=j;k=k-1){
l*=k;
l=l/(x-k+1);
}
m+=l;
}
if(y%2==1){
for(int c=1;c<=y;c+=2){
for(int d=y;d>=c;d=d-1){
e*=d;
e=e/(y-c+1);
}
f+=e;
}
}else{
for(int c=1;c<=y-1;c+=2){
for(int d=y;d>=c;d=d-1){
e*=d;
e=e/(y-c+1);
}
f+=e;
}
}
cout<<m*f<<endl;
}
} | a.cc: In function 'int main()':
a.cc:42:2: error: 'else' without a previous 'if'
42 | }else{
| ^~~~
|
s840017758 | p03665 | Java | import java.math.BigInteger;
import java.util.Scanner;
public class Biscuits {
public static void main(String args[] ) throws Exception {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int P = sc.nextInt();
int Ec = 0;
for (int i = 0; i < N; i++) {
int num = sc.nextInt();
if(num % 2 == 0)
Ec++;
}
int Oc = N - Ec;
BigInteger ans = BigInteger.ONE;
if(P == 1) {
BigInteger temp = new BigInteger("2").pow(Oc).divide(new BigInteger("2"));
ans = ans.max(temp);
if(Oc == 0)
ans = BigInteger.ZERO;
temp = ans.multiply(new BigInteger("2").pow(Ec));
ans = ans.max(temp);
}
else {
BigInteger temp = new BigInteger("2").pow(Oc).divide(new BigInteger("2"));
ans = ans.max(temp);
temp = ans.multiply(new BigInteger("2").pow(Ec));
ans = ans.max(temp);
}
System.out.println(ans);
}
}
| Main.java:4: error: class Biscuits is public, should be declared in a file named Biscuits.java
public class Biscuits {
^
1 error
|
s343832120 | p03665 | C++ | #include <algorithm>
#include <iostream>
using namespace std;
int main(){
long long int N,P,a[50],x,y,z,l,m,e,f;
cin>>N>>P;
for(int i=0;i<N;i++){
cin>>a[i];
if(P==0){
if(a[i]%2==0){
x+=1;
}else{
y+=1;
}
for(int j=1;j<=x;j++){
for(int k=x;k>=j;k=k-1){
l*=k;
l=l/(x-k+1);
}
m+=l;
}
if(y%2==0){
for(int c=2;c<=y;c+=2){
for(int d=y;d>=c;d-=1){
e*=d;
e=e/(y-c+1);
}
f+=e;
}
}else{
for(int c=2;c<=y-1;c+=2){
for(int d=y;d>=c;d-=1){
e*=d;
e=e/(y-c+1);
}
f+=e;
}
}
cout<<m*f<<endl;
}else{
if(a[i]%2==0){
x+=1;
}else{
y+=1;
}
for(int j=1;j<=x;j++;){
for(int k=x;k>=j;k-=){
l*=k;
l=l/(x-k+1);
}
m+=l;
}
if(y%2==1){
for(int c=1;c<=y;c+=2){
for(int d=y;d>=c;d=d-1){
e*=d;
e=e/(y-c+1);
}
f+=e;
}
}else{
for(int c=1;c<=y-1;c+=2){
for(int d=y;d>=c;d=d-1){
e*=d;
e=e/(y-c+1);
}
f+=e;
}
}
cout<<m*f<<endl;
}
}
} | a.cc: In function 'int main()':
a.cc:47:21: error: expected ')' before ';' token
47 | for(int j=1;j<=x;j++;){
| ~ ^
| )
a.cc:47:22: error: expected primary-expression before ')' token
47 | for(int j=1;j<=x;j++;){
| ^
|
s207139132 | p03665 | C++ | #include <algorithm>
#include <iostream>
using namespace std;
int main(){
long long int N,P,a[50],x,y,z,l,m,e,f;
cin>>N>>P;
for(int i=0;i<N;i++){
cin>>a[i];
if(P==0){
if(a[i]%2==0){
x+=1;
}else{
y+=1;
}
for(int j=1;j<=x;j++){
for(int k=x;k>=j;k=k-1){
l*=k;
l=l/(x-k+1);
}
m+=l;
}
if(y%2==0){
for(int c=2;c<=y;c+=2){
for(int d=y;d>=c;d-=1){
e*=d;
e=e/(y-c+1);
}
f+=e;
}
}else{
for(int c=2;c<=y-1;c+=2){
for(int d=y;d>=c;d-=1){
e*=d;
e=e/(y-c+1);
}
f+=e;
}
}
cout>>m*f>>endl;
}else{
if(a[i]%2==0){
x+=1;
}else{
y+=1;
}
for(int j=1;j<=x;j++;){
for(int k=x;k>=j;k-=){
l*=k;
l=l/(x-k+1);
}
m+=l;
}
if(y%2==1){
for(int c=1;c<=y;c+=2){
for(int d=y;d>=c;d-=1){
e*=d;
e=e/(y-c+1);
}
f+=e;
}
}else{
for(int c=1;c<=y-1;c+=2){
for(int d=y;d>=c;d-=1){
e*=d;
e=e/(y-c+1);
}
f+=e;
}
}
cout>>m*f>>endl;
}
}
} | a.cc: In function 'int main()':
a.cc:40:5: error: no match for 'operator>>' (operand types are 'std::ostream' {aka 'std::basic_ostream<char>'} and 'long long int')
40 | cout>>m*f>>endl;
| ~~~~^~~~~
| | |
| | long long int
| std::ostream {aka std::basic_ostream<char>}
a.cc:40:5: note: candidate: 'operator>>(int, long long int)' (built-in)
40 | cout>>m*f>>endl;
| ~~~~^~~~~
a.cc:40:5: note: no known conversion for argument 1 from 'std::ostream' {aka 'std::basic_ostream<char>'} to 'int'
In file included from /usr/include/c++/14/string:55,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:2:
/usr/include/c++/14/bits/basic_string.tcc:835:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::basic_istream<_CharT, _Traits>& std::operator>>(basic_istream<_CharT, _Traits>&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
835 | operator>>(basic_istream<_CharT, _Traits>& __in,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.tcc:835:5: note: template argument deduction/substitution failed:
a.cc:40:9: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<_CharT, _Traits>'
40 | cout>>m*f>>endl;
| ^
In file included from /usr/include/c++/14/bits/memory_resource.h:38,
from /usr/include/c++/14/string:68:
/usr/include/c++/14/cstddef:131:5: note: candidate: 'template<class _IntegerType> constexpr std::__byte_op_t<_IntegerType> std::operator>>(byte, _IntegerType)'
131 | operator>>(byte __b, _IntegerType __shift) noexcept
| ^~~~~~~~
/usr/include/c++/14/cstddef:131:5: note: template argument deduction/substitution failed:
a.cc:40:1: note: cannot convert 'std::cout' (type 'std::ostream' {aka 'std::basic_ostream<char>'}) to type 'std::byte'
40 | cout>>m*f>>endl;
| ^~~~
In file included from /usr/include/c++/14/istream:1109,
from /usr/include/c++/14/iostream:42:
/usr/include/c++/14/bits/istream.tcc:978:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(basic_istream<_CharT, _Traits>&, _CharT&)'
978 | operator>>(basic_istream<_CharT, _Traits>& __in, _CharT& __c)
| ^~~~~~~~
/usr/include/c++/14/bits/istream.tcc:978:5: note: template argument deduction/substitution failed:
a.cc:40:9: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<_CharT, _Traits>'
40 | cout>>m*f>>endl;
| ^
/usr/include/c++/14/istream:849:5: note: candidate: 'template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(basic_istream<char, _Traits>&, unsigned char&)'
849 | operator>>(basic_istream<char, _Traits>& __in, unsigned char& __c)
| ^~~~~~~~
/usr/include/c++/14/istream:849:5: note: template argument deduction/substitution failed:
a.cc:40:9: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<char, _Traits>'
40 | cout>>m*f>>endl;
| ^
/usr/include/c++/14/istream:854:5: note: candidate: 'template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(basic_istream<char, _Traits>&, signed char&)'
854 | operator>>(basic_istream<char, _Traits>& __in, signed char& __c)
| ^~~~~~~~
/usr/include/c++/14/istream:854:5: note: template argument deduction/substitution failed:
a.cc:40:9: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<char, _Traits>'
40 | cout>>m*f>>endl;
| ^
/usr/include/c++/14/istream:896:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(basic_istream<_CharT, _Traits>&, _CharT*)'
896 | operator>>(basic_istream<_CharT, _Traits>& __in, _CharT* __s)
| ^~~~~~~~
/usr/include/c++/14/istream:896:5: note: template argument deduction/substitution failed:
a.cc:40:9: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<_CharT, _Traits>'
40 | cout>>m*f>>endl;
| ^
/usr/include/c++/14/istream:939:5: note: candidate: 'template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(basic_istream<char, _Traits>&, unsigned char*)'
939 | operator>>(basic_istream<char, _Traits>& __in, unsigned char* __s)
| ^~~~~~~~
/usr/include/c++/14/istream:939:5: note: template argument deduction/substitution failed:
a.cc:40:9: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<char, _Traits>'
40 | cout>>m*f>>endl;
| ^
/usr/include/c++/14/istream:945:5: note: candidate: 'template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(basic_istream<char, _Traits>&, signed char*)'
945 | operator>>(basic_istream<char, _Traits>& __in, signed char* __s)
| ^~~~~~~~
/usr/include/c++/14/istream:945:5: note: template argument deduction/substitution failed:
a.cc:40:9: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<char, _Traits>'
40 | cout>>m*f>>endl;
| ^
/usr/include/c++/14/istream:1099:5: note: candidate: 'template<class _Istream, class _Tp> _Istream&& std::operator>>(_Istream&&, _Tp&&)'
1099 | operator>>(_Istream&& __is, _Tp&& __x)
| ^~~~~~~~
/usr/include/c++/14/istream:1099:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/istream: In substitution of 'template<class _Istream, class _Tp> _Istream&& std::operator>>(_Istream&&, _Tp&&) [with _Istream = std::basic_ostream<char>&; _Tp = long long int]':
a.cc:40:9: required from here
40 | cout>>m*f>>endl;
| ^
/usr/include/c++/14/istream:1099:5: error: no type named 'type' in 'struct std::enable_if<false, void>'
1099 | operator>>(_Istream&& __is, _Tp&& __x)
| ^~~~~~~~
a.cc:47:21: error: expected ')' before ';' token
47 | for(int j=1;j<=x;j++;){
| ~ ^
| )
a.cc:47:22: error: expected primary-expression before ')' token
47 | for(int j=1;j<=x;j++;){
| ^
a.cc:71:5: error: no match for 'operator>>' (operand types are 'std::ostream' {aka 'std::basic_ostream<char>'} and 'long long int')
71 | cout>>m*f>>endl;
| ~~~~^~~~~
| | |
| | long long int
| std::ostream {aka std::basic_ostream<char>}
a.cc:71:5: note: candidate: 'operator>>(int, long long int)' (built-in)
71 | cout>>m*f>>endl;
| ~~~~^~~~~
a.cc:71:5: note: no known conversion for argument 1 from 'std::ostream' {aka 'std::basic_ostream<char>'} to 'int'
/usr/include/c++/14/bits/basic_string.tcc:835:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::basic_istream<_CharT, _Traits>& std::operator>>(basic_istream<_CharT, _Traits>&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
835 | operator>>(basic_istream<_CharT, _Traits>& __in,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.tcc:835:5: note: template argument deduction/substitution failed:
a.cc:71:9: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<_CharT, _Traits>'
71 | cout>>m*f>>endl;
| ^
/usr/include/c++/14/cstddef:131:5: note: candidate: 'template<class _IntegerType> constexpr std::__byte_op_t<_IntegerType> std::operator>>(byte, _IntegerType)'
131 | operator>>(byte __b, _IntegerType __shift) noexcept
| ^~~~~~~~
/usr/include/c++/14/cstddef:131:5: note: template argument deduction/substitution failed:
a.cc:71:1: note: cannot convert 'std::cout' (type 'std::ostream' {aka 'std::basic_ostream<char>'}) to type 'std::byte'
71 | cout>>m*f>>endl;
| ^~~~
/usr/include/c++/14/bits/istream.tcc:978:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(basic_istream<_CharT, _Traits>&, _CharT&)'
978 | operator>>(basic_istream<_CharT, _Traits>& __in, _CharT& __c)
| ^~~~~~~~
/usr/include/c++/14/bits/istream.tcc:978:5: note: template argument deduction/substitution failed:
a.cc:71:9: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<_CharT, _Traits>'
71 | cout>>m*f>>endl;
| ^
/usr/include/c++/14/istream:849:5: note: candidate: 'template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(basic_istream<char, _Traits>&, unsigned char&)'
849 | operator>>(basic_istream<char, _Traits>& __in, unsigned char& __c)
| ^~~~~~~~
/usr/include/c++/14/istream:849:5: note: template argument deduction/substitution failed:
a.cc:71:9: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<char, _Traits>'
71 | cout>>m*f>>endl;
| ^
/usr/include/c++/14/istream:854:5: note: candidate: 'template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(basic_istream<char, _Traits>&, signed char&)'
854 | operator>>(basic_istream<char, _Traits>& __in, signed char& __c)
| ^~~~~~~~
/usr/include/c++/14/istream:854:5: note: template argument deduction/substitution failed:
a.cc:71:9: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<char, _Traits>'
71 | cout>>m*f>>endl;
| ^
/usr/include/c++/14/istream:896:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(basic_istream<_CharT, _Traits>&, _CharT*)'
896 | operator>>(basic_istream<_CharT, _Traits>& __in, _CharT* __s)
| ^~~~~~~~
/usr/include/c++/14/istream:896:5: note: template argument deduction/substitution failed:
a.cc:71:9: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<_CharT, _Traits>'
|
s003567590 | p03665 | C++ | #include <algorithm>
#include <iostream>
using namespace std;
int main(){
long long int N,P,a[50],x,y,z,l,m,e,f;
cin>>N>>P;
for(int i=0;i<N;i++){
cin>>a[i];
if(P==0){
if(a[i]%2==0){
x+=1;
}else{
y+=1;
}
for(int j=1;j<=x;j++){
for(int k=x;k>=j;k-=){
l*=k;
l=l/(x-k+1);
}
m+=l;
}
if(y%2==0){
for(int c=2;c<=y;c+=2){
for(int d=y;d>=c;d-=1){
e*=d;
e=e/(y-c+1);
}
f+=e;
}
}else{
for(int c=2;c<=y-1;c+=2){
for(int d=y;d>=c;d-=1){
e*=d;
e=e/(y-c+1);
}
f+=e;
}
}
cout>>m*f>>endl;
}else{
if(a[i]%2==0){
x+=1;
}else{
y+=1;
}
for(int j=1;j<=x;j++;){
for(int k=x;k>=j;k-=){
l*=k;
l=l/(x-k+1);
}
m+=l;
}
if(y%2==1){
for(int c=1;c<=y;c+=2){
for(int d=y;d>=c;d-=1){
e*=d;
e=e/(y-c+1);
}
f+=e;
}
}else{
for(int c=1;c<=y-1;c+=2){
for(int d=y;d>=c;d-=1){
e*=d;
e=e/(y-c+1);
}
f+=e;
}
}
cout>>m*f>>endl;
}
}
} | a.cc: In function 'int main()':
a.cc:17:26: error: expected primary-expression before ')' token
17 | for(int k=x;k>=j;k-=){
| ^
a.cc:40:5: error: no match for 'operator>>' (operand types are 'std::ostream' {aka 'std::basic_ostream<char>'} and 'long long int')
40 | cout>>m*f>>endl;
| ~~~~^~~~~
| | |
| | long long int
| std::ostream {aka std::basic_ostream<char>}
a.cc:40:5: note: candidate: 'operator>>(int, long long int)' (built-in)
40 | cout>>m*f>>endl;
| ~~~~^~~~~
a.cc:40:5: note: no known conversion for argument 1 from 'std::ostream' {aka 'std::basic_ostream<char>'} to 'int'
In file included from /usr/include/c++/14/string:55,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:2:
/usr/include/c++/14/bits/basic_string.tcc:835:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::basic_istream<_CharT, _Traits>& std::operator>>(basic_istream<_CharT, _Traits>&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
835 | operator>>(basic_istream<_CharT, _Traits>& __in,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.tcc:835:5: note: template argument deduction/substitution failed:
a.cc:40:9: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<_CharT, _Traits>'
40 | cout>>m*f>>endl;
| ^
In file included from /usr/include/c++/14/bits/memory_resource.h:38,
from /usr/include/c++/14/string:68:
/usr/include/c++/14/cstddef:131:5: note: candidate: 'template<class _IntegerType> constexpr std::__byte_op_t<_IntegerType> std::operator>>(byte, _IntegerType)'
131 | operator>>(byte __b, _IntegerType __shift) noexcept
| ^~~~~~~~
/usr/include/c++/14/cstddef:131:5: note: template argument deduction/substitution failed:
a.cc:40:1: note: cannot convert 'std::cout' (type 'std::ostream' {aka 'std::basic_ostream<char>'}) to type 'std::byte'
40 | cout>>m*f>>endl;
| ^~~~
In file included from /usr/include/c++/14/istream:1109,
from /usr/include/c++/14/iostream:42:
/usr/include/c++/14/bits/istream.tcc:978:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(basic_istream<_CharT, _Traits>&, _CharT&)'
978 | operator>>(basic_istream<_CharT, _Traits>& __in, _CharT& __c)
| ^~~~~~~~
/usr/include/c++/14/bits/istream.tcc:978:5: note: template argument deduction/substitution failed:
a.cc:40:9: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<_CharT, _Traits>'
40 | cout>>m*f>>endl;
| ^
/usr/include/c++/14/istream:849:5: note: candidate: 'template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(basic_istream<char, _Traits>&, unsigned char&)'
849 | operator>>(basic_istream<char, _Traits>& __in, unsigned char& __c)
| ^~~~~~~~
/usr/include/c++/14/istream:849:5: note: template argument deduction/substitution failed:
a.cc:40:9: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<char, _Traits>'
40 | cout>>m*f>>endl;
| ^
/usr/include/c++/14/istream:854:5: note: candidate: 'template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(basic_istream<char, _Traits>&, signed char&)'
854 | operator>>(basic_istream<char, _Traits>& __in, signed char& __c)
| ^~~~~~~~
/usr/include/c++/14/istream:854:5: note: template argument deduction/substitution failed:
a.cc:40:9: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<char, _Traits>'
40 | cout>>m*f>>endl;
| ^
/usr/include/c++/14/istream:896:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(basic_istream<_CharT, _Traits>&, _CharT*)'
896 | operator>>(basic_istream<_CharT, _Traits>& __in, _CharT* __s)
| ^~~~~~~~
/usr/include/c++/14/istream:896:5: note: template argument deduction/substitution failed:
a.cc:40:9: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<_CharT, _Traits>'
40 | cout>>m*f>>endl;
| ^
/usr/include/c++/14/istream:939:5: note: candidate: 'template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(basic_istream<char, _Traits>&, unsigned char*)'
939 | operator>>(basic_istream<char, _Traits>& __in, unsigned char* __s)
| ^~~~~~~~
/usr/include/c++/14/istream:939:5: note: template argument deduction/substitution failed:
a.cc:40:9: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<char, _Traits>'
40 | cout>>m*f>>endl;
| ^
/usr/include/c++/14/istream:945:5: note: candidate: 'template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(basic_istream<char, _Traits>&, signed char*)'
945 | operator>>(basic_istream<char, _Traits>& __in, signed char* __s)
| ^~~~~~~~
/usr/include/c++/14/istream:945:5: note: template argument deduction/substitution failed:
a.cc:40:9: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<char, _Traits>'
40 | cout>>m*f>>endl;
| ^
/usr/include/c++/14/istream:1099:5: note: candidate: 'template<class _Istream, class _Tp> _Istream&& std::operator>>(_Istream&&, _Tp&&)'
1099 | operator>>(_Istream&& __is, _Tp&& __x)
| ^~~~~~~~
/usr/include/c++/14/istream:1099:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/istream: In substitution of 'template<class _Istream, class _Tp> _Istream&& std::operator>>(_Istream&&, _Tp&&) [with _Istream = std::basic_ostream<char>&; _Tp = long long int]':
a.cc:40:9: required from here
40 | cout>>m*f>>endl;
| ^
/usr/include/c++/14/istream:1099:5: error: no type named 'type' in 'struct std::enable_if<false, void>'
1099 | operator>>(_Istream&& __is, _Tp&& __x)
| ^~~~~~~~
a.cc:47:21: error: expected ')' before ';' token
47 | for(int j=1;j<=x;j++;){
| ~ ^
| )
a.cc:47:22: error: expected primary-expression before ')' token
47 | for(int j=1;j<=x;j++;){
| ^
a.cc:71:5: error: no match for 'operator>>' (operand types are 'std::ostream' {aka 'std::basic_ostream<char>'} and 'long long int')
71 | cout>>m*f>>endl;
| ~~~~^~~~~
| | |
| | long long int
| std::ostream {aka std::basic_ostream<char>}
a.cc:71:5: note: candidate: 'operator>>(int, long long int)' (built-in)
71 | cout>>m*f>>endl;
| ~~~~^~~~~
a.cc:71:5: note: no known conversion for argument 1 from 'std::ostream' {aka 'std::basic_ostream<char>'} to 'int'
/usr/include/c++/14/bits/basic_string.tcc:835:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::basic_istream<_CharT, _Traits>& std::operator>>(basic_istream<_CharT, _Traits>&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
835 | operator>>(basic_istream<_CharT, _Traits>& __in,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.tcc:835:5: note: template argument deduction/substitution failed:
a.cc:71:9: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<_CharT, _Traits>'
71 | cout>>m*f>>endl;
| ^
/usr/include/c++/14/cstddef:131:5: note: candidate: 'template<class _IntegerType> constexpr std::__byte_op_t<_IntegerType> std::operator>>(byte, _IntegerType)'
131 | operator>>(byte __b, _IntegerType __shift) noexcept
| ^~~~~~~~
/usr/include/c++/14/cstddef:131:5: note: template argument deduction/substitution failed:
a.cc:71:1: note: cannot convert 'std::cout' (type 'std::ostream' {aka 'std::basic_ostream<char>'}) to type 'std::byte'
71 | cout>>m*f>>endl;
| ^~~~
/usr/include/c++/14/bits/istream.tcc:978:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(basic_istream<_CharT, _Traits>&, _CharT&)'
978 | operator>>(basic_istream<_CharT, _Traits>& __in, _CharT& __c)
| ^~~~~~~~
/usr/include/c++/14/bits/istream.tcc:978:5: note: template argument deduction/substitution failed:
a.cc:71:9: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<_CharT, _Traits>'
71 | cout>>m*f>>endl;
| ^
/usr/include/c++/14/istream:849:5: note: candidate: 'template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(basic_istream<char, _Traits>&, unsigned char&)'
849 | operator>>(basic_istream<char, _Traits>& __in, unsigned char& __c)
| ^~~~~~~~
/usr/include/c++/14/istream:849:5: note: template argument deduction/substitution failed:
a.cc:71:9: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<char, _Traits>'
71 | cout>>m*f>>endl;
| ^
/usr/include/c++/14/istream:854:5: note: candidate: 'template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(basic_istream<char, _Traits>&, signed char&)'
854 | operator>>(basic_istream<char, _Traits>& __in, signed char& __c)
| ^~~~~~~~
/usr/include/c++/14/istream:854:5: note: template argument deduction/substitution failed:
a.cc:71:9: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<char, _Traits>'
71 | cout>>m*f>>endl;
| ^
/usr/include/c++/14/istream:896:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(basic_istream<_CharT, _Traits>&, _CharT*)'
896 | operator>>(basic_istream<_CharT, _Traits>& __in, _CharT* __s)
| ^~~~~~~~
/usr/include/c++/14/istream:896:5: note: template argument deduction/substitution |
s612897410 | p03665 | C++ | #include <algorithm>
#include <iostream>
using namespace std;
int main(){
long long int N,P,a[50],x,y,z,l,m,e,f;
cin>>N>>P;
for(int i=0;i<N;i++){
cin>>a[i];
if(P==0){
if(a[i]%2==0){
x+=1;
}else{
y+=1;
}
for(int j=1;j<=x;j++;){
for(int k=x;k>=j;k-=){
l*=k;
l=l/(x-k+1);
}
m+=l;
}
if(y%2==0){
for(int c=2;c<=y;c+=2){
for(int d=y;d>=c;d-=1){
e*=d;
e=e/(y-c+1);
}
f+=e;
}
}else{
for(int c=2;c<=y-1;c+=2){
for(int d=y;d>=c;d-=1){
e*=d;
e=e/(y-c+1);
}
f+=e;
}
}
cout>>m*f>>endl;
}else{
if(a[i]%2==0){
x+=1;
}else{
y+=1;
}
for(int j=1;j<=x;j++;){
for(int k=x;k>=j;k-=){
l*=k;
l=l/(x-k+1);
}
m+=l;
}
if(y%2==1){
for(int c=1;c<=y;c+=2){
for(int d=y;d>=c;d-=1){
e*=d;
e=e/(y-c+1);
}
f+=e;
}
}else{
for(int c=1;c<=y-1;c+=2){
for(int d=y;d>=c;d-=1){
e*=d;
e=e/(y-c+1);
}
f+=e;
}
}
cout>>m*f>>endl;
}
}
} | a.cc: In function 'int main()':
a.cc:16:21: error: expected ')' before ';' token
16 | for(int j=1;j<=x;j++;){
| ~ ^
| )
a.cc:16:22: error: expected primary-expression before ')' token
16 | for(int j=1;j<=x;j++;){
| ^
a.cc:40:5: error: no match for 'operator>>' (operand types are 'std::ostream' {aka 'std::basic_ostream<char>'} and 'long long int')
40 | cout>>m*f>>endl;
| ~~~~^~~~~
| | |
| | long long int
| std::ostream {aka std::basic_ostream<char>}
a.cc:40:5: note: candidate: 'operator>>(int, long long int)' (built-in)
40 | cout>>m*f>>endl;
| ~~~~^~~~~
a.cc:40:5: note: no known conversion for argument 1 from 'std::ostream' {aka 'std::basic_ostream<char>'} to 'int'
In file included from /usr/include/c++/14/string:55,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:2:
/usr/include/c++/14/bits/basic_string.tcc:835:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::basic_istream<_CharT, _Traits>& std::operator>>(basic_istream<_CharT, _Traits>&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
835 | operator>>(basic_istream<_CharT, _Traits>& __in,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.tcc:835:5: note: template argument deduction/substitution failed:
a.cc:40:9: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<_CharT, _Traits>'
40 | cout>>m*f>>endl;
| ^
In file included from /usr/include/c++/14/bits/memory_resource.h:38,
from /usr/include/c++/14/string:68:
/usr/include/c++/14/cstddef:131:5: note: candidate: 'template<class _IntegerType> constexpr std::__byte_op_t<_IntegerType> std::operator>>(byte, _IntegerType)'
131 | operator>>(byte __b, _IntegerType __shift) noexcept
| ^~~~~~~~
/usr/include/c++/14/cstddef:131:5: note: template argument deduction/substitution failed:
a.cc:40:1: note: cannot convert 'std::cout' (type 'std::ostream' {aka 'std::basic_ostream<char>'}) to type 'std::byte'
40 | cout>>m*f>>endl;
| ^~~~
In file included from /usr/include/c++/14/istream:1109,
from /usr/include/c++/14/iostream:42:
/usr/include/c++/14/bits/istream.tcc:978:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(basic_istream<_CharT, _Traits>&, _CharT&)'
978 | operator>>(basic_istream<_CharT, _Traits>& __in, _CharT& __c)
| ^~~~~~~~
/usr/include/c++/14/bits/istream.tcc:978:5: note: template argument deduction/substitution failed:
a.cc:40:9: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<_CharT, _Traits>'
40 | cout>>m*f>>endl;
| ^
/usr/include/c++/14/istream:849:5: note: candidate: 'template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(basic_istream<char, _Traits>&, unsigned char&)'
849 | operator>>(basic_istream<char, _Traits>& __in, unsigned char& __c)
| ^~~~~~~~
/usr/include/c++/14/istream:849:5: note: template argument deduction/substitution failed:
a.cc:40:9: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<char, _Traits>'
40 | cout>>m*f>>endl;
| ^
/usr/include/c++/14/istream:854:5: note: candidate: 'template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(basic_istream<char, _Traits>&, signed char&)'
854 | operator>>(basic_istream<char, _Traits>& __in, signed char& __c)
| ^~~~~~~~
/usr/include/c++/14/istream:854:5: note: template argument deduction/substitution failed:
a.cc:40:9: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<char, _Traits>'
40 | cout>>m*f>>endl;
| ^
/usr/include/c++/14/istream:896:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(basic_istream<_CharT, _Traits>&, _CharT*)'
896 | operator>>(basic_istream<_CharT, _Traits>& __in, _CharT* __s)
| ^~~~~~~~
/usr/include/c++/14/istream:896:5: note: template argument deduction/substitution failed:
a.cc:40:9: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<_CharT, _Traits>'
40 | cout>>m*f>>endl;
| ^
/usr/include/c++/14/istream:939:5: note: candidate: 'template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(basic_istream<char, _Traits>&, unsigned char*)'
939 | operator>>(basic_istream<char, _Traits>& __in, unsigned char* __s)
| ^~~~~~~~
/usr/include/c++/14/istream:939:5: note: template argument deduction/substitution failed:
a.cc:40:9: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<char, _Traits>'
40 | cout>>m*f>>endl;
| ^
/usr/include/c++/14/istream:945:5: note: candidate: 'template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(basic_istream<char, _Traits>&, signed char*)'
945 | operator>>(basic_istream<char, _Traits>& __in, signed char* __s)
| ^~~~~~~~
/usr/include/c++/14/istream:945:5: note: template argument deduction/substitution failed:
a.cc:40:9: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<char, _Traits>'
40 | cout>>m*f>>endl;
| ^
/usr/include/c++/14/istream:1099:5: note: candidate: 'template<class _Istream, class _Tp> _Istream&& std::operator>>(_Istream&&, _Tp&&)'
1099 | operator>>(_Istream&& __is, _Tp&& __x)
| ^~~~~~~~
/usr/include/c++/14/istream:1099:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/istream: In substitution of 'template<class _Istream, class _Tp> _Istream&& std::operator>>(_Istream&&, _Tp&&) [with _Istream = std::basic_ostream<char>&; _Tp = long long int]':
a.cc:40:9: required from here
40 | cout>>m*f>>endl;
| ^
/usr/include/c++/14/istream:1099:5: error: no type named 'type' in 'struct std::enable_if<false, void>'
1099 | operator>>(_Istream&& __is, _Tp&& __x)
| ^~~~~~~~
a.cc:47:21: error: expected ')' before ';' token
47 | for(int j=1;j<=x;j++;){
| ~ ^
| )
a.cc:47:22: error: expected primary-expression before ')' token
47 | for(int j=1;j<=x;j++;){
| ^
a.cc:71:5: error: no match for 'operator>>' (operand types are 'std::ostream' {aka 'std::basic_ostream<char>'} and 'long long int')
71 | cout>>m*f>>endl;
| ~~~~^~~~~
| | |
| | long long int
| std::ostream {aka std::basic_ostream<char>}
a.cc:71:5: note: candidate: 'operator>>(int, long long int)' (built-in)
71 | cout>>m*f>>endl;
| ~~~~^~~~~
a.cc:71:5: note: no known conversion for argument 1 from 'std::ostream' {aka 'std::basic_ostream<char>'} to 'int'
/usr/include/c++/14/bits/basic_string.tcc:835:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::basic_istream<_CharT, _Traits>& std::operator>>(basic_istream<_CharT, _Traits>&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
835 | operator>>(basic_istream<_CharT, _Traits>& __in,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.tcc:835:5: note: template argument deduction/substitution failed:
a.cc:71:9: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<_CharT, _Traits>'
71 | cout>>m*f>>endl;
| ^
/usr/include/c++/14/cstddef:131:5: note: candidate: 'template<class _IntegerType> constexpr std::__byte_op_t<_IntegerType> std::operator>>(byte, _IntegerType)'
131 | operator>>(byte __b, _IntegerType __shift) noexcept
| ^~~~~~~~
/usr/include/c++/14/cstddef:131:5: note: template argument deduction/substitution failed:
a.cc:71:1: note: cannot convert 'std::cout' (type 'std::ostream' {aka 'std::basic_ostream<char>'}) to type 'std::byte'
71 | cout>>m*f>>endl;
| ^~~~
/usr/include/c++/14/bits/istream.tcc:978:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(basic_istream<_CharT, _Traits>&, _CharT&)'
978 | operator>>(basic_istream<_CharT, _Traits>& __in, _CharT& __c)
| ^~~~~~~~
/usr/include/c++/14/bits/istream.tcc:978:5: note: template argument deduction/substitution failed:
a.cc:71:9: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<_CharT, _Traits>'
71 | cout>>m*f>>endl;
| ^
/usr/include/c++/14/istream:849:5: note: candidate: 'template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(basic_istream<char, _Traits>&, unsigned char&)'
849 | operator>>(basic_istream<char, _Traits>& __in, unsigned char& __c)
| ^~~~~~~~
/usr/include/c++/14/istream:849:5: note: template argument deduction/substitution failed:
a.cc:71:9: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<char, _Traits>'
71 | cout>>m*f>>endl;
| ^
/usr/include/c++/14/istream:854:5: note: candidate: 'template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(basic_istream<char, _Traits>&, signed char&)'
854 | operator>>(basic_istream<char, _Traits>& __in, signed char& __c)
| ^~~~~~~~
/usr/include/c++/14/istream:854:5: note: template argument deduction/substitution failed:
a.cc:71:9: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<char, _Traits>'
71 | cout>>m*f>>endl;
| ^
/usr/include/c++/14/istream:896:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(basic_istream<_CharT, _Traits>&, _CharT*)'
896 | operator>>(basic_istream<_CharT, _ |
s632781081 | p03665 | C++ | #include <algorithm>
#include <iostream>
using namespace std;
int main(){
long long int N,P,a[50],x,y,z,l,m,e,f;
cin>>N>>P>>endl;
for(int i=0;i<N;i++){
cin>>a[i];
if(P==0){
if(a[i]%2==0){
x+=1;
}else{
y+=1;
}
for(int j=1;j<=x;j++;){
for(int k=x;k>=j;k-=){
l*=k;
l=l/(x-k+1);
}
m+=l;
}
if(y%2==0){
for(int c=2;c<=y;c+=2){
for(int d=y;d>=c;d-=1){
e*=d;
e=e/(y-c+1);
}
f+=e;
}
}else{
for(int c=2;c<=y-1;c+=2){
for(int d=y;d>=c;d-=1){
e*=d;
e=e/(y-c+1);
}
f+=e;
}
}
cout>>m*f;
}else{
if(a[i]%2==0){
x+=1;
}else{
y+=1;
}
for(int j=1;j<=x;j++;){
for(int k=x;k>=j;k-=){
l*=k;
l=l/(x-k+1);
}
m+=l;
}
if(y%2==1){
for(int c=1;c<=y;c+=2){
for(int d=y;d>=c;d-=1){
e*=d;
e=e/(y-c+1);
}
f+=e;
}
}else{
for(int c=1;c<=y-1;c+=2){
for(int d=y;d>=c;d-=1){
e*=d;
e=e/(y-c+1);
}
f+=e;
}
}
cout>>m*f;
}
}
} | a.cc: In function 'int main()':
a.cc:7:10: error: no match for 'operator>>' (operand types are 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} and '<unresolved overloaded function type>')
7 | cin>>N>>P>>endl;
| ~~~~~~~~~^~~~~~
In file included from /usr/include/c++/14/iostream:42,
from a.cc:2:
/usr/include/c++/14/istream:170:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
170 | operator>>(bool& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:170:24: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'bool&'
170 | operator>>(bool& __n)
| ~~~~~~^~~
/usr/include/c++/14/istream:174:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]'
174 | operator>>(short& __n);
| ^~~~~~~~
/usr/include/c++/14/istream:174:25: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'short int&'
174 | operator>>(short& __n);
| ~~~~~~~^~~
/usr/include/c++/14/istream:177:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
177 | operator>>(unsigned short& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:177:34: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'short unsigned int&'
177 | operator>>(unsigned short& __n)
| ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/istream:181:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]'
181 | operator>>(int& __n);
| ^~~~~~~~
/usr/include/c++/14/istream:181:23: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'int&'
181 | operator>>(int& __n);
| ~~~~~^~~
/usr/include/c++/14/istream:184:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
184 | operator>>(unsigned int& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:184:32: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'unsigned int&'
184 | operator>>(unsigned int& __n)
| ~~~~~~~~~~~~~~^~~
/usr/include/c++/14/istream:188:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
188 | operator>>(long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:188:24: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long int&'
188 | operator>>(long& __n)
| ~~~~~~^~~
/usr/include/c++/14/istream:192:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
192 | operator>>(unsigned long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:192:33: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long unsigned int&'
192 | operator>>(unsigned long& __n)
| ~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/istream:199:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
199 | operator>>(long long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:199:29: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long long int&'
199 | operator>>(long long& __n)
| ~~~~~~~~~~~^~~
/usr/include/c++/14/istream:203:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
203 | operator>>(unsigned long long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:203:38: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long long unsigned int&'
203 | operator>>(unsigned long long& __n)
| ~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/istream:219:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(float&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
219 | operator>>(float& __f)
| ^~~~~~~~
/usr/include/c++/14/istream:219:25: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'float&'
219 | operator>>(float& __f)
| ~~~~~~~^~~
/usr/include/c++/14/istream:223:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
223 | operator>>(double& __f)
| ^~~~~~~~
/usr/include/c++/14/istream:223:26: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'double&'
223 | operator>>(double& __f)
| ~~~~~~~~^~~
/usr/include/c++/14/istream:227:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
227 | operator>>(long double& __f)
| ^~~~~~~~
/usr/include/c++/14/istream:227:31: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long double&'
227 | operator>>(long double& __f)
| ~~~~~~~~~~~~~^~~
/usr/include/c++/14/istream:328:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
328 | operator>>(void*& __p)
| ^~~~~~~~
/usr/include/c++/14/istream:328:25: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'void*&'
328 | operator>>(void*& __p)
| ~~~~~~~^~~
/usr/include/c++/14/istream:122:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__istream_type& (*)(__istream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
122 | operator>>(__istream_type& (*__pf)(__istream_type&))
| ^~~~~~~~
/usr/include/c++/14/istream:122:36: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&)' {aka 'std::basic_istream<char>& (*)(std::basic_istream<char>&)'}
122 | operator>>(__istream_type& (*__pf)(__istream_type&))
| ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/istream:126:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>; __ios_type = std::basic_ios<char>]'
126 | operator>>(__ios_type& (*__pf)(__ios_type&))
| ^~~~~~~~
/usr/include/c++/14/istream:126:32: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::basic_istream<char>::__ios_type& (*)(std::basic_istream<char>::__ios_type&)' {aka 'std::basic_ios<char>& (*)(std::basic_ios<char>&)'}
126 | operator>>(__ios_type& (*__pf)(__ios_type&))
| ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
/usr/include/c++/14/istream:133:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::ios_base& (*)(std::ios_base&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
133 | operator>>(ios_base& (*__pf)(ios_base&))
| ^~~~~~~~
/usr/include/c++/14/istream:133:30: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::ios_base& (*)(std::ios_base&)'
133 | operator>>(ios_base& (*__pf)(ios_base&))
| ~~~~~~~~~~~~^~~~~~~~~~~~~~~~
/usr/include/c++/14/istream:352:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(__streambuf_type*) [with _CharT = char; _Traits = std::char_traits<char>; __streambuf_type = std::basic_streambuf<char>]'
352 | operator>>(__streambuf_type* __sb);
| ^~~~~~~~
/usr/include/c++/14/istream:352:36: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::basic_istream<char>::__streambuf_type*' {aka 'std::basic_streambuf<char>*'}
352 | operator>>(__streambuf_type* __sb);
| ~~~~~~~~~ |
s004321534 | p03665 | C++ | #include <iostream>
#include <fstream>
#include <cstdio>
#include <cassert>
#include <complex>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <sstream>
#include <ctime>
#include <cctype>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <deque>
#include <stack>
#include <memory.h>
#include <_mingw.h>
using namespace std;
int z=0,o=0,n,p;
int candy[51];
long long d2(int x){
if(x==1){
return 2;
}
if(x==0){
return 1;
}
else{
if(x%2==0){
long long a=d2(x/2)*d2(x/2);
return a;
}
else {
long long a=d2((x-1)/2)*d2((x-1)/2)*2;
}
}
}
int main()
{
long long ans=0;
cin>>n>>p;
for(int i=0;i<n;i++){
cin>>candy[i];
candy[i]=candy[i]%2;
if(candy[i]==0)z++;
else o++;
}
n-=1;
cout<<d2(n);
return 0;
} | a.cc:24:10: fatal error: _mingw.h: No such file or directory
24 | #include <_mingw.h>
| ^~~~~~~~~~
compilation terminated.
|
s770182967 | p03665 | C++ | #include <iostream>
#include <fstream>
#include <cstdio>
#include <cassert>
#include <complex>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <sstream>
#include <ctime>
#include <cctype>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <deque>
#include <stack>
#include <memory.h>
#include <_mingw.h>
using namespace std;
int z=0,o=0,n,p;
int candy[51];
long long d2(int x){
if(x==1){
return 2;
}
if(x==0){
return 1;
}
else{
if(x%2==0){
long long a=d2(x/2)*d2(x/2);
return a;
}
else {
long long a=d2((x-1)/2)*d2((x-1)/2)*2;
}
}
}
int main()
{
long long ans=0;
cin>>n>>p;
for(int i=0;i<n;i++){
cin>>candy[i];
candy[i]=candy[i]%2;
if(candy[i]==0)z++;
else o++;
}
n-=1;
cout<<d2(n);
return 0;
} | a.cc:24:10: fatal error: _mingw.h: No such file or directory
24 | #include <_mingw.h>
| ^~~~~~~~~~
compilation terminated.
|
s441844776 | p03665 | C++ | #include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <queue>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
#define MP make_pair
#define PB push_back
#define FF first
#define SS second
#define FORN(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)
#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }
// #define FL fflush(stdout)
#define MOD 1000000007
#define INF 2000000000
#define MAXN 55
int GLL(LL& x) {
return scanf("%lld", &x);
}
int GI(int& x) {
return scanf("%d", &x);
}
int n, p, a[MAXN];
int c1, c0;
LL pascal[MAXN][MAXN];
//LL powmod(LL a, LL b) {LL res=1; a %= MOD; for(;b;b>>=1) {if (b&1) res = res*a % MOD; a = a*a % MOD;} return res;}
LL build_pascal() {
// pascal's triangle
// k: 0 1 2 3 4
// ---------------
// n: 0| 1 0 0 0 0
// 1| 1 1 0 0 0
// 2| 1 2 1 0 0
// 3| 1 3 3 1 0
// 4| 1 4 6 4 1
for (int n = 2; n < MAXN; n++) {
FOR1(k, n) {
pascal[n][k] = pascal[n-1][k-1] + pascal[n-1][k];
}
}
}
int main() {
memset(pascal, 0, sizeof pascal);
FORN(i, MAXN) {
FORN(j, i + 1) pascal[i][j] = 1;
}
build_pascal();
GI(n);
GI(p);
c1 = 0;
c0 = 0;
FORN(i, n) {
int tmp;
GI(tmp);
c1 += tmp&1;
c0 += (tmp&1) == 0;
}
// if (c1 == 0 && c0 > 0 && p == 0) {
// printf("here\n");
// printf("%lld\n", powmod(2, c0));
// return 0;
// }
// printf("c1: %d, c0: %d\n", c1, c0);
LL ans = 0;
if (p == 1) {
for (int tot = 0; tot < n+1; tot++) {
for (int i0 = 0; i0 < min(c0+1, tot) + 1; i0++) {
int i1 = tot - i0;
if (i1 + i0 == 0) continue;
if (i1 > c1) continue;
if ((i1&1) == 0) continue;
ans += pascal[c0][i0] * pascal[c1][i1];
// printf("0: %d, 1: %d, ans %lld\n", i0, i1, ans);
}
}
}
else {
for (int tot = 0; tot < n+1; tot++) {
for (int i0 = 0; i0 < min(c0+1, tot) + 1; i0++) {
int i1 = tot - i0;
// printf(" %d (%d)\n", i1, c1);
if (i1 > c1) continue;
if (i1&1) continue;
// printf(" %d c %d, %d c %d\n", c0, i0, c1, i1);
ans += pascal[c0][i0] * pascal[c1][i1];
// printf("0: %3d, 1: %3d, ans %lld\n", i0, i1, ans);
}
}
}
printf("%lld\n", ans);
return 0;
}
| a.cc:53:1: error: extended character is not valid in an identifier
53 | // pascal's triangle
| ^
a.cc:54:1: error: extended character is not valid in an identifier
54 | // k: 0 1 2 3 4
| ^
a.cc:55:1: error: extended character is not valid in an identifier
55 | // ---------------
| ^
a.cc:56:1: error: extended character is not valid in an identifier
56 | // n: 0| 1 0 0 0 0
| ^
a.cc:57:1: error: extended character is not valid in an identifier
57 | // 1| 1 1 0 0 0
| ^
a.cc:58:1: error: extended character is not valid in an identifier
58 | // 2| 1 2 1 0 0
| ^
a.cc:59:1: error: extended character is not valid in an identifier
59 | // 3| 1 3 3 1 0
| ^
a.cc:60:1: error: extended character is not valid in an identifier
60 | // 4| 1 4 6 4 1
| ^
a.cc:62:1: error: extended character is not valid in an identifier
62 | for (int n = 2; n < MAXN; n++) {
| ^
a.cc:63:1: error: extended character is not valid in an identifier
63 | FOR1(k, n) {
| ^
a.cc:63:3: error: extended character is not valid in an identifier
63 | FOR1(k, n) {
| ^
a.cc:64:1: error: extended character is not valid in an identifier
64 | pascal[n][k] = pascal[n-1][k-1] + pascal[n-1][k];
| ^
a.cc:64:3: error: extended character is not valid in an identifier
64 | pascal[n][k] = pascal[n-1][k-1] + pascal[n-1][k];
| ^
a.cc:64:5: error: extended character is not valid in an identifier
64 | pascal[n][k] = pascal[n-1][k-1] + pascal[n-1][k];
| ^
a.cc:65:1: error: extended character is not valid in an identifier
65 | }
| ^
a.cc:65:3: error: extended character is not valid in an identifier
65 | }
| ^
a.cc:65:6: error: extended character is not valid in an identifier
65 | }
| ^
a.cc:65:8: error: extended character is not valid in an identifier
65 | }
| ^
a.cc:66:1: error: extended character is not valid in an identifier
66 | }
| ^
a.cc:72:1: error: extended character is not valid in an identifier
72 | memset(pascal, 0, sizeof pascal);
| ^
a.cc:73:1: error: extended character is not valid in an identifier
73 | FORN(i, MAXN) {
| ^
a.cc:74:1: error: extended character is not valid in an identifier
74 | FORN(j, i + 1) pascal[i][j] = 1;
| ^
a.cc:74:3: error: extended character is not valid in an identifier
74 | FORN(j, i + 1) pascal[i][j] = 1;
| ^
a.cc:75:1: error: extended character is not valid in an identifier
75 | }
| ^
a.cc:76:1: error: extended character is not valid in an identifier
76 | build_pascal();
| ^
a.cc: In function 'LL build_pascal()':
a.cc:53:1: error: '\U000000a0' was not declared in this scope
53 | // pascal's triangle
| ^
a.cc:62:32: error: expected ';' before ')' token
62 | for (int n = 2; n < MAXN; n++) {
| ^
| ;
a.cc:67:1: warning: no return statement in function returning non-void [-Wreturn-type]
67 | }
| ^
a.cc: In function 'int main()':
a.cc:72:1: error: '\U000000a0' was not declared in this scope
72 | memset(pascal, 0, sizeof pascal);
| ^
a.cc:73:2: error: expected ';' before 'for'
73 | FORN(i, MAXN) {
| ^
| ;
a.cc:73:8: error: 'i' was not declared in this scope
73 | FORN(i, MAXN) {
| ^
a.cc:27:36: note: in definition of macro 'FORN'
27 | #define FORN(i, n) for (int i = 0; i < (int)(n); i++)
| ^
a.cc:76:2: error: expected ';' before 'build_pascal'
76 | build_pascal();
| ^~~~~~~~~~~~~
| ;
|
s257718125 | p03665 | C++ | #include <iostream>
#include <string>
#include <array>
#include <vector>
#include <math.h>
#include <algorithm>
#include <set>
#include <deque>
#include <utility>
#include <map>
#define ll long long int
#define MAX 1000000
using namespace std;
ll cnt = 0;
ll a[55];
ll p;
void search(ll sum, ll i) //i番目の合計
{
if (a[i] == -1) { //終了
return;
}
if ((sum + a[i]) % 2 == p) {
cnt++;
}
search(sum + a[i], i + 1);
search(sum, i + 1);
}
int main(void)
{
ll n;
memset(a, -1, sizeof(a));
cin >> n >> p;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
if (p == 0) {
cnt++;
}
search(0, 0);
cout << cnt << endl;
return (0);
} | a.cc: In function 'int main()':
a.cc:40:9: error: 'memset' was not declared in this scope
40 | memset(a, -1, sizeof(a));
| ^~~~~~
a.cc:11:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
10 | #include <map>
+++ |+#include <cstring>
11 |
|
s788648948 | p03665 | C++ | import java.util.Scanner;
public class Main {
static Scanner sc = new Scanner(System.in);
static int N = sc.nextInt();
static int P = sc.nextInt();
static int A[] = new int[N];
public static void main(String[] args) {
for(int i=0; i < N; i++) {
A[i] = sc.nextInt();
}
int evenCount = 0;
int oddCount = 0;
for(int i=0; i < N; i++) {
if (A[i] % 2 == 0) {
evenCount ++;
} else {
oddCount ++;
}
}
long a = 0;
for(int i=0; i <= oddCount; i += 2) {
a += combination(oddCount, i);
}
if(oddCount == 0) {
a = 0;
}
long b = (int)Math.pow(2, evenCount);
long result = b * a;
System.out.println(result);
}
static long combination( int n, int m ) {
long c = 1;
m = ( n - m < m ? n - m : m );
for( int ns = n - m + 1, ms = 1; ms <= m; ns ++, ms ++ ) {
c *= ns;
c /= ms;
}
return c;
}
}
| a.cc:1:1: error: 'import' does not name a type
1 | import java.util.Scanner;
| ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: expected unqualified-id before 'public'
3 | public class Main {
| ^~~~~~
|
s572963886 | p03665 | C++ | #include <iostream>
#include <string>
#include <array>
#include <vector>
#include <math.h>
#include <algorithm>
#include <set>
#include <deque>
#include <utility>
#include <map>
#define ll long long int
#define MAX 1000000
using namespace std;
ll cnt = 0;
ll a[55];
ll p;
void search(ll sum, ll i) //i番目の合計
{
if (a[i] == -1) { //終了
return;
}
if ((sum + a[i]) % 2 == p) {
cnt++;
}
search(sum + a[i], i + 1);
search(sum, i + 1);
}
int main(void)
{
ll n;
memset(a, -1, sizeof(a));
cin >> n >> p;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
if (p == 0) {
cnt++;
}
search(0, 0);
cout << cnt << endl;
return (0);
}
| a.cc: In function 'int main()':
a.cc:40:9: error: 'memset' was not declared in this scope
40 | memset(a, -1, sizeof(a));
| ^~~~~~
a.cc:11:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
10 | #include <map>
+++ |+#include <cstring>
11 |
|
s212423033 | p03665 | C++ | #include <iostream>
int main (void) {
int N, P;
int A[110];
std::cin >> N >> P;
int i;
int odd = 0;
int even = 0;
for (i=0;i<N;i++) {
std::cin >> A[i];
if (A[i]%2==1) {
odd++;
} else {
even++;
}
}
// if (P%2==1) {
// odd--;
// }
long long int ans;
if (odd==0 && P==1) {
ans = 0;
} else {
ans = 1;
if (odd>1) {
for (i=0;i<(odd-1);i++) {
ans *= 2;
}
}
for (i=0;i<even;i++) {
ans *= 2;
}
}
std::cout << ans << std::endl;
return 0;#include <iostream>
int main (void) {
int N, P;
int A[110];
std::cin >> N >> P;
int i;
int odd = 0;
int even = 0;
for (i=0;i<N;i++) {
std::cin >> A[i];
if (A[i]%2==1) {
odd++;
} else {
even++;
}
}
// if (P%2==1) {
// odd--;
// }
long long int ans;
if (odd==0 && P==1) {
ans = 0;
} else {
ans = 1;
if (odd>1) {
for (i=0;i<(odd-1);i++) {
ans *= 2;
}
}
for (i=0;i<even;i++) {
ans *= 2;
}
}
std::cout << ans << std::endl;
return 0;
}
}
| a.cc:41:12: error: stray '#' in program
41 | return 0;#include <iostream>
| ^
a.cc: In function 'int main()':
a.cc:41:13: error: 'include' was not declared in this scope
41 | return 0;#include <iostream>
| ^~~~~~~
a.cc:41:22: error: 'iostream' was not declared in this scope; did you mean 'std::iostream'?
41 | return 0;#include <iostream>
| ^~~~~~~~
| std::iostream
In file included from /usr/include/c++/14/ios:40,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/iosfwd:146:41: note: 'std::iostream' declared here
146 | typedef basic_iostream<char> iostream;
| ^~~~~~~~
a.cc:43:1: error: expected primary-expression before 'int'
43 | int main (void) {
| ^~~
|
s977282136 | p03665 | C | //Written by Zhu Zeqi
//Come on,baby
//Hack,please
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define MAX 100000000000000000
#define MOD 1000000007
#define PI 3.141592653589793238462
#define INF 1000000000
typedef long long ll;
using namespace std;
ll a[55],ans;
ll comb(ll n,ll k)
{
if(n==k || k==0)
return 1;
else
return comb(n-1,k)+comb(n-1,k-1);
}
int main(){
//freopen("input.in","r",stdin);
//freopen("output.out","w",stdout);
ll n,p,cnt1=0,cnt2=0;
cin>>n>>p;
for(ll i=1;i<=n;i++)
cin>>a[i];
if(p==0){
ans=1;
for(ll i=1;i<=n;i++)
if(a[i]%2==0)
cnt1++;
else
cnt2++;
if(cnt1>=1)
for(ll j=1;j<=cnt1;j++){
ans+=comb(cnt1,j);
}
if(cnt2>=2)
for(ll j=2;j<=cnt2;j+=2){
ans+=comb(cnt2,j);
}
cout<<ans;
}
else{
int sol=0;
ans=0;
for(ll i=1;i<=n;i++)
if(a[i]%2==0)
cnt1++;
else
cnt2++;
if(cnt1>=1)
for(ll j=1;j<=cnt1;j++){
sol+=comb(cnt1,j);
}
if(cnt2>=1)
for(ll j=1;j<=cnt2;j+=2){
ans+=comb(cnt2,j);
}
cout<<ans*(sol+1);
}
//system("pause");
return 0;
} | main.c:4:9: fatal error: cmath: No such file or directory
4 | #include<cmath>
| ^~~~~~~
compilation terminated.
|
s131191777 | p03665 | C++ | #include <iostream>
#include <string>
#include <vector>
using namespace std;
unsigned long long nCr(int n, int r) {
unsigned long long ans = 1;
for (int i = n; i > n - r; --i) {
ans = ans*i;
}
for (int i = 1; i < r + 1; ++i) {
ans = ans / i;
}
return ans;
}
int main(void)
{
int N, P, a0 = 0, a1 = 0;
cin >> N >> P;
vector<int> A(N);
unsigned long long int ans = 0;
for (int i = 0; i < N; i++) {
cin >> A[i];
if (A[i] % 2) {
a1++;
} else {
a0++;
}
}
if (P==0) {
ans += 1;
for (int i = 1; i <= a0; i++) {
ans *= i;
}
for (int i = 1; i <= a1; i++) {
ans *= i;
}ans /= 2;
ans+=1;
} else {
if (a1 == 0) {
cout << "0" << endl;
return 0;
}
for (int i = 1; i <= round(a1/2); i+=2) {
ans += nCr(a1,i);
}ans *= 2;
for (int i = 1; i <= a0; i++) {
ans *= 2;
}
}
cout << ans << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:47:38: error: 'round' was not declared in this scope
47 | for (int i = 1; i <= round(a1/2); i+=2) {
| ^~~~~
|
s955990994 | p03665 | C++ | #include <stdio.h>
#include <iostream>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>
#include <stack>
#include <vector>
#include <map>
#include <ctime>
#include <string.h>
#define inf 0x7fffffff
using namespace std;
int a,b,c,n,m,d,k,l[300010],o[300100][3],i;
int j[201000][10]={{1,0,-1,0},{0,-1,0,1}};
long long z[110][60][2],x,y;
char r[300],r1[600];
//deque<int> d;
vector<int> v[101000];
//A 65 a 97
//z 122 Z 90
/*struct P
{
int x,y;
bool operator<(const P &a)const
{
//printf("#%d %d\n",o[x],o[y]);
return min(o[x],o[y])>min(o[a.x],o[a.y]);
}
};*/
queue<int> q;
int f(int t,int w)
{
if(t==a&&w==b) return 1;
if(t==a) return 0;
if(o[t][w]>=0) return o[t][w];
i=( (w+o[t]) % 2);
return o[t][w]=f(t+1,i)+f(t+1,w);
}
int main()
{
memset(o,-1,sizeof(o));
scanf("%d %d",&a,&b);
for(int t=0;t<a;t++)
scanf("%d",&o[t]);
printf("%d",f(0,0));
}
| a.cc: In function 'int f(int, int)':
a.cc:41:18: error: invalid operands of types 'int*' and 'int' to binary 'operator%'
41 | i=( (w+o[t]) % 2);
| ~~~~~~~~ ^ ~
| | |
| int* int
|
s881847515 | p03665 | C++ | #include <iostream>
using namespace std;
typedef long long ll;
int n, a[50], p, b = 0, c = 0;
ll nPr(ll n, ll r) {
ll res = 1;
for (int i = 0; i < r; i++) {
res *= (n - i);
}
return res;
}
ll nCr(ll n, ll r) {
//ll res = nPr(n, r) / nPr(r, r);
double res = 1;
for (int i = 0; i < r; i++) {
res *= (n - i);
res /= (i+1);
}
return (ll)res;
}
int main() {
cin >> n >> p;
for (int i = 0; i < n; i++) {
cin >> a[i];
if (a[i] % 2 == 0) {
b++;
}
else {
c++;
}
}
//cout << "b:" << b << " c:" << c << endl;
ll bsum = 0, csum = 0;
bsum = (ll)pow(2, b);
if (p == 0) {
for (int i = 0; i <= c; i++) {
if (i % 2 == 0) {
csum += nCr(c, i);
}
}
}
else {
for (int i = 0; i <= c; i++) {
if (i % 2 == 1) {
csum += nCr(c, i);
}
}
}
ll ans = bsum*csum;
cout << ans << endl;
} | a.cc: In function 'int main()':
a.cc:40:20: error: 'pow' was not declared in this scope
40 | bsum = (ll)pow(2, b);
| ^~~
|
s064474765 | p03665 | C++ | #include <iostream>
using namespace std;
typedef long long ll;
int n, a[50], p, b = 0, c = 0;
ll nPr(ll n, ll r) {
ll res = 1;
for (int i = 0; i < r; i++) {
res *= (n - i);
}
return res;
}
ll nCr(ll n, ll r) {
//ll res = nPr(n, r) / nPr(r, r);
double res = 1;
for (int i = 0; i < r; i++) {
res *= (n - i);
res /= (i+1);
}
return (ll)res;
}
int main() {
cin >> n >> p;
for (int i = 0; i < n; i++) {
cin >> a[i];
if (a[i] % 2 == 0) {
b++;
}
else {
c++;
}
}
//cout << "b:" << b << " c:" << c << endl;
ll bsum = 0, csum = 0;
bsum = pow(2, b);
if (p == 0) {
for (int i = 0; i <= c; i++) {
if (i % 2 == 0) {
csum += nCr(c, i);
}
}
}
else {
for (int i = 0; i <= c; i++) {
if (i % 2 == 1) {
csum += nCr(c, i);
}
}
}
ll ans = bsum*csum;
cout << ans << endl;
} | a.cc: In function 'int main()':
a.cc:40:16: error: 'pow' was not declared in this scope
40 | bsum = pow(2, b);
| ^~~
|
s675878207 | p03665 | C++ | #include<iostream>
#include<utility>
#include<tuple>
#include<set>
#include<list>
#include<vector>
#include<map>
#include<algorithm>
#include<queue>
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FUNCTION__ << endl;
#define int long long
const long long MAXN = 100;
const long long MOD = 1e9+7;
const long long INF = __LONG_LONG_MAX__ / 2;
using namespace std;
int hoge[MAXN];
constexpr int power(int b, int i){
if (i == 1) return b % MOD;
if (i % 2 == 0) {
return power(b*b % MOD, i/2) ;
} else {
return power(b*b % MOD, i/2)*b % MOD ;
}
}
constexpr int factseed(int n){
if (n == 0 ) return 1;
return (n * (factseed(n-1))) % MOD;
}
constexpr int invMod(int n){
return power(n,MOD - 2);
}
template<int N>
struct Facts {
constexpr Facts() : arr() {
for (auto i = 0; i != N; ++i){
arr[i] = factseed(i);
}
}
int arr[N];
};
constexpr auto facts = Facts<MAXN>();
constexpr int fact(int n){
return facts.arr[n];
}
template<int N>
struct Finv {
constexpr Finv() : arr() {
for (auto i = 0; i != N; ++i){
arr[i] = invMod(fact(i));
}
}
int arr[N];
};
constexpr auto finvs = Finv<MAXN>();
int combination(int m, int n){
if(m<0 || n < 0 || m < n) return 0;
return (((fact(m)*invMod(fact(n))) % MOD) * invMod(fact(m-n))) % MOD;
}
int perm(int m,int n){
if (n == 0) return 1;
return m * (perm (m-1, n-1));
}
signed main(){
int N, P;
cin >> N >> P;
int even_counts = 0;
int odd_counts = 0;
for (int i = 0; i < N; i++){
int a;
cin >> a;
if (a % 2 == 0){
even_counts++;
}
}
odd_counts = N - even_counts;
if (P == 0){// must be even
int prod = 0;
for(int i = 0; i<= odd_counts / 2 ; i += 2){
prod += combination(odd_counts, i);
}
printf("%lld\n",prod *(int)pow(2, even_counts + 1));
} else {
int prod = 0;
for(int i = 1; i<= odd_counts / 2 ; i += 2){
prod += combination(odd_counts, i);
}
printf("%lld\n",prod *(int)pow(2, even_counts + 1));
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:97:34: error: 'pow' was not declared in this scope
97 | printf("%lld\n",prod *(int)pow(2, even_counts + 1));
| ^~~
a.cc:103:34: error: 'pow' was not declared in this scope
103 | printf("%lld\n",prod *(int)pow(2, even_counts + 1));
| ^~~
|
s362956392 | p03665 | C++ | #include<iostream>
#include<utility>
#include<tuple>
#include<set>
#include<list>
#include<vector>
#include<map>
#include<algorithm>
#include<queue>
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FUNCTION__ << endl;
#define int long long
const long long MAXN = 100;
const long long MOD = 1e9+7;
const long long INF = __LONG_LONG_MAX__ / 2;
using namespace std;
int hoge[MAXN];
constexpr int power(int b, int i){
if (i == 1) return b % MOD;
if (i % 2 == 0) {
return power(b*b % MOD, i/2) ;
} else {
return power(b*b % MOD, i/2)*b % MOD ;
}
}
constexpr int factₛeed(int n){
if (n == 0 ) return 1;
return (n * (factₛeed(n-1))) % MOD;
}
constexpr int invMod(int n){
return power(n,MOD - 2);
}
template<int N>
struct Facts {
constexpr Facts() : arr() {
for (auto i = 0; i != N; ++i){
arr[i] = factₛeed(i);
}
}
int arr[N];
};
constexpr auto facts = Facts<MAXN>();
constexpr int fact(int n){
return facts.arr[n];
}
template<int N>
struct Finv {
constexpr Finv() : arr() {
for (auto i = 0; i != N; ++i){
arr[i] = invMod(fact(i));
}
}
int arr[N];
};
constexpr auto finvs = Finv<MAXN>();
int combination(int m, int n){
if(m<0 || n < 0 || m < n) return 0;
return (((fact(m)*invMod(fact(n))) % MOD) * invMod(fact(m-n))) % MOD;
}
int perm(int m,int n){
if (n == 0) return 1;
return m * (perm (m-1, n-1));
}
signed main(){
int N, P;
cin >> N >> P;
int even_counts = 0;
int odd_counts = 0;
for (int i = 0; i < N; i++){
int a;
cin >> a;
if (a % 2 == 0){
even_counts++;
}
}
odd_counts = N - even_counts;
if (P == 0){// must be even
int prod = 0;
for(int i = 0; i<= odd_counts / 2 ; i += 2){
prod += combination(odd_counts, i);
}
printf("%lld\n",prod *(int)pow(2, even_counts + 1));
} else {
int prod = 0;
for(int i = 1; i<= odd_counts / 2 ; i += 2){
prod += combination(odd_counts, i);
}
printf("%lld\n",prod *(int)pow(2, even_counts + 1));
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:97:34: error: 'pow' was not declared in this scope
97 | printf("%lld\n",prod *(int)pow(2, even_counts + 1));
| ^~~
a.cc:103:34: error: 'pow' was not declared in this scope
103 | printf("%lld\n",prod *(int)pow(2, even_counts + 1));
| ^~~
|
s142672903 | p03665 | C++ | #include<iostream>
#include<utility>
#include<tuple>
#include<set>
#include<list>
#include<vector>
#include<map>
#include<algorithm>
#include<queue>
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FUNCTION__ << endl;
#define int long long
const long long MAXN = 100;
const long long MOD = 1e9+7;
const long long INF = __LONG_LONG_MAX__ / 2;
using namespace std;
int hoge[MAXN];
constexpr int power(int b, int i){
if (i == 1) return b % MOD;
if (i % 2 == 0) {
return power(b*b % MOD, i/2) ;
} else {
return power(b*b % MOD, i/2)*b % MOD ;
}
}
constexpr int factₛeed(int n){
if (n == 0 ) return 1;
return (n * (factₛeed(n-1))) % MOD;
}
constexpr int invMod(int n){
return power(n,MOD - 2);
}
template<int N>
struct Facts {
constexpr Facts() : arr() {
for (auto i = 0; i != N; ++i){
arr[i] = factₛeed(i);
}
}
int arr[N];
};
constexpr auto facts = Facts<MAXN>();
constexpr int fact(int n){
return facts.arr[n];
}
template<int N>
struct Finv {
constexpr Finv() : arr() {
for (auto i = 0; i != N; ++i){
arr[i] = invMod(fact(i));
}
}
int arr[N];
};
constexpr auto finvs = Finv<MAXN>();
int combination(int m, int n){
if(m<0 || n < 0 || m < n) return 0;
return (((fact(m)*invMod(fact(n))) % MOD) * invMod(fact(m-n))) % MOD;
}
int perm(int m,int n){
if (n == 0) return 1;
return m * (perm (m-1, n-1));
}
signed main(){
int N, P;
cin >> N >> P;
int even_counts = 0;
int odd_counts = 0;
for (int i = 0; i < N; i++){
int a;
cin >> a;
if (a % 2 == 0){
even_counts++;
}
}
odd_counts = N - even_counts;
if (P == 0){// must be even
int prod = 0;
for(int i = 0; i<= odd_counts / 2 ; i += 2){
prod += combination(odd_counts, i);
}
printf("%lld\n",prod *(int)pow(2, even_counts + 1));
} else {
int prod = 0;
for(int i = 1; i<= odd_counts / 2 ; i += 2){
prod += combination(odd_counts, i);
}
printf("%lld\n",prod *(int)pow(2, even_counts + 1));
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:97:34: error: 'pow' was not declared in this scope
97 | printf("%lld\n",prod *(int)pow(2, even_counts + 1));
| ^~~
a.cc:103:34: error: 'pow' was not declared in this scope
103 | printf("%lld\n",prod *(int)pow(2, even_counts + 1));
| ^~~
|
s293453349 | p03665 | C++ | #include<bits/stdc++.h>
using namespace std;
int num[100];
int p,n;
long long C(int n,int m)
{
if(n<m) return 0;
long long ans=1;
for(int i=0;i<m;i++) ans=ans*(long long)(n-i)/(long long)(i+1);
return ans;
}
long long A(int n,int m)
{
if(n<m) return 0;
long long ans=1;
for(int i=0;i<m;i++) ans*=(long long)(n-i);
return ans;
}
signedmain(){
int Numz=0;
int Numo=0;
cin>>n>>p;
for(int i=1;i<=n;i++){
cin>>num[i];
num[i]%=2;
if(num[i]==0){
Numz++;
}else{
Numo++;
}
}
long long ans=0;
if(p==0){
for(int i=0;i<=Numz;i++){
long long pos=C(Numz,i);
for(int j=0;j<=Numo;j+=2){
long long base=C(Numo,j);
ans+=(pos*base);
}
}
cout<<ans<<endl;
}else if(p==1){
for(int i=0;i<=Numz;i++){
long long pos=C(Numz,i);
for(int j=1;j<=Numo;j+=2){
long long base=C(Numo,j);
ans+=(pos*base);
}
}
cout<<ans<<endl;
}
return 0;
}
| a.cc:19:1: error: ISO C++ forbids declaration of 'signedmain' with no type [-fpermissive]
19 | signedmain(){
| ^~~~~~~~~~
|
s673366235 | p03665 | C++ | #include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
using namespace std;
typedef __int64 ll;
int main()
{
int n,p;
int a;
ll odd = 0;
ll even = 0;
ll er[55];
er[0] = 1;
for(int i = 1; i <= 50; i++)
{
er[i] = er[i-1]<<1;
}
cin>>n>>p;
for(int i = 0 ; i < n; i++)
{
cin>>a;
if( a & 1 )
odd++;
else
even++;
}
ll ans = er[even];
if( 0 == p)
{
if( odd & 1)
{
ans *= er[odd - 1];
}
else
{
if( odd > 0)
ans *= er[odd - 1];
}
}
else
{
if( 0 == odd)
ans = 0;
else
{
if( odd & 1)
{
ans *= er[odd - 1];
}
else
{
ans *= er[odd - 1];
}
}
}
printf("%I64d\n", ans);
//system("pause");
} | a.cc:8:9: error: '__int64' does not name a type; did you mean '__int64_t'?
8 | typedef __int64 ll;
| ^~~~~~~
| __int64_t
a.cc: In function 'int main()':
a.cc:14:9: error: 'll' was not declared in this scope
14 | ll odd = 0;
| ^~
a.cc:15:11: error: expected ';' before 'even'
15 | ll even = 0;
| ^~~~~
| ;
a.cc:16:11: error: expected ';' before 'er'
16 | ll er[55];
| ^~~
| ;
a.cc:17:9: error: 'er' was not declared in this scope
17 | er[0] = 1;
| ^~
a.cc:27:25: error: 'odd' was not declared in this scope
27 | odd++;
| ^~~
a.cc:29:25: error: 'even' was not declared in this scope
29 | even++;
| ^~~~
a.cc:31:11: error: expected ';' before 'ans'
31 | ll ans = er[even];
| ^~~~
| ;
a.cc:34:21: error: 'odd' was not declared in this scope
34 | if( odd & 1)
| ^~~
a.cc:36:25: error: 'ans' was not declared in this scope; did you mean 'abs'?
36 | ans *= er[odd - 1];
| ^~~
| abs
a.cc:41:33: error: 'ans' was not declared in this scope; did you mean 'abs'?
41 | ans *= er[odd - 1];
| ^~~
| abs
a.cc:46:26: error: 'odd' was not declared in this scope
46 | if( 0 == odd)
| ^~~
a.cc:47:25: error: 'ans' was not declared in this scope; did you mean 'abs'?
47 | ans = 0;
| ^~~
| abs
a.cc:52:33: error: 'ans' was not declared in this scope; did you mean 'abs'?
52 | ans *= er[odd - 1];
| ^~~
| abs
a.cc:56:33: error: 'ans' was not declared in this scope; did you mean 'abs'?
56 | ans *= er[odd - 1];
| ^~~
| abs
a.cc:60:27: error: 'ans' was not declared in this scope; did you mean 'abs'?
60 | printf("%I64d\n", ans);
| ^~~
| abs
|
s606352168 | p03665 | C++ | #include <iostream>
using namespace std;
int main()
{
int n,p,bis[51],mol,k=0,he[51],ti[51];
cin>>n>>p;
for(int var1=1;var1<=n;var1++)
{
cin>>bis[var1];
}
memset(he,0,sizeof(he));
bis[0]=0;
he[0]=0;
if(p%2==0) k++;
for(int var1=1;var1<=n;var1++)
{
for(int var2=1;var2<=n+1-var1;var2++)
{
he[var1]=bis[var1]+he[var1];
ti[var1]=he[var1];
}
}
for(int var1=1;var1<=n;var1++)
{
for(int var2=1;var2<=n-1;var2++)
{
he[var1]=he[var1]-bis[var2];
if(he[var1]%2==p) k++;
}
he[var1]=ti[var1];
}
cout<<k;
return 0;
} | a.cc: In function 'int main()':
a.cc:11:9: error: 'memset' was not declared in this scope
11 | memset(he,0,sizeof(he));
| ^~~~~~
a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
1 | #include <iostream>
+++ |+#include <cstring>
2 | using namespace std;
|
s426337897 | p03665 | Java | import java.math.BigInteger;
import java.util.Scanner;
public class A {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int N = scan.nextInt();
int P = scan.nextInt();
if(P==0){
BigInteger a = new BigInteger("2");
a = a.pow((N-1));
System.out.println(a.toString());
}else{
BigInteger a = new BigInteger("2");
a = a.pow((N-1));
BigInteger b = new BigInteger("2");
b = b.pow(N);
b = b.subtract(a);
System.out.println(b.toString());
}
}
}
| Main.java:4: error: class A is public, should be declared in a file named A.java
public class A {
^
1 error
|
s767153429 | p03665 | C++ | #include<iostream>
#include<utility>
#include<tuple>
#include<set>
#include<list>
#include<vector>
#include<map>
#include<algorithm>
#include<queue>
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FUNCTION__ << endl;
#define int long long
const long long MAXN = 100;
const long long MOD = 1e9+7;
const long long INF = __LONG_LONG_MAX__ / 2;
using namespace std;
int hoge[MAXN];
constexpr int power(int b, int i){
if (i == 1) return b % MOD;
if (i % 2 == 0) {
return power(b*b % MOD, i/2) ;
} else {
return power(b*b % MOD, i/2)*b % MOD ;
}
}
constexpr int factₛeed(int n){
if (n == 0 ) return 1;
return (n * (factₛeed(n-1))) % MOD;
}
constexpr int invMod(int n){
return power(n,MOD - 2);
}
template<int N>
struct Facts {
constexpr Facts() : arr() {
for (auto i = 0; i != N; ++i){
arr[i] = factₛeed(i);
}
}
int arr[N];
};
constexpr auto facts = Facts<MAXN>();
constexpr int fact(int n){
return facts.arr[n];
}
template<int N>
struct Finv {
constexpr Finv() : arr() {
for (auto i = 0; i != N; ++i){
arr[i] = invMod(fact(i));
}
}
int arr[N];
};
constexpr auto finvs = Finv<MAXN>();
int combination(int m, int n){
if(m<0 || n < 0 || m < n) return 0;
return (((fact(m)*invMod(fact(n))) % MOD) * invMod(fact(m-n))) % MOD;
}
int perm(int m,int n){
if (n == 0) return 1;
return m * (perm (m-1, n-1));
}
signed main(){
int N, P;
cin >> N >> P;
int even_counts = 0;
int odd_counts = 0;
for (int i = 0; i < N; i++){
int a;
cin >> a;
if (a % 2 == 0){
even_counts++;
}
}
odd_counts = N - even_counts;
if (P == 0){// must be even
int prod = 0;
for(int i = 0; i<= odd_counts / 2 ; i += 2){
prod += combination(odd_counts, i);
}
printf("%lld\n",prod *(int)pow(2, even_counts + 1));
} else {
int prod = 0;
for(int i = 1; i<= odd_counts / 2 ; i += 2){
prod += combination(odd_counts, i);
}
printf("%lld\n",prod *(int)pow(2, even_counts + 1));
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:97:34: error: 'pow' was not declared in this scope
97 | printf("%lld\n",prod *(int)pow(2, even_counts + 1));
| ^~~
a.cc:103:34: error: 'pow' was not declared in this scope
103 | printf("%lld\n",prod *(int)pow(2, even_counts + 1));
| ^~~
|
s782034958 | p03665 | C++ | #include<iostream>
#include<algorithm>
#include<cmath>
int a[55];
using namespace std;
int f(int n){
if(n==0)
return 0;
if(n==1)
return 1;
return a(n-1)+a(n-2);
}
int main()
{
int n,p,temp;
cin>>n>>p;
for(int i=1;i<=n;i++)cin>>a[i];
temp=f(i);
if(temp%n!=p)
cout<<0;
}
| a.cc: In function 'int f(int)':
a.cc:12:13: error: 'a' cannot be used as a function
12 | return a(n-1)+a(n-2);
| ~^~~~~
a.cc:12:20: error: 'a' cannot be used as a function
12 | return a(n-1)+a(n-2);
| ~^~~~~
a.cc: In function 'int main()':
a.cc:19:16: error: 'i' was not declared in this scope
19 | temp=f(i);
| ^
|
s185697825 | p03665 | C++ | #include <vector>
#include <algorithm>
#include <string>
#include <iostream>
using namespace std;
int res = 0;
int main() {
int N, P;
cin >> N >> P;
vector<int> nums(N, 0);
for (int i = 0; i < N; i++) {
cin >> nums[i];
}
long long size = pow(2, N);
for (long long i = 0; i < size; i++) {
long long j = i;
int sum = 0;
int index = 0;
while (j) {
if (j & 1) {
sum += nums[index];
}
j >>= 1;
index++;
}
if (sum % 2 == P % 2) {
res++;
}
}
cout << res << endl;
} | a.cc: In function 'int main()':
a.cc:15:26: error: 'pow' was not declared in this scope
15 | long long size = pow(2, N);
| ^~~
|
s552688897 | p03665 | C++ | #include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
long long n,p;
long long l=0,r=0;
long long a[55];
long long d[55][55];
int main()
{
cin >> n >> p;
for(int i=0; i<n; i++)
{
cin >> a[i];
if(a[i]%2)
l++;
else
r++;
}
d[0][0]=1;
for(int i=1; i<51; i++)
{
for(int j=0; j<=i; j++)
{
d[i][j]=d[i-1][j]+d[i-1][j-1];
}
}
long long ans=0;
if(!p)
{
for(int i=0; i<=l; i+=2)
{
ans+=d[l][i];
}
for(int i=0;i<rm;i++)
{
ans*=2;
}
}
else
{
for(int i=1; i<=l; i+=2)
{
ans+=d[l][i];
}
for(int i=0;i<r;i++)
{
ans*=2;
}
}
cout << ans << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:39:23: error: 'rm' was not declared in this scope; did you mean 'tm'?
39 | for(int i=0;i<rm;i++)
| ^~
| tm
|
s404208663 | p03665 | C++ |
//#define NDEBUG
#include <iostream>
#include <array>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <memory>
#include <cassert>
#include <functional>
#include <chrono>
#ifdef NDEBUG
#define vcerr NullStream()
#else
#define vcerr std::cerr
#endif
using namespace std;
namespace ValLib {
const int MOD = 1000000007;
typedef unsigned long long ull;
template<typename Key, typename Value>
using umap = std::unordered_map<Key, Value>;
template<typename T>
using uset = std::unordered_set<T>;
template <typename T>
using sptr = typename std::shared_ptr<T>;
class vnode;
class vegde;
class vgraph;
class NullStream {
public:
template<typename T> NullStream& operator<<(T const&) { return *this; }
};
template<typename T>
void fill(vector<T>& vec, const T& value) {
std::fill(vec.begin(), vec.end(), value);
}
template<typename T>
void fill(vector<vector<T>>& vec, const T& value) {
for (vector<T>& t : vec) std::fill(t.begin(), t.end(), value);
}
template<typename T>
void resize(vector<vector<T>>& vec, int size1, int size2) {
vec.resize(size1);
for (vector<T>& t : vec) t.resize(size2);
}
int accumulate(const vector<int>& vec) {
return std::accumulate(vec.begin(), vec.end(), 0);
}
template <typename _Pr>
int accumulate(const vector<int>& vec, _Pr func) {
return std::accumulate(vec.begin(), vec.end(), 0, func);
}
double accumulate(const vector<double>& vec) {
return std::accumulate(vec.begin(), vec.end(), 0.0);
}
template <typename _Pr>
double accumulate(const vector<double>& vec, _Pr func) {
return std::accumulate(vec.begin(), vec.end(), 0.0, func);
}
float accumulate(const vector<float>& vec) {
return std::accumulate(vec.begin(), vec.end(), 0.f);
}
template <typename _Pr>
float accumulate(const vector<float>& vec, _Pr func) {
return std::accumulate(vec.begin(), vec.end(), 0.f, func);
}
template <typename T, typename _Pr>
bool all_of(const vector<T>& vec, _Pr pred) {
return std::all_of(vec.begin(), vec.end(), pred);
}
template <typename T, typename _Pr>
bool any_of(const vector<T>& vec, _Pr pred) {
return std::any_of(vec.begin(), vec.end(), pred);
}
template <typename T, typename _Pr>
bool none_of(const vector<T>& vec, _Pr pred) {
return std::none_of(vec.begin(), vec.end(), pred);
}
template <typename T>
bool contains(const vector<T>& vec, const T& val) {
return std::find(vec.begin(), vec.end(), val) != vec.end();
}
template <typename T, typename _Pr>
bool contains_if(const vector<T>& vec, _Pr pred) {
return std::find_if(vec.begin(), vec.end(), pred) != vec.end();
}
template<typename T, size_t N>
void fill(array<T, N>& ary, const T& value) {
std::fill(ary.begin(), ary.end(), value);
}
template<typename T, size_t N, size_t M>
void fill(array<array<T, M>, N>& ary, const T& value) {
for (array<T, M>& t : ary) std::fill(t.begin(), t.end(), value);
}
template <size_t N>
int accumulate(const array<int, N>& ary) {
return std::accumulate(ary.begin(), ary.end(), 0);
}
template <size_t N, typename _Pr>
int accumulate(const array<int, N>& ary, _Pr func) {
return std::accumulate(ary.begin(), ary.end(), 0, func);
}
template <size_t N>
double accumulate(const array<double, N>& ary) {
return std::accumulate(ary.begin(), ary.end(), 0.0);
}
template <size_t N, typename _Pr>
double accumulate(const array<double, N>& ary, _Pr func) {
return std::accumulate(ary.begin(), ary.end(), 0.0, func);
}
template <size_t N>
float accumulate(const array<float, N>& ary) {
return std::accumulate(ary.begin(), ary.end(), 0.f);
}
template <size_t N, typename _Pr>
float accumulate(const array<float, N>& ary, _Pr func) {
return std::accumulate(ary.begin(), ary.end(), 0.f, func);
}
template <typename T, size_t N, typename _Pr>
bool all_of(const array<T, N>& ary, _Pr pred) {
return std::all_of(ary.begin(), ary.end(), pred);
}
template <typename T, size_t N, typename _Pr>
bool any_of(const array<T, N>& ary, _Pr pred) {
return std::any_of(ary.begin(), ary.end(), pred);
}
template <typename T, size_t N, typename _Pr>
bool none_of(const array<T, N>& ary, _Pr pred) {
return std::none_of(ary.begin(), ary.end(), pred);
}
template <typename T, size_t N>
bool contains(const array<T, N>& ary, const T& val) {
return std::find(ary.begin(), ary.end(), val) != ary.end();
}
template <typename T, size_t N, typename _Pr>
bool contains_if(const array<T, N>& ary, _Pr pred) {
return std::find_if(ary.begin(), ary.end(), pred) != ary.end();
}
template<typename Key, typename Value>
bool containsKey(const umap<Key, Value>& m, const Key& key) {
return m.find(key) != m.end();
}
template<typename Key, typename Value>
bool containsValue(const umap<Key, Value>& m, const Value& val) {
for (auto it = m.begin(); it != m.end(); ++it)
if (it->second == val)
return true;
return false;
}
template<typename T>
bool contains(const uset<T>& s, const T& key) {
return s.find(key) != s.end();
}
void test() {
vector<int> v = {};
bool c = contains(v, 2);
int x = count_if(v, [](int y) { return y <= 0; });
cout << x << endl;
uset<int> s;
s.insert(1);
s.insert(4);
s.insert(1);
s.insert(2);
bool bb = contains(s, 1);
cout << bb << endl;
bb = contains(s, 3);
cout << bb << endl;
umap<int, string> m;
m[0] = "a";
m[4] = "b";
m[2] = "c";
auto au = m.find(4);
if (au != m.end()) {
string val = (*au).second;
}
bool b = containsKey(m, 1);
cout << b << endl;
b = containsKey(m, 3);
cout << b << endl;
b = containsValue(m, string("a"));
cout << b << endl;
b = containsValue(m, string("d"));
cout << b << endl;
getchar();
getchar();
}
class Point {
public:
inline Point() :
x(-1),
y(-1)
{}
inline Point(int _x, int _y) :
x(_x),
y(_y)
{}
static Point getDistance(const Point& p1, const Point& p2) {
return move(Point(abs(p1.x - p2.x), abs(p1.y - p2.y)));
}
void setPos(const Point& pos) { x = pos.x; y = pos.y; }
void setPos(int x, int y) { this->x = x; this->y = y; }
Point operator+ (const Point &p) const { return move(Point(x + p.x, y + p.y)); }
Point operator- (const Point &p) const { return move(Point(x - p.x, y - p.y)); }
void operator+= (const Point &p) { x += p.x; y += p.y; }
void operator-= (const Point &p) { x -= p.x; y -= p.y; }
bool operator== (const Point &p) const { return x == p.x && y == p.y; }
bool operator!= (const Point &p) const { return x != p.x || y != p.y; }
//bool operator<(const Point &p) const {return x * x + y * y < p.x * p.x + p.y * p.y;}
const Point& getPos() const { return *this; }
string to_string() const { return "(" + std::to_string(x) + ", " + std::to_string(y) + ")"; }
int x;
int y;
};
/// <summary>
/// 素集合データ構造
/// </summary>
class UnionFind {
public:
/// <summary>
/// コンストラクタ
/// </summary>
/// <param name="N">要素数</param>
UnionFind(int N) {
parent.resize(N);
for (int i = 0; i < N; ++i) {
parent[i] = i;
}
}
/// <summary>
/// 要素xの根を探索
/// </summary>
/// <param name="x">探索する要素番号(0~N-1)</param>
/// <returns>要素xの根(0~N-1)</returns>
int find(int x) {
if (parent[x] == x) {
return x;
} else {
parent[x] = find(parent[x]); // 経路圧縮(間接的な要素をrootに直接つなぐ)
return parent[x];
}
}
/// <summary>
/// 2つの要素の根が同じか
/// </summary>
/// <param name="x1">探索する要素番号1(0~N-1)</param>
/// <param name="x2">探索する要素番号2(0~N-1)</param>
/// <returns>true: 同じ根, false: 異なる根</returns>
bool same(int x1, int x2) {
return find(x1) == find(x2);
}
/// <summary>
/// 2つの要素の根同士を繋ぐ
/// </summary>
/// <param name="x1">要素番号1(0~N-1)</param>
/// <param name="x2">要素番号1(0~N-1)</param>
void union_elements(int x1, int x2) {
int rootX1 = find(x1);
int rootX2 = find(x2);
parent[rootX2] = rootX1;
}
private:
vector<int> parent;
};
class vmath {
public:
// 約数を全て求める O(√n)
static ull calcDivisors(list<ull>* divisors, ull n) {
divisors->clear();
if (n <= 0ull) {
return 0ull;
}
divisors->push_back(1ull);
if (n != 1ull) {
divisors->push_back(n);
}
for (ull i = 2ull; i * i <= n; ++i) {
if (n % i == 0ull) {
divisors->push_back(i);
if (i != n / i) {
divisors->push_back(n / i);
}
}
}
return divisors->size();
}
// 約数の個数を返す O(√n)
static ull calcDivisorNum(ull n) {
if (n <= 0ull) {
return 0ull;
}
ull count = 1ull; // for 1
if (n != 1ull) {
++count; // for n
}
// for 2~n-1
for (ull i = 2ull; i * i <= n; ++i) {
if (n % i == 0ull) {
count += 1ull;
if (i != n / i) {
count += 1ull;
}
}
}
return count;
}
// 素因数分解 O(√n)
static int calcDecompositPrime(list<ull>* primes, ull n) {
primes->clear();
if (n == 0) {
return 0ull;
}
if (n == 1) {
primes->push_back(1);
return 1ull;
}
// 割る数の初期値
ull a = 2ull;
// √n ≧ a ( n ≧ a * a ) の間ループ処理
while (n >= a * a) {
if (n % a == 0ull) {
// a で割り切れたら、a は素因数
primes->push_back(a);
// そして、割られる数を a で割る
n /= a;
} else {
// a で割り切れなかったら、 a を 1 増加させる
a++;
}
}
primes->push_back(n);
return primes->size();
}
// 素因数の数を返す O(√n)
static ull calcDecompositPrimeNum(ull n) {
if (n <= 1) {
return n;
}
ull count = 0ull;
// 割る数の初期値
ull a = 2ull;
// √n ≧ a ( n ≧ a * a ) の間ループ処理
while (n >= a * a) {
if (n % a == 0ull) {
// a で割り切れたら、a は素因数
++count;
// そして、割られる数を a で割る
n /= a;
} else {
// a で割り切れなかったら、 a を 1 増加させる
a++;
}
}
++count; // for n
return count;
}
// 階乗
static ull fact(ull x) {
if (x == 0ull) {
return 1ull;
} else {
return x * fact(x - 1ull);
}
}
// 順列 nPr
static ull permutation(int n, int r) {
assert(n >= r);
//return fact(n) / fact(n - r);
ull result = 1;
for (ull i = n; i > n - r; --i) {
result *= i;
}
return result;
}
// 組み合わせ nCr
// 先にmakePascalTriangleでパスカルの三角形を作成しておく必要がある
static ull combination(int n, int r) {
assert(n >= r);
assert(n <= mPascalTriangleDepth);
return mPascalTriangle[n][r];
}
// 重複組合せ nHr = n+r-1Cr
// 使いどころ:n人にr個を配るとき、同じ人に何個配っても良い場合とか
// 4人に5個の◯を配るときa=2,b=0,c=2,d=1のとき、◯◯||◯◯|◯みたいになる。
// これは◯と|を混ぜた組み合わせで、◯の数がn,棒の数はr-1だから全体でn+r-1
// (n-r)で割ったものが順列n+r-1Prで、それを更にrで割っているからnHr = n+r-1Cr
static ull repeatedCombination(int n, int r) {
return combination(n + r - 1, r);
}
// パスカルの三角形。組み合わせの計算に使用するのでこれを先に作成しておく必要がある。
static void makePascalTriangle(int depth) {
resize(mPascalTriangle, depth + 1, depth + 1);
for (int i = 0; i <= depth; ++i) {
mPascalTriangle[i][0] = 1;
for (int j = 1; j <= i; ++j) {
mPascalTriangle[i][j] = mPascalTriangle[i - 1][j] + mPascalTriangle[i - 1][j - 1];
}
}
mPascalTriangleDepth = depth;
}
// xのN桁目の数値を得る
static ull getNDigitNumber(ull x, ull n) {
return (x / pow(10ull, n - 1ull)) % 10;
}
// xのN桁目の数値を得る
static int getNDigitNumber(int x, int n) {
assert(n <= 10);
return (x / pow(10, n - 1)) % 10;
}
// xのN乗を求める(バイナリ法) O(logN)
static ull pow(ull x, ull n) {
assert(x >= 0ull);
assert(n >= 0ull);
if (x == 0ull) {
if (n == 0ull) {
return 1ull;
} else {
return 0ull;
}
}
ull result = 1ull;
ull z = x;
while (n > 0ull) {
if (n & 1ull) {
result *= z;
}
z *= z;
n >>= 1;
}
return result;
}
// xのN乗を求める(バイナリ法) O(logN)
static int pow(int x, int n) {
assert(x >= 0);
assert(n >= 0);
if (x == 0) {
if (n == 0) {
return 1;
} else {
return 0;
}
}
int result = 1;
int z = x;
while (n > 0) {
if (n & 1) {
result *= z;
}
z *= z;
n >>= 1;
}
return result;
}
private:
static int mPascalTriangleDepth;
static vector<vector<ull>> mPascalTriangle;
};
int vmath::mPascalTriangleDepth = 0;
vector<vector<ull>> vmath::mPascalTriangle;
class vmath_mod {
public:
// 階乗
static ull fact(ull x) {
ull result = 1ull;
for (ull i = 1ull; i <= x; ++i) {
result *= i;
result %= MOD;
}
return result;
}
// 順列 nPr
static ull permutation(int n, int r) {
assert(n >= r);
//return fact(n) / fact(n - r);
ull result = 1;
for (ull i = n; i > n - r; --i) {
result *= i;
result %= MOD;
}
return result;
}
// 組み合わせ nCr
// 先にmakePascalTriangleでパスカルの三角形を作成しておく必要がある
static ull combination(int n, int r) {
assert(n >= r);
assert(n <= mPascalTriangleDepth);
return mPascalTriangle[n][r];
}
// 重複組合せ nHr = n+r-1Cr
// 使いどころ:n人にr個を配るとき、同じ人に何個配っても良い場合とか
// 4人に5個の◯を配るときa=2,b=0,c=2,d=1のとき、◯◯||◯◯|◯みたいになる。
// これは◯と|を混ぜた組み合わせで、◯の数がn,棒の数はr-1だから全体でn+r-1
// (n-r)で割ったものが順列n+r-1Prで、それを更にrで割っているからnHr = n+r-1Cr
static ull repeatedCombination(int n, int r) {
return combination(n + r - 1, r);
}
// パスカルの三角形。組み合わせの計算に使用するのでこれを先に作成しておく必要がある。
static void makePascalTriangle(int depth) {
resize(mPascalTriangle, depth + 1, depth + 1);
for (int i = 0; i <= depth; ++i) {
mPascalTriangle[i][0] = 1;
for (int j = 1; j <= i; ++j) {
mPascalTriangle[i][j] = (mPascalTriangle[i - 1][j] + mPascalTriangle[i - 1][j - 1]) % MOD;
}
}
mPascalTriangleDepth = depth;
}
// xのN桁目の数値を得る
static ull getNDigitNumber(ull x, ull n) {
return (x / pow(10ull, n - 1ull)) % 10;
}
// xのN桁目の数値を得る
static int getNDigitNumber(int x, int n) {
assert(n <= 10);
return (x / pow(10, n - 1)) % 10;
}
// xのN乗を求める O(n)
static ull pow(ull x, ull n) {
if (x == 0ull) {
if (n == 0ull) {
return 1ull;
} else {
return 0ull;
}
}
ull result = 1ull;
for (ull i = 0ull; i < n; ++i) {
result *= x;
result %= MOD;
}
return result;
}
// xのN乗を求める O(n)
static int pow(int x, int n) {
assert(x >= 0);
assert(n >= 0);
if (x == 0) {
if (n == 0) {
return 1;
} else {
return 0;
}
}
int result = 1;
for (int i = 0; i < n; ++i) {
result *= x;
result %= MOD;
}
return result;
}
private:
static int mPascalTriangleDepth;
static vector<vector<ull>> mPascalTriangle;
};
int vmath_mod::mPascalTriangleDepth = 0;
vector<vector<ull>> vmath_mod::mPascalTriangle;
class vegde {
public:
vegde() : vegde(-1) {
}
vegde(int cost) :
mCost(cost) {
}
int getCost() const { return mCost; }
private:
int mCost;
};
class vnode {
public:
vnode() : vnode(-1) {
}
vnode(int id) :
mID(id) {
}
void addEgde(const vegde& egde, const vnode* node) {
mEgdeList.emplace_back(egde, node);
}
void removeEgde(int nodeID) {
auto itrNewEnd = std::remove_if(mEgdeList.begin(), mEgdeList.end(), [=](const pair<vegde, const vnode*>& p)->bool {
return (p.second->getID() == nodeID);
});
mEgdeList.erase(itrNewEnd, mEgdeList.end());
}
int getID() const { return mID; }
const list<pair<vegde, const vnode*>>& getEgde() const { return mEgdeList; }
private:
list<pair<vegde, const vnode*>> mEgdeList;
int mID;
};
class AdjacencyMatrix {
public:
AdjacencyMatrix() {
}
AdjacencyMatrix(int nodeNum) {
resize(mConnectionMap, nodeNum, nodeNum);
resize(mCostMap, nodeNum, nodeNum);
resize(mMinimumDistMap, nodeNum, nodeNum);
resize(mPrevNodeMap, nodeNum, nodeNum);
}
void addEgde(int nodeID1, int nodeID2, int cost) {
mConnectionMap[nodeID1][nodeID2] = true;
mConnectionMap[nodeID2][nodeID1] = true;
mCostMap[nodeID1][nodeID2] = cost;
mCostMap[nodeID2][nodeID1] = cost;
}
void removeEgde(int nodeID1, int nodeID2) {
mConnectionMap[nodeID1][nodeID2] = false;
mConnectionMap[nodeID2][nodeID1] = false;
mCostMap[nodeID1][nodeID2] = 0;
mCostMap[nodeID2][nodeID1] = 0;
}
void warshallFloyd(int nodeNum) {
for (int k = 0; k < nodeNum; ++k) {
for (int i = 0; i < nodeNum; ++i) {
for (int j = 0; j < nodeNum; ++j) {
if (mConnectionMap[i][j]) {
mMinimumDistMap[i][j] = mCostMap[i][j];
} else {
mMinimumDistMap[i][j] = 99999999;
}
}
}
}
for (int k = 0; k < nodeNum; ++k) {
for (int i = 0; i < nodeNum; ++i) {
for (int j = 0; j < nodeNum; ++j) {
mMinimumDistMap[i][j] = min(mMinimumDistMap[i][j], mMinimumDistMap[i][k] + mMinimumDistMap[k][j]);
}
}
}
//for (int i = 0; i < mNodeNum; ++i) {
// for (int j = 0; j < mNodeNum; ++j) {
// cerr << mMinimumDistMap[i][j] << ", ";
// }
// cerr << endl;
//}
}
const vector<vector<bool>>& getConnectionMap() const { return mConnectionMap; }
const vector<vector<int>>& getCostMap() const { return mCostMap; }
const vector<vector<int>>& getMinimumDistMap() const { return mMinimumDistMap; }
const vector<vector<int>>& getPrevNodeMap() const { return mPrevNodeMap; }
private:
vector<vector<bool>> mConnectionMap;
vector<vector<int>> mCostMap;
vector<vector<int>> mMinimumDistMap;
vector<vector<int>> mPrevNodeMap;
};
// グラフ
class vgraph {
public:
const int INF = 1000000;
vgraph(int nodeNum) {
mNodeNum = nodeNum;
mNodes.resize(nodeNum);
for (int i = 0; i < nodeNum; ++i) {
mNodes[i] = move(vnode(i));
}
mMinimumDists.resize(mNodeNum);
mPrevNodes.resize(mNodeNum);
}
void addEgde(int nodeID1, int nodeID2) {
addEgde(nodeID1, nodeID2, 1);
}
virtual void addEgde(int nodeID1, int nodeID2, int cost) = 0;
virtual void removeEgde(int nodeID1, int nodeID2) = 0;
int dfs(int start) {
vector<bool> check(mNodes.size());
fill(check, false);
int MAX_DEPTH = INF; // 探索の深さ制限があれば定義する
return dfsSub(start, check, MAX_DEPTH, 0);
}
void bfs(int start) {
vector<bool> check(mNodes.size());
fill(check, false);
int MAX_DEPTH = INF; // 探索の深さ制限があれば定義する
return bfsSub(start, check, MAX_DEPTH);
}
// ベルマンフォード法を使ってある頂点から全ての頂点への最短距離を求める
// startからたどり着ける場所に負のループが存在する場合はfalseを返す
// ダイクストラ法と違い、負のコストの辺があっても最短距離を計算できる
// O(V*E)
bool bellmanFord(int start) {
vector<int>& dist = mMinimumDists;
fill(dist, INF);
dist[start] = 0;
for (int i = 0; i < mNodeNum; ++i) {
bool update = false;
for (vnode node : mNodes) {
for (const pair<vegde, const vnode*> egde : node.getEgde()) {
int from = node.getID();
int to = egde.second->getID();
if (dist[from] == INF) {
continue;
}
if (dist[from] + egde.first.getCost() < dist[to]) {
dist[to] = dist[from] + egde.first.getCost();
update = true;
if (i == mNodeNum - 1) {
//return false;
}
}
}
}
if (!update) {
break;
}
}
return true;
}
// ダイクストラ法を使ってある頂点から全ての頂点への最短距離を求める
// 負のコストの辺があると最短距離を計算できない点に注意する
// O(E*logV)
void dijkstraSearch(int start) {
// Minimum distances for each nodes
vector<int>& dpMinDists = mMinimumDists;
fill(dpMinDists, INF);
// Result of the previous visited node
vector<int>& resultPrev = mPrevNodes;
fill(resultPrev, -1);
// Create a priority_queue for search.
typedef pair<int, int> P; // key: その頂点までの最短距離, value: 頂点の番号
priority_queue<P, vector<P>, greater<P>> pq_node;
// Mark the current node as visited and enqueue it
pq_node.push(P(0, start));
dpMinDists[start] = 0;
while (!pq_node.empty()) {
P p = pq_node.top();
pq_node.pop();
int nowDist = p.first;
int nowNodeID = p.second;
if (dpMinDists[nowNodeID] < nowDist) {
continue;
}
for (const pair<vegde, const vnode*>& egde : mNodes[nowNodeID].getEgde()) {
const vnode* nextNode = egde.second;
int nextNodeID = nextNode->getID();
int nextNodeDist = nowDist + egde.first.getCost();
if (nextNodeDist < dpMinDists[nextNodeID]) {
dpMinDists[nextNodeID] = nextNodeDist;
resultPrev[nextNodeID] = nowNodeID;
pq_node.push(P(nextNodeDist, nextNodeID));
}
}
}
}
int calcMaxDepth() const {
pair<int, int> farestNodeData = getFarestNodeID(0);
pair<int, int> farestNodeData2 = getFarestNodeID(farestNodeData.first);
return farestNodeData2.second;
}
int getNodeNum() const { return mNodeNum; }
const vector<vnode>& getNodes() const { return mNodes; }
const vector<int>& getMinimumDists() const { return mMinimumDists; }
const vector<int>& getPrevNodes() const { return mPrevNodes; }
protected:
int dfsSub(int nodeIndex, vector<bool>& check, int MAX_DEPTH, int depth) {
check[nodeIndex] = true;
int result = 0;
// 隣接する辺を探索
if (depth < MAX_DEPTH) {
for (auto t : mNodes[nodeIndex].getEgde()) {
if (check[t.second->getID()]) {
// 巡回済みの辺は見ない
continue;
}
result += dfsSub(t.second->getID(), check, MAX_DEPTH, depth + 1);
}
}
// 末端での処理
result += 1; // この巡回順で末端に辿り着いた時、目的の条件を満たすなら+1する
check[nodeIndex] = false;
return result;
}
void bfsSub(int start, vector<bool>& check, int MAX_DEPTH) {
queue<pair<int, int>> target;
target.push(pair<int, int>(start, 0));
while (!target.empty()) {
pair<int, int> now = target.front();
target.pop();
// ノードに対して何かやることがあればここでやる
//mNodes[now.first].something = someData;
check[now.first] = true;
int egdeCount = 0;
if (now.second < MAX_DEPTH) {
for (const pair<vegde, const vnode*>& egde : mNodes[now.first].getEgde()) {
if (check[egde.second->getID()]) {
// このノードはもっと少ない手順で巡回可能なので行かない
continue;
}
++egdeCount;
target.push(pair<int, int>(egde.second->getID(), now.second + 1));
}
}
if (now.second == MAX_DEPTH || egdeCount == 0) {
// 探索深さ制限またはこのノードから繋がる辺が全て巡回済み
// doSomething.
}
}
}
// 引数で受け取ったノードから最も遠いノードのidと距離を返す
// グラフにループがあると無限ループになるので注意する(つまり木専用)
pair<int, int> getFarestNodeID(int start) const {
queue<pair<int, int>> q; // nodeID, このノードまでの距離
q.push(make_pair(start, 0));
pair<int, int> finalNodeData;
vector<bool> opened(mNodeNum);
fill(opened, false);
while (!q.empty()) {
pair<int, int> nodeData = q.front();
int nodeID = nodeData.first;
int dist = nodeData.second;
if (dist > finalNodeData.second) {
finalNodeData.second = dist;
finalNodeData.first = nodeID;
}
q.pop();
for (const pair<vegde, const vnode*> egde : mNodes[nodeID].getEgde()) {
int id = egde.second->getID();
if (opened[id]) {
continue;
}
opened[id] = true;
q.push(make_pair(id, dist + egde.first.getCost()));
}
}
return finalNodeData;
}
int mNodeNum;
bool mUseMaps;
vector<vnode> mNodes;
vector<int> mMinimumDists;
vector<int> mPrevNodes;
};
// 無向グラフ UnDirected Val Graph.
class udvgraph : public vgraph {
public:
udvgraph(int nodeNum) :
vgraph(nodeNum) {
}
void addEgde(int nodeID1, int nodeID2, int cost) {
mNodes[nodeID1].addEgde(move(vegde(cost)), &mNodes[nodeID2]);
mNodes[nodeID2].addEgde(move(vegde(cost)), &mNodes[nodeID1]);
}
void removeEgde(int nodeID1, int nodeID2) {
mNodes[nodeID1].removeEgde(nodeID2);
mNodes[nodeID2].removeEgde(nodeID1);
}
};
// 隣接行列付きの無向グラフ。ワーシャルフロイドが使える。 UnDirected Val Graph Matrix
class udvgraph_m : public udvgraph {
public:
udvgraph_m(int nodeNum) :
udvgraph(nodeNum) {
mAdjacencyMatrix = AdjacencyMatrix(nodeNum);
}
void addEgde(int nodeID1, int nodeID2, int cost) {
udvgraph::addEgde(nodeID1, nodeID2, cost);
mAdjacencyMatrix.addEgde(nodeID1, nodeID2, cost);
}
void removeEgde(int nodeID1, int nodeID2) {
udvgraph::removeEgde(nodeID1, nodeID2);
mAdjacencyMatrix.removeEgde(nodeID1, nodeID2);
}
void warshallFloyd() {
mAdjacencyMatrix.warshallFloyd(mNodeNum);
}
const vector<vector<bool>>& getConnectionMap() const { return mAdjacencyMatrix.getConnectionMap(); }
const vector<vector<int>>& getCostMap() const { return mAdjacencyMatrix.getCostMap(); }
const vector<vector<int>>& getMinimumDistMap() const { return mAdjacencyMatrix.getMinimumDistMap(); }
const vector<vector<int>>& getPrevNodeMap() const { return mAdjacencyMatrix.getPrevNodeMap(); }
private:
AdjacencyMatrix mAdjacencyMatrix;
};
// 有向グラフ Directed Val Graph.
class dvgraph : public vgraph {
public:
dvgraph(int nodeNum) :
vgraph(nodeNum) {
}
void addEgde(int nodeID1, int nodeID2, int cost) {
mNodes[nodeID1].addEgde(move(vegde(cost)),&mNodes[nodeID2]);
}
void removeEgde(int nodeID1, int nodeID2) {
mNodes[nodeID1].removeEgde(nodeID2);
}
// 入力のないノードのリストを返す
list<int> searchStartNodes() const {
list<int> startNodes;
unordered_map<int, int> nodesInputs; // key:ノード番号, value:インプット数
for (auto node : mNodes) {
for (auto edge : node.getEgde()) {
++nodesInputs[edge.second->getID()];
}
}
for (int i = 0; i < mNodeNum; ++i) {
if (nodesInputs.find(i) == nodesInputs.end()) {
startNodes.push_back(i);
}
}
return move(startNodes);
}
};
// 隣接行列付きの有向グラフ。ワーシャルフロイドが使える。 Directed Val Graph Matrix
class dvgraph_m : public dvgraph {
public:
dvgraph_m(int nodeNum) :
dvgraph(nodeNum) {
mAdjacencyMatrix = AdjacencyMatrix(nodeNum);
}
void addEgde(int nodeID1, int nodeID2, int cost) {
dvgraph::addEgde(nodeID1, nodeID2, cost);
mAdjacencyMatrix.addEgde(nodeID1, nodeID2, cost);
}
void removeEgde(int nodeID1, int nodeID2) {
dvgraph::removeEgde(nodeID1, nodeID2);
mAdjacencyMatrix.removeEgde(nodeID1, nodeID2);
}
void warshallFloyd() {
mAdjacencyMatrix.warshallFloyd(mNodeNum);
}
const vector<vector<bool>>& getConnectionMap() const { return mAdjacencyMatrix.getConnectionMap(); }
const vector<vector<int>>& getCostMap() const { return mAdjacencyMatrix.getCostMap(); }
const vector<vector<int>>& getMinimumDistMap() const { return mAdjacencyMatrix.getMinimumDistMap(); }
const vector<vector<int>>& getPrevNodeMap() const { return mAdjacencyMatrix.getPrevNodeMap(); }
private:
AdjacencyMatrix mAdjacencyMatrix;
};
}
using namespace ValLib;
int main()
{
int N, P;
cin >> N >> P;
vector<int> A(N);
for (int i = 0; i < N; ++i) {
cin >> A[i];
}
vector<int> odd;
odd.reserve(N);
vector<int> even;
even.reserve(N);
for (int i = 0; i < N; ++i) {
if (A[i] % 2 == 1) {
odd.push_back(A[i]);
} else {
even.push_back(A[i]);
}
}
vmath::makePascalTriangle(max(odd.size(), even.size()));
ull result = 0ull;
for (int i = 0; i <= even.size(); ++i) {
for (int j = 0; j <= odd.size(); ++j) {
if (P == 0) {
if (j % 2 == 1) {
continue;
}
} else {
if (j % 2 == 0) {
continue;
}
}
result +=
vmath::combination(even.size(), i)
* vmath::combination(odd.size(), j);
}
}
cout << result << endl;
getchar();
getchar();
}
| a.cc: In function 'void ValLib::test()':
a.cc:183:33: error: no matching function for call to 'count_if(std::vector<int>&, ValLib::test()::<lambda(int)>)'
183 | int x = count_if(v, [](int y) { return y <= 0; });
| ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:61,
from a.cc:15:
/usr/include/c++/14/bits/stl_algo.h:4049:5: note: candidate: 'template<class _IIter, class _Predicate> typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::count_if(_IIter, _IIter, _Predicate)'
4049 | count_if(_InputIterator __first, _InputIterator __last, _Predicate __pred)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:4049:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:86:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:106:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Predicate> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, typename std::iterator_traits<_II>::difference_type> std::count_if(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _Predicate)'
106 | count_if(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred);
| ^~~~~~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:106:1: note: candidate expects 4 arguments, 2 provided
|
s894144457 | p03665 | C++ | #include <vector>
#include <algorithm>
#include <string>
#include <iostream>
using namespace std;
int res = 0;
int main() {
int N, P;
cin >> N >> P;
vector<int> nums(N, 0);
for (int i = 0; i < N; i++) {
cin >> nums[i];
}
long long size = pow(2, N);
for (long long i = 0; i < size; i++) {
long long j = i;
int sum = 0;
int index = 0;
while (j) {
if (j & 1) {
sum += nums[index];
}
j >>= 1;
index++;
}
if (sum % 2 == P % 2) {
res++;
}
}
cout << res << endl;
} | a.cc: In function 'int main()':
a.cc:15:26: error: 'pow' was not declared in this scope
15 | long long size = pow(2, N);
| ^~~
|
s231250514 | p03665 | C++ |
//#define NDEBUG
#include <iostream>
#include <array>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <memory>
#include <cassert>
#include <functional>
#include <chrono>
#ifdef NDEBUG
#define vcerr NullStream()
#else
#define vcerr std::cerr
#endif
using namespace std;
namespace ValLib {
const int MOD = 1000000007;
typedef unsigned long long ull;
template<typename Key, typename Value>
using umap = std::unordered_map<Key, Value>;
template<typename T>
using uset = std::unordered_set<T>;
template <typename T>
using sptr = typename std::shared_ptr<T>;
class vnode;
class vegde;
class vgraph;
class NullStream {
public:
template<typename T> NullStream& operator<<(T const&) { return *this; }
};
template<typename T>
void fill(vector<T>& vec, const T& value) {
std::fill(vec.begin(), vec.end(), value);
}
template<typename T>
void fill(vector<vector<T>>& vec, const T& value) {
for (vector<T>& t : vec) std::fill(t.begin(), t.end(), value);
}
template<typename T>
void resize(vector<vector<T>>& vec, int size1, int size2) {
vec.resize(size1);
for (vector<T>& t : vec) t.resize(size2);
}
template <typename T>
typename const vector<T>::const_iterator max_element(const vector<T>& vec) {
assert(!vec.empty());
return std::max_element(vec.begin(), vec.end());
}
template <typename T, typename _Pr>
typename const vector<T>::const_iterator max_element(const vector<T>& vec, _Pr lessThan) {
assert(!vec.empty());
return std::max_element(vec.begin(), vec.end(), lessThan);
}
template <typename T>
typename const vector<T>::const_iterator min_element(const vector<T>& vec) {
assert(!vec.empty());
return std::min_element(vec.begin(), vec.end());
}
template <typename T, typename _Pr>
typename const vector<T>::const_iterator min_element(const vector<T>& vec, _Pr lessThan) {
assert(!vec.empty());
return std::min_element(vec.begin(), vec.end(), lessThan);
}
int accumulate(const vector<int>& vec) {
return std::accumulate(vec.begin(), vec.end(), 0);
}
template <typename _Pr>
int accumulate(const vector<int>& vec, _Pr func) {
return std::accumulate(vec.begin(), vec.end(), 0, func);
}
double accumulate(const vector<double>& vec) {
return std::accumulate(vec.begin(), vec.end(), 0.0);
}
template <typename _Pr>
double accumulate(const vector<double>& vec, _Pr func) {
return std::accumulate(vec.begin(), vec.end(), 0.0, func);
}
float accumulate(const vector<float>& vec) {
return std::accumulate(vec.begin(), vec.end(), 0.f);
}
template <typename _Pr>
float accumulate(const vector<float>& vec, _Pr func) {
return std::accumulate(vec.begin(), vec.end(), 0.f, func);
}
template <typename T, typename _Pr>
bool all_of(const vector<T>& vec, _Pr pred) {
return std::all_of(vec.begin(), vec.end(), pred);
}
template <typename T, typename _Pr>
bool any_of(const vector<T>& vec, _Pr pred) {
return std::any_of(vec.begin(), vec.end(), pred);
}
template <typename T, typename _Pr>
bool none_of(const vector<T>& vec, _Pr pred) {
return std::none_of(vec.begin(), vec.end(), pred);
}
template <typename T>
typename const vector<T>::const_iterator find(const vector<T>& vec, const T& val) {
return std::find(vec.begin(), vec.end(), val);
}
template <typename T, typename _Pr>
typename const vector<T>::const_iterator find_if(const vector<T>& vec, _Pr pred) {
return std::find_if(vec.begin(), vec.end(), pred);
}
template <typename T>
bool contains(const vector<T>& vec, const T& val) {
return std::find(vec.begin(), vec.end(), val) != vec.end();
}
template <typename T, typename _Pr>
bool contains_if(const vector<T>& vec, _Pr pred) {
return std::find_if(vec.begin(), vec.end(), pred) != vec.end();
}
template <typename T, typename _Pr>
typename iterator_traits<typename const vector<T>::const_iterator>::difference_type count_if(const vector<T>& vec, _Pr pred) {
return std::count_if(vec.begin(), vec.end(), pred);
}
template<typename T, size_t N>
void fill(array<T, N>& ary, const T& value) {
std::fill(ary.begin(), ary.end(), value);
}
template<typename T, size_t N, size_t M>
void fill(array<array<T, M>, N>& ary, const T& value) {
for (array<T, M>& t : ary) std::fill(t.begin(), t.end(), value);
}
template <typename T, size_t N, typename _Pr>
typename const array<T, N>::const_iterator max_element(const array<T, N>& ary) {
assert(!ary.empty());
return std::max_element(ary.begin(), ary.end());
}
template <typename T, size_t N, typename _Pr>
typename const vector<T>::const_iterator max_element(const array<T, N>& ary) {
assert(!ary.empty());
return std::max_element(ary.begin(), ary.end());
}
template <typename T, size_t N, typename _Pr>
typename const array<T, N>::const_iterator max_element(const array<T, N>& ary, _Pr lessThan) {
assert(!ary.empty());
return std::max_element(ary.begin(), ary.end(), lessThan);
}
template <typename T, size_t N, typename _Pr>
typename const array<T, N>::const_iterator min_element(const array<T, N>& ary) {
assert(!ary.empty());
return std::min_element(ary.begin(), ary.end());
}
template <typename T, size_t N, typename _Pr>
typename const array<T, N>::const_iterator min_element(const array<T, N>& ary, _Pr lessThan) {
assert(!ary.empty());
return std::min_element(ary.begin(), ary.end(), lessThan);
}
template <size_t N>
int accumulate(const array<int, N>& ary) {
return std::accumulate(ary.begin(), ary.end(), 0);
}
template <size_t N, typename _Pr>
int accumulate(const array<int, N>& ary, _Pr func) {
return std::accumulate(ary.begin(), ary.end(), 0, func);
}
template <size_t N>
double accumulate(const array<double, N>& ary) {
return std::accumulate(ary.begin(), ary.end(), 0.0);
}
template <size_t N, typename _Pr>
double accumulate(const array<double, N>& ary, _Pr func) {
return std::accumulate(ary.begin(), ary.end(), 0.0, func);
}
template <size_t N>
float accumulate(const array<float, N>& ary) {
return std::accumulate(ary.begin(), ary.end(), 0.f);
}
template <size_t N, typename _Pr>
float accumulate(const array<float, N>& ary, _Pr func) {
return std::accumulate(ary.begin(), ary.end(), 0.f, func);
}
template <typename T, size_t N, typename _Pr>
bool all_of(const array<T, N>& ary, _Pr pred) {
return std::all_of(ary.begin(), ary.end(), pred);
}
template <typename T, size_t N, typename _Pr>
bool any_of(const array<T, N>& ary, _Pr pred) {
return std::any_of(ary.begin(), ary.end(), pred);
}
template <typename T, size_t N, typename _Pr>
bool none_of(const array<T, N>& ary, _Pr pred) {
return std::none_of(ary.begin(), ary.end(), pred);
}
template <typename T, size_t N>
typename const array<T, N>::const_iterator find(const array<T, N>& ary, const T& val) {
return std::find(ary.begin(), ary.end(), val);
}
template <typename T, size_t N, typename _Pr>
typename const array<T, N>::const_iterator find_if(const array<T, N>& ary, _Pr pred) {
return std::find_if(ary.begin(), ary.end(), pred);
}
template <typename T, size_t N>
bool contains(const array<T, N>& ary, const T& val) {
return std::find(ary.begin(), ary.end(), val) != ary.end();
}
template <typename T, size_t N, typename _Pr>
bool contains_if(const array<T, N>& ary, _Pr pred) {
return std::find_if(ary.begin(), ary.end(), pred) != ary.end();
}
template <typename T, size_t N, typename _Pr>
typename iterator_traits<typename const array<T, N>::const_iterator>::difference_type count_if(const array<T, N>& ary, _Pr pred) {
return std::count_if(ary.begin(), ary.end(), pred);
}
template<typename Key, typename Value>
bool containsKey(const umap<Key, Value>& m, const Key& key) {
return m.find(key) != m.end();
}
template<typename Key, typename Value>
bool containsValue(const umap<Key, Value>& m, const Value& val) {
for (auto it = m.begin(); it != m.end(); ++it)
if (it->second == val)
return true;
return false;
}
template<typename T>
typename const uset<T>::const_iterator find(const uset<T>& s, const T& key) {
return s.find(key);
}
template<typename T>
bool contains(const uset<T>& s, const T& key) {
return s.find(key) != s.end();
}
void test() {
vector<int> v = {};
bool c = contains(v, 2);
int x = count_if(v, [](int y) { return y <= 0; });
cout << x << endl;
uset<int> s;
s.insert(1);
s.insert(4);
s.insert(1);
s.insert(2);
bool bb = contains(s, 1);
cout << bb << endl;
bb = contains(s, 3);
cout << bb << endl;
umap<int, string> m;
m[0] = "a";
m[4] = "b";
m[2] = "c";
auto au = m.find(4);
if (au != m.end()) {
string val = (*au).second;
}
bool b = containsKey(m, 1);
cout << b << endl;
b = containsKey(m, 3);
cout << b << endl;
b = containsValue(m, string("a"));
cout << b << endl;
b = containsValue(m, string("d"));
cout << b << endl;
getchar();
getchar();
}
class Point {
public:
inline Point() :
x(-1),
y(-1)
{}
inline Point(int _x, int _y) :
x(_x),
y(_y)
{}
static Point getDistance(const Point& p1, const Point& p2) {
return move(Point(abs(p1.x - p2.x), abs(p1.y - p2.y)));
}
void setPos(const Point& pos) { x = pos.x; y = pos.y; }
void setPos(int x, int y) { this->x = x; this->y = y; }
Point operator+ (const Point &p) const { return move(Point(x + p.x, y + p.y)); }
Point operator- (const Point &p) const { return move(Point(x - p.x, y - p.y)); }
void operator+= (const Point &p) { x += p.x; y += p.y; }
void operator-= (const Point &p) { x -= p.x; y -= p.y; }
bool operator== (const Point &p) const { return x == p.x && y == p.y; }
bool operator!= (const Point &p) const { return x != p.x || y != p.y; }
//bool operator<(const Point &p) const {return x * x + y * y < p.x * p.x + p.y * p.y;}
const Point& getPos() const { return *this; }
string to_string() const { return "(" + std::to_string(x) + ", " + std::to_string(y) + ")"; }
int x;
int y;
};
/// <summary>
/// 素集合データ構造
/// </summary>
class UnionFind {
public:
/// <summary>
/// コンストラクタ
/// </summary>
/// <param name="N">要素数</param>
UnionFind(int N) {
parent.resize(N);
for (int i = 0; i < N; ++i) {
parent[i] = i;
}
}
/// <summary>
/// 要素xの根を探索
/// </summary>
/// <param name="x">探索する要素番号(0~N-1)</param>
/// <returns>要素xの根(0~N-1)</returns>
int find(int x) {
if (parent[x] == x) {
return x;
} else {
parent[x] = find(parent[x]); // 経路圧縮(間接的な要素をrootに直接つなぐ)
return parent[x];
}
}
/// <summary>
/// 2つの要素の根が同じか
/// </summary>
/// <param name="x1">探索する要素番号1(0~N-1)</param>
/// <param name="x2">探索する要素番号2(0~N-1)</param>
/// <returns>true: 同じ根, false: 異なる根</returns>
bool same(int x1, int x2) {
return find(x1) == find(x2);
}
/// <summary>
/// 2つの要素の根同士を繋ぐ
/// </summary>
/// <param name="x1">要素番号1(0~N-1)</param>
/// <param name="x2">要素番号1(0~N-1)</param>
void union_elements(int x1, int x2) {
int rootX1 = find(x1);
int rootX2 = find(x2);
parent[rootX2] = rootX1;
}
private:
vector<int> parent;
};
class vmath {
public:
// 約数を全て求める O(√n)
static ull calcDivisors(list<ull>* divisors, ull n) {
divisors->clear();
if (n <= 0ull) {
return 0ull;
}
divisors->push_back(1ull);
if (n != 1ull) {
divisors->push_back(n);
}
for (ull i = 2ull; i * i <= n; ++i) {
if (n % i == 0ull) {
divisors->push_back(i);
if (i != n / i) {
divisors->push_back(n / i);
}
}
}
return divisors->size();
}
// 約数の個数を返す O(√n)
static ull calcDivisorNum(ull n) {
if (n <= 0ull) {
return 0ull;
}
ull count = 1ull; // for 1
if (n != 1ull) {
++count; // for n
}
// for 2~n-1
for (ull i = 2ull; i * i <= n; ++i) {
if (n % i == 0ull) {
count += 1ull;
if (i != n / i) {
count += 1ull;
}
}
}
return count;
}
// 素因数分解 O(√n)
static int calcDecompositPrime(list<ull>* primes, ull n) {
primes->clear();
if (n == 0) {
return 0ull;
}
if (n == 1) {
primes->push_back(1);
return 1ull;
}
// 割る数の初期値
ull a = 2ull;
// √n ≧ a ( n ≧ a * a ) の間ループ処理
while (n >= a * a) {
if (n % a == 0ull) {
// a で割り切れたら、a は素因数
primes->push_back(a);
// そして、割られる数を a で割る
n /= a;
} else {
// a で割り切れなかったら、 a を 1 増加させる
a++;
}
}
primes->push_back(n);
return primes->size();
}
// 素因数の数を返す O(√n)
static ull calcDecompositPrimeNum(ull n) {
if (n <= 1) {
return n;
}
ull count = 0ull;
// 割る数の初期値
ull a = 2ull;
// √n ≧ a ( n ≧ a * a ) の間ループ処理
while (n >= a * a) {
if (n % a == 0ull) {
// a で割り切れたら、a は素因数
++count;
// そして、割られる数を a で割る
n /= a;
} else {
// a で割り切れなかったら、 a を 1 増加させる
a++;
}
}
++count; // for n
return count;
}
// 階乗
static ull fact(ull x) {
if (x == 0ull) {
return 1ull;
} else {
return x * fact(x - 1ull);
}
}
// 順列 nPr
static ull permutation(int n, int r) {
assert(n >= r);
//return fact(n) / fact(n - r);
ull result = 1;
for (ull i = n; i > n - r; --i) {
result *= i;
}
return result;
}
// 組み合わせ nCr
// 先にmakePascalTriangleでパスカルの三角形を作成しておく必要がある
static ull combination(int n, int r) {
assert(n >= r);
assert(n <= mPascalTriangleDepth);
return mPascalTriangle[n][r];
}
// 重複組合せ nHr = n+r-1Cr
// 使いどころ:n人にr個を配るとき、同じ人に何個配っても良い場合とか
// 4人に5個の◯を配るときa=2,b=0,c=2,d=1のとき、◯◯||◯◯|◯みたいになる。
// これは◯と|を混ぜた組み合わせで、◯の数がn,棒の数はr-1だから全体でn+r-1
// (n-r)で割ったものが順列n+r-1Prで、それを更にrで割っているからnHr = n+r-1Cr
static ull repeatedCombination(int n, int r) {
return combination(n + r - 1, r);
}
// パスカルの三角形。組み合わせの計算に使用するのでこれを先に作成しておく必要がある。
static void makePascalTriangle(int depth) {
resize(mPascalTriangle, depth + 1, depth + 1);
for (int i = 0; i <= depth; ++i) {
mPascalTriangle[i][0] = 1;
for (int j = 1; j <= i; ++j) {
mPascalTriangle[i][j] = mPascalTriangle[i - 1][j] + mPascalTriangle[i - 1][j - 1];
}
}
mPascalTriangleDepth = depth;
}
// xのN桁目の数値を得る
static ull getNDigitNumber(ull x, ull n) {
return (x / pow(10ull, n - 1ull)) % 10;
}
// xのN桁目の数値を得る
static int getNDigitNumber(int x, int n) {
assert(n <= 10);
return (x / pow(10, n - 1)) % 10;
}
// xのN乗を求める(バイナリ法) O(logN)
static ull pow(ull x, ull n) {
assert(x >= 0ull);
assert(n >= 0ull);
if (x == 0ull) {
if (n == 0ull) {
return 1ull;
} else {
return 0ull;
}
}
ull result = 1ull;
ull z = x;
while (n > 0ull) {
if (n & 1ull) {
result *= z;
}
z *= z;
n >>= 1;
}
return result;
}
// xのN乗を求める(バイナリ法) O(logN)
static int pow(int x, int n) {
assert(x >= 0);
assert(n >= 0);
if (x == 0) {
if (n == 0) {
return 1;
} else {
return 0;
}
}
int result = 1;
int z = x;
while (n > 0) {
if (n & 1) {
result *= z;
}
z *= z;
n >>= 1;
}
return result;
}
private:
static int mPascalTriangleDepth;
static vector<vector<ull>> mPascalTriangle;
};
int vmath::mPascalTriangleDepth = 0;
vector<vector<ull>> vmath::mPascalTriangle;
class vmath_mod {
public:
// 階乗
static ull fact(ull x) {
ull result = 1ull;
for (ull i = 1ull; i <= x; ++i) {
result *= i;
result %= MOD;
}
return result;
}
// 順列 nPr
static ull permutation(int n, int r) {
assert(n >= r);
//return fact(n) / fact(n - r);
ull result = 1;
for (ull i = n; i > n - r; --i) {
result *= i;
result %= MOD;
}
return result;
}
// 組み合わせ nCr
// 先にmakePascalTriangleでパスカルの三角形を作成しておく必要がある
static ull combination(int n, int r) {
assert(n >= r);
assert(n <= mPascalTriangleDepth);
return mPascalTriangle[n][r];
}
// 重複組合せ nHr = n+r-1Cr
// 使いどころ:n人にr個を配るとき、同じ人に何個配っても良い場合とか
// 4人に5個の◯を配るときa=2,b=0,c=2,d=1のとき、◯◯||◯◯|◯みたいになる。
// これは◯と|を混ぜた組み合わせで、◯の数がn,棒の数はr-1だから全体でn+r-1
// (n-r)で割ったものが順列n+r-1Prで、それを更にrで割っているからnHr = n+r-1Cr
static ull repeatedCombination(int n, int r) {
return combination(n + r - 1, r);
}
// パスカルの三角形。組み合わせの計算に使用するのでこれを先に作成しておく必要がある。
static void makePascalTriangle(int depth) {
resize(mPascalTriangle, depth + 1, depth + 1);
for (int i = 0; i <= depth; ++i) {
mPascalTriangle[i][0] = 1;
for (int j = 1; j <= i; ++j) {
mPascalTriangle[i][j] = (mPascalTriangle[i - 1][j] + mPascalTriangle[i - 1][j - 1]) % MOD;
}
}
mPascalTriangleDepth = depth;
}
// xのN桁目の数値を得る
static ull getNDigitNumber(ull x, ull n) {
return (x / pow(10ull, n - 1ull)) % 10;
}
// xのN桁目の数値を得る
static int getNDigitNumber(int x, int n) {
assert(n <= 10);
return (x / pow(10, n - 1)) % 10;
}
// xのN乗を求める O(n)
static ull pow(ull x, ull n) {
if (x == 0ull) {
if (n == 0ull) {
return 1ull;
} else {
return 0ull;
}
}
ull result = 1ull;
for (ull i = 0ull; i < n; ++i) {
result *= x;
result %= MOD;
}
return result;
}
// xのN乗を求める O(n)
static int pow(int x, int n) {
assert(x >= 0);
assert(n >= 0);
if (x == 0) {
if (n == 0) {
return 1;
} else {
return 0;
}
}
int result = 1;
for (int i = 0; i < n; ++i) {
result *= x;
result %= MOD;
}
return result;
}
private:
static int mPascalTriangleDepth;
static vector<vector<ull>> mPascalTriangle;
};
int vmath_mod::mPascalTriangleDepth = 0;
vector<vector<ull>> vmath_mod::mPascalTriangle;
class vegde {
public:
vegde() : vegde(-1) {
}
vegde(int cost) :
mCost(cost) {
}
int getCost() const { return mCost; }
private:
int mCost;
};
class vnode {
public:
vnode() : vnode(-1) {
}
vnode(int id) :
mID(id) {
}
void addEgde(const vegde& egde, const vnode* node) {
mEgdeList.emplace_back(egde, node);
}
void removeEgde(int nodeID) {
auto itrNewEnd = std::remove_if(mEgdeList.begin(), mEgdeList.end(), [=](const pair<vegde, const vnode*>& p)->bool {
return (p.second->getID() == nodeID);
});
mEgdeList.erase(itrNewEnd, mEgdeList.end());
}
int getID() const { return mID; }
const list<pair<vegde, const vnode*>>& getEgde() const { return mEgdeList; }
private:
list<pair<vegde, const vnode*>> mEgdeList;
int mID;
};
class AdjacencyMatrix {
public:
AdjacencyMatrix() {
}
AdjacencyMatrix(int nodeNum) {
resize(mConnectionMap, nodeNum, nodeNum);
resize(mCostMap, nodeNum, nodeNum);
resize(mMinimumDistMap, nodeNum, nodeNum);
resize(mPrevNodeMap, nodeNum, nodeNum);
}
void addEgde(int nodeID1, int nodeID2, int cost) {
mConnectionMap[nodeID1][nodeID2] = true;
mConnectionMap[nodeID2][nodeID1] = true;
mCostMap[nodeID1][nodeID2] = cost;
mCostMap[nodeID2][nodeID1] = cost;
}
void removeEgde(int nodeID1, int nodeID2) {
mConnectionMap[nodeID1][nodeID2] = false;
mConnectionMap[nodeID2][nodeID1] = false;
mCostMap[nodeID1][nodeID2] = 0;
mCostMap[nodeID2][nodeID1] = 0;
}
void warshallFloyd(int nodeNum) {
for (int k = 0; k < nodeNum; ++k) {
for (int i = 0; i < nodeNum; ++i) {
for (int j = 0; j < nodeNum; ++j) {
if (mConnectionMap[i][j]) {
mMinimumDistMap[i][j] = mCostMap[i][j];
} else {
mMinimumDistMap[i][j] = 99999999;
}
}
}
}
for (int k = 0; k < nodeNum; ++k) {
for (int i = 0; i < nodeNum; ++i) {
for (int j = 0; j < nodeNum; ++j) {
mMinimumDistMap[i][j] = min(mMinimumDistMap[i][j], mMinimumDistMap[i][k] + mMinimumDistMap[k][j]);
}
}
}
//for (int i = 0; i < mNodeNum; ++i) {
// for (int j = 0; j < mNodeNum; ++j) {
// cerr << mMinimumDistMap[i][j] << ", ";
// }
// cerr << endl;
//}
}
const vector<vector<bool>>& getConnectionMap() const { return mConnectionMap; }
const vector<vector<int>>& getCostMap() const { return mCostMap; }
const vector<vector<int>>& getMinimumDistMap() const { return mMinimumDistMap; }
const vector<vector<int>>& getPrevNodeMap() const { return mPrevNodeMap; }
private:
vector<vector<bool>> mConnectionMap;
vector<vector<int>> mCostMap;
vector<vector<int>> mMinimumDistMap;
vector<vector<int>> mPrevNodeMap;
};
// グラフ
class vgraph {
public:
const int INF = 1000000;
vgraph(int nodeNum) {
mNodeNum = nodeNum;
mNodes.resize(nodeNum);
for (int i = 0; i < nodeNum; ++i) {
mNodes[i] = move(vnode(i));
}
mMinimumDists.resize(mNodeNum);
mPrevNodes.resize(mNodeNum);
}
void addEgde(int nodeID1, int nodeID2) {
addEgde(nodeID1, nodeID2, 1);
}
virtual void addEgde(int nodeID1, int nodeID2, int cost) = 0;
virtual void removeEgde(int nodeID1, int nodeID2) = 0;
int dfs(int start) {
vector<bool> check(mNodes.size());
fill(check, false);
int MAX_DEPTH = INF; // 探索の深さ制限があれば定義する
return dfsSub(start, check, MAX_DEPTH, 0);
}
void bfs(int start) {
vector<bool> check(mNodes.size());
fill(check, false);
int MAX_DEPTH = INF; // 探索の深さ制限があれば定義する
return bfsSub(start, check, MAX_DEPTH);
}
// ベルマンフォード法を使ってある頂点から全ての頂点への最短距離を求める
// startからたどり着ける場所に負のループが存在する場合はfalseを返す
// ダイクストラ法と違い、負のコストの辺があっても最短距離を計算できる
// O(V*E)
bool bellmanFord(int start) {
vector<int>& dist = mMinimumDists;
fill(dist, INF);
dist[start] = 0;
for (int i = 0; i < mNodeNum; ++i) {
bool update = false;
for (vnode node : mNodes) {
for (const pair<vegde, const vnode*> egde : node.getEgde()) {
int from = node.getID();
int to = egde.second->getID();
if (dist[from] == INF) {
continue;
}
if (dist[from] + egde.first.getCost() < dist[to]) {
dist[to] = dist[from] + egde.first.getCost();
update = true;
if (i == mNodeNum - 1) {
//return false;
}
}
}
}
if (!update) {
break;
}
}
return true;
}
// ダイクストラ法を使ってある頂点から全ての頂点への最短距離を求める
// 負のコストの辺があると最短距離を計算できない点に注意する
// O(E*logV)
void dijkstraSearch(int start) {
// Minimum distances for each nodes
vector<int>& dpMinDists = mMinimumDists;
fill(dpMinDists, INF);
// Result of the previous visited node
vector<int>& resultPrev = mPrevNodes;
fill(resultPrev, -1);
// Create a priority_queue for search.
typedef pair<int, int> P; // key: その頂点までの最短距離, value: 頂点の番号
priority_queue<P, vector<P>, greater<P>> pq_node;
// Mark the current node as visited and enqueue it
pq_node.push(P(0, start));
dpMinDists[start] = 0;
while (!pq_node.empty()) {
P p = pq_node.top();
pq_node.pop();
int nowDist = p.first;
int nowNodeID = p.second;
if (dpMinDists[nowNodeID] < nowDist) {
continue;
}
for (const pair<vegde, const vnode*>& egde : mNodes[nowNodeID].getEgde()) {
const vnode* nextNode = egde.second;
int nextNodeID = nextNode->getID();
int nextNodeDist = nowDist + egde.first.getCost();
if (nextNodeDist < dpMinDists[nextNodeID]) {
dpMinDists[nextNodeID] = nextNodeDist;
resultPrev[nextNodeID] = nowNodeID;
pq_node.push(P(nextNodeDist, nextNodeID));
}
}
}
}
int calcMaxDepth() const {
pair<int, int> farestNodeData = getFarestNodeID(0);
pair<int, int> farestNodeData2 = getFarestNodeID(farestNodeData.first);
return farestNodeData2.second;
}
int getNodeNum() const { return mNodeNum; }
const vector<vnode>& getNodes() const { return mNodes; }
const vector<int>& getMinimumDists() const { return mMinimumDists; }
const vector<int>& getPrevNodes() const { return mPrevNodes; }
protected:
int dfsSub(int nodeIndex, vector<bool>& check, int MAX_DEPTH, int depth) {
check[nodeIndex] = true;
int result = 0;
// 隣接する辺を探索
if (depth < MAX_DEPTH) {
for (auto t : mNodes[nodeIndex].getEgde()) {
if (check[t.second->getID()]) {
// 巡回済みの辺は見ない
continue;
}
result += dfsSub(t.second->getID(), check, MAX_DEPTH, depth + 1);
}
}
// 末端での処理
result += 1; // この巡回順で末端に辿り着いた時、目的の条件を満たすなら+1する
check[nodeIndex] = false;
return result;
}
void bfsSub(int start, vector<bool>& check, int MAX_DEPTH) {
queue<pair<int, int>> target;
target.push(pair<int, int>(start, 0));
while (!target.empty()) {
pair<int, int> now = target.front();
target.pop();
// ノードに対して何かやることがあればここでやる
//mNodes[now.first].something = someData;
check[now.first] = true;
int egdeCount = 0;
if (now.second < MAX_DEPTH) {
for (const pair<vegde, const vnode*>& egde : mNodes[now.first].getEgde()) {
if (check[egde.second->getID()]) {
// このノードはもっと少ない手順で巡回可能なので行かない
continue;
}
++egdeCount;
target.push(pair<int, int>(egde.second->getID(), now.second + 1));
}
}
if (now.second == MAX_DEPTH || egdeCount == 0) {
// 探索深さ制限またはこのノードから繋がる辺が全て巡回済み
// doSomething.
}
}
}
// 引数で受け取ったノードから最も遠いノードのidと距離を返す
// グラフにループがあると無限ループになるので注意する(つまり木専用)
pair<int, int> getFarestNodeID(int start) const {
queue<pair<int, int>> q; // nodeID, このノードまでの距離
q.push(make_pair(start, 0));
pair<int, int> finalNodeData;
vector<bool> opened(mNodeNum);
fill(opened, false);
while (!q.empty()) {
pair<int, int> nodeData = q.front();
int nodeID = nodeData.first;
int dist = nodeData.second;
if (dist > finalNodeData.second) {
finalNodeData.second = dist;
finalNodeData.first = nodeID;
}
q.pop();
for (const pair<vegde, const vnode*> egde : mNodes[nodeID].getEgde()) {
int id = egde.second->getID();
if (opened[id]) {
continue;
}
opened[id] = true;
q.push(make_pair(id, dist + egde.first.getCost()));
}
}
return finalNodeData;
}
int mNodeNum;
bool mUseMaps;
vector<vnode> mNodes;
vector<int> mMinimumDists;
vector<int> mPrevNodes;
};
// 無向グラフ UnDirected Val Graph.
class udvgraph : public vgraph {
public:
udvgraph(int nodeNum) :
vgraph(nodeNum) {
}
void addEgde(int nodeID1, int nodeID2, int cost) {
mNodes[nodeID1].addEgde(move(vegde(cost)), &mNodes[nodeID2]);
mNodes[nodeID2].addEgde(move(vegde(cost)), &mNodes[nodeID1]);
}
void removeEgde(int nodeID1, int nodeID2) {
mNodes[nodeID1].removeEgde(nodeID2);
mNodes[nodeID2].removeEgde(nodeID1);
}
};
// 隣接行列付きの無向グラフ。ワーシャルフロイドが使える。 UnDirected Val Graph Matrix
class udvgraph_m : public udvgraph {
public:
udvgraph_m(int nodeNum) :
udvgraph(nodeNum) {
mAdjacencyMatrix = AdjacencyMatrix(nodeNum);
}
void addEgde(int nodeID1, int nodeID2, int cost) {
udvgraph::addEgde(nodeID1, nodeID2, cost);
mAdjacencyMatrix.addEgde(nodeID1, nodeID2, cost);
}
void removeEgde(int nodeID1, int nodeID2) {
udvgraph::removeEgde(nodeID1, nodeID2);
mAdjacencyMatrix.removeEgde(nodeID1, nodeID2);
}
void warshallFloyd() {
mAdjacencyMatrix.warshallFloyd(mNodeNum);
}
const vector<vector<bool>>& getConnectionMap() const { return mAdjacencyMatrix.getConnectionMap(); }
const vector<vector<int>>& getCostMap() const { return mAdjacencyMatrix.getCostMap(); }
const vector<vector<int>>& getMinimumDistMap() const { return mAdjacencyMatrix.getMinimumDistMap(); }
const vector<vector<int>>& getPrevNodeMap() const { return mAdjacencyMatrix.getPrevNodeMap(); }
private:
AdjacencyMatrix mAdjacencyMatrix;
};
// 有向グラフ Directed Val Graph.
class dvgraph : public vgraph {
public:
dvgraph(int nodeNum) :
vgraph(nodeNum) {
}
void addEgde(int nodeID1, int nodeID2, int cost) {
mNodes[nodeID1].addEgde(move(vegde(cost)),&mNodes[nodeID2]);
}
void removeEgde(int nodeID1, int nodeID2) {
mNodes[nodeID1].removeEgde(nodeID2);
}
// 入力のないノードのリストを返す
list<int> searchStartNodes() const {
list<int> startNodes;
unordered_map<int, int> nodesInputs; // key:ノード番号, value:インプット数
for (auto node : mNodes) {
for (auto edge : node.getEgde()) {
++nodesInputs[edge.second->getID()];
}
}
for (int i = 0; i < mNodeNum; ++i) {
if (nodesInputs.find(i) == nodesInputs.end()) {
startNodes.push_back(i);
}
}
return move(startNodes);
}
};
// 隣接行列付きの有向グラフ。ワーシャルフロイドが使える。 Directed Val Graph Matrix
class dvgraph_m : public dvgraph {
public:
dvgraph_m(int nodeNum) :
dvgraph(nodeNum) {
mAdjacencyMatrix = AdjacencyMatrix(nodeNum);
}
void addEgde(int nodeID1, int nodeID2, int cost) {
dvgraph::addEgde(nodeID1, nodeID2, cost);
mAdjacencyMatrix.addEgde(nodeID1, nodeID2, cost);
}
void removeEgde(int nodeID1, int nodeID2) {
dvgraph::removeEgde(nodeID1, nodeID2);
mAdjacencyMatrix.removeEgde(nodeID1, nodeID2);
}
void warshallFloyd() {
mAdjacencyMatrix.warshallFloyd(mNodeNum);
}
const vector<vector<bool>>& getConnectionMap() const { return mAdjacencyMatrix.getConnectionMap(); }
const vector<vector<int>>& getCostMap() const { return mAdjacencyMatrix.getCostMap(); }
const vector<vector<int>>& getMinimumDistMap() const { return mAdjacencyMatrix.getMinimumDistMap(); }
const vector<vector<int>>& getPrevNodeMap() const { return mAdjacencyMatrix.getPrevNodeMap(); }
private:
AdjacencyMatrix mAdjacencyMatrix;
};
}
using namespace ValLib;
int main()
{
int N, P;
cin >> N >> P;
vector<int> A(N);
for (int i = 0; i < N; ++i) {
cin >> A[i];
}
vector<int> odd;
odd.reserve(N);
vector<int> even;
even.reserve(N);
for (int i = 0; i < N; ++i) {
if (A[i] % 2 == 1) {
odd.push_back(A[i]);
} else {
even.push_back(A[i]);
}
}
vmath::makePascalTriangle(max(odd.size(), even.size()));
ull result = 0ull;
for (int i = 0; i <= even.size(); ++i) {
for (int j = 0; j <= odd.size(); ++j) {
if (P == 0) {
if (j % 2 == 1) {
continue;
}
} else {
if (j % 2 == 0) {
continue;
}
}
result +=
vmath::combination(even.size(), i)
* vmath::combination(odd.size(), j);
}
}
cout << result << endl;
getchar();
getchar();
}
| a.cc:70:18: error: expected nested-name-specifier before 'const'
70 | typename const vector<T>::const_iterator max_element(const vector<T>& vec) {
| ^~~~~
a.cc:70:50: error: expected initializer before 'max_element'
70 | typename const vector<T>::const_iterator max_element(const vector<T>& vec) {
| ^~~~~~~~~~~
a.cc:75:18: error: expected nested-name-specifier before 'const'
75 | typename const vector<T>::const_iterator max_element(const vector<T>& vec, _Pr lessThan) {
| ^~~~~
a.cc:75:50: error: expected initializer before 'max_element'
75 | typename const vector<T>::const_iterator max_element(const vector<T>& vec, _Pr lessThan) {
| ^~~~~~~~~~~
a.cc:80:18: error: expected nested-name-specifier before 'const'
80 | typename const vector<T>::const_iterator min_element(const vector<T>& vec) {
| ^~~~~
a.cc:80:50: error: expected initializer before 'min_element'
80 | typename const vector<T>::const_iterator min_element(const vector<T>& vec) {
| ^~~~~~~~~~~
a.cc:85:18: error: expected nested-name-specifier before 'const'
85 | typename const vector<T>::const_iterator min_element(const vector<T>& vec, _Pr lessThan) {
| ^~~~~
a.cc:85:50: error: expected initializer before 'min_element'
85 | typename const vector<T>::const_iterator min_element(const vector<T>& vec, _Pr lessThan) {
| ^~~~~~~~~~~
a.cc:123:18: error: expected nested-name-specifier before 'const'
123 | typename const vector<T>::const_iterator find(const vector<T>& vec, const T& val) {
| ^~~~~
a.cc:123:50: error: expected initializer before 'find'
123 | typename const vector<T>::const_iterator find(const vector<T>& vec, const T& val) {
| ^~~~
a.cc:127:18: error: expected nested-name-specifier before 'const'
127 | typename const vector<T>::const_iterator find_if(const vector<T>& vec, _Pr pred) {
| ^~~~~
a.cc:127:50: error: expected initializer before 'find_if'
127 | typename const vector<T>::const_iterator find_if(const vector<T>& vec, _Pr pred) {
| ^~~~~~~
a.cc:139:74: error: template argument 1 is invalid
139 | typename iterator_traits<typename const vector<T>::const_iterator>::difference_type count_if(const vector<T>& vec, _Pr pred) {
| ^
a.cc:139:18: error: expected nested-name-specifier
139 | typename iterator_traits<typename const vector<T>::const_iterator>::difference_type count_if(const vector<T>& vec, _Pr pred) {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:139:93: error: expected initializer before 'count_if'
139 | typename iterator_traits<typename const vector<T>::const_iterator>::difference_type count_if(const vector<T>& vec, _Pr pred) {
| ^~~~~~~~
a.cc:152:18: error: expected nested-name-specifier before 'const'
152 | typename const array<T, N>::const_iterator max_element(const array<T, N>& ary) {
| ^~~~~
a.cc:152:52: error: expected initializer before 'max_element'
152 | typename const array<T, N>::const_iterator max_element(const array<T, N>& ary) {
| ^~~~~~~~~~~
a.cc:157:18: error: expected nested-name-specifier before 'const'
157 | typename const vector<T>::const_iterator max_element(const array<T, N>& ary) {
| ^~~~~
a.cc:157:50: error: expected initializer before 'max_element'
157 | typename const vector<T>::const_iterator max_element(const array<T, N>& ary) {
| ^~~~~~~~~~~
a.cc:162:18: error: expected nested-name-specifier before 'const'
162 | typename const array<T, N>::const_iterator max_element(const array<T, N>& ary, _Pr lessThan) {
| ^~~~~
a.cc:162:52: error: expected initializer before 'max_element'
162 | typename const array<T, N>::const_iterator max_element(const array<T, N>& ary, _Pr lessThan) {
| ^~~~~~~~~~~
a.cc:167:18: error: expected nested-name-specifier before 'const'
167 | typename const array<T, N>::const_iterator min_element(const array<T, N>& ary) {
| ^~~~~
a.cc:167:52: error: expected initializer before 'min_element'
167 | typename const array<T, N>::const_iterator min_element(const array<T, N>& ary) {
| ^~~~~~~~~~~
a.cc:172:18: error: expected nested-name-specifier before 'const'
172 | typename const array<T, N>::const_iterator min_element(const array<T, N>& ary, _Pr lessThan) {
| ^~~~~
a.cc:172:52: error: expected initializer before 'min_element'
172 | typename const array<T, N>::const_iterator min_element(const array<T, N>& ary, _Pr lessThan) {
| ^~~~~~~~~~~
a.cc:213:18: error: expected nested-name-specifier before 'const'
213 | typename const array<T, N>::const_iterator find(const array<T, N>& ary, const T& val) {
| ^~~~~
a.cc:213:52: error: expected initializer before 'find'
213 | typename const array<T, N>::const_iterator find(const array<T, N>& ary, const T& val) {
| ^~~~
a.cc:217:18: error: expected nested-name-specifier before 'const'
217 | typename const array<T, N>::const_iterator find_if(const array<T, N>& ary, _Pr pred) {
| ^~~~~
a.cc:217:52: error: expected initializer before 'find_if'
217 | typename const array<T, N>::const_iterator find_if(const array<T, N>& ary, _Pr pred) {
| ^~~~~~~
a.cc:229:76: error: template argument 1 is invalid
229 | typename iterator_traits<typename const array<T, N>::const_iterator>::difference_type count_if(const array<T, N>& ary, _Pr pred) {
| ^
a.cc:229:18: error: expected nested-name-specifier
229 | typename iterator_traits<typename const array<T, N>::const_iterator>::difference_type count_if(const array<T, N>& ary, _Pr pred) {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:229:95: error: expected initializer before 'count_if'
229 | typename iterator_traits<typename const array<T, N>::const_iterator>::difference_type count_if(const array<T, N>& ary, _Pr pred) {
| ^~~~~~~~
a.cc:245:18: error: expected nested-name-specifier before 'const'
245 | typename const uset<T>::const_iterator find(const uset<T>& s, const T& key) {
| ^~~~~
a.cc:245:48: error: expected initializer before 'find'
245 | typename const uset<T>::const_iterator find(const uset<T>& s, const T& key) {
| ^~~~
a.cc: In function 'void ValLib::test()':
a.cc:256:33: error: no matching function for call to 'count_if(std::vector<int>&, ValLib::test()::<lambda(int)>)'
256 | int x = count_if(v, [](int y) { return y <= 0; });
| ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:61,
from a.cc:15:
/usr/include/c++/14/bits/stl_algo.h:4049:5: note: candidate: 'template<class _IIter, class _Predicate> typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::count_if(_IIter, _IIter, _Predicate)'
4049 | count_if(_InputIterator __first, _InputIterator __last, _Predicate __pred)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:4049:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:86:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:106:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Predicate> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, typename std::iterator_traits<_II>::difference_type> std::count_if(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _Predicate)'
106 | count_if(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred);
| ^~~~~~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:106:1: note: candidate expects 4 arguments, 2 provided
|
s395159440 | p03665 | Java | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.HashMap;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*/
public class Main {
public static void main(String[] args) {
InputStream inputStream = System.in;
OutputStream outputStream = System.out;
Scanner in = new Scanner(inputStream);
PrintWriter out = new PrintWriter(outputStream);
Atg017A solver = new Atg017A();
solver.solve(1, in, out);
out.close();
}
static class Atg017A {
int a;
int p;
int n;
HashMap<String, Long> cache = new HashMap<String, Long>();
public void solve(int testNumber, Scanner in, PrintWriter out) {
n = in.nextInt();
p = in.nextInt();
a = new int[n];
for (int i = 0; i < n; i++) {
a[i] = in.nextInt();
}
if (p != 0 && p != 1) {
out.println("0");
return;
}
long result = calc(0, false);
out.println(result);
}
long calc(int index, boolean isOdd) {
String key = index + "-" + (isOdd ? 1 : 0);
Long result = cache.get(key);
if (result != null) {
return result;
}
if (index == n) {
return ((p == 0 && !isOdd) || (p == 1 && isOdd)) ? 1 : 0;
}
boolean isOdd2;
if ((a[index] % 2) == 1) {
isOdd2 = !isOdd;
} else {
isOdd2 = isOdd;
}
long total = calc(index + 1, isOdd) + calc(index + 1, isOdd2);
cache.put(key, total);
return total;
}
}
}
| Main.java:32: error: incompatible types: int[] cannot be converted to int
a = new int[n];
^
Main.java:34: error: array required, but int found
a[i] = in.nextInt();
^
Main.java:54: error: array required, but int found
if ((a[index] % 2) == 1) {
^
3 errors
|
s410159245 | p03665 | C++ | import numpy as np
a = np.array(A)
f = 2**N-1
cnt = 0
for i in range(2**N):
ff = np.array(list(map(int,list(format(f,'b').zfill(N)))))
s = np.sum(ff * a)
print(ff)
if ( s%2 == P ):
cnt+=1
f-=1
print (cnt)
| a.cc:1:1: error: 'import' does not name a type
1 | import numpy as np
| ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
|
s473620347 | p03665 | C++ | #include<iostream>
#include<stdint>
using namespace std;
int main() {
int N, P, A, odd = 0, even = 0;
int64_t sum = 0, num;
cin >> N >> P;
for (int i = 0;i < N;i ++) {
cin >> A;
if (A % 2) odd ++;
else even ++;
}
for (int i = P;i <= odd;i += 2) {
for (int j = 0;j <= even;j ++) {
num = 1;
for (int k = 0;k < i;k ++) {
num *= odd - k;
num /= k + 1;
}
for (int k = 0;k < j;k ++) {
num *= even - k;
num /= k + 1;
}
sum += num;
}
}
cout << sum;
return 0;
} | a.cc:2:9: fatal error: stdint: No such file or directory
2 | #include<stdint>
| ^~~~~~~~
compilation terminated.
|
s702196536 | p03665 | C++ | #include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
using namespace std;
long long int C(int p, int q) {
long long int temp = 1;
int s = min(p - q, q);
for (int i = p; i > (p - s); i--) {
temp *= i;
}
for (int i = 2; i <= s; i++) {
temp /= i;
}
return temp;
}
int main() {
int N, P;
cin >> N >> P;
vector<int> odd;
vector<int> even;
int temp;
for (int i = 0; i < N; i++) {
cin >> temp;
if (temp % 2 == 0) {
even.push_back(temp);
} else {
odd.push_back(temp);
}
}
long long unsigned int count = 0;
if (P == 0) {
count += pow(2, even.size());
int odd_size = odd.size();
long long int t = 0;
for (int i = 0; i <= odd_size; i += 2) {
t += C(odd_size, i);
}
count *= t;
} else {
int odd_size = odd.size();
for (int i = 1; i <= odd_size; i += 2) {
count += C(odd_size, i);
}
count *= pow(2, even.size());
}
cout << count << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:43:26: error: 'pow' was not declared in this scope
43 | count += pow(2, even.size());
| ^~~
a.cc:56:26: error: 'pow' was not declared in this scope
56 | count *= pow(2, even.size());
| ^~~
|
s527811711 | p03665 | C++ | /*
* A.cpp
*
* Created on: 2017/07/09
* Author: LitMc
*/
#define MYDEBUG
#include <bits/stdc++.h>
//#ifdef MYDEBUG
#define dbp(x) cout<<#x<<": "<<x<<endl
#define dbp2(x,y) cout<<#x<<","<<#y<<": "<<x<<","<<y<<endl
#define dbp3(x,y,z) cout<<#x<<","<<#y<<","<<#z<<": "<<x<<","<<y<<","<<z<<endl
#define dbp4(w,x,y,z) cout<<#w<<","<<#x<<","<<#y<<","<<#z<<": "<<w<<","<<x<<","<<y<<","<<z<<endl
#define ifcin(x) std::ifstream cin(x)
#else
#define dbp(x)
#define dbp2(x,y)
#define dbp3(x,y,z)
#define dbp4(w,x,y,z)
#define ifcin(x)
#endif
#define ll long long
#define ull unsigned long long
#define all(x) x.begin(), x.end()
#define rep(i, from, to) for(int i=from; i<to; ++i)
#define REP(i, from, to) for(int i=from; i<=to; ++i)
#define EPS = 1e-14;
using std::vector;
using std::cout;
using std::cin;
using std::endl;
using std::max;
using std::min;
using std::swap;
using std::string;
using std::fill;
using std::pair;
using std::sort;
using std::reverse;
using std::pair;
using std::greater;
using std::priority_queue;
using std::ostream;
typedef std::complex<int> P;
template<typename T>
ostream& operator<<(ostream& out, const vector<vector<T> >& v) {
for (size_t i = 0; i < v.size(); ++i) {
out << v[i] << endl;
}
return out;
}
template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
out << "[";
size_t last = v.size() - 1;
for (size_t i = 0; i < v.size(); ++i) {
out << v[i];
if (i != last) {
out << ",";
}
}
out << "]";
return out;
}
static const ll MOD = 1000000007;
static const ll MAX_N = 110;
ll c[MAX_N][MAX_N];
ll n, p;
vector<ll> a;
ll even, odd;
void tbl() {
memset(c, 0, sizeof(c));
rep(n,0,MAX_N)
{
c[n][0] = 1;
rep(r,1,MAX_N)
{
c[n][r] = c[n - 1][r - 1] + c[n - 1][r];
}
}
}
void solve() {
tbl();
cin >> n >> p;
even = odd = 0;
rep(i,0,n)
{
ll ai;
cin >> ai;
a.push_back(ai);
if (ai % 2 == 0) {
even++;
} else {
odd++;
}
}
sort(all(a));
ll e = 0, o = 0;
REP(k,0,even)
{
e += c[even][k];
}
for (ll k = p; k <= odd; k += 2) {
o += c[odd][k];
}
ll ans = e * o;
dbp3(e, o, ans);
cout << ans << endl;
}
int main() {
solve();
}
| a.cc:17:2: error: #else without #if
17 | #else
| ^~~~
a.cc:18:9: warning: "dbp" redefined
18 | #define dbp(x)
| ^~~
a.cc:12:9: note: this is the location of the previous definition
12 | #define dbp(x) cout<<#x<<": "<<x<<endl
| ^~~
a.cc:19:9: warning: "dbp2" redefined
19 | #define dbp2(x,y)
| ^~~~
a.cc:13:9: note: this is the location of the previous definition
13 | #define dbp2(x,y) cout<<#x<<","<<#y<<": "<<x<<","<<y<<endl
| ^~~~
a.cc:20:9: warning: "dbp3" redefined
20 | #define dbp3(x,y,z)
| ^~~~
a.cc:14:9: note: this is the location of the previous definition
14 | #define dbp3(x,y,z) cout<<#x<<","<<#y<<","<<#z<<": "<<x<<","<<y<<","<<z<<endl
| ^~~~
a.cc:21:9: warning: "dbp4" redefined
21 | #define dbp4(w,x,y,z)
| ^~~~
a.cc:15:9: note: this is the location of the previous definition
15 | #define dbp4(w,x,y,z) cout<<#w<<","<<#x<<","<<#y<<","<<#z<<": "<<w<<","<<x<<","<<y<<","<<z<<endl
| ^~~~
a.cc:22:9: warning: "ifcin" redefined
22 | #define ifcin(x)
| ^~~~~
a.cc:16:9: note: this is the location of the previous definition
16 | #define ifcin(x) std::ifstream cin(x)
| ^~~~~
a.cc:23:2: error: #endif without #if
23 | #endif
| ^~~~~
|
s433326002 | p03665 | C++ | #include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <numeric>
/*
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::::::::::::::::::::::::::::::::::::::::::::'''```````:::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::''`_,-''.,... `::::::::::::::::::
:::::::::::::::::::::::::::::::::::::' _,-',;;!!!!!!!!!; `::::::::::::::::
::::::::::::::'`````:::::::::::::'' .-' ;<!!!!!!!'''`_..' `:::::::::::::::
::::::::::'' ,;!!!;,`::::::::::' .-`.,,,zcccc,,cccd$$"",;> `::::::::::::::
:::::::::' ;!!!!!!!!; ``:::::' ;' ,c$$$$$$$$$$$CC<<" ````_ ::::::::::::::
:::::::' ;!!!!!!!!!!!!!; ' ;! z$$$$$$$$$$$$$$$$$$$$$$??". ::::::::::::::
::::::: <!!!!!!!!!!!!!' . .!',c$$$$$$$$$$$$$c, `"""',;;<!! ::::::::::::::
:::::: ,!!!!!!!!!!!'`,;! .<! ,$$$$$$$$$$$$$$$$hc,,,..- !!!! `:::::::::::::
::::' <!!!!!!!!!' .<!!!;!! ,$$$$$""???$$$"""?????"" .<!!!! ::::::::::::::
::: ;><!!!!!!!!! ,<!!!!!!!',c, "??.< . "??h. -;;;;!!!!!!!' ::::::::::::::
::: !!!!!!!!!!' ;!!!!!!!!' d$$h.`$ccr,$h `;,." `!!!!!!!!! :::::::::::::::
:::.`<!!!!!!!' !!!!!!!!!! dP"""?.`$$F`$$h.`!!!!!!!!!!!!!! .:::::::::::::::
::::. <!!!!!! !!!!!!!!!! ,$ .nn.' "$$ P" <!!!!!!!!!!!' .::::::::::::::::
:::::. <!!!! ;!!!!!!!!!! $$ MMMMx ?$ ,dx `!!!!!!!!!!' ::::::::::::::::::
```:::: `!!! !!!'!!!!!! `$ MMMMMM, $r MMMr !!!!!!!!' .:::::::::::::::::::
`!!;,.`' ``' ``,;!!!!' ch." 4MMMMMM "$ 4MMM `!!!!!' ..::::::::::::::::::::
!!!!!'````'``<!!!'`.z$$$$. MMMMMMb $h MMM `!!'' .:::::::::::::::::::::::
..``.,d$$$$$c,,,. $$$$$F"? "MMMMMM $$ 4P" ' . ::::::::::::::::::::::::::
dM""..""?$$$$$$$$$$$$$$$$$$c "MM" $$>` ,c `:::::::::::::::::::::::::
MMn.`"?hc,d$$$$$$$$$$$$$$$$$$. `P $P' -??P== `:::::::::::::::::::::::
MMMMMnx`"?$$$$$$$$$$$P".,.`"??$ccccc$.z$$$$. `' .:::::::::::::::::' ''
MMMMMM,' .?$$$$$$$$$$ d$$$ d$$$$$$$$$$$$$h..``::::::::::::::::'
MMMMMMMn `?$$$$$$$$$$,.?$$h. =."?$$$$$$$$$$$$$$hc,.``'::::::::::'
MMMMMMMM ;, `"??$$$$$$h ?$$h. -m,``""??$$$$$$$$$$$$$c,.``````'
MMMMMMM> !!! ?cc,.,d$$$$h.`"?$hc `P .`"?$$$$$$$$$$$$$$$$$$$ .:
MMMMMMM ,!!'. $$$$$$$$$??=== `"""=c, " P n. "$$$$$$$$$$$$$$$$c_ ,.::::
MMMMMMP !!! Mr<$$$$"".,c,;M ;<!! ..""=_ ' 4 .br .`""??$$$$$$$$??"".:::::::
MMMMMM';!!',M>'$$$$$$$$$>4M `!!! 4MMbn.`"=cc," -'P",c=.,.`.. .= :::::::::
MMMMM' !!! dMb $$$$$$$$P MM> !!! 4MMMMMMr :..`"-._""Pr4"'-P" .,.`:::::::::
MMMM' <!!!,MMM "$$$$$$P dMM>;!!! 4MMMMMMb :::::.. "-=cczyycc??" .:::::::::
MMMP <!!! dMMMb "?$$P" uMMM>;!!! 4MMMMMMMr`:::::::::.........:::::::::::::
MMP';!!! ;MMMMMMn,.".uMMMMM ;!!! MMMMMMMMM,`::::::::::::::::::::::::::::::
MM ;!!!! MMMMMMMMMMMMMMMMMM !!!! MMMMMMMMMb `:::::::::::::::::::::::::::::
M" !!!! uMMMMMMMMMMMMMMMMMP !!! ;MMMMMMMMMMx :::::::::::::::::::::::::::::
P.!!!! ,MMMMMMMMMMMMMMMMMM ,!!! MMMMMMMMMMMMx`::::::::::::::::::::::::::::
!!!!> MMMMMMMMMMMMMMMMMMP !!!',MMMMMMMMMMMMM `:::::::::::::::::::::::::::
*/
std::vector<long long> dp(100);
long long brute_force(long long p, long long sum, long long pos, std::vector<long long> a)
{
long long ret = 0;
if (pos == a.size()) {
return (sum % 2 == p);
}
if (dp[pos] != -1) {
return dp[pos];
}
ret += brute_force(p, sum + a[pos], pos + 1, a);
ret += brute_force(p, sum, pos + 1, a);
dp[pos] = ret;
return ret;
}
int main()
{
long long n, p;
std::cin >> n >> p;
std::vector<long long> a(n);
for (int i = 0; i < n; i++) {
std::cin >> a[i];
}
for (int i = 0; i < dp.size() i++) {
dp[i] = -1;
}
std::cout << brute_force(p, 0, 0, a) << std::endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:85:38: error: expected ';' before 'i'
85 | for (int i = 0; i < dp.size() i++) {
| ^~
| ;
|
s553126369 | p03665 | C++ | 45 1
17 55 85 55 74 20 90 67 40 70 39 89 91 50 16 24 14 43 24 66 25 9 89 71 41 16 53 13 61 15 85 72 62 67 42 26 36 66 4 87 59 91 4 25 26 | a.cc:1:1: error: expected unqualified-id before numeric constant
1 | 45 1
| ^~
|
s876908192 | p03665 | C++ | import sys
# sys.stdin = open('a1.in')
def read_int_list():
return list(map(int, input().split()))
def read_int():
return int(input())
def read_str_list():
return input().split()
def read_str():
return input()
def solve():
n, p = read_int_list()
a = read_int_list()
a = map(lambda x: x % 2, a)
o = sum(a)
e = n - o
res = 0
c = 1
for k in range(o + 1):
if k % 2 == p % 2:
res += c
c *= o - k
c //= k + 1
res *= 2 ** e
return res
def main():
res = solve()
print(res)
if __name__ == '__main__':
main()
| a.cc:3:3: error: invalid preprocessing directive #sys
3 | # sys.stdin = open('a1.in')
| ^~~
a.cc:44:16: warning: multi-character literal with 8 characters exceeds 'int' size of 4 bytes
44 | if __name__ == '__main__':
| ^~~~~~~~~~
a.cc:1:1: error: 'import' does not name a type
1 | import sys
| ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
|
s036199394 | p03665 | Java | import java.io.*;
import java.util.*;
import java.math.*;
public class A implements Runnable {
private static BufferedReader in;
private static PrintWriter out;
private static StringTokenizer st;
private static Random rnd;
private void solve() throws IOException {
int n = nextInt();
int p = nextInt();
long zero = 1, one = 0;
for (int i = 0; i < n; i++) {
int a = nextInt() % 2;
long newZero = 0;
long newOne = 0;
if (a == 0) {
newZero = 2 * zero;
newOne = 2 * one;
} else {
newZero = (zero + one);
newOne = (zero + one);
}
zero = newZero;
one = newOne;
}
long result = (p == 0 ? zero : one);
out.println(result);
}
public static void main(String[] args) {
new A().run();
}
public void run() {
try {
in = new BufferedReader(new InputStreamReader(System.in));
out = new PrintWriter(System.out);
rnd = new Random();
solve();
out.close();
} catch (IOException e) {
e.printStackTrace();
System.exit(1);
}
}
private String nextToken() throws IOException {
while (st == null || !st.hasMoreTokens()) {
String line = in.readLine();
if (line == null)
return null;
st = new StringTokenizer(line);
}
return st.nextToken();
}
private int nextInt() throws IOException {
return Integer.parseInt(nextToken());
}
private long nextLong() throws IOException {
return Long.parseLong(nextToken());
}
private double nextDouble() throws IOException {
return Double.parseDouble(nextToken());
}
} | Main.java:5: error: class A is public, should be declared in a file named A.java
public class A implements Runnable {
^
1 error
|
s935791852 | p03665 | C++ | #include "grader.h"
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define re return
#define fi first
#define mp make_pair
#define se second
#define sz(a) (int)a.size()
#define prev previ
#define tm tmmm
#define div divv
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
const ll mod = ll(1e9) + 9LL, pr = 239, mod2 = ll(1e9) + 7;
int n, p, sum, k[2];
ll cnt[100][100];
int main() {
iostream::sync_with_stdio(0), cin.tie(0);
cin >> n >> p;
forn (i, n) {
int a;
cin >> a;
k[a % 2]++;
sum = (sum + a) % 2;
}
int k1 = 0;
if ((sum + p) % 2)
k1 = 1;
ll ans = 1;
forn (i, k[0])
ans = ans * 2LL;
cnt[0][0] = 1;
for (int i = 1; i < 100; i++) {
cnt[i][0] = 1;
for (int j = 1; j <= i; j++)
cnt[i][j] = cnt[i - 1][j] + cnt[i - 1][j - 1];
}
sum = 0;
for (int i = k1; i <= k[1]; i += 2)
sum += cnt[k[1]][i];
ans *= sum;
cout << ans;
} | a.cc:1:10: fatal error: grader.h: No such file or directory
1 | #include "grader.h"
| ^~~~~~~~~~
compilation terminated.
|
s776075507 | p03665 | C++ | w#include <cstdio>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
#define TRACE(x) cerr << #x << " = " << x << endl
#define REP(i, n) for (int i=0; i<n; i++)
#define FOR(i, a, b) for (int i=(a); i<(b); i++)
#define _ << " " <<
typedef long long ll;
typedef pair<int, int> P;
#define X first
#define Y second
const int MAX = 55;
ll dp[MAX][2];
int pp[MAX];
int main()
{
int n, p;
scanf("%d%d", &n, &p);
REP(i, n)
scanf("%d", &pp[i]);
dp[0][0] = 1;
REP(i, n) {
REP(j, 2) {
dp[i+1][j] += dp[i][j];
dp[i+1][(j+pp[i])%2] += dp[i][j];
}
}
printf("%lld\n", dp[n][p]);
return 0;
}
| a.cc:1:2: error: stray '#' in program
1 | w#include <cstdio>
| ^
a.cc:1:1: error: 'w' does not name a type
1 | w#include <cstdio>
| ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:62,
from /usr/include/c++/14/algorithm:60,
from a.cc:4:
/usr/include/c++/14/ext/type_traits.h:164:35: error: 'constexpr const bool __gnu_cxx::__is_null_pointer' redeclared as different kind of entity
164 | __is_null_pointer(std::nullptr_t)
| ^
/usr/include/c++/14/ext/type_traits.h:159:5: note: previous declaration 'template<class _Type> constexpr bool __gnu_cxx::__is_null_pointer(_Type)'
159 | __is_null_pointer(_Type)
| ^~~~~~~~~~~~~~~~~
/usr/include/c++/14/ext/type_traits.h:164:26: error: 'nullptr_t' is not a member of 'std'
164 | __is_null_pointer(std::nullptr_t)
| ^~~~~~~~~
In file included from /usr/include/c++/14/bits/stl_pair.h:60,
from /usr/include/c++/14/bits/stl_algobase.h:64:
/usr/include/c++/14/type_traits:666:33: error: 'nullptr_t' is not a member of 'std'
666 | struct is_null_pointer<std::nullptr_t>
| ^~~~~~~~~
/usr/include/c++/14/type_traits:666:42: error: template argument 1 is invalid
666 | struct is_null_pointer<std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:670:48: error: template argument 1 is invalid
670 | struct is_null_pointer<const std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:674:51: error: template argument 1 is invalid
674 | struct is_null_pointer<volatile std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:678:57: error: template argument 1 is invalid
678 | struct is_null_pointer<const volatile std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1429 | : public integral_constant<std::size_t, alignof(_Tp)>
| ^~~~~~
In file included from /usr/include/string.h:33,
from /usr/include/c++/14/cstring:43,
from a.cc:2:
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1429:57: error: template argument 1 is invalid
1429 | : public integral_constant<std::size_t, alignof(_Tp)>
| ^
/usr/include/c++/14/type_traits:1429:57: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1438:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1438 | : public integral_constant<std::size_t, 0> { };
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1438:46: error: template argument 1 is invalid
1438 | : public integral_constant<std::size_t, 0> { };
| ^
/usr/include/c++/14/type_traits:1438:46: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1440:26: error: 'std::size_t' has not been declared
1440 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:1441:21: error: '_Size' was not declared in this scope
1441 | struct rank<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:1441:27: error: template argument 1 is invalid
1441 | struct rank<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:1442:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1442:65: error: template argument 1 is invalid
1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^
/usr/include/c++/14/type_traits:1442:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1446:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1446:65: error: template argument 1 is invalid
1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^
/usr/include/c++/14/type_traits:1446:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:2086:26: error: 'std::size_t' has not been declared
2086 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:2087:30: error: '_Size' was not declared in this scope
2087 | struct remove_extent<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:2087:36: error: template argument 1 is invalid
2087 | struct remove_extent<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:2099:26: error: 'std::size_t' has not been declared
2099 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:2100:35: error: '_Size' was not declared in this scope
2100 | struct remove_all_extents<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:2100:41: error: template argument 1 is invalid
2100 | struct remove_all_extents<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:2171:12: error: 'std::size_t' has not been declared
2171 | template<std::size_t _Len>
| ^~~
/usr/include/c++/14/type_traits:2176:30: error: '_Len' was not declared in this scope
2176 | unsigned char __data[_Len];
| ^~~~
/usr/include/c++/14/type_traits:2194:12: error: 'std::size_t' has not been declared
2194 | template<std::size_t _Len, std::size_t _Align =
| ^~~
/usr/include/c++/14/type_traits:2194:30: error: 'std::size_t' has not been declared
2194 | template<std::size_t _Len, std::size_t _Align =
| ^~~
/usr/include/c++/14/type_traits:2195:55: error: '_Len' was not declared in this scope
2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)>
| ^~~~
/usr/include/c++/14/type_traits:2195:59: error: template argument 1 is invalid
2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)>
| ^
/usr/include/c++/14/type_traits:2202:30: error: '_Len' was not declared in this scope
2202 | unsigned char __data[_Len];
| ^~~~
/usr/include/c++/14/type_traits:2203:44: error: '_Align' was not declared in this scope
2203 | struct __attribute__((__aligned__((_Align)))) { } __align;
| ^~~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:65:
/usr/include/c++/14/bits/stl_iterator_base_types.h:125:67: error: 'ptrdiff_t' does not name a type
125 | template<typename _Category, typename _Tp, typename _Distance = ptrdiff_t,
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_types.h:1:1: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
+++ |+#include <cstddef>
1 | // Types used in iterator implementation -*- C++ -*-
/usr/include/c++/14/bits/stl_iterator_base_types.h:214:15: error: 'ptrdiff_t' does not name a type
214 | typedef ptrdiff_t difference_type;
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_types.h:214:15: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/c++/14/bits/stl_iterator_base_types.h:225:15: error: 'ptrdiff_t' does not name a type
225 | typedef ptrdiff_t difference_type;
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_types.h:225:15: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
In file included from /usr/include/c++/14/bits/stl_algobase.h:66:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:112:5: error: 'ptrdiff_t' does not name a type
112 | ptrdiff_t
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:66:1: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
65 | #include <debug/assertions.h>
+++ |+#include <cstddef>
66 | #include <bits/stl_iterator_base_types.h>
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:118:5: error: 'ptrdiff_t' does not name a type
118 | ptrdiff_t
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:118:5: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
In file included from /usr/include/c++/14/bits/stl_iterator.h:67,
from /usr/include/c++/14/bits/stl_algobase.h:67:
/usr/include/c++/14/bits/ptr_trai |
s139361410 | p03665 | C++ | #include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <iomanip>
using namespace std;
const int N = 50 + 7;
ll dp[N][2];
int main()
{
#ifdef ONPC
freopen("a.in", "r", stdin);
#endif
dp[0][0] = 1;
int n, p;
scanf("%d%d", &n, &p);
for (int i = 0; i < n; i++)
{
int x;
scanf("%d", &x);
dp[i + 1][0] += dp[i][0];
dp[i + 1][1] += dp[i][1];
if (x)
{
dp[i + 1][1] += dp[i][0];
dp[i + 1][0] += dp[i][1];
}
else
{
dp[i + 1][0] += dp[i][0];
dp[i + 1][1] += dp[i][1];
}
}
cout << dp[n][p] << endl;
}
| a.cc:22:1: error: 'll' does not name a type
22 | ll dp[N][2];
| ^~
a.cc: In function 'int main()':
a.cc:29:5: error: 'dp' was not declared in this scope
29 | dp[0][0] = 1;
| ^~
|
s315111814 | p03666 | C++ | #include <bits/stdc++.h>
#include <atcoder/mincostflow>
using namespace atcoder;
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <iostream>
#include <numeric>
#define rep(i,n) for (int i = 0;i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
int INF = 1e9;
ll LINF = 1e18;
int main(){
int n,a,b,c,d;cin >> n >> a >> b >> c >> d;
--n;
bool flag = false;
for(int i = 0;2*i <= n;i++){
int diff1 = abs(b-a) - i*abs(c-d);
int diff2 = abs(b-a) - i*abs(c-d);
if(diff1%c==0 && diff1/c <= n-2*i && (diff1/c - (n-2*i))%2 == 0) flag = true;
else if(diff2%c==0 && diff2/c <= n-2*i && (diff2/c - (n-2*i))%2 == 0) flag = true;
else if(diff1%d==0 && diff1/d <= n-2*i && (diff1/d - (n-2*i))%2 == 0) flag = true;
else if(diff2%d==0 && diff2/d <= n-2*i && (diff2/d - (n-2*i))%2 == 0) flag = true;
}
if(flag) cout << "YES" << endl;
else cout << "NO" << endl;
} | a.cc:2:10: fatal error: atcoder/mincostflow: No such file or directory
2 | #include <atcoder/mincostflow>
| ^~~~~~~~~~~~~~~~~~~~~
compilation terminated.
|
s543211596 | p03666 | C++ | #ifdef __LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b) {if(a<b) {a=b; return true;} return false;}
template<typename T> bool chmin(T &a,T b) {if(a>b) {a=b; return true;} return false;}
#define itn int
#define fi first
#define se second
#define intmax numeric_limits<int>::max()
#define llmax numeric_limits<ll>::max()
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>=1;i--)
#define all(vec) vec.begin(),vec.end()
#define sortt(vec) sort((vec).begin(),(vec).end())
#define rsort(vec) sort((vec).rbegin(), (vec).rend())
typedef int128_t ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=1<<30;
const ll lnf=1ll<<60;
int main(){
itn n; cin >> n;
ll a,b,c,d; cin >> a >> b >> c >> d;
if()
vector<ll> m={a+n/2*(c-d),a+n/2*(d-c)};
vector<ll> l={a-d+(n-1)/2*(c-d),a-c+(n-1)/2*(d-c)};
vector<ll> r={a+c+(n-1)/2*(c-d),a+d+(n-1)/2*(d-c)};
if(n%2==0){
if(l[0]<=b&&b<=l[1]||r[0]<=b&&b<=r[1]){
cout << "YES" << endl;
return 0;
}
else{
cout << "NO" << endl;
return 0;
}
}
else{
if(m[0]<=b&&b<=m[1]){
cout << "YES" << endl;
return 0;
}
else{
cout << "NO" << endl;
return 0;
}
}
} | a.cc:20:9: error: 'int128_t' does not name a type; did you mean 'int8_t'?
20 | typedef int128_t ll;
| ^~~~~~~~
| int8_t
a.cc:22:14: error: 'll' was not declared in this scope; did you mean 'ld'?
22 | typedef pair<ll,ll> pll;
| ^~
| ld
a.cc:22:17: error: 'll' was not declared in this scope; did you mean 'ld'?
22 | typedef pair<ll,ll> pll;
| ^~
| ld
a.cc:22:19: error: template argument 1 is invalid
22 | typedef pair<ll,ll> pll;
| ^
a.cc:22:19: error: template argument 2 is invalid
a.cc:24:15: error: 'll' was not declared in this scope; did you mean 'pll'?
24 | typedef tuple<ll,ll,ll> tlll;
| ^~
| pll
a.cc:24:18: error: 'll' was not declared in this scope; did you mean 'pll'?
24 | typedef tuple<ll,ll,ll> tlll;
| ^~
| pll
a.cc:24:21: error: 'll' was not declared in this scope; did you mean 'pll'?
24 | typedef tuple<ll,ll,ll> tlll;
| ^~
| pll
a.cc:24:23: error: template argument 1 is invalid
24 | typedef tuple<ll,ll,ll> tlll;
| ^
a.cc:24:23: error: template argument 2 is invalid
a.cc:24:23: error: template argument 3 is invalid
a.cc:26:7: error: 'll' does not name a type; did you mean 'pll'?
26 | const ll mod=1e9+7;
| ^~
| pll
a.cc:28:7: error: 'll' does not name a type; did you mean 'pll'?
28 | const ll lnf=1ll<<60;
| ^~
| pll
a.cc: In function 'int main()':
a.cc:32:3: error: 'll' was not declared in this scope; did you mean 'pll'?
32 | ll a,b,c,d; cin >> a >> b >> c >> d;
| ^~
| pll
a.cc:32:22: error: 'a' was not declared in this scope
32 | ll a,b,c,d; cin >> a >> b >> c >> d;
| ^
a.cc:32:27: error: 'b' was not declared in this scope
32 | ll a,b,c,d; cin >> a >> b >> c >> d;
| ^
a.cc:32:32: error: 'c' was not declared in this scope
32 | ll a,b,c,d; cin >> a >> b >> c >> d;
| ^
a.cc:32:37: error: 'd' was not declared in this scope
32 | ll a,b,c,d; cin >> a >> b >> c >> d;
| ^
a.cc:33:6: error: expected primary-expression before ')' token
33 | if()
| ^
a.cc:34:12: error: template argument 2 is invalid
34 | vector<ll> m={a+n/2*(c-d),a+n/2*(d-c)};
| ^
a.cc:34:14: error: scalar object 'm' requires one element in initializer
34 | vector<ll> m={a+n/2*(c-d),a+n/2*(d-c)};
| ^
a.cc:35:12: error: template argument 2 is invalid
35 | vector<ll> l={a-d+(n-1)/2*(c-d),a-c+(n-1)/2*(d-c)};
| ^
a.cc:35:14: error: scalar object 'l' requires one element in initializer
35 | vector<ll> l={a-d+(n-1)/2*(c-d),a-c+(n-1)/2*(d-c)};
| ^
a.cc:36:12: error: template argument 2 is invalid
36 | vector<ll> r={a+c+(n-1)/2*(c-d),a+d+(n-1)/2*(d-c)};
| ^
a.cc:36:14: error: scalar object 'r' requires one element in initializer
36 | vector<ll> r={a+c+(n-1)/2*(c-d),a+d+(n-1)/2*(d-c)};
| ^
a.cc:48:8: error: 'm' was not declared in this scope
48 | if(m[0]<=b&&b<=m[1]){
| ^
|
s839995828 | p03666 | C++ | #include <bits/stdc++.h>
using namespace std;
#define int long long
int main(){
int N, A, B, C, D; cin >> N >> A >> B >> C >> D;
int b = abs(A - B);
bool o = false;
for(int i=0; i<N-1; i++){
int p = i, m = N-1 - i;
int n = C*p - D*m, x = D*p - C*m;
if(n <= b&&b <= x){
o = true;
}
}
if(o){
cout << "YES";
}else{
cout << "NO";
}
return 0;
}
| cc1plus: error: '::main' must return 'int'
|
s867388784 | p03666 | C++ | #include <bits/stdc++.h>
using namespace std;
#define int long long
int main(){
int N, A, B, C, D; cin >> N >> A >> B >> C >> D;
int b = abs(A - B);
bool o = false;
for(int i=0; i<N-1; i++){
int p = i, m = N-1 - i;
int n = C*p - D*m, x = D*p - C*m;
if(n <= b&&b <= x){
o = true;
}
}
if(o){
cout << "YES";
}else{
cout << "NO";
}
}
| cc1plus: error: '::main' must return 'int'
|
s406960928 | p03666 | C++ | #include <bits/stdc++.h>
using namespace std;
#define int long long
int main(){
int N, A, B, C, D; cin >> N >> A >> B >> C >> D;
int b = abs(A - B);
bool o = false;
for(int i=0; i<N-1; i++){
int p = i, m = N-1 - i;
int n = C*p - D*m, x = D*p - C*m;
if(n <= b&&b <= x){
ok = true;
}
}
if(o){
cout << "YES";
}else{
cout << "NO";
}
} | cc1plus: error: '::main' must return 'int'
a.cc: In function 'int main()':
a.cc:13:13: error: 'ok' was not declared in this scope; did you mean 'o'?
13 | ok = true;
| ^~
| o
|
s712355977 | p03666 | C++ | #include <bits/stdc++.h>
using namespace std;
int main(){
int N, A, B, C, D; cin >> N >> A >> B >> C >> D;
int b = abs(A - B);
bool o = false;
for(int i=0; i<N-1; i++){
int p = i, m = N-1 - i;
int n = C*p - D*m, x = D*p - C*m;
if(n <= b&&b <= x){
ok = true;
}
}
if(o){
cout << "YES";
}else{
cout << "NO";
}
}
| a.cc: In function 'int main()':
a.cc:12:13: error: 'ok' was not declared in this scope; did you mean 'o'?
12 | ok = true;
| ^~
| o
|
s258523244 | p03666 | C++ | #include <bits/stdc++.h>
using namespace std;
int main(){
int N, A, B, C, D; cin >> N >> A >> B >> C >> D;
int b = abs(A - B);
bool o = false;
for(int i=0; i<N-1; i++){
int p = i, m = N-1 - i;
int n = C*p - D*m, x = D*p - C*m;
if(n <= b&&b <= x){
ok = true;
}
}
if(ok){
cout << "YES";
}else{
cout << "NO";
}
}
| a.cc: In function 'int main()':
a.cc:12:13: error: 'ok' was not declared in this scope; did you mean 'o'?
12 | ok = true;
| ^~
| o
a.cc:15:8: error: 'ok' was not declared in this scope; did you mean 'o'?
15 | if(ok){
| ^~
| o
|
s879593239 | p03666 | C++ | N, A, B, C, D = map(int, input().split())
left_max = [A] * N
left_min = [A] * N
right_max = [B] * N
right_min = [B] * N
for i in range(1, N):
left_max[i] = left_max[i - 1] + D
left_min[i] = left_min[i - 1] + C
for i in range(N - 2, -1, -1):
right_max[i] = right_max[i + 1] + D
right_min[i] = right_min[i + 1] + C
able = False
for i in range(N):
if left_max[i] >= right_min[i] and left_min[i] <= right_max[i]:
able = True
break
print("YES" if able else "NO") | a.cc:1:1: error: 'N' does not name a type
1 | N, A, B, C, D = map(int, input().split())
| ^
|
s429555830 | p03666 | C++ | #include <bits/stdc++.h>
typedef long long ll;
int main(){
ll n,a,b,l,r;
cin>>n>>a>>b>>l>>r;
int flag = 1;
ll x,y;
for(ll i = 0; i <= n-1;i++){
x = a+l*i-(n-i-1)*r;
y = a+r*i-(n-i-1)*l;
if(x <= b && b <= y){
flag = 0;
}
}
if(flag)cout<<"NO"<<endl;
else cout<<"YES"<<endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:7:5: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
7 | cin>>n>>a>>b>>l>>r;
| ^~~
| std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146,
from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
62 | extern istream cin; ///< Linked to standard input
| ^~~
a.cc:17:13: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
17 | if(flag)cout<<"NO"<<endl;
| ^~~~
| std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
63 | extern ostream cout; ///< Linked to standard output
| ^~~~
a.cc:17:25: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
17 | if(flag)cout<<"NO"<<endl;
| ^~~~
| std::endl
In file included from /usr/include/c++/14/istream:41,
from /usr/include/c++/14/sstream:40,
from /usr/include/c++/14/complex:45,
from /usr/include/c++/14/ccomplex:39,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
744 | endl(basic_ostream<_CharT, _Traits>& __os)
| ^~~~
a.cc:18:10: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
18 | else cout<<"YES"<<endl;
| ^~~~
| std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
63 | extern ostream cout; ///< Linked to standard output
| ^~~~
a.cc:18:23: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
18 | else cout<<"YES"<<endl;
| ^~~~
| std::endl
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
744 | endl(basic_ostream<_CharT, _Traits>& __os)
| ^~~~
|
s406332381 | p03666 | C++ | #include <bits/stdc++.h>
typedef long long ll;
int main(){
ll n,a,b,l,r;
cin>>n>>a>>b>>l>>r;
int flag = 1;
ll x,y;
for(ll i = 0; i <= n-1;i++){
x = a+l*i-(n-i-1)*r;
y = a+r*i-(n-i-1)*l;
if(x <= b && b <= y){
flag = 0;
}
}
printf("%s\n", flag?"NO":"YES");
return 0;
} | a.cc: In function 'int main()':
a.cc:7:5: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
7 | cin>>n>>a>>b>>l>>r;
| ^~~
| std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146,
from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
62 | extern istream cin; ///< Linked to standard input
| ^~~
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.