submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s217141074
p03674
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> using namespace std; #define ll long long ll exp_mod(int a,int b,int p) { ll ans=1; ll cur=a; while (b>0){ if (b%2==1) ans=(ans*cur) % p; cur=(cur*cur) % p; b/=2; } return ans; }   int main(int argc,char **argv) { int n,x,y; cin>>n; map<int,int> h; for (int i=0; i < n+1; ++i) { int k; cin>>k; map<int,int> it=h.find(k); if (it != h.end()) { x=it->second; y=i+1; } else h[k]=i+1; } const int P=1000000007; ll a=1; ll b=1; int exp=1; for (int k=1;k<= n+1; ++k) { int w=exp_mod(k,P-2,P); a=(a*(n+2-k))%P; a=(a*w)%P;   if (k>=2) { b=(b*(n+x-y-k+2))%P; b=(b*prev_exp)%P; } exp=w; int c=(a-b)%P; if (c<0)c+=P; cout<<c; } return 0; }
a.cc:37:1: error: extended character   is not valid in an identifier 37 |   | ^ a.cc:61:1: error: extended character   is not valid in an identifier 61 |   | ^ a.cc:37:1: error: '\U000000a0' does not name a type 37 |   | ^
s702892496
p03674
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> using namespace std; #define ll long long ll exp_mod(int a,int b,int p) { ll ans=1; ll cur=a; while (b>0){ if (b%2==1) ans=(ans*cur) % p; cur=(cur*cur) % p; b/=2; } return ans; }   int main(int argc,char **argv) { int n,x,y; cin>>n; map<int,int> h; for (int i=0; i < n+1; ++i) { int k; cin>>k; map<int,int> it=h.find(k); if (it != h.end()) { x=it->second; y=i+1; } else h[k]=i+1; } const int P=1000000007; ll a=1; ll b=1; int exp=1; for (int k=1;k<= n+1; ++k) { int w=exp_mod(k,P-2,P); a=(a*(n+2-k))%P; a=(a*w)%P;   if (k>=2) { b=(b*(n+x-y-k+2))%P; b=(b*prev_exp)%P; } exp=w; int c=(a-b)%P; if (c<0)c+=P; cout<<c; } return 0; }
a.cc:37:1: error: extended character   is not valid in an identifier 37 |   | ^ a.cc:61:1: error: extended character   is not valid in an identifier 61 |   | ^ a.cc:37:1: error: '\U000000a0' does not name a type 37 |   | ^
s524355593
p03674
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> using namespace std; #define ll long long ll exp_mod(int a,int b,int p) { ll ans=1; ll cur=a; while (b>0){ if (b%2==1) ans=(ans*cur) % p; cur=(cur*cur) % p; b/=2; } return ans; }   int main(int argc,char **argv) { int n,x,y; cin>>n; map<int,int> h; for (int i=0; i < n+1; ++i) { int k; cin>>k; map<int,int> it=h.find(k); if (it != h.end()) { x=it->second; y=i+1; } else h[k]=i+1; } const int P=1000000007; ll a=1; ll b=1; int exp=1; for (int k=1;k<= n+1; ++k) { int w=exp_mod(k,P-2,P); a=(a*(n+2-k))%P; a=(a*w)%P;   if (k>=2) { b=(b*(n+x-y-k+2))%P; b=(b*prev_exp)%P; } exp=w; int c=(a-b)%P; if (c<0)c+=P; cout<<c; } return 0; }
a.cc:37:1: error: extended character   is not valid in an identifier 37 |   | ^ a.cc:61:1: error: extended character   is not valid in an identifier 61 |   | ^ a.cc:37:1: error: '\U000000a0' does not name a type 37 |   | ^
s970757609
p03674
C++
#include <iostream> #include<sstream> #include<vector> #include<iterator> #include<map> using namespace std; typedef long long LL; class Combination { public: Combination(LL sz, LL m) : size(sz+1), mod(m), param(size, 1) { for(LL i=2; i<size; i++) { param[i] = param[i-1] * i; param[i] %= mod; } } LL nCr(LL n, LL c) { LL ret = param[n]; ret *= inverse(c); ret %= mod; ret *= inverse(n-c); ret %= mod; return ret; } private: LL inverse(LL n) { LL ret = 1; LL a = param[n]; for(LL i=mod-2; i>0; i/=2) { if(i&1) { ret *= a; ret %= mod; } a *= a; a %= mod; } return ret % mod; } const LL size; const LL mod; vector<LL> param; }; int main(void) { int n; cin >> n; vector<int> a(n+1); map<int, int> table; for(int i=0; i<n+1; i++) { cin >> a[i]; table[a[i]]++; } int left, right; for(auto it=table.begin(); it!=table.end(); it++) { if(it->second == 2) { left = find(a.begin(), a.end(), it->first) - a.begin(); right = find(a.begin()+left+1, a.end(), it->first) - a.begin(); break; } } Combination comb(n+1, 1E9+7); for(int i=1; i<=n+1; i++) { long long ret = comb.nCr(n+1, i); if(left+n-right >= i-1) ret -= comb.nCr(left+n-right, i-1); cout << ret << endl; } return 0; }
a.cc: In function 'int main()': a.cc:77:36: error: no matching function for call to 'find(std::vector<int>::iterator, std::vector<int>::iterator, const int&)' 77 | left = find(a.begin(), a.end(), it->first) - a.begin(); | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/bits/locale_facets.h:48, from /usr/include/c++/14/bits/basic_ios.h:37, from /usr/include/c++/14/ios:46, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)' 435 | find(istreambuf_iterator<_CharT> __first, | ^~~~ /usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: template argument deduction/substitution failed: a.cc:77:36: note: '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'std::istreambuf_iterator<_CharT>' 77 | left = find(a.begin(), a.end(), it->first) - a.begin(); | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:78:37: error: no matching function for call to 'find(__gnu_cxx::__normal_iterator<int*, std::vector<int> >, std::vector<int>::iterator, const int&)' 78 | right = find(a.begin()+left+1, a.end(), it->first) - a.begin(); | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)' 435 | find(istreambuf_iterator<_CharT> __first, | ^~~~ /usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: template argument deduction/substitution failed: a.cc:78:37: note: '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'std::istreambuf_iterator<_CharT>' 78 | right = find(a.begin()+left+1, a.end(), it->first) - a.begin(); | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
s887018027
p03674
C++
#include <iostream> #include <cstring> #include <algorithm> #define MOD 1000000007 using namespace std; typedef __int128 ll; ll *FACT, *IFACT; ll extgcd(ll a, ll b, ll &x, ll &y) { ll g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; } ll invMod(ll a, ll m) { ll x, y; if (extgcd(a, m, x, y) == 1) return (x + m) % m; else return 0; // unsolvable } void init(ll N){ FACT = new ll[N + 1]; IFACT = new ll[N + 1]; FACT[0] = 1; IFACT[0] = 1; for (ll i = 1; i <= N; i++){ FACT[i] = FACT[i - 1] * i % MOD; IFACT[i] = invMod(FACT[i], MOD); } } long C(ll n, ll r) { if (n < 0 || r < 0 || r > n)return 0; if (r > n / 2)r = n - r; return FACT[n] * IFACT[n - r] % MOD*IFACT[r] % MOD; } signed main() { ll ans; ll i; ll j; ll n; ll dup; ll dup_f = -1; ll dup_b; cin >> n; ll a[100005]; ll b[100005]; init(100010); for (i = 0; i<n + 1; i++){ int buf; cin >> buf; a[i] = (ll)buf; }; memcpy(b, a, sizeof(ll)*100005); sort(begin(a), begin(a) + n); for (i = 0; i<n + 1; i++){ if (a[i] == a[i + 1]){ dup = a[i]; }; }; for (i = 0; i<n + 1; i++){ if (b[i] == dup && dup_f == -1){ dup_f = i; } else if (b[i] == dup){ dup_b = i; }; }; for (i = 0; i<n + 1; i++){ ans = C(n + 1, i + 1) - C(dup_f + n - dup_b, i); if (ans < 0){ ans = ans + MOD; } long long int buf = (long long int)ans; cout << buf << endl; }; return 0; }
a.cc: In function 'int main()': a.cc:46:13: error: no match for 'operator>>' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and 'll' {aka '__int128'}) 46 | cin >> n; | ~~~ ^~ ~ | | | | | ll {aka __int128} | std::istream {aka std::basic_istream<char>} In file included from /usr/include/c++/14/iostream:42, from a.cc:1: /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>]' (near match) 170 | operator>>(bool& __n) | ^~~~~~~~ /usr/include/c++/14/istream:170:7: note: conversion of argument 1 would be ill-formed: a.cc:46:16: error: cannot bind non-const lvalue reference of type 'bool&' to a value of type 'll' {aka '__int128'} 46 | cin >> 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>]' (near match) 174 | operator>>(short& __n); | ^~~~~~~~ /usr/include/c++/14/istream:174:7: note: conversion of argument 1 would be ill-formed: a.cc:46:16: error: cannot bind non-const lvalue reference of type 'short int&' to a value of type 'll' {aka '__int128'} 46 | cin >> 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>]' (near match) 177 | operator>>(unsigned short& __n) | ^~~~~~~~ /usr/include/c++/14/istream:177:7: note: conversion of argument 1 would be ill-formed: a.cc:46:16: error: cannot bind non-const lvalue reference of type 'short unsigned int&' to a value of type 'll' {aka '__int128'} 46 | cin >> 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>]' (near match) 181 | operator>>(int& __n); | ^~~~~~~~ /usr/include/c++/14/istream:181:7: note: conversion of argument 1 would be ill-formed: a.cc:46:16: error: cannot bind non-const lvalue reference of type 'int&' to a value of type 'll' {aka '__int128'} 46 | cin >> 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>]' (near match) 184 | operator>>(unsigned int& __n) | ^~~~~~~~ /usr/include/c++/14/istream:184:7: note: conversion of argument 1 would be ill-formed: a.cc:46:16: error: cannot bind non-const lvalue reference of type 'unsigned int&' to a value of type 'll' {aka '__int128'} 46 | cin >> 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>]' (near match) 188 | operator>>(long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:188:7: note: conversion of argument 1 would be ill-formed: a.cc:46:16: error: cannot bind non-const lvalue reference of type 'long int&' to a value of type 'll' {aka '__int128'} 46 | cin >> 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>]' (near match) 192 | operator>>(unsigned long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:192:7: note: conversion of argument 1 would be ill-formed: a.cc:46:16: error: cannot bind non-const lvalue reference of type 'long unsigned int&' to a value of type 'll' {aka '__int128'} 46 | cin >> 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>]' (near match) 199 | operator>>(long long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:199:7: note: conversion of argument 1 would be ill-formed: a.cc:46:16: error: cannot bind non-const lvalue reference of type 'long long int&' to a value of type 'll' {aka '__int128'} 46 | cin >> 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>]' (near match) 203 | operator>>(unsigned long long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:203:7: note: conversion of argument 1 would be ill-formed: a.cc:46:16: error: cannot bind non-const lvalue reference of type 'long long unsigned int&' to a value of type 'll' {aka '__int128'} 46 | cin >> 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>]' (near match) 219 | operator>>(float& __f) | ^~~~~~~~ /usr/include/c++/14/istream:219:7: note: conversion of argument 1 would be ill-formed: a.cc:46:16: error: cannot bind non-const lvalue reference of type 'float&' to a value of type 'll' {aka '__int128'} 46 | cin >> n; | ^ /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>]' (near match) 223 | operator>>(double& __f) | ^~~~~~~~ /usr/include/c++/14/istream:223:7: note: conversion of argument 1 would be ill-formed: a.cc:46:16: error: cannot bind non-const lvalue reference of type 'double&' to a value of type 'll' {aka '__int128'} 46 | cin >> n; | ^ /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>]' (near match) 227 | operator>>(long double& __f) | ^~~~~~~~ /usr/include/c++/14/istream:227:7: note: conversion of argument 1 would be ill-formed: a.cc:46:16: error: cannot bind non-const lvalue reference of type 'long double&' to a value of type 'll' {aka '__int128'} 46 | cin >> n; | ^ /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>]' (near match) 328 | operator>>(void*& __p) | ^~~~~~~~ /usr/include/c++/14/istream:328:7: note: conversion of argument 1 would be ill-formed: a.cc:46:16: error: invalid conversion from 'll' {aka '__int128'} to 'void*' [-fpermissive] 46 | cin >> n; | ^ | | | ll {aka __int128} a.cc:46:16: error: cannot bind rvalue '(void*)((long int)n)' to 'void*&' /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>]' (near match) 122 | operator>>(__istream_type& (*__pf)(__istream_type&)) | ^~~~~~~~ /usr/include/c++/14/istream:122:7: note: conversion of argument 1 would be ill-formed: a.cc:46:16: error: invalid conversion from 'll' {aka '__int128'} to 'std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&)' {aka 'std::basic_istream<char>& (*)(std::basic_istream<char>&)'} [-fpermissive] 46 | cin >> n; | ^ | | | ll {aka __int128} /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>]' (near match) 126 | operator>>(__ios_type& (*__pf)(__ios_type&)) | ^~~~~~~~ /usr/include/c++/14/istream:126:7: note: conversion of argument 1 would be ill-formed: a.cc:46:16: error: invalid conversion from 'll' {aka '__int128'} to 'std::basic_istream<char>::__ios_type& (*)(std::basic_istream<char>::__ios_type&)' {aka 'std::basic_ios<char>& (*)(std::basic_ios<char>&)'} [-fpermissive] 46 | cin >> n; | ^ | | | ll {aka __int128} /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_istrea
s695399975
p03674
C++
#include <iostream> #include <cstring> #include <algorithm> #define MOD 1000000007 using namespace std; typedef __int128 ll; ll *FACT, *IFACT; ll extgcd(ll a, ll b, ll &x, ll &y) { ll g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; } ll invMod(ll a, ll m) { ll x, y; if (extgcd(a, m, x, y) == 1) return (x + m) % m; else return 0; // unsolvable } void init(ll N){ FACT = new ll[N + 1]; IFACT = new ll[N + 1]; FACT[0] = 1; IFACT[0] = 1; for (ll i = 1; i <= N; i++){ FACT[i] = FACT[i - 1] * i % MOD; IFACT[i] = invMod(FACT[i], MOD); } } long C(ll n, ll r) { if (n < 0 || r < 0 || r > n)return 0; if (r > n / 2)r = n - r; return FACT[n] * IFACT[n - r] % MOD*IFACT[r] % MOD; } signed main() { ll ans; ll i; ll j; ll n; ll dup; ll dup_f = -1; ll dup_b; cin >> n; ll a[100005]; ll b[100005]; init(100010); for (i = 0; i<n + 1; i++){ cin >> a[i]; }; memcpy(b, a, sizeof(ll)*100005); sort(begin(a), begin(a) + n); for (i = 0; i<n + 1; i++){ if (a[i] == a[i + 1]){ dup = a[i]; }; }; for (i = 0; i<n + 1; i++){ if (b[i] == dup && dup_f == -1){ dup_f = i; } else if (b[i] == dup){ dup_b = i; }; }; for (i = 0; i<n + 1; i++){ ans = C(n + 1, i + 1) - C(dup_f + n - dup_b, i); if (ans < 0){ ans = ans + MOD; } cout << ans << endl; }; return 0; }
a.cc: In function 'int main()': a.cc:46:13: error: no match for 'operator>>' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and 'll' {aka '__int128'}) 46 | cin >> n; | ~~~ ^~ ~ | | | | | ll {aka __int128} | std::istream {aka std::basic_istream<char>} In file included from /usr/include/c++/14/iostream:42, from a.cc:1: /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>]' (near match) 170 | operator>>(bool& __n) | ^~~~~~~~ /usr/include/c++/14/istream:170:7: note: conversion of argument 1 would be ill-formed: a.cc:46:16: error: cannot bind non-const lvalue reference of type 'bool&' to a value of type 'll' {aka '__int128'} 46 | cin >> 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>]' (near match) 174 | operator>>(short& __n); | ^~~~~~~~ /usr/include/c++/14/istream:174:7: note: conversion of argument 1 would be ill-formed: a.cc:46:16: error: cannot bind non-const lvalue reference of type 'short int&' to a value of type 'll' {aka '__int128'} 46 | cin >> 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>]' (near match) 177 | operator>>(unsigned short& __n) | ^~~~~~~~ /usr/include/c++/14/istream:177:7: note: conversion of argument 1 would be ill-formed: a.cc:46:16: error: cannot bind non-const lvalue reference of type 'short unsigned int&' to a value of type 'll' {aka '__int128'} 46 | cin >> 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>]' (near match) 181 | operator>>(int& __n); | ^~~~~~~~ /usr/include/c++/14/istream:181:7: note: conversion of argument 1 would be ill-formed: a.cc:46:16: error: cannot bind non-const lvalue reference of type 'int&' to a value of type 'll' {aka '__int128'} 46 | cin >> 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>]' (near match) 184 | operator>>(unsigned int& __n) | ^~~~~~~~ /usr/include/c++/14/istream:184:7: note: conversion of argument 1 would be ill-formed: a.cc:46:16: error: cannot bind non-const lvalue reference of type 'unsigned int&' to a value of type 'll' {aka '__int128'} 46 | cin >> 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>]' (near match) 188 | operator>>(long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:188:7: note: conversion of argument 1 would be ill-formed: a.cc:46:16: error: cannot bind non-const lvalue reference of type 'long int&' to a value of type 'll' {aka '__int128'} 46 | cin >> 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>]' (near match) 192 | operator>>(unsigned long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:192:7: note: conversion of argument 1 would be ill-formed: a.cc:46:16: error: cannot bind non-const lvalue reference of type 'long unsigned int&' to a value of type 'll' {aka '__int128'} 46 | cin >> 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>]' (near match) 199 | operator>>(long long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:199:7: note: conversion of argument 1 would be ill-formed: a.cc:46:16: error: cannot bind non-const lvalue reference of type 'long long int&' to a value of type 'll' {aka '__int128'} 46 | cin >> 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>]' (near match) 203 | operator>>(unsigned long long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:203:7: note: conversion of argument 1 would be ill-formed: a.cc:46:16: error: cannot bind non-const lvalue reference of type 'long long unsigned int&' to a value of type 'll' {aka '__int128'} 46 | cin >> 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>]' (near match) 219 | operator>>(float& __f) | ^~~~~~~~ /usr/include/c++/14/istream:219:7: note: conversion of argument 1 would be ill-formed: a.cc:46:16: error: cannot bind non-const lvalue reference of type 'float&' to a value of type 'll' {aka '__int128'} 46 | cin >> n; | ^ /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>]' (near match) 223 | operator>>(double& __f) | ^~~~~~~~ /usr/include/c++/14/istream:223:7: note: conversion of argument 1 would be ill-formed: a.cc:46:16: error: cannot bind non-const lvalue reference of type 'double&' to a value of type 'll' {aka '__int128'} 46 | cin >> n; | ^ /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>]' (near match) 227 | operator>>(long double& __f) | ^~~~~~~~ /usr/include/c++/14/istream:227:7: note: conversion of argument 1 would be ill-formed: a.cc:46:16: error: cannot bind non-const lvalue reference of type 'long double&' to a value of type 'll' {aka '__int128'} 46 | cin >> n; | ^ /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>]' (near match) 328 | operator>>(void*& __p) | ^~~~~~~~ /usr/include/c++/14/istream:328:7: note: conversion of argument 1 would be ill-formed: a.cc:46:16: error: invalid conversion from 'll' {aka '__int128'} to 'void*' [-fpermissive] 46 | cin >> n; | ^ | | | ll {aka __int128} a.cc:46:16: error: cannot bind rvalue '(void*)((long int)n)' to 'void*&' /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>]' (near match) 122 | operator>>(__istream_type& (*__pf)(__istream_type&)) | ^~~~~~~~ /usr/include/c++/14/istream:122:7: note: conversion of argument 1 would be ill-formed: a.cc:46:16: error: invalid conversion from 'll' {aka '__int128'} to 'std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&)' {aka 'std::basic_istream<char>& (*)(std::basic_istream<char>&)'} [-fpermissive] 46 | cin >> n; | ^ | | | ll {aka __int128} /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>]' (near match) 126 | operator>>(__ios_type& (*__pf)(__ios_type&)) | ^~~~~~~~ /usr/include/c++/14/istream:126:7: note: conversion of argument 1 would be ill-formed: a.cc:46:16: error: invalid conversion from 'll' {aka '__int128'} to 'std::basic_istream<char>::__ios_type& (*)(std::basic_istream<char>::__ios_type&)' {aka 'std::basic_ios<char>& (*)(std::basic_ios<char>&)'} [-fpermissive] 46 | cin >> n; | ^ | | | ll {aka __int128} /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_istrea
s813546219
p03674
C++
#include <iostream> #include <cstring> #include <algorithm> #define MOD 1000000007 using namespace std; typedef _int128 ll; ll *FACT, *IFACT; ll extgcd(ll a, ll b, ll &x, ll &y) { ll g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; } ll invMod(ll a, ll m) { ll x, y; if (extgcd(a, m, x, y) == 1) return (x + m) % m; else return 0; // unsolvable } void init(ll N){ FACT = new ll[N + 1]; IFACT = new ll[N + 1]; FACT[0] = 1; IFACT[0] = 1; for (ll i = 1; i <= N; i++){ FACT[i] = FACT[i - 1] * i % MOD; IFACT[i] = invMod(FACT[i], MOD); } } long C(ll n, ll r) { if (n < 0 || r < 0 || r > n)return 0; if (r > n / 2)r = n - r; return FACT[n] * IFACT[n - r] % MOD*IFACT[r] % MOD; } signed main() { ll ans; ll i; ll j; ll n; ll dup; ll dup_f = -1; ll dup_b; cin >> n; ll a[100005]; ll b[100005]; init(100010); for (i = 0; i<n + 1; i++){ cin >> a[i]; }; memcpy(b, a, sizeof(ll)*100005); sort(begin(a), begin(a) + n); for (i = 0; i<n + 1; i++){ if (a[i] == a[i + 1]){ dup = a[i]; }; }; for (i = 0; i<n + 1; i++){ if (b[i] == dup && dup_f == -1){ dup_f = i; } else if (b[i] == dup){ dup_b = i; }; }; for (i = 0; i<n + 1; i++){ ans = C(n + 1, i + 1) - C(dup_f + n - dup_b, i); if (ans < 0){ ans = ans + MOD; } cout << ans << endl; }; return 0; }
a.cc:6:9: error: '_int128' does not name a type; did you mean '__int128'? 6 | typedef _int128 ll; | ^~~~~~~ | __int128 a.cc:8:1: error: 'll' does not name a type 8 | ll *FACT, *IFACT; | ^~ a.cc:9:1: error: 'll' does not name a type 9 | ll extgcd(ll a, ll b, ll &x, ll &y) { | ^~ a.cc:14:1: error: 'll' does not name a type 14 | ll invMod(ll a, ll m) { | ^~ a.cc:20:6: error: variable or field 'init' declared void 20 | void init(ll N){ | ^~~~ a.cc:20:11: error: 'll' was not declared in this scope 20 | void init(ll N){ | ^~ a.cc:30:8: error: 'll' was not declared in this scope 30 | long C(ll n, ll r) | ^~ a.cc:30:14: error: 'll' was not declared in this scope 30 | long C(ll n, ll r) | ^~ a.cc:30:18: error: expression list treated as compound expression in initializer [-fpermissive] 30 | long C(ll n, ll r) | ^ a.cc: In function 'int main()': a.cc:39:9: error: 'll' was not declared in this scope 39 | ll ans; | ^~ a.cc:40:11: error: expected ';' before 'i' 40 | ll i; | ^~ | ; a.cc:41:11: error: expected ';' before 'j' 41 | ll j; | ^~ | ; a.cc:42:11: error: expected ';' before 'n' 42 | ll n; | ^~ | ; a.cc:43:11: error: expected ';' before 'dup' 43 | ll dup; | ^~~~ | ; a.cc:44:11: error: expected ';' before 'dup_f' 44 | ll dup_f = -1; | ^~~~~~ | ; a.cc:45:11: error: expected ';' before 'dup_b' 45 | ll dup_b; | ^~~~~~ | ; a.cc:46:16: error: 'n' was not declared in this scope 46 | cin >> n; | ^ a.cc:47:11: error: expected ';' before 'a' 47 | ll a[100005]; | ^~ | ; a.cc:48:11: error: expected ';' before 'b' 48 | ll b[100005]; | ^~ | ; a.cc:49:9: error: 'init' was not declared in this scope; did you mean 'int'? 49 | init(100010); | ^~~~ | int a.cc:50:14: error: 'i' was not declared in this scope 50 | for (i = 0; i<n + 1; i++){ | ^ a.cc:51:24: error: 'a' was not declared in this scope 51 | cin >> a[i]; | ^ a.cc:53:16: error: 'b' was not declared in this scope 53 | memcpy(b, a, sizeof(ll)*100005); | ^ a.cc:53:19: error: 'a' was not declared in this scope 53 | memcpy(b, a, sizeof(ll)*100005); | ^ a.cc:55:14: error: 'i' was not declared in this scope 55 | for (i = 0; i<n + 1; i++){ | ^ a.cc:57:25: error: 'dup' was not declared in this scope 57 | dup = a[i]; | ^~~ a.cc:60:14: error: 'i' was not declared in this scope 60 | for (i = 0; i<n + 1; i++){ | ^ a.cc:61:29: error: 'dup' was not declared in this scope 61 | if (b[i] == dup && dup_f == -1){ | ^~~ a.cc:61:36: error: 'dup_f' was not declared in this scope 61 | if (b[i] == dup && dup_f == -1){ | ^~~~~ a.cc:65:25: error: 'dup_b' was not declared in this scope 65 | dup_b = i; | ^~~~~ a.cc:68:14: error: 'i' was not declared in this scope 68 | for (i = 0; i<n + 1; i++){ | ^ a.cc:69:17: error: 'ans' was not declared in this scope; did you mean 'abs'? 69 | ans = C(n + 1, i + 1) - C(dup_f + n - dup_b, i); | ^~~ | abs a.cc:69:37: error: 'C' cannot be used as a function 69 | ans = C(n + 1, i + 1) - C(dup_f + n - dup_b, i); | ^ a.cc:69:43: error: 'dup_f' was not declared in this scope 69 | ans = C(n + 1, i + 1) - C(dup_f + n - dup_b, i); | ^~~~~ a.cc:69:55: error: 'dup_b' was not declared in this scope 69 | ans = C(n + 1, i + 1) - C(dup_f + n - dup_b, i); | ^~~~~ a.cc:69:42: error: 'C' cannot be used as a function 69 | ans = C(n + 1, i + 1) - C(dup_f + n - dup_b, i); | ~^~~~~~~~~~~~~~~~~~~~~~
s513785786
p03674
C++
#include <iostream> #include <cstring> #include <algorithm> #define MOD 1000000007 using namespace std; typedef long long int ll; ll *FACT, *IFACT; ll extgcd(ll a, ll b, ll &x, ll &y) { ll g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; } ll invMod(ll a, ll m) { ll x, y; if (extgcd(a, m, x, y) == 1) return (x + m) % m; else return 0; // unsolvable } void init(ll N){ FACT = new ll[N + 1]; IFACT = new ll[N + 1]; FACT[0] = 1; IFACT[0] = 1; for (ll i = 1; i <= N; i++){ FACT[i] = FACT[i - 1] * i % MOD; IFACT[i] = invMod(FACT[i], MOD); } } long C(ll n, ll r) { if (n < 0 || r < 0 || r > n)return 0; if (r > n / 2)r = n - r; return FACT[n] * IFACT[n - r] % MOD*IFACT[r] % MOD; } ll main() { ll ans; ll i; ll j; ll n; ll dup; ll dup_f = -1; ll dup_b; cin >> n; ll a[100005]; ll b[100005]; init(100010); for (i = 0; i<n + 1; i++){ cin >> a[i]; }; memcpy(b, a, 100005); sort(begin(a), begin(a) + n); for (i = 0; i<n + 1; i++){ if (a[i] == a[i + 1]){ dup = a[i]; }; }; for (i = 0; i<n + 1; i++){ if (b[i] == dup && dup_f == -1){ dup_f = i; } else if (b[i] == dup){ dup_b = i; }; }; for (i = 0; i<n + 1; i++){ ans = C(n + 1, i + 1) - C(dup_f + n - dup_b, i); if (ans <= -1){ ans = ans + MOD; } cout << ans << endl; }; return 0; }
a.cc:37:1: error: '::main' must return 'int' 37 | ll main() | ^~
s968631906
p03674
C++
def comb(n,k): if k == 0: return 1 if n < k: return 0 ret = 1 for i in xrange(k): ret *= n-i for i in xrange(1,k+1): ret /= i return ret % 1000000007 n = int(raw_input()) a = map(int,raw_input().split()) b = sorted(a) t = -1 for i in xrange(len(b)-1): if b[i] == b[i+1]: t = b[i] L = 0 M = 0 R = 0 c = 0 for i in xrange(len(a)): if a[i] == t: c += 1 elif c == 0: L += 1 elif c == 1: M += 1 elif c == 2: R += 1 lc = {} rc = {} for i in xrange(0,L+1): lc[i] = comb(L,i) for i in xrange(0,R+1): rc[i] = comb(R,i) for k in xrange(1,n+2): total = 0 for i in xrange(k): K = k-1 if i not in lc: lc[i] = 0 if K-i not in rc: rc[K-i] = 0 # print i,K-i," ",lc[i],rc[K-i],lc[i] * rc[K-i] total += lc[i] * rc[K-i] total %= 1000000007 print comb(n+1,k) - total
a.cc:54:7: error: invalid preprocessing directive #print 54 | # print i,K-i," ",lc[i],rc[K-i],lc[i] * rc[K-i] | ^~~~~ a.cc:1:1: error: 'def' does not name a type 1 | def comb(n,k): | ^~~ a.cc:38:1: error: 'rc' does not name a type 38 | rc = {} | ^~ a.cc:39:1: error: expected unqualified-id before 'for' 39 | for i in xrange(0,L+1): | ^~~
s861375841
p03674
Java
import java.util.Scanner; import java.util.Arrays; public class Main { private static final long MOD = 1_000_000_000 + 7; // 反復二乗法を用いる public static long myPow(long a) { long ans = 1L; long x = a; long b = 1_000_000_000 + 5L; for(int i = 0; i < 64; i++) { if((b & (1L << i)) != 0L) { ans = (ans * x) % MOD; } x = (x * x) % MOD; } return ans; } public static long nck(int n, int k, long[] fact, long[] inverse) { if(n < k || n < 0 || k < 0) { return 0; } return (((fact[n] * myPow(fact[n - k])) % MOD) * myPow(fact[k])) % MOD; } public static void main(String[] args) { new Main().run(); Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] a = new int[n + 1]; int[] count = new int[n + 1]; int tar = 0; int l = 0; int r = 0; for(int i = 0; i < n + 1; i++) { a[i] = sc.nextInt(); count[a[i]]++; if(count[a[i]] == 2) { tar = a[i]; r = i + 1; } } for(int i = 0; i < n + 1; i++) { if(a[i] == tar) { l = i + 1; break; } } // n+1までの階乗の計算 long[] fact = new long[n + 2]; fact[0] = 1L; for(int i = 1; i <= n + 1; i++) { fact[i] = (fact[i - 1] * i) % MOD; } for(int k = 1; k <= n + 1; k++) { long comb1 = nck(n + 1, k, fact); long comb2 = nck(l + n - r, k - 1, fact); System.out.println((comb1 - comb2 + MOD) % MOD); } } }
Main.java:31: error: cannot find symbol new Main().run(); ^ symbol: method run() location: class Main Main.java:66: error: method nck in class Main cannot be applied to given types; long comb1 = nck(n + 1, k, fact); ^ required: int,int,long[],long[] found: int,int,long[] reason: actual and formal argument lists differ in length Main.java:67: error: method nck in class Main cannot be applied to given types; long comb2 = nck(l + n - r, k - 1, fact); ^ required: int,int,long[],long[] found: int,int,long[] reason: actual and formal argument lists differ in length 3 errors
s726571120
p03674
Java
import java.util.Scanner; import java.util.Arrays; public class Main { private static final long MOD = 1_000_000_000 + 7; // 反復二乗法を用いる public static long myPow(long a) { long ans = 1L; long x = a; long b = (1_000_000_000 + 5)L; for(int i = 0; i < 32; i++) { if((b & (1L << i)) != 0L) { ans = (ans * x) % MOD; } x = (x * x) % MOD; } return ans % MOD; } public static long nck(int n, int k, long[] fact) { if(n < k) { return 0; } return (((fact[n] * myPow(fact[n - k])) % MOD) * myPow(fact[k])) % MOD; } public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] a = new int[n + 1]; int[] count = new int[n + 1]; int tar = 0; int l = -1; int r = -1; for(int i = 0; i < n + 1; i++) { a[i] = sc.nextInt(); count[a[i]]++; if(count[a[i]] == 2) { tar = a[i]; r = i + 1; } } for(int i = 0; i < n + 1; i++) { if(a[i] == tar) { l = i + 1; break; } } // n+1までの階乗の計算 long[] fact = new long[n + 2]; fact[0] = 1; for(int i = 1; i <= n + 1; i++) { fact[i] = (fact[i - 1] * i) % MOD; } for(int k = 1; k <= n + 1; k++) { // long comb1 = (fact[n + 1] * ((myPow(fact[n + 1 - k]) * myPow(fact[k])) % MOD)) % MOD; long comb1 = nck(n + 1, k, fact); // long comb2 = 0; // if(l + n - r >= k - 1) { // comb2 = (fact[l + n - r] * ((myPow(fact[l + n - r - k + 1]) * myPow(fact[k - 1])) % MOD)) % MOD; // } long comb2 = nck(l + n - r, k - 1, fact); System.out.println((comb1 - comb2) % MOD); } } }
Main.java:11: error: ';' expected long b = (1_000_000_000 + 5)L; ^ 1 error
s968910380
p03674
C++
#include <iostream> #include <sstream> #include <stdio.h> #include <stdlib.h> #include <string> #include <vector> #include <map> #include <queue> #include <stack> #include <algorithm> #include <utility> #include <functional> #include <cmath> #define REP(i,x,y) for(int i=(int)(x);i<(int)(y);i++) #define RREP(i,x,y) for(int i=(int)(x);i>=(int)(y);i--) #define all(x) (x).begin(),(x).end() #ifdef LOCAL #define eprintf(...) fprintf(stderr, __VA_ARGS__) #else #define eprintf(...) 42 #endif typedef long long ll; typedef int long long; using namespace std; const int MAX_N = 100001; const ll MOD = 1000000000 + 7; int n; int a[MAX_N]; int _a[MAX_N]; ll F[MAX_N]; // k! void factorial(){ F[0] = 1; F[1] = 1; REP(i, 2, n+2){ F[i] = F[i-1] * i % MOD; eprintf("F[%d]=%d\n",i,F[i]); } } int extgcd(int a, int b, int &x, int &y) { for (int u = y = 1, v = x = 0; a;) { int q = b / a; swap(x -= q * u, u); swap(y -= q * v, v); b -= q*a; swap(b, a); } return b; } int invmod(int a, int m) { int x, y; if (extgcd(a, m, x, y) == 1) return (x + m) % m; else return 0; // unsolvable } int combination(int _n ,int _r){ if(F[0] != 1) factorial(); // nCr = n!/(n-r)!r! ll combination = 1; combination = F[_n]; combination *= invmod(F[_n - _r], MOD); combination %= MOD; combination *= invmod(F[_r], MOD); combination %= MOD; return combination; } string solve() { string ans = ""; ll cmb = 1; int both_sides_num = 0; int two_num = -1; int left_pos = -1; int right_pos = -1; sort(begin(_a), begin(_a) + n + 1); REP(i,0,n){ if(_a[i] == _a[i+1]){ two_num = _a[i]; break; } } REP(i,0,n+1){ if(left_pos == -1){ if(a[i] == two_num) left_pos = i; }else{ if(a[i] == two_num){ right_pos = i; break; } } } // n+1Ck - both_sides_numC(k-1) both_sides_num = left_pos - right_pos + n; eprintf("leftpos:%d, rightpos:%d\n",left_pos, right_pos); eprintf("both_sides_num: %d\n", both_sides_num); REP(k, 1, n+2){ if(both_sides_num >= k - 1){ cmb = combination(n+1, k) - combination(both_sides_num, k-1); }else{ cmb = combination(n+1, k); } // if(k != n+1) { ans += to_string(cmb) + "\n"; // }else{ // ans += to_string(cmb); // } } return ans; } int main() { // to shorten execution time for iostream cin.tie(0); ios::sync_with_stdio(false); F[0] = -1; cin >> n; REP(i, 0, n+1){ cin >> a[i]; _a[i] = a[i]; } cout << solve() << "\n"; return 0; }
a.cc:26:18: error: declaration does not declare anything [-fpermissive] 26 | typedef int long long; | ^~~~
s654104601
p03674
C++
#include<iostream> #include<cstdio> using namespace std; #define p 1000000007 int N,d1,d2; //cmb(n,k)の実装nCk%p int fact(int x){ if(x==0) return 1; if(x>0) return x*fact(x-1); }; int cmb(int x,int r){ if(x<r) return 0; if(x==r) return 1; if(r==0 && x!=0) return 1; if(r>x/2) r=x-r; return (x*fact(x-1))/fact(x-1)*fact(x-r); }; //cmbを使ってans long long ans(int k){ long long rt=cmb(N+1,k); if(d1+1>=k)rt-=cmb(d1,k-1); if(n-d2+1>=k)rt-=cmb(N-d2,k-1); return rt%=p; }; int main(void){//d1は重複してるやつがd項目ってこと(a[d1]==a[d2]) scanf("%d",&N); int a[N+1],b[N+1]; fill(b, b+N+1, 0); for(int i=0;i<N+1;i++){ cin>>a[i]; b[a[i]]++; if(b[a[i]]==2){ d2=i; break; } } for(int i=0;i<N+1;i++){ if(a[i]==a[d2]){ d1=i; break; } } printf("%d\n",N); for(int k=2;k<N+2;k++) printf("%lld\n",ans(k)); return 0; }
a.cc: In function 'long long int ans(int)': a.cc:26:12: error: 'n' was not declared in this scope 26 | if(n-d2+1>=k)rt-=cmb(N-d2,k-1); | ^ a.cc: In function 'int fact(int)': a.cc:12:1: warning: control reaches end of non-void function [-Wreturn-type] 12 | }; | ^
s059192245
p03674
C++
#include<iostream> #include<cstdio> using namespace std; #define p 1000000007 int N,d1,d2; //cmb(n,k)の実装nCk%p int fact(int n){ if(x==0) {return 1;} if(x>0) {return n*fact(n-1);} }; int cmb(int x,int r){ if(x==r) return 1; if (r==0 && x!=0) return 1; else return (x*fact(x-1))/fact(x-1)*fact(x-r); }; //cmbを使ってans long long ans(int k){ long long rt=cmb(N+1,k); rt-=cmb(d1,k-1); rt-=cmb(N-d2,k-1); return rt%=p; }; int main(void){//d1は重複してるやつがd項目ってこと(a[d1]==a[d2]) scanf("%d",&N); int a[N+1],b[N+1]; fill(b, b+N+1, 0); for(int i=0;i<N+1;i++){ cin>>a[i]; b[a[i]]++; if(b[a[i]]==2){ d2=i; break; } } for(int i=0;i<N+1;i++){ if(a[i]==a[d2]){ d1=i; break; } } printf("%d\n",N); for(int k=2;k<N+2;k++) printf("%lld\n",ans(k)); return 0; }
a.cc: In function 'int fact(int)': a.cc:10:8: error: 'x' was not declared in this scope 10 | if(x==0) {return 1;} | ^ a.cc:11:8: error: 'x' was not declared in this scope 11 | if(x>0) {return n*fact(n-1);} | ^ a.cc:12:1: warning: control reaches end of non-void function [-Wreturn-type] 12 | }; | ^
s953830646
p03674
C++
#include<iostream> #include<cstdio> using namespace std; #define p 1000000007 int N,d1,d2; //cmb(n,k)の実装nCk%p int fact(int x){ if(x==0) {return 1;} if(x>0) {return x*fact(n-1);} }; int cmb(int x,int r){ if(x==r) return 1; if (r==0 && x!=0) return 1; else return (x*fact(x-1))/fact(x-1)*fact(x-r); }; //cmbを使ってans long long ans(int k){ long long rt=cmb(N+1,k); rt-=cmb(d1,k-1); rt-=cmb(N-d2,k-1); return rt%=p; }; int main(void){//d1は重複してるやつがd項目ってこと(a[d1]==a[d2]) scanf("%d",&N); int a[N+1],b[N+1]; fill(b, b+N+1, 0); for(int i=0;i<N+1;i++){ cin>>a[i]; b[a[i]]++; if(b[a[i]]==2){ d2=i; break; } } for(int i=0;i<N+1;i++){ if(a[i]==a[d2]){ d1=i; break; } } printf("%d\n",N); for(int k=2;k<N+2;k++) printf("%lld\n",ans(k)); return 0; }
a.cc: In function 'int fact(int)': a.cc:11:28: error: 'n' was not declared in this scope 11 | if(x>0) {return x*fact(n-1);} | ^
s723645039
p03674
C++
#include<iostream> #include<cstdio> using namespace std; #define p 1000000007 int N,d1,d2; //cmb(n,k)の実装nCk%p int fact(int x){ if(x==0) return 1; if (x>0) return x*fact(n-1); }; int cmb(int x,int r){ if(x==r) return 1; if (r==0 && x!=0) return 1; else return (x*fact(x-1))/fact(x-1)*fact(x-r); }; //cmbを使ってans long long ans(int k){ long long rt=cmb(N+1,k); rt-=cmb(d1,k-1); rt-=cmb(N-d2,k-1); return rt%=p; }; int main(void){//d1は重複してるやつがd項目ってこと(a[d1]==a[d2]) scanf("%d",&N); int a[N+1],b[N+1]; fill(b, b+N+1, 0); for(int i=0;i<N+1;i++){ cin>>a[i]; b[a[i]]++; if(b[a[i]]==2){ d2=i; break; } } for(int i=0;i<N+1;i++){ if(a[i]==a[d2]){ d1=i; break; } } printf("%d\n",N); for(int k=2;k<N+2;k++) printf("%d\n",ans(k)); return 0; }
a.cc: In function 'int fact(int)': a.cc:11:28: error: 'n' was not declared in this scope 11 | if (x>0) return x*fact(n-1); | ^
s045002747
p03674
C
#include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #define NUM 100010 #define TEISUU 1000000007 unsigned long long expo(unsigned long long x, unsigned long long n) { unsigned long long res = 1; while (n) { if (n & 1ULL) { res = (res * x) % TEISUU; } x = (x * x) % TEISUU; n >>= 1ULL; } return (res % TEISUU); } unsigned long long calc_combi(int n, int r) { int i; unsigned long long int bunshi = 1; unsigned long long int bunbo = 1; if (r > n) { return 0; } if (n - r > r) { r = n - r; } if (r == 0) { return 1; } else { for (i = 1; i <= r; i++) { bunbo = bunbo * i; bunshi = (bunshi * (n - r + i)); if (bunbo >> 10) { bunbo = bunbo % TEISUU; } if (bunshi >> 10) { bunshi = bunshi % TEISUU; } } bunbo = expo(bunbo, TEISUU - 2); return (bunbo * bunshi) % TEISUU; } } int main() { int i, j; int *x = (int *)malloc(sizeof(int) * NUM); int n; int temp; int between; unsigned long long int answer; unsigned long long int combinarion[NUM]; for (i = 0; i < NUM; i++) { x[i] = -1; } scanf("%d", &n); for (i = 1; i <= n + 1; i++) { scanf(" %d", &temp); if (x[temp] == -1) { x[temp] = i; } else { between = i - x[temp] - 1; break; } } for (i = 0; i <= n + 1; i++) { if (i > n + 1 - i) { combination[i] = combination[n + 1 - i]; } else { combination[i] = calc_combi(n + 1, i); } } if (n == 1) { printf("1\n"); printf("1\n"); } else { printf("%d\n", n); for (i = 2; i <= n + 1; i++) { // answer = calc_combi(n - 1, i) + 2 * calc_combi(n - 1, i - 1) - // calc_combi(n - 1 - between, i - 1) + calc_combi(n - 1, i - // 2); // answer = calc_combi(n + 1, i) - calc_combi(n - 1 - between, i - 1); answer = combinaion[i] - calc_combi(n - 1 - between, i - 1); printf("%llu\n", answer % TEISUU); fflush(stdout); } } return 0; }
main.c: In function 'main': main.c:78:7: error: 'combination' undeclared (first use in this function); did you mean 'combinarion'? 78 | combination[i] = combination[n + 1 - i]; | ^~~~~~~~~~~ | combinarion main.c:78:7: note: each undeclared identifier is reported only once for each function it appears in main.c:94:16: error: 'combinaion' undeclared (first use in this function); did you mean 'combinarion'? 94 | answer = combinaion[i] - calc_combi(n - 1 - between, i - 1); | ^~~~~~~~~~ | combinarion
s488732897
p03674
C++
n = int(input()) a = list(map(int, input().split())) M = 10**9 + 7 def calc_index(a): t = sorted(a) for i, x in enumerate(t[1:]): if t[i] == x: break result = [] for i, v in enumerate(a): if v == x: result.append(i) return result f, e = calc_index(a) out = n - e + f facts = [0 for x in range(10**5 + 1)] fresult = 1 for i in range(1, 10**5 + 1): fresult *= i if fresult > M: fresult %= M facts[i] = fresult def fact(a): return facts[a] def powmod(a, b): if b == 0: return 1 elif b & 1: return (powmod(a, b - 1) * a) % M else: return powmod(a, b // 2)**2 % M def c(a, b): if b > a: return 0 return fact(a) * powmod(fact(b) * fact(a - b) % M, M - 2) % M for i in range(1, n + 1): c1, c2 = c(n + 1, i), c(out, i - 1) r = c1 - c2 if r < 0: r += M print(r) print(1)
a.cc:1:1: error: 'n' does not name a type 1 | n = int(input()) | ^
s748136643
p03674
C++
n = int(input()) a = list(map(int, input().split())) M = 10**9 + 7 def calc_index(a): t = sorted(a) for i, x in enumerate(t[1:]): if t[i] == x: break result = [] for i, v in enumerate(a): if v == x: result.append(i) return result f, e = calc_index(a) out = n - e + f facts = [0 for x in range(10**5 + 1)] fresult = 1 for i in range(1, 10**5 + 1): fresult *= i if fresult > M: fresult %= M facts[i] = fresult def fact(a): return facts[a] def powmod(a, b): if b == 0: return 1 elif b & 1: return (powmod(a, b - 1) * a) % M else: return powmod(a, b // 2)**2 % M def c(a, b): if b > a: return 0 return fact(a) * powmod(fact(b) * fact(a - b) % M, M - 2) % M for i in range(1, n + 1): c1, c2 = c(n + 1, i), c(out, i - 1) r = c1 - c2 if r < 0: r += M print(r) print(1)
a.cc:1:1: error: 'n' does not name a type 1 | n = int(input()) | ^
s228561981
p03674
C
#include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #define NUM 100010 #define TEISUU 1000000007 unsigned long long expo(unsigned long long x, unsigned long long n){ unsigned long long res = 1; while (n){ if (n & 1ULL){ res = (res * x) % TEISUU; } x = (x * x) % TEISUU; n >>= 1ULL; } return (res % TEISUU); } unsigned long long calc_combi(int n, int r) { int i; unsigned long long int bunshi = 1; unsigned long long int bunbo = 1; if (r > n) { return 0; } if (n-r > r){ r = n - r; } if (r == 0) { return 1; } else { for (i = 1; i <= r; i++) { bunbo = bunbo * i; bunshi = (bunshi * (n - r + i)); if(bunbo >> 10){ bunbo = bunbo % TEISUU; } if (bunshi >> 10) { bunshi = bunshi % TEISUU; } } bunbo = expo(bunbo, TEISUU - 2); return (bunbo * bunshi) % TEISUU; } } int main() { int i, j; int *x = (int *)malloc(sizeof(int) * NUM); int n; int temp; int between; unsigned long long int answer; for (i = 0; i < NUM; i++) { x[i] = -1; } scanf("%d", &n); for (i = 1; i <= n + 1; i++) { scanf(" %d", &temp); if (x[temp] == -1) { x[temp] = i; } else { between = i - x[temp] - 1; break; } } if (n == 1) { printf("1\n"); printf("1\n"); } else { printf("%d\n", n); for (i = 2; i <= n + 1; i++) { //answer = calc_combi(n - 1, i) + 2 * calc_combi(n - 1, i - 1) - // calc_combi(n - 1 - between, i - 1) + calc_combi(n - 1, i - 2); answer = calc_combi(n + 1, i) - calc_combi(n + 1 - between); printf("%llu\n", answer % TEISUU); fflush(stdout); } } return 0; }
main.c: In function 'main': main.c:84:39: error: too few arguments to function 'calc_combi' 84 | answer = calc_combi(n + 1, i) - calc_combi(n + 1 - between); | ^~~~~~~~~~ main.c:22:20: note: declared here 22 | unsigned long long calc_combi(int n, int r) { | ^~~~~~~~~~
s004535764
p03674
C++
#include <bits/stdc++.h>> using namespace std; typedef long long ll; const int N = 1e5 + 2, MOD = 1e9 + 7; ll fpm(ll x, ll n) { ll y = 1; for (; n; (x *= x) %= MOD, n >>= 1) if (n & 1) (y *= x) %= MOD; return y; } ll fac[N], ifac[N]; int pos[N]; inline ll C(int n, int k) { if (k > n) return 0; return fac[n] * ifac[k] % MOD * ifac[n-k] % MOD; } int main() { int n; scanf("%d", &n); ++n; fac[0] = 1; for(int i = 1;i < n+1;i++) fac[i] = fac[i-1] * i % MOD; ifac[n] = fpm(fac[n], MOD-2); per (i, n, 1) ifac[i-1] = ifac[i] * i % MOD; int m, x; rep (i, 1, n+1) { scanf("%d", &x); if (pos[x]) { m = n - (i - pos[x] + 1); break; } pos[x] = i; } rep (i, 1, n+1) printf("%lld\n", (C(n, i) - C(m, i-1)) % MOD); return 0; }
a.cc:1:25: warning: extra tokens at end of #include directive 1 | #include <bits/stdc++.h>> | ^ a.cc: In function 'int main()': a.cc:35:14: error: 'i' was not declared in this scope 35 | per (i, n, 1) ifac[i-1] = ifac[i] * i % MOD; | ^ a.cc:35:9: error: 'per' was not declared in this scope 35 | per (i, n, 1) ifac[i-1] = ifac[i] * i % MOD; | ^~~ a.cc:37:9: error: 'rep' was not declared in this scope 37 | rep (i, 1, n+1) | ^~~
s516149623
p03674
Java
import java.util.Scanner; class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] a = new int[n + 1]; boolean[] hasOne = new boolean[n + 1]; boolean[] hasTwo = new boolean[n + 1]; for(int i = 0; i < n + 1; i++){ a[i] = sc.nextInt(); hasOne[i + 1] = false; hasTwo[i + 1] = false; } int[] position = new int[n + 1]; int firstPosition = 0; int secondPosition = 0; for(int i = 0; i < n + 1; i++){ if(hasOne[a[i]]){ hasTwo[a[i]] = true; firstPosition = position[a[i]]; secondPosition = i; break; }else{ position[a[i]] = i; hasOne[a[i]] = true; } } int x = firstPosition + (n + 1 - secondPosition - 1); long[] ans = new long[n + 2]; long[] combX = new long[x + 1]; combX[0] = 1; long[] comb[] = new long[n + 2]; comb[0] = 1; for(int i = 1; i <= n + 1; i++){ if(i <= x){ combX[i] = 1; if(i >= x / 2 + 1){ combX[i] = combX[x - i]; }else{ for(int j = 1; j <= i; j++){ combX[i] *= (long)(x - j + 1); combX[i] /= (long)j; combX[i] = combX[i] % 1000000007; } } } comb[i] = 1; if(i >= (n + 1) / 2 + 1){ comb[i] = comb[(n + 1) - i]; }else{ for(int j = 1; j <= i; j++){ comb[i] *= (long)(n + 1 - j + 1); comb[i] /= (long)j; comb[i] = comb[i] % 1000000007; } } if(i - 1 <= x){ ans[i] = comb[i] - combX[i - 1]; if(ans[i] < 0){ ans[i] += 1000000007; } }else{ ans[i] = comb[i]; } System.out.println(ans[i]); } } }
Main.java:39: error: incompatible types: long[] cannot be converted to long[][] long[] comb[] = new long[n + 2]; ^ Main.java:40: error: incompatible types: int cannot be converted to long[] comb[0] = 1; ^ Main.java:55: error: incompatible types: int cannot be converted to long[] comb[i] = 1; ^ Main.java:60: error: bad operand types for binary operator '*' comb[i] *= (long)(n + 1 - j + 1); ^ first type: long[] second type: long Main.java:61: error: bad operand types for binary operator '/' comb[i] /= (long)j; ^ first type: long[] second type: long Main.java:62: error: bad operand types for binary operator '%' comb[i] = comb[i] % 1000000007; ^ first type: long[] second type: int Main.java:67: error: bad operand types for binary operator '-' ans[i] = comb[i] - combX[i - 1]; ^ first type: long[] second type: long Main.java:72: error: incompatible types: long[] cannot be converted to long ans[i] = comb[i]; ^ 8 errors
s179982079
p03674
C
#include <ctype.h> #include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #define MOD 1000000007 #define ll long long long long expo(long long x, long long n){ long long res = 1; while (n){ if (n & 1LL) res = (res * x) % MOD; x = (x * x) % MOD; n >>= 1LL; } return (res % MOD); } long long lol(int n, int k){ long long x = fact[n]; long long y = (fact[k] * fact[n - k]) % MOD; long long res = (x * expo(y, MOD - 2)) % MOD; return res; } int main(int argc, char **argv){ ll fact[100006]; ll n; scanf("%lld",&n); ll a[n+2],i,j; for (i = 1, fact[0] = 1; i < 100006; i++) fact[i] = (fact[i - 1] * i) % MOD; for(i=1;i<=n+1;i++) scanf("%lld",&a[i]); n++; //a[1] to a[n] int hash[100006]={0}; for(i=1;i<=n;i++) hash[a[i]]++; for(i=1;i<=n;i++) if(hash[i]==2) break; //i repeated twice ll occur[3],uwu=0; for(j=1;j<=n;j++){ if(a[j]==i){ occur[uwu]=j; uwu++; } } ll left=occur[0]-1; ll right=n-occur[1]; ll k,diff; printf("%lld ",n-1); for(k=2;k<=n;k++){ diff=lol(n,k); if(k<=left+right+1) { ll z=0; if(k-1-right>z) z=k-1-right; for(;z<=left;z++) { diff=(diff-(lol(left,z)*lol(right,k-1-z)))%MOD; } while(diff<0) diff+=MOD; } else { diff=lol(n,k); } printf("%lld ",diff); } printf("\n"); return 0; }
main.c: In function 'lol': main.c:22:19: error: 'fact' undeclared (first use in this function) 22 | long long x = fact[n]; | ^~~~ main.c:22:19: note: each undeclared identifier is reported only once for each function it appears in
s052984337
p03674
C++
//#pragma GCC optimize "O3" #include <algorithm> #include <iostream> #include <map> #include <queue> #include <set> #include <vector> using namespace std; #define LL 1000000007 void calc(vector<vector<long long int> > &v) { for (int i = 0; i < v.size(); i++) { v[i][0] = 1; v[i][i] = 1; } for (int k = 1; k < v.size(); k++) { for (int j = 1; j < k; j++) { v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]); } } } long long comb(int n, int k) { vector<vector<long long int> > v(n + 1, vector<long long int>(n + 1, 0)); calc(v); return v[n][k]; } int main() { int n; cin >> n; set<int> st; int a[n + 1]; int dupl = -1; for (int i = 0; i < n + 1; i++) { int tmp = st.size(); cin >> a[i]; st.insert(a[i]); if (tmp == st.size()) { dupl = a[i]; } } int a1, a2; a1 = a2 = 0; int cnt = 0; for (int i = 0; i < n + 1; i++) { if (a[i] == dupl) { cnt++; cnt == 1 ? a1 = i : a2 = i; } } int diff = a2 - a1; // cerr << a1 << "\n" << a2 << "\n" << diff << endl; for (int i = 0; i < n + 1; i++) { //cerr << n + 1 << "C" << i + 1 << " : "; cout << (comb(n + 1, i + 1) % LL << endl; } return 0; }
a.cc: In function 'int main()': a.cc:63:39: error: invalid operands of types 'long long int' and '<unresolved overloaded function type>' to binary 'operator<<' 63 | cout << (comb(n + 1, i + 1) % LL << endl; | ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~ a.cc:63:46: error: expected ')' before ';' token 63 | cout << (comb(n + 1, i + 1) % LL << endl; | ~ ^ | )
s870582618
p03674
Java
import com.sun.xml.internal.fastinfoset.util.CharArray; import java.util.*; /** * Created by DELL on 2017/7/1. */ public class Main { static long fac(int x,int num){ long a=1; for (int i = 0; i <num ; i++) { a*=x-i; a/=(i+1); if(a>1e9+7) a-=1e9+7; } return a; } public static void main(String[] args) { Scanner in=new Scanner(System.in); int n=in.nextInt(); int dup=0; List<Integer>list=new ArrayList<>(); List<Integer>list1=new ArrayList<>(); for (int i = 0; i <n+1 ; i++) { int x=in.nextInt(); list.add(x); if(list.contains(x))dup=list.indexOf(x); } for (int i = 1; i <n+2; i++) { System.out.println(fac(n+1,i)-fac(n-dup,i-2)<0?fac(n+1,i)-fac(n-dup,i-2)+1e9+7:fac(n+1,i)-fac(n-dup,i-2)); } } }
Main.java:1: error: package com.sun.xml.internal.fastinfoset.util does not exist import com.sun.xml.internal.fastinfoset.util.CharArray; ^ 1 error
s192399587
p03674
C++
#include <bits/stdc++.h> using namespace std; int count1[100001]={0}; // Utility function to split the string using a delim. Refer - // http://stackoverflow.com/questions/236129/split-a-string-in-c vector<string> split(const string &s, char delim) { vector<string> elems; stringstream ss(s); string item; while (getline(ss, item, delim)) elems.push_back(item); return elems; } // Function to find all subsets of given set. Any repeated // subset is considered only once in the output int printPowerSet(int arr[], int n) { vector<string> list; /* Run counter i from 000..0 to 111..1*/ for (int i = 0; i < (int) pow(2, n); i++) { string subset = ""; // consider each element in the set for (int j = 0; j < n; j++) { // Check if jth bit in the i is set. If the bit // is set, we consider jth element from set if ((i & (1 << j)) != 0) subset += to_string(arr[j]) + "|"; } // if subset is encountered for the first time // If we use set<string>, we can directly insert if (find(list.begin(), list.end(), subset) == list.end()) list.push_back(subset); } // consider every subset for (string subset : list) { // split the subset and print its elements vector<string> arr = split(subset, '|'); count1[arr.size()]++; //cout<<arr.size()<<endl; //cout << endl; } } // Driver code int main() { int n; cin>>n; int arr[n]; int i; for(i=0;i<n;i++) cin>>arr[i]; printPowerSet(arr, n); for(i=1;i<=n;i++) cout<<count1[i]%mod<<endl; // return 0; }
a.cc: In function 'int printPowerSet(int*, int)': a.cc:53:1: warning: no return statement in function returning non-void [-Wreturn-type] 53 | } | ^ a.cc: In function 'int main()': a.cc:66:33: error: 'mod' was not declared in this scope; did you mean 'modf'? 66 | cout<<count1[i]%mod<<endl; | ^~~ | modf
s601789582
p03674
C++
#include <bits/stdc++.h> using namespace std; int count1[100001]={0}; // Utility function to split the string using a delim. Refer - // http://stackoverflow.com/questions/236129/split-a-string-in-c vector<string> split(const string &s, char delim) { vector<string> elems; stringstream ss(s); string item; while (getline(ss, item, delim)) elems.push_back(item); return elems; } // Function to find all subsets of given set. Any repeated // subset is considered only once in the output int printPowerSet(int arr[], int n) { vector<string> list; /* Run counter i from 000..0 to 111..1*/ for (int i = 0; i < (int) pow(2, n); i++) { string subset = ""; // consider each element in the set for (int j = 0; j < n; j++) { // Check if jth bit in the i is set. If the bit // is set, we consider jth element from set if ((i & (1 << j)) != 0) subset += to_string(arr[j]) + "|"; } // if subset is encountered for the first time // If we use set<string>, we can directly insert if (find(list.begin(), list.end(), subset) == list.end()) list.push_back(subset); } // consider every subset for (string subset : list) { // split the subset and print its elements vector<string> arr = split(subset, '|'); count1[arr.size()]++; //cout<<arr.size()<<endl; //cout << endl; } } // Driver code int main() { int n; cin>>n; int arr[n]; for(i=0;i<n;i++) cin>>arr[i]; printPowerSet(arr, n); for(i=1;i<=n;i++) cout<<count1[i]<<endl; // return 0; }
a.cc: In function 'int printPowerSet(int*, int)': a.cc:53:1: warning: no return statement in function returning non-void [-Wreturn-type] 53 | } | ^ a.cc: In function 'int main()': a.cc:61:9: error: 'i' was not declared in this scope 61 | for(i=0;i<n;i++) | ^ a.cc:64:13: error: 'i' was not declared in this scope 64 | for(i=1;i<=n;i++) | ^
s071298331
p03675
C++
N = int(input()) A = list(map(int, input().split())) A.reverse() B = [] C = [] for i, a in enumerate(A): if i%2==0: B.append(a) else: C.append(a) print(*(B+list(reversed(C))))
a.cc:1:1: error: 'N' does not name a type 1 | N = int(input()) | ^
s119392724
p03675
Java
import java.io.*; import java.util.ArrayList; import java.util.Collections; import org.graalvm.compiler.nodes.calc.IntegerDivRemNode; public class Main{ public static void main(String[] args) throws Exception{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); ArrayList<Integer> temp = new ArrayList<Integer>(); int n = Integer.parseInt(br.readLine()); String[] s = br.readLine().split(" "); for(int i = 0; i < s.length; ++i) { if(i%2 == 0) { temp.add(Integer.parseInt(s[i])); } else { temp.add(0, Integer.parseInt(s[i])); } } if(n%2 == 1) { Collections.reverse(temp); } String res = ""; for(int i = 0; i < temp.size() - 1; ++i) { res += temp.get(i) + " "; } res += temp.get(temp.size()-1); System.out.println(res); } }
Main.java:5: error: package org.graalvm.compiler.nodes.calc does not exist import org.graalvm.compiler.nodes.calc.IntegerDivRemNode; ^ 1 error
s890263704
p03675
C++
#include <bits/stdc++.h> #include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <deque> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <tuple> #include <utility> #include <vector> #define pi 3.14159265358979323846264338327950L using namespace std; int main() { int64_t n; cin >> n; vector<int64_t> a(n); for (int64_t i=0; i<n; i++) { cin >> a[i]; }
a.cc: In function 'int main()': a.cc:26:4: error: expected '}' at end of input 26 | } | ^ a.cc:20:12: note: to match this '{' 20 | int main() { | ^
s194239694
p03675
C++
#inlcude<bits/stdc++.h> using namespace std; int main(){ long long int n; cin>>n; long long int a[n+1]; for(long long int i=1;i<=n;i++)cin>>a[i]; if(n%2){ for(long long int j=n;j>=1;j=j-2)cout<<a[j]<<" "; for(long long int j=2;j<=n-1;j=j+2)cout<<a[j]<<" "; } else{ for(long long int j=n;j>=2;j=j-2)cout<<a[j]<<" "; for(long long int j=1;j<=n-1;j=j+2)cout<<a[j]<<" "; } cout<<"\n"; }
a.cc:1:2: error: invalid preprocessing directive #inlcude; did you mean #include? 1 | #inlcude<bits/stdc++.h> | ^~~~~~~ | include a.cc: In function 'int main()': a.cc:5:3: error: 'cin' was not declared in this scope 5 | cin>>n; | ^~~ a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' +++ |+#include <iostream> 1 | #inlcude<bits/stdc++.h> a.cc:9:40: error: 'cout' was not declared in this scope 9 | for(long long int j=n;j>=1;j=j-2)cout<<a[j]<<" "; | ^~~~ a.cc:9:40: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:10:42: error: 'cout' was not declared in this scope 10 | for(long long int j=2;j<=n-1;j=j+2)cout<<a[j]<<" "; | ^~~~ a.cc:10:42: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:13:38: error: 'cout' was not declared in this scope 13 | for(long long int j=n;j>=2;j=j-2)cout<<a[j]<<" "; | ^~~~ a.cc:13:38: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:14:40: error: 'cout' was not declared in this scope 14 | for(long long int j=1;j<=n-1;j=j+2)cout<<a[j]<<" "; | ^~~~ a.cc:14:40: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:16:3: error: 'cout' was not declared in this scope 16 | cout<<"\n"; | ^~~~ a.cc:16:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
s212663823
p03675
C++
#include <iostream> // cout, endl, cin #include <string> // string, to_string, stoi #include <vector> // vector #include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound #include <utility> // pair, make_pair #include <tuple> // tuple, make_tuple #include <cstdint> // int64_t, int*_t #include <cstdio> // printf #include <map> // map #include <queue> // queue, priority_queue #include <set> // set #include <stack> // stack #include <deque> // deque #include <unordered_map> // unordered_map #include <unordered_set> // unordered_set #include <bitset> // bitset #include <cctype> // isupper, islower, isdigit, toupper, tolower using namespace std; int main() { int n; cin >> n; vector<int>a(n); for (int i = 0; i < n; i++) { cin >> a.at(i); } for (int j = 0; j < n; j++) { a.push_back(a.at(j)); reverse(a.begin(), a.end()); } cout << a << endl; }
a.cc: In function 'int main()': a.cc:34:14: error: no match for 'operator<<' (operand types are 'std::ostream' {aka 'std::basic_ostream<char>'} and 'std::vector<int>') 34 | cout << a << endl; | ~~~~ ^~ ~ | | | | | std::vector<int> | std::ostream {aka std::basic_ostream<char>} In file included from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/ostream:116:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ostream_type& (*)(__ostream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 116 | operator<<(__ostream_type& (*__pf)(__ostream_type&)) | ^~~~~~~~ /usr/include/c++/14/ostream:116:36: note: no known conversion for argument 1 from 'std::vector<int>' to 'std::basic_ostream<char>::__ostream_type& (*)(std::basic_ostream<char>::__ostream_type&)' {aka 'std::basic_ostream<char>& (*)(std::basic_ostream<char>&)'} 116 | operator<<(__ostream_type& (*__pf)(__ostream_type&)) | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/ostream:125:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>; __ios_type = std::basic_ios<char>]' 125 | operator<<(__ios_type& (*__pf)(__ios_type&)) | ^~~~~~~~ /usr/include/c++/14/ostream:125:32: note: no known conversion for argument 1 from 'std::vector<int>' to 'std::basic_ostream<char>::__ios_type& (*)(std::basic_ostream<char>::__ios_type&)' {aka 'std::basic_ios<char>& (*)(std::basic_ios<char>&)'} 125 | operator<<(__ios_type& (*__pf)(__ios_type&)) | ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~ /usr/include/c++/14/ostream:135:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::ios_base& (*)(std::ios_base&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 135 | operator<<(ios_base& (*__pf) (ios_base&)) | ^~~~~~~~ /usr/include/c++/14/ostream:135:30: note: no known conversion for argument 1 from 'std::vector<int>' to 'std::ios_base& (*)(std::ios_base&)' 135 | operator<<(ios_base& (*__pf) (ios_base&)) | ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ /usr/include/c++/14/ostream:174:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 174 | operator<<(long __n) | ^~~~~~~~ /usr/include/c++/14/ostream:174:23: note: no known conversion for argument 1 from 'std::vector<int>' to 'long int' 174 | operator<<(long __n) | ~~~~~^~~ /usr/include/c++/14/ostream:178:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 178 | operator<<(unsigned long __n) | ^~~~~~~~ /usr/include/c++/14/ostream:178:32: note: no known conversion for argument 1 from 'std::vector<int>' to 'long unsigned int' 178 | operator<<(unsigned long __n) | ~~~~~~~~~~~~~~^~~ /usr/include/c++/14/ostream:182:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(bool) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 182 | operator<<(bool __n) | ^~~~~~~~ /usr/include/c++/14/ostream:182:23: note: no known conversion for argument 1 from 'std::vector<int>' to 'bool' 182 | operator<<(bool __n) | ~~~~~^~~ In file included from /usr/include/c++/14/ostream:1022: /usr/include/c++/14/bits/ostream.tcc:96:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short int) [with _CharT = char; _Traits = std::char_traits<char>]' 96 | basic_ostream<_CharT, _Traits>:: | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/ostream.tcc:97:22: note: no known conversion for argument 1 from 'std::vector<int>' to 'short int' 97 | operator<<(short __n) | ~~~~~~^~~ /usr/include/c++/14/ostream:189:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(short unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 189 | operator<<(unsigned short __n) | ^~~~~~~~ /usr/include/c++/14/ostream:189:33: note: no known conversion for argument 1 from 'std::vector<int>' to 'short unsigned int' 189 | operator<<(unsigned short __n) | ~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/bits/ostream.tcc:110:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(int) [with _CharT = char; _Traits = std::char_traits<char>]' 110 | basic_ostream<_CharT, _Traits>:: | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/ostream.tcc:111:20: note: no known conversion for argument 1 from 'std::vector<int>' to 'int' 111 | operator<<(int __n) | ~~~~^~~ /usr/include/c++/14/ostream:200:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 200 | operator<<(unsigned int __n) | ^~~~~~~~ /usr/include/c++/14/ostream:200:31: note: no known conversion for argument 1 from 'std::vector<int>' to 'unsigned int' 200 | operator<<(unsigned int __n) | ~~~~~~~~~~~~~^~~ /usr/include/c++/14/ostream:211:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 211 | operator<<(long long __n) | ^~~~~~~~ /usr/include/c++/14/ostream:211:28: note: no known conversion for argument 1 from 'std::vector<int>' to 'long long int' 211 | operator<<(long long __n) | ~~~~~~~~~~^~~ /usr/include/c++/14/ostream:215:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 215 | operator<<(unsigned long long __n) | ^~~~~~~~ /usr/include/c++/14/ostream:215:37: note: no known conversion for argument 1 from 'std::vector<int>' to 'long long unsigned int' 215 | operator<<(unsigned long long __n) | ~~~~~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/ostream:231:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 231 | operator<<(double __f) | ^~~~~~~~ /usr/include/c++/14/ostream:231:25: note: no known conversion for argument 1 from 'std::vector<int>' to 'double' 231 | operator<<(double __f) | ~~~~~~~^~~ /usr/include/c++/14/ostream:235:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(float) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 235 | operator<<(float __f) | ^~~~~~~~ /usr/include/c++/14/ostream:235:24: note: no known conversion for argument 1 from 'std::vector<int>' to 'float' 235 | operator<<(float __f) | ~~~~~~^~~ /usr/include/c++/14/ostream:243:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 243 | operator<<(long double __f) | ^~~~~~~~ /usr/include/c++/14/ostream:243:30: note: no known conversion for argument 1 from 'std::vector<int>' to 'long double' 243 | operator<<(long double __f) | ~~~~~~~~~~~~^~~ /usr/include/c++/14/ostream:301:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(const void*) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 301 | operator<<(const void* __p) | ^~~~~~~~ /usr/include/c++/14/ostream:301:30: note: no known conversion for argument 1 from 'std::vector<int>' to 'const void*' 301 | operator<<(const void* __p) | ~~~~~~~~~~~~^~~ /usr/include/c++/14/ostream:306:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::nullptr_t) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>; std::nullptr_t = std::nullptr_t]' 306 | operator<<(nullptr_t) | ^~~~~~~~ /usr/include/c++/14/ostream:306:18: note: no known conversion for argument 1 from 'std::vector<int>' to 'std::nullptr_t' 306 | operator<<(nullptr_t) | ^~~~~~~~~ /usr/include/c++/14/bits/ostream.tcc:124:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(__streambuf_type*) [with _CharT = char; _Traits = std::char_tra
s146085901
p03675
C++
#include<bits/stdc++.h> using namespace std; using ll = long long; using Graph = vector<vector<int>>; int main() { ll n; cin>>n; ll a[n]={}; ll b[n]={}; deque<ll> d; ll aa; for(ll i=0; i<n; i++){ cin>>a[i];} ll counter=1000000; for(ll i=0; i<n; i++){ if(i%2==0){ d.push_back(a[i]);} else d.push_front(a[i]);} while(!=d.empty()){ aa=d.front(); d.pop_front(); cout<<aa<<" ";}}
a.cc: In function 'int main()': a.cc:21:7: error: expected primary-expression before '!=' token 21 | while(!=d.empty()){ | ^~
s362895980
p03675
C++
#include<bits/stdc++.h> #include <iostream> #include <string> using namespace std; #define ll long long #define rep(i, n) for (ll i = 0; i < (n); i++) #define FOR(i,a,b) for(ll i=(a);i<(b);i++) #define FORR(i,a,b)for(ll i=(a);i<=(b);i++) #define repR(i,n) for(ll i=n;i>=0;i--) #define all(v)(v).begin(),(v).end() #define rall(v)(v).rbegin(),(v).rend() #define F first #define S second #define pb push_back #define pu push #define COUT(x) cout<<(x)<<endl #define PQ priority_queue<ll> #define PQR priority_queue<ll,vector<ll>,greater<ll>> #define YES(n) cout << ((n) ? "YES" : "NO" ) << endl #define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl #define mp make_pair #define maxs(x,y) (x = max(x,y)) #define mins(x,y) (x = min(x,y)) #define sz(x) (int)(x).size() typedef pair<int,int> pii; typedef pair<ll,ll> pll; const ll MOD = 1000000007LL; const ll INF = 1LL << 60; using vll = vector<ll>; using vvll = vector<vll>; using vstr = vector<string>; using pll = pair<ll, ll>; int main(){ ll n; cin>>n; vll a(n); ll X=0; rep(i,n) cin>>a[i]; vll b(0); if(n%2==0){ ll k=n-2; while(k>=0){ b.pb(a[k]); k-=2; } for(int i=1;i<n;i+=2){ b.pb(a[i]); } } else{ ll k=n-2; while(k>=1){ b.pb(a[k]); k-=2; } for(int i=0;i<n;i+=2){ b.pb(a[i]); } } rep(i,n) COUT(a[i]<<" "); }
a.cc: In function 'int main()': a.cc:60:21: error: invalid operands of types '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} and 'const char [2]' to binary 'operator<<' 60 | rep(i,n) COUT(a[i]<<" "); a.cc:16:24: note: in definition of macro 'COUT' 16 | #define COUT(x) cout<<(x)<<endl | ^
s107928362
p03675
Java
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n=sc.nextInt(); int a[]=new int[n]; StringBuilder ans = new StringBuilder(); String for(int i=0;i<n;i++){ a[i] = sc.nextInt(); } for(int j = n-1;j<0;j--){ ans.append(a[j]); j--; } for(int k = n-2;k<0;k++){ ans.append(a[k]); k++; } System.out.println(new String(ans)); } }
Main.java:9: error: not a statement String ^ Main.java:9: error: ';' expected String ^ 2 errors
s367058046
p03675
Java
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n=sc.nextInt(); int a[]=new int[n]; StringBuilder ans = new StringBuilder(); String for(int i=0;i<n;i++){ a[i] = sc.nextInt(); } for(int j = n-1;j<0;j--){ ans.append(a[j]); j--; } for(int k = n-2;k<0;k--){ ans.append(a[k]); k--; } System.out.println(new String(ans)); } }
Main.java:9: error: not a statement String ^ Main.java:9: error: ';' expected String ^ 2 errors
s479080953
p03675
Java
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n=sc.nextInt(); int a[]=new int[n]; for(int i=0;i<n;i++){ a[i] = sc.nextInt(); } for(int j = n-1;j<0;2*j--){ System.out.print(a[j]); } for(int k = n-2;k<0;2*k--){ System.out.print(a[k]); } } }
Main.java:12: error: not a statement for(int j = n-1;j<0;2*j--){ ^ Main.java:15: error: not a statement for(int k = n-2;k<0;2*k--){ ^ 2 errors
s430660388
p03675
Java
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n=sc.nextInt(); List<Integer> a = new ArrayList<Integer>(); for(int i=0;i<n;i++){ if(n % 2 == 0){ if(i % 2 == 0){ a.add(0,sc.nextInt()); }else{ a.add(sc.nextInt()); } }else{ if(i % 2 != 0){ a.add(0,sc.nextInt()); }else{ a.add(sc.nextInt()); } } } System.out.println(String.join("",a)); } }
Main.java:25: error: no suitable method found for join(String,List<Integer>) System.out.println(String.join("",a)); ^ method String.join(CharSequence,CharSequence...) is not applicable (varargs mismatch; List<Integer> cannot be converted to CharSequence) method String.join(CharSequence,Iterable<? extends CharSequence>) is not applicable (argument mismatch; List<Integer> cannot be converted to Iterable<? extends CharSequence>) Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output 1 error
s336534146
p03675
Java
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n=sc.nextInt(); List<String> a = new ArrayList<String>(); for(int i=0;i<n;i++){ if(n % 2 == 0){ if(i % 2 == 0){ a.add(0,sc.next()); }else{ a.add(sc.next()); } }else{ if(i % 2 != 0){ a.add(0,sc.next()); }else{ a.add(sc.next()); } } } System.out.println(String.join('',a)); } }
Main.java:25: error: empty character literal System.out.println(String.join('',a)); ^ Main.java:25: error: not a statement System.out.println(String.join('',a)); ^ Main.java:25: error: ';' expected System.out.println(String.join('',a)); ^ 3 errors
s364038411
p03675
Java
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n=sc.nextInt(); List<Integer> a = new ArrayList<Integer>(); for(int i=0;i<n;i++){ if(n % 2 == 0){ if(i % 2 == 0){ a.add(0,sc.nextInt()); }else{ a.add(sc.nextInt()); } }else{ if(i % 2 != 0){ a.add(0,sc.nextInt()); }else{ a.add(sc.nextInt()); } } } System.out.println(String.join('',a)); } }
Main.java:25: error: empty character literal System.out.println(String.join('',a)); ^ Main.java:25: error: not a statement System.out.println(String.join('',a)); ^ Main.java:25: error: ';' expected System.out.println(String.join('',a)); ^ 3 errors
s526965327
p03675
Java
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n=sc.nextInt(); List<Integer> a = new ArrayList<Integer>(); for(int i=0;i<n;i++){ if(n % 2 == 0){ if(i % 2 == 0){ a.add(0,sc.nextInt()); }else{ a.add(sc.nextInt()); } }else{ if(i % 2 != 0){ a.add(0,sc.nextInt()); }else{ a.add(sc.nextInt()); } } } System.out.println(String.join(a)); } }
Main.java:25: error: incompatible types: List<Integer> cannot be converted to CharSequence System.out.println(String.join(a)); ^ Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output 1 error
s558935162
p03675
Java
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n=sc.nextInt(); int a[]=new a[n]; int b[]=new b[n]; for(int i=0;i<n;i++){ a[i] = sc.nextInt(); for(int j=0;j<=i;j++){ b[i-j] = a[j]; } } String ans = Arrays.toString(b); System.out.println(ans); } }
Main.java:7: error: cannot find symbol int a[]=new a[n]; ^ symbol: class a location: class Main Main.java:8: error: cannot find symbol int b[]=new b[n]; ^ symbol: class b location: class Main 2 errors
s257687748
p03675
C++
#include <iostream> #include <vector> #include <algorithm> #include <bits/stdc++.h> using namespace std; long long int a,b,c[200010],d[100010],ans =1,ant=1; int main(){ cin >> a ; for(int i=0;i<a;i++) cin >> c[i]; for(int i=1;i<=a;i++){ reverse(c,c+i); } for(int i=0;i<a;i++) cout << c[i] << " " <<; cout << endl; }
a.cc: In function 'int main()': a.cc:23:25: error: expected primary-expression before ';' token 23 | cout << c[i] << " " <<; | ^
s234673024
p03675
Java
import java.util.*; import java.lang.*; public class Main{ public static void main(String[] args){ FastScanner sc = new FastScanner(System.in); int N = sc.nextInt(); long[] ans = new long[N+1]; int b = N/2+1; int c = N/2+2; int d = N/2; if( N%2!=0 ){ for( int i=1; i<=N; i++ ){ if( i%2!=0 ){ ans[b] = sc.nextLong(); b--; }else{ ans[c] = sc.nextLong(); c++; } } } if( N%2==0 ){ for( int i=1; i<=N; i++ ){ if( i%2!=0 ){ ans[b] = sc.nextLong(); b++; }else{ ans[d] = sc.nextLong(); d--; } } } String ss = "A"; for( int i=1; i<=N; i++ ){ ss = ss + " " + String.valueOf(ans[i]); } System.out.println(ss.substring(2)); } }
Main.java:5: error: cannot find symbol FastScanner sc = new FastScanner(System.in); ^ symbol: class FastScanner location: class Main Main.java:5: error: cannot find symbol FastScanner sc = new FastScanner(System.in); ^ symbol: class FastScanner location: class Main 2 errors
s460815707
p03675
C++
#include <bits/stdc++.h> #define int long long #define rep(i,n) for(int i=0;i<n;++i) #define rep1(i,n) for(int i=1;i<=n;++i) #define all(a) a.begin(),a.end() #define P pair<long long,long long> #define double long double using namespace std; //桁 int kt(int a){ double b=a; b=log10(b); int c=b; return c+1; } int lcm(int a,int b){ int d=a,e=b,f; if(a<b) swap(a,b); int c,m=1; while(m){ c=a%b; if(c==0){ f=b; m--; } else{ a=b; b=c; } } return d*e/f; } int gcm(int a,int b){ int d=a,e=b,f; if(a<b) swap(a,b); int c,m=1; while(m){ c=a%b; if(c==0){ f=b; m--; } else{ a=b; b=c; } } return f; } signed main(){ int a; cin>>a; vector<int> b(a); rep(i,a) cin>>b[i]; queue<int> c; stack<int> d; rep(i,a){ if(i%2==0){ c.push(b[i]); } else{ d.push(b[i]); } } while(d.empty()){ cout<<d.front(); d.pop(); } while(c.empty()){ cout<<c.top(); c.pop(); } }
a.cc: In function 'int main()': a.cc:69:11: error: 'class std::stack<long long int>' has no member named 'front' 69 | cout<<d.front(); | ^~~~~ a.cc:73:11: error: 'class std::queue<long long int>' has no member named 'top'; did you mean 'pop'? 73 | cout<<c.top(); | ^~~ | pop
s116522970
p03675
C++
#include <bits/stdc++.h> #define int long long #define rep(i,n) for(int i=0;i<n;++i) #define rep1(i,n) for(int i=1;i<=n;++i) #define all(a) a.begin(),a.end() #define P pair<long long,long long> #define double long double using namespace std; //桁 int kt(int a){ double b=a; b=log10(b); int c=b; return c+1; } int lcm(int a,int b){ int d=a,e=b,f; if(a<b) swap(a,b); int c,m=1; while(m){ c=a%b; if(c==0){ f=b; m--; } else{ a=b; b=c; } } return d*e/f; } int gcm(int a,int b){ int d=a,e=b,f; if(a<b) swap(a,b); int c,m=1; while(m){ c=a%b; if(c==0){ f=b; m--; } else{ a=b; b=c; } } return f; } signed main(){ int a; cin>>a; vector<int> b(a); rep(i,a) cin>>b[i]; queue<int> c; stack<int> d; rep(i,a){ if(i%2==0){ c.push(b[i]); } else{ d.push(b[i]); } } while(d.empty()){ cout<<d.top(); d.pop(); } while(c.empty()){ cout<<c.top(); c.pop(); } }
a.cc: In function 'int main()': a.cc:73:11: error: 'class std::queue<long long int>' has no member named 'top'; did you mean 'pop'? 73 | cout<<c.top(); | ^~~ | pop
s897850027
p03675
C++
#include <bits/stdc++.h> #define int long long #define rep(i,n) for(int i=0;i<n;++i) #define rep1(i,n) for(int i=1;i<=n;++i) #define all(a) a.begin(),a.end() #define P pair<long long,long long> #define double long double using namespace std; //桁 int kt(int a){ double b=a; b=log10(b); int c=b; return c+1; } int lcm(int a,int b){ int d=a,e=b,f; if(a<b) swap(a,b); int c,m=1; while(m){ c=a%b; if(c==0){ f=b; m--; } else{ a=b; b=c; } } return d*e/f; } int gcm(int a,int b){ int d=a,e=b,f; if(a<b) swap(a,b); int c,m=1; while(m){ c=a%b; if(c==0){ f=b; m--; } else{ a=b; b=c; } } return f; } signed main(){ int a; cin>>a; vector<int> b(a); rep(i,a) cin>>b[i]; queue<int> c; stack<int> d; rep(i,a){ if(i%2==0){ c.push(b[i]); } else{ d.push(b[i]); } } while(d.empty()){ cout<<d.top(); d.pop(); } while(c.empty()){ cout<<c.top(); c.pop(); } } }
a.cc: In function 'int main()': a.cc:73:11: error: 'class std::queue<long long int>' has no member named 'top'; did you mean 'pop'? 73 | cout<<c.top(); | ^~~ | pop a.cc: At global scope: a.cc:78:1: error: expected declaration before '}' token 78 | } | ^
s984033935
p03675
C++
#include <bits/stdc++.h> using namespace std; #define all(x) x.begin(), x.end() #define rep(i, n) for (int i = 0; i < n; ++i) #define reps(i, m, n) for (int i = m; i <= n; ++i) using i64 = long long; using pii = pair<i64, i64>; template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;} template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;} constexpr int INF = 0x3f3f3f3f; constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL; constexpr int MOD = int(1e9) + 7; signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector<int> a(n+1); reps(i, 1, n) { cin >> a[i]; } vector<int> b; reps(i, 1, n) { b.push_back(a[i]); reverse(all(b)); signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector<int> a(n+1); reps(i, 1, n) { cin >> a[i]; } if (n == 1) { cout << a[1] << "\n"; return 0; } vector<int> first; vector<int> second; if (n % 2 != 0) { reps(i, 1, n) { if (i % 2 != 0) first.push_back(a[i]); else second.push_back(a[i]); } } else { reps(i, 1, n) { if (i % 2 == 0) first.push_back(a[i]); else second.push_back(a[i]); } } reverse(all(first)); for (int i = 0; i < first.size(); ++i) { cout << first[i] << ' '; } for (int i = 0; i < second.size(); ++i) { cout << second[i] << " \n"[i==second.size()-1]; } return 0; }
a.cc: In function 'int main()': a.cc:36:12: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse] 36 | signed main() | ^~ a.cc:36:12: note: remove parentheses to default-initialize a variable 36 | signed main() | ^~ | -- a.cc:36:12: note: or replace parentheses with braces to value-initialize a variable a.cc:37:1: error: a function-definition is not allowed here before '{' token 37 | { | ^ a.cc:82:2: error: expected '}' at end of input 82 | } | ^ a.cc:33:17: note: to match this '{' 33 | reps(i, 1, n) { | ^ a.cc:82:2: error: expected '}' at end of input 82 | } | ^ a.cc:20:1: note: to match this '{' 20 | { | ^
s213214568
p03675
C++
#include<bits/stdc++.h> using namespace std; typedef long long LL; const int N=200005; const int MOD=1e9+7; int n; int a[N]; int b[N]; int main() { cin>>n; for(int i=1;i<=n;i++) { scanf("%d",&a[i]); } int m=n; int j=1; for(int i=n;i>=2;i-=2) { b[j]=a[i]; b[n-j+1]=a[i-1]; j++; } if(i&1) { b[j]=a[1]; } for(int i=1;i<=n;i++) printf("%d ",b[i]); return 0; }
a.cc: In function 'int main()': a.cc:25:7: error: 'i' was not declared in this scope 25 | if(i&1) | ^
s848854588
p03675
C++
#include<iostream> #include<algorithm> using namespace std; const int S=(1<<20)+5; char buf[S],*H,*T; inline char Get() { if(H==T) T=(H=buf)+fread(buf,1,S,stdin); if(H==T) return -1; return *H++; } inline int read() { int x=0; char c=Get(); while(!isdigit(c)) c=Get(); while(isdigit(c)) x=x*10+c-'0',c=Get(); return x; } typedef long long LL; struct Seg { int l,r,extra; }seg[1000000<<1]; vector<Seg> R[1000000]; int n,m,a[1000000],tot=0; int main() { int cross=0,p=1; LL ans=0x7fffffff,cur=0; n=read(); m=read(); for(int i=1; i<=n; i++) a[i]=read(); for(int i=1; i<n; i++) if(a[i]<a[i+1]) { seg[++tot]= {a[i],a[i+1],0}; R[a[i+1]].push_back(seg[tot]); cur+=a[i+1]-a[i]; } else { seg[++tot]= {a[i],m,0}; R[m].push_back(seg[tot]); seg[++tot]= {0,a[i+1],m-a[i]}; R[a[i+1]].push_back(seg[tot]); cur+=a[i+1]+m-a[i]; } sort(seg+1,seg+1+tot,[](Seg a,Seg b) { return a.l<b.l; }); for(int i=0; i<=m; i++) { cur-=cross; ans=min(ans,cur); for(Seg s : R[i]) { cur+=s.extra+i-s.l-1; cross--; } while(p<=tot&&seg[p].l<=i) { Seg s=seg[p]; cur-=s.extra+i-s.l-1; cross++; p++; } } printf("%lld\n",ans); return 0; }
a.cc:31:1: error: 'vector' does not name a type 31 | vector<Seg> R[1000000]; | ^~~~~~ a.cc: In function 'int main()': a.cc:45:25: error: 'R' was not declared in this scope 45 | R[a[i+1]].push_back(seg[tot]); | ^ a.cc:51:25: error: 'R' was not declared in this scope 51 | R[m].push_back(seg[tot]); | ^ a.cc:64:29: error: 'R' was not declared in this scope 64 | for(Seg s : R[i]) | ^
s721941411
p03675
C++
#include<iostream> #include<vector> #include<string> using namespace std; int main(){ int n; int a[200005]; cin>>n; for(int i=0;i<n;i++){ cin>>a[i]; } vector<int> b; for(int i=0;i<n;i++){ b.push_back(a[i]); reverse(b.begin(),b.end()); } for(int i=0;i<n-1;i++){ cout<<b[i]<<" "; } cout<<b[n-1]<<"\n"; return 0; }
a.cc: In function 'int main()': a.cc:15:5: error: 'reverse' was not declared in this scope 15 | reverse(b.begin(),b.end()); | ^~~~~~~
s131553755
p03675
C++
#include <bits/stdc++.h> using namespace std; int main(){ int n,a[200000],ans[200000]; cin>>n; for(int i=0;i<n;i++)cin>>a[i]; for(int i=n-1;i>=0;i--){ if((n-i)%2)ans[(n-i)/2)]=a[i]; else ans[n-((n-i)/2)]=a[i]; } for(int i=0;i<n;i++){ if(i!=n-1)cout<<ans[i]<<" "; else cout<<ans[i]<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:8:31: error: expected ']' before ')' token 8 | if((n-i)%2)ans[(n-i)/2)]=a[i]; | ^ | ] a.cc:8:31: error: expected ';' before ')' token 8 | if((n-i)%2)ans[(n-i)/2)]=a[i]; | ^ | ;
s791227414
p03675
C++
#include <bits/stdc++.h> using namespace std; int main(){ int n,a[200000],ans[200000]; cin>>n; for(int i=0;i<n;i++)cin>>a[i]; for(int i=n-1;i>=0;i++){ if((n-i)%2)ans[(n-i)/2)]=a[i]; else ans[n-((n-i)/2)]=a[i]; } for(int i=0;i<n;i++){ if(i!=n-1)cout<<ans[i]<<" "; else cout<<ans[i]<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:8:31: error: expected ']' before ')' token 8 | if((n-i)%2)ans[(n-i)/2)]=a[i]; | ^ | ] a.cc:8:31: error: expected ';' before ')' token 8 | if((n-i)%2)ans[(n-i)/2)]=a[i]; | ^ | ;
s871504176
p03675
C++
#include <bits/stdc++.h> using namespace std; const int maxn=1e5+7; int a[maxn]; int b[maxn<<1]; int c[maxn<<1]; int main() { // freopen("in.txt","r",stdin); int n,m; long long sum=0; scanf("%d%d",&n,&m); for(int i=1; i<=n; ++i) scanf("%d",&a[i]); for(int i=2; i<=n; ++i) { if(a[i]>a[i-1]) { sum+=a[i]-a[i-1]; b[a[i-1]+1]+=a[i-1]+1; b[a[i]+1]-=a[i-1]+1; c[a[i-1]+1]++; c[a[i]+1]--; } else { sum += m-a[i-1]+a[i]; b[a[i-1]+1] += a[i-1]+1; b[a[i]+1] += m-a[i-1]-1; b[1] -= m-a[i-1]-1; c[1]++; c[a[i-1]+1]++; c[a[i]+1]--; } } for(int i=1; i<=m; ++i) { c[i]+=c[i-1]; b[i]+=b[i-1]; } long long ma=0; for(int x=1; x<=m; ++x) { if(c[x]) { ma=max(ma,1LL(x*c[x]-b[x])); } } printf("%lld\n",sum-ma); return 0; }
a.cc: In function 'int main()': a.cc:38:26: error: expression cannot be used as a function 38 | ma=max(ma,1LL(x*c[x]-b[x])); | ~~~^~~~~~~~~~~~~
s904262065
p03675
C
#include<bits/stdc++.h> using namespace std; const int maxn = 2e5+7; int a[maxn],ans[maxn]; int n; int main() { scanf("%d",&n); for(int i=1;i<=n;i++){ scanf("%d",&a[i]); } int l=1,r=n,k=n,cnt=1; for(int i=n;i>=1;i--){ if(cnt&1) ans[l++]=a[k--]; else ans[r--]=a[k--]; cnt++; } for(int i=1;i<=n-1;i++) printf("%d ",ans[i]); printf("%d\n",ans[n]); }
main.c:1:9: fatal error: bits/stdc++.h: No such file or directory 1 | #include<bits/stdc++.h> | ^~~~~~~~~~~~~~~ compilation terminated.
s202010357
p03675
C++
#include <bits/stdc++.h> using namespace std; int b[1000000001]; int main() { int i, a, n; cin >> n; int mid = (n - 1) / 2; for(i=0; i<n; i++) { cin >> a; //if(i % 2 == 0) b[mid-(i+1)/2] = a; else b[mid+(i+1)/2] = a; } if(n % 2 == 0) for(i=n-1; i>=0; i--) { printf("%d ", b[i]); } else for(i=0; i<n; i++) { printf("%d ", b[i]); } puts(""); return 0; }
a.cc: In function 'int main()': a.cc:14:9: error: 'else' without a previous 'if' 14 | else b[mid+(i+1)/2] = a; | ^~~~
s628137347
p03675
Java
import java.util.*; class Main{ public static void main(String[] args){   Scanner sc = new Scanner(System.in); Deque<Integer> q = new ArrayDeque<Integer>(); int n = sc.nextInt(); int a[] = new int[n]; for(int i = 0;i < n;i++){ a[i] = sc.nextInt(); } if(n%2 == 0){ for(int i = 0;i < n;i++){ if(a[i]%2 == 1){ q.addLast(a[i]); }else{ q.addFirst(a[i]); } } }else{ for(int i = 0;i < n;i++){ if(a[i]%2 == 1){ q.addFirst(a[i]); }else{ q.addLast(a[i]); } } } while(!q.isEmpty()){ System.out.print(q.poll()); System.out.print(" "); } System.out.println(); } }
Main.java:5: error: illegal character: '\u00a0' ? ^ 1 error
s439439174
p03675
Java
improt java.util.*; class Main{ public static void main(String[] args){   Scanner sc = new Scanner(System.in); Deque<Integer> q = new ArrayDeque<Integer>(); int n = sc.nextInt(); int a[] = new int[n]; for(int i = 0;i < n;i++){ a[i] = sc.nextInt(); } if(n%2 == 0){ for(int i = 0;i < n;i++){ if(a[i]%2 == 1){ q.addLast(a[i]); }else{ q.addFirst(a[i]); } } }else{ for(int i = 0;i < n;i++){ if(a[i]%2 == 1){ q.addFirst(a[i]); }else{ q.addLast(a[i]); } } } while(!q.isEmpty()){ System.out.print(q.poll()); System.out.print(" "); } System.out.println(); } }
Main.java:1: error: class, interface, enum, or record expected improt java.util.*; ^ Main.java:5: error: illegal character: '\u00a0' ? ^ 2 errors
s018839635
p03675
Java
class Main{ public static void main(String[] args){   Scanner sc = new Scanner(System.in); Deque<Integer> q = new ArrayDeque<Integer>(); int n = sc.nextInt(); int a[] = new int[n]; for(int i = 0;i < n;i++){ a[i] = sc.nextInt(); } if(n%2 == 0){ for(int i = 0;i < n;i++){ if(a[i]%2 == 1){ q.addLast(a[i]); }else{ q.addFirst(a[i]); } } }else{ for(int i = 0;i < n;i++){ if(a[i]%2 == 1){ q.addFirst(a[i]); }else{ q.addLast(a[i]); } } } while(!q.isEmpty()){ System.out.print(q.poll()); System.out.print(" "); } System.out.println(); } }
Main.java:3: error: illegal character: '\u00a0' ? ^ 1 error
s868681026
p03675
C++
//#include "IntMod.h" //typedef IntMod<1000000007> MInt; //#include "Union_Find.h" #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <string> #include <vector> #include <utility> #include <algorithm> #include <functional> #include <cmath> #include <stack> #include <queue> #include <set> #include <map> #include <iomanip> #include <sstream> #include <numeric> #include <array> #include <bitset> using namespace std; #define REP(i,a,n) for(int i = (a); i < (int)(n); ++i) #define REPM(i,n,a) for(int i = ((n) - 1); i >= (a); --i) #define EPS 0.0001 #define INF 0x3FFFFFFF #define INFLL 0x3FFFFFFF3FFFFFFF #define INFD 1.0e+308 #define FLOAT setprecision(16) typedef long long LL; typedef unsigned long long ULL; typedef pair<LL, LL> PP; template <class T, class U> istream& operator>>(istream& ist, pair<T, U>& right) { return ist >> right.first >> right.second; } template <class T, class U> ostream& operator<<(ostream& ost, pair<T, U>& right) { return ost << right.first << ' ' << right.second; } template <class T, class TCompatible, size_t N> void Fill(T(&dest)[N], const TCompatible& val) { fill(begin(dest), end(dest), val); } template <class T, class TCompatible, size_t M, size_t N> void Fill(T(&dest)[M][N], const TCompatible& val) { for (int i = 0; i < M; ++i) Fill(dest[i], val); } #if 1 #include <unordered_set> #include <unordered_map> template<class T> using PriorityQ = priority_queue<T, vector<T>, greater<T> >; // コスト小を優先 #endif int N; list<int> L; int main() { cin >> N; REP(i, 0, N) { int a; cin >> a; if ((N - i) % 2 == 0) { L.push_back(a); } else { L.push_front(a); } } for (auto it = L.begin(); it != L.end(); ++it) { cout << *it << (it != prev(L.end()) ? ' ' : '\n'); } return 0; }
a.cc:56:1: error: 'list' does not name a type 56 | list<int> L; | ^~~~ a.cc: In function 'int main()': a.cc:63:25: error: 'L' was not declared in this scope 63 | L.push_back(a); | ^ a.cc:65:25: error: 'L' was not declared in this scope 65 | L.push_front(a); | ^ a.cc:68:24: error: 'L' was not declared in this scope 68 | for (auto it = L.begin(); it != L.end(); ++it) { | ^
s021345106
p03675
C++
include<bits/stdc++.h> using namespace std; int main(){ vector <int> a; vector <int> b; int N; cin>>N; for(int i=0;i<N;i++){ int aa; cin>>aa; a.push_back(aa); } for(int i=0;i<N;i++){ b.push_back(a[i]); reverse(b.begin(), b.end()); } for(int i=0;i<N;i++){ cout<<b[i]; if(i!=N-1)cout<<" "; else cout<<endl; } return 0; }
a.cc:1:1: error: 'include' does not name a type 1 | include<bits/stdc++.h> | ^~~~~~~ a.cc: In function 'int main()': a.cc:6:9: error: 'vector' was not declared in this scope 6 | vector <int> a; | ^~~~~~ a.cc:6:17: error: expected primary-expression before 'int' 6 | vector <int> a; | ^~~ a.cc:7:17: error: expected primary-expression before 'int' 7 | vector <int> b; | ^~~ a.cc:9:9: error: 'cin' was not declared in this scope 9 | cin>>N; | ^~~ a.cc:13:17: error: 'a' was not declared in this scope; did you mean 'aa'? 13 | a.push_back(aa); | ^ | aa a.cc:16:17: error: 'b' was not declared in this scope 16 | b.push_back(a[i]); | ^ a.cc:16:29: error: 'a' was not declared in this scope 16 | b.push_back(a[i]); | ^ a.cc:17:17: error: 'reverse' was not declared in this scope 17 | reverse(b.begin(), b.end()); | ^~~~~~~ a.cc:20:17: error: 'cout' was not declared in this scope 20 | cout<<b[i]; | ^~~~ a.cc:20:23: error: 'b' was not declared in this scope 20 | cout<<b[i]; | ^ a.cc:22:28: error: 'endl' was not declared in this scope 22 | else cout<<endl; | ^~~~
s483348833
p03675
C++
#include <iostream> #include <algorithm> #include <cstring> #include <cstdio> #include <vector> #include <cstdlib> #include <iomanip> #include <cmath> #include <ctime> #include <map> #include <set> #include <queue> #include <stack> using namespace std; #define lowbit(x) (x&(-x)) #define max(x,y) (x>y?x:y) #define min(x,y) (x<y?x:y) #define MAX 100000000000000000 #define MOD 1000000007 #define pi acos(-1.0) #define ei exp(1) #define PI 3.141592653589793238462 #define INF 0x3f3f3f3f3f #define mem(a) (memset(a,0,sizeof(a))) typedef long long ll; ll gcd(ll a,ll b){ return b?gcd(b,a%b):a; } const int N=200005; const int mod=1e9+7; int a[N]; int main() { std::ios::sync_with_stdio(false); while(cin>>n){ for(int i=1;i<=n;++i){ cin>>a[i]; } if(n&1){ cout<<a[n]; for(int i=n-2;i>=1;i-=2) cout<<" "<<a[i]; for(int i=2;i<=n-1;i+=2) cout<<" "<<a[i]; cout<<endl; }else{ cout<<a[n]; for(int i=n-2;i>=2;i-=2) cout<<" "<<a[i]; for(int i=1;i<=n-1;i+=2) cout<<" "<<a[i]; cout<<endl; } } return 0; }
a.cc: In function 'int main()': a.cc:35:16: error: 'n' was not declared in this scope 35 | while(cin>>n){ | ^
s920852152
p03675
C++
#include <iostream> #include <vector> using namespace std; int main() { int n; cin>>n; vector<int> vec(n); for(int i=0;i<n;i++) { cin>>vec[i]; reverse(vec.begin(),vec.end()); } for(int i=0;i<n;i++) cout<<vec[i]<<" "; return 0; }
a.cc: In function 'int main()': a.cc:12:1: error: 'reverse' was not declared in this scope 12 | reverse(vec.begin(),vec.end()); | ^~~~~~~
s891402309
p03675
C++
#include<iostream> #include<string> #include<vector> #include<sstream> using namespace std; int main() { int n; cin >> n; vector<int> b; int btmp; for (int i = 0; i < n; i++) { cin >> btmp; b.push_back(btmp); reverse(b.begin(), b.end()); } auto itr = b.begin(); while (itr != b.end()) { string s = (itr + 1 == b.end()) ? "" : " "; cout << *itr << s; itr++; } return 0; }
a.cc: In function 'int main()': a.cc:15:17: error: 'reverse' was not declared in this scope 15 | reverse(b.begin(), b.end()); | ^~~~~~~
s621160414
p03675
C++
import java.io.*; import java.lang.reflect.Array; import java.math.*; import java.security.KeyStore.Entry; import java.util.*; public class Main { private InputStream is; private PrintWriter out; int time = 0, dp[][], DP[][], dist[], prime[], start[], parent[], end[], val[], black[], arr[], arr1[][]; long MOD = (long) (1e9 + 9); Queue<Integer>[] amp; boolean b[], b1[]; Pair prr1[]; char ch[][], c[]; HashSet<Integer> hs1 = new HashSet<>(), hs2 = new HashSet<>(); public static void main(String[] args) throws Exception { new Thread(null, new Runnable() { public void run() { try { // new Main().soln(); } catch (Exception e) { System.out.println(e); } } }, "1", 1 << 26).start(); new Main().soln(); } int MAX = 1000010, N, K; double Q = 1; double a = 1 , fa = 0; long B = 0; PriorityQueue<Pair> pq; int Dp[][] = new int[1010][1010]; int MOD1 = 1000000007, MOD2 = 1000000009; void solve() { int n = ni(); int arr[] = new int[n+1]; for(int i = 1;i<=n;i++) arr[i] = ni(); if(n%2==0){ for(int i = n;i>=2;i-=2) out.print(arr[i]+" "); for(int i = 1;i<=n;i+=2) out.print(arr[i]+" "); } else{ for(int i = n;i>=1;i-=2) out.print(arr[i]+" "); for(int i = 2;i<=n;i+=2) out.print(arr[i]+" "); } } void recur(int x, int y, int p){ int val = 0; if(x>y || y<x) return; if(x>0){ if(p==1){ val = arr[x]-arr[x-1]; } if(p==3){ if(arr[x]-arr[x-1]<K){ recur(x+1,y,3); } else val = arr[x]-arr[x-1]; } } if(y<N){ if(p==4){ B += arr[y+1]-arr[y]; } if(p==2){ if(arr[y+1]-arr[y]<K){ recur(x,y-1,2); } else val = arr[y+1]-arr[y]; } } B += val; if(x==y){ System.out.println(B+" "+a); fa += B*a; } //System.out.println(Q); a*=Q; recur(x+1,y,1); recur(x,y-1,2); a/=Q; a*=(1-Q); recur(x+1,y,3); recur(x,y-1,4); a/=(1-Q); B -= val; //System.out.println(a+" "+B); } class cell implements Comparable<cell>{ char ch; int i; cell(char c, int x){ ch = c; i = x; } public boolean equals(Object o) { cell other = (cell) o; return ((ch == other.ch && i == other.i));// || (v == other.u && u == // other.v)); } @Override public int compareTo(cell c) { if(this.ch<c.ch) return -1; if(this.ch==c.ch) { if(this.i<c.i)return 1; if(this.i==c.i) return 0; return -1; } return 1; } public String toString() { return "[u=" + ch + ", v=" + i + "]"; } } int T[] = new int[100010], L[] = new int[100010]; int P[][] = new int[100010][30]; void process3(int N) { int i, j; // we initialize every element in P with -1 for (i = 0; i < N; i++) for (j = 0; 1 << j < N; j++) P[start[i]][j] = -1; // the first ancestor of every node i is T[i] for (i = 0; i < N; i++) P[start[i]][0] = T[i]; // bottom up dynamic programing for (j = 1; 1 << j < N; j++) for (i = 0; i < N; i++) if (P[start[i]][j - 1] != -1) P[start[i]][j] = P[P[start[i]][j - 1]][j - 1]; } int query(int p, int q) { int tmp = 0, log = 0, i = 0; // if p is situated on a higher level than q then we swap them if (L[p] < L[q]) tmp = p; p = q; q = tmp; // we compute the value of [log(L[p)] for (log = 1; 1 << log <= L[p]; log++) ; log--; // we find the ancestor of node p situated on the same level // with q using the values in P for (i = log; i >= 0; i--) if (L[p] - (1 << i) >= L[q]) p = P[p][i]; if (p == q) return p; // we compute LCA(p, q) using the values in P for (i = log; i >= 0; i--) if (P[p][i] != -1 && P[p][i] != P[q][i]) p = P[p][i]; q = P[q][i]; return T[p]; } long ans = 0; void recur(int i, int k, long sum) { if (k > K) return; if (k == K) { ans = Math.max(ans, sum); } for (int j = i; j < N; j++) { recur(j + 1, k + 1, sum); } } long[] mul(long arr[][], long temp[]) { long ans[] = new long[temp.length]; for (int i = 0; i < arr.length; i++) { long sum = 0; for (int j = 0; j < arr.length; j++) { sum = (sum + arr[i][j] * temp[j]) % MOD; } ans[i] = sum; } return ans; } void printMat(long arr[][]) { for (int i = 0; i < arr.length; i++) { for (int j = 0; j < arr.length; j++) { System.out.print(arr[i][j] + " "); } System.out.println(); } System.out.println("-----"); } void printMat(long arr[]) { for (int i = 0; i < arr.length; i++) { System.out.print(arr[i] + " "); } System.out.println(); System.out.println("-----"); } long[][] matMul(int n, long arr[][], long y) { long iden[][] = new long[n][n]; for (int i = 0; i < n; i++) iden[i][i] = 1; // printMat(iden); while (y > 0) { if (y % 2 == 1) { iden = mul(n, iden, arr); // printMat(iden); y--; } else { arr = mul(n, arr, arr); // printMat(arr); y /= 2; } } return iden; } long[][] mul(int n, long a1[][], long a2[][]) { long temp[][] = new long[n][n]; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { long sum = 0; for (int k = 0; k < n; k++) { sum = (sum + a1[i][k] * a2[k][j]) % MOD; } temp[i][j] = sum; } } return temp; } void seive(int n) { b = new boolean[n + 1]; prime = new int[n + 1]; for (int i = 2; i * i <= n; i++) { if (!b[i]) { for (int j = 2 * i; j <= n; j += i) { if (!b[j]) { b[j] = true; prime[j] = i; } } } } } int binarySearch1(int arr[], int x) { int ans = -1; int low = 0, high = arr.length - 1; while (high >= low) { int mid = (low + high) / 2; if (arr[mid] >= x) { ans = mid; high = mid - 1; } else low = mid + 1; } return ans; } int binarySearch2(Integer arr[], int x) { int ans = -1; int low = 0, high = arr.length - 1; while (high >= low) { int mid = (low + high) / 2; if (arr[mid] >= x) { ans = mid; low = mid + 1; } else high = mid - 1; } return ans + 1; } int cntEven(String str) { int cnt = 0; for (int i = str.length() - 1; i >= 0; i--) { if ((str.charAt(i) - '0') % 2 == 0) { cnt++; } } return cnt; } int max = 0; int getParent(int x) { // System.out.println(x+" "+parent[x]); if (parent[x] != x) { parent[x] = getParent(parent[x]); } return parent[x]; } class Pair implements Comparable<Pair> { int u; int v, r, i; Pair(int u, int v, int r, int i) { this.u = u; this.v = v; this.r = r; this.i = i; } Pair(int u, int v, int r) { this.u = u; this.v = v; this.r = r; } Pair(int u, int v) { this.u = u; this.v = v; } public int hashCode() { return Objects.hash(); } public boolean equals(Object o) { Pair other = (Pair) o; return ((u == other.u && v == other.v));// || (v == other.u && u == // other.v)); } public int compareTo(Pair other) { //return Long.compare(r, other.r); return Long.compare(u, other.u) != 0 ? (Long.compare(u, other.u)) : (Long.compare(v, other.v)); // :(Long.compare(other.r, r))) ; } } int min(int x, int y) { if (x < y) return x; return y; } int max(int x, int y) { if (x > y) return x; return y; } long modInverse(long a, long mOD2) { return power(a, mOD2 - 2, mOD2); } long power(long x, long y, long m) { if (y == 0) return 1; long p = power(x, y / 2, m) % m; p = (p * p) % m; return (y % 2 == 0) ? p : (x * p) % m; } boolean isPrime(int x) { for (int i = 2; i * 1L * i <= x; i++) if (x % i == 0) return false; return true; } public long gcd(long a, long b) { if (b == 0) return a; return gcd(b, a % b); } void failFn(String str, int arr[]) { int len = 0; arr[0] = 0; int i = 1; while (i < arr.length) { if (str.charAt(i) == str.charAt(len)) { arr[i++] = ++len; continue; } if (len == 0) { arr[i] = len; i++; continue; } if (str.charAt(i) != str.charAt(len)) { len = arr[len - 1]; } } } static class ST1 { int arr[], st[], size; ST1(int a[]) { arr = a.clone(); size = 10 * arr.length; st = new int[size]; build(0, arr.length - 1, 1); } void build(int ss, int se, int si) { if (ss == se) { st[si] = arr[ss]; return; } int mid = (ss + se) / 2; int val = 2 * si; build(ss, mid, val); build(mid + 1, se, val + 1); st[si] = (st[val] + st[val + 1]); } int get(int ss, int se, int l, int r, int si) { if (l > se || r < ss || l > r) return Integer.MAX_VALUE; if (l <= ss && r >= se) return st[si]; int mid = (ss + se) / 2; int val = 2 * si; return (get(ss, mid, l, r, val) + get(mid + 1, se, l, r, val + 1)); } } static class ST { int arr[], lazy[], n; ST(int a) { n = a; arr = new int[10 * n]; lazy = new int[10 * n]; } void up(int l, int r, int val) { update(0, n - 1, 0, l, r, val); } void update(int l, int r, int c, int x, int y, int val) { if (lazy[c] != 0) { lazy[2 * c + 1] ^= lazy[c]; lazy[2 * c + 2] ^= lazy[c]; if (l == r) arr[c] ^= lazy[c]; lazy[c] = 0; } if (l > r || x > y || l > y || x > r) return; if (x <= l && y >= r) { if ((r - l + 1) % 2 == 1) lazy[c] ^= val; return; } int mid = l + r >> 1; update(l, mid, 2 * c + 1, x, y, val); update(mid + 1, r, 2 * c + 2, x, y, val); arr[c] = (arr[2 * c + 1] + arr[2 * c + 2]); } int an(int ind) { return ans(0, n - 1, 0, ind); } int ans(int l, int r, int c, int ind) { if (lazy[c] != 0) { lazy[2 * c + 1] += lazy[c]; lazy[2 * c + 2] += lazy[c]; if (l == r) arr[c] += lazy[c]; lazy[c] = 0; } if (l == r) return arr[c]; int mid = l + r >> 1; if (mid >= ind) return ans(l, mid, 2 * c + 1, ind); return ans(mid + 1, r, 2 * c + 2, ind); } } static long[] array; public static class FenwickTree { // 1-indexed array, In this array We save cumulative // information to perform efficient range queries and // updates public FenwickTree(int size) { array = new long[size + 1]; } int getSum(int index) { int sum = 0; // Iniialize result // index in BITree[] is 1 more than the index in arr[] index = index + 1; // Traverse ancestors of BITree[index] while (index>0) { // Add current element of BITree to sum sum ^= array[index]; // Move index to parent node in getSum View index -= index & (-index); } return sum; } public long rsq(int ind) { assert ind > 0; long sum = 0; ind = ind+1; while (ind > 0) { sum ^= array[ind]; // Extracting the portion up to the first significant one of the // binary representation of 'ind' and decrementing ind by that // number ind -= ind & (-ind); } return sum; } public long rsq(int a, int b) { assert b >= a && a > 0 && b > 0; return rsq(b) ^ rsq(a - 1); } public void update(int ind, long value) { assert ind > 0; ind = ind+1; while (ind < array.length) { array[ind] ^= value; // Extracting the portion up to the first significant one of the // binary representation of 'ind' and incrementing ind by that // number ind += ind & (-ind); } } public int size() { return array.length - 1; } } public static int[] shuffle(int[] a, Random gen) { for (int i = 0, n = a.length; i < n; i++) { int ind = gen.nextInt(n - i) + i; int d = a[i]; a[i] = a[ind]; a[ind] = d; } return a; } long power(long x, long y, int mod) { long ans = 1; while (y > 0) { if (y % 2 == 0) { x = (x * x) % mod; y /= 2; } else { ans = (x * ans) % mod; y--; } } return ans; } void soln() { is = System.in; out = new PrintWriter(System.out); long s = System.currentTimeMillis(); solve(); out.close(); out.flush(); tr(System.currentTimeMillis() - s + "ms"); } // To Get Input // Some Buffer Methods private byte[] inbuf = new byte[1024]; public int lenbuf = 0, ptrbuf = 0; private int readByte() { if (lenbuf == -1) throw new InputMismatchException(); if (ptrbuf >= lenbuf) { ptrbuf = 0; try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); } if (lenbuf <= 0) return -1; } return inbuf[ptrbuf++]; } private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); } private int skip() { int b; while ((b = readByte()) != -1 && isSpaceChar(b)) ; return b; } private double nd() { return Double.parseDouble(ns()); } private char nc() { return (char) skip(); } private String ns() { int b = skip(); StringBuilder sb = new StringBuilder(); while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' // ') sb.appendCodePoint(b); b = readByte(); } return sb.toString(); } private char[] ns(int n) { char[] buf = new char[n]; int b = skip(), p = 0; while (p < n && !(isSpaceChar(b))) { buf[p++] = (char) b; b = readByte(); } return n == p ? buf : Arrays.copyOf(buf, p); } private char[][] nm(int n, int m) { char[][] map = new char[n][]; for (int i = 0; i < n; i++) map[i] = ns(m); return map; } private int[] na(int n) { int[] a = new int[n]; for (int i = 0; i < n; i++) a[i] = ni(); return a; } private int ni() { int num = 0, b; boolean minus = false; while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ; if (b == '-') { minus = true; b = readByte(); } while (true) { if (b >= '0' && b <= '9') { num = num * 10 + (b - '0'); } else { return minus ? -num : num; } b = readByte(); } } private long nl() { long num = 0; int b; boolean minus = false; while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ; if (b == '-') { minus = true; b = readByte(); } while (true) { if (b >= '0' && b <= '9') { num = num * 10 + (b - '0'); } else { return minus ? -num : num; } b = readByte(); } } private boolean oj = System.getProperty("ONLINE_JUDGE") != null; private void tr(Object... o) { if (!oj) System.out.println(Arrays.deepToString(o)); } }
a.cc:107:17: error: stray '@' in program 107 | @Override | ^ a.cc:1:1: error: 'import' does not name a type 1 | import java.io.*; | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:2:1: error: 'import' does not name a type 2 | import java.lang.reflect.Array; | ^~~~~~ a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:3:1: error: 'import' does not name a type 3 | import java.math.*; | ^~~~~~ a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:4:1: error: 'import' does not name a type 4 | import java.security.KeyStore.Entry; | ^~~~~~ a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:5:1: error: 'import' does not name a type 5 | import java.util.*; | ^~~~~~ a.cc:5:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:7:1: error: expected unqualified-id before 'public' 7 | public class Main { | ^~~~~~
s094944950
p03675
Java
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; public class ContestMain { public static void main( String... args ) throws Exception { BufferedReader in = new BufferedReader( new InputStreamReader( System.in ) ); String input = in.readLine(); List<String> inputList = new ArrayList<>(); List<String> outputList = new ArrayList<>(); while ( input != null ) { inputList.add( input ); input = in.readLine(); } int number = Integer.parseInt( inputList.get( 0 ) ); for ( String a : inputList.get( 1 ).split( " " ) ) { if ( outputList.size() < number ) { outputList.add( a ); outputList = reverse( outputList ); } } System.out.println( String.join( " ", outputList ) ); } /** * @param inputList * @return */ private static List<String> reverse( List<String> inputList ) { List<String> outputList = new ArrayList<>(); for ( int i = inputList.size(); i > 0; i-- ) { outputList.add( inputList.get( i - 1 ) ); } return outputList; } }
Main.java:6: error: class ContestMain is public, should be declared in a file named ContestMain.java public class ContestMain { ^ 1 error
s360595079
p03675
C++
#include <stdio.h> #include <stdint.h> uint32_t a[200000]; uint32_t e[200000]; int main(int argc, char **argv) { int n; scanf("%d\n", &n); for (int i = 0; i < n; i++) { scanf("%d ", &a[i]); } const int c = 200000 / 2; int f; if (n % 2) { // odd for (int i = 0; i < n; i++) { int j = ((i + 1) % 2) ? -1 : 1; e[c + (i + 1) / 2 * j] = a[i]; } f = c - n / 2; } else { // even for (int i = 0; i < n; i++) { int j = (i % 2) ? -1 : 1; e[c + (i + 1) / 2 * j] = a[i]; } f = c - n / 2; } for (int i = 0; i < n - 1; i++) { printf("%d ", e[f + i]); } printf("%d\n", e[f + n - 1]); return 0;
a.cc: In function 'int main(int, char**)': a.cc:38:12: error: expected '}' at end of input 38 | return 0; | ^ a.cc:8:1: note: to match this '{' 8 | { | ^
s997042054
p03675
Java
import java.util.*; public class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); // 回数 int N = sc.nextInt(); //元になる数列を格納 ArrayList list = new ArrayList(); ArrayList b = new ArrayList(); while (sc.hasNextLine()) { list.add(Integer.parseInt(sc.next()) + " "); } //メイン処理 for(int i = 0; i < N; i++){ //新しい配列に要素を格納 if(i % 2 == N % 2){ b.add(list.get(i)); }else{ b.add(0,list.get(i)); } } //回答用出力 for(int j = 0; j < b.size(); j++){ /* if(j == (b.size()-1)){ System.out.print(b.get(j)); }else{ System.out.print(b.get(j)+" "); } */ System.out.print(b.get(j)); } return 0; } }
Main.java:38: error: incompatible types: unexpected return value return 0; ^ Note: Main.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 1 error
s685060564
p03675
C++
#include <iostream.h> using namespace std; void SortIn(int *b,int a,int i) { int *tmp; tmp = (int *)malloc(sizeof(int)*(i+1)); b[i]=a; for(int j=0; j<=i; j++) { tmp[j]=b[j]; } for(int j=i; j>=0; j--) { b[i-j]=tmp[j]; } free(tmp); } int main() { int n; cin>>n; int a; int* b; b=(int *)malloc(sizeof(int)*n); for(int i=0; i<n; i++) { cin>>a; SortIn(b, a, i); } for(int i=0;i<n;i++) { cout<<b[i]; if(i==n-1) { cout<<"\n"; } else { cout<<" "; } } free(b); return 0; }
a.cc:1:10: fatal error: iostream.h: No such file or directory 1 | #include <iostream.h> | ^~~~~~~~~~~~ compilation terminated.
s004826446
p03675
C++
#include <iostream> #include <deque> using namespace std; int main() { int n; cin >> n; deque<int> d; bool isReversed = false; for (int i = 0; i < n; i++) { int value; cin >> value; if (isReversed) { d.push_front(value); } else { d.push_back(value); } isReversed = !isReversed; } if (isReversed) { reverse(d.begin(), d.end()); } for (auto& i : d) { cout << i << " "; } cout << endl; }
a.cc: In function 'int main()': a.cc:27:9: error: 'reverse' was not declared in this scope; did you mean 'isReversed'? 27 | reverse(d.begin(), d.end()); | ^~~~~~~ | isReversed
s884753539
p03675
C++
#include <iostream> #include <deque> #include <queue> #include <vector> #include <algorithm> using namespace std; int main() { bool flag = true; int n; cin >> n; vector<int> nums(n), res; deque<int> que; for (int i = 0; i < n; i++) cin >> nums[i]; for (int i = 0; i < n; i++) { if (flag) que.push_back(nums[i]); else que.push_front(nums[i]); flag = !flag; } for (int x : que) res.push_back(x); if (n % 2 == 1) reserve(res.begin(), res.end()); for (int x : res) cout << x << " "; cout << endl; }
a.cc: In function 'int main()': a.cc:21:21: error: 'reserve' was not declared in this scope 21 | if (n % 2 == 1) reserve(res.begin(), res.end()); | ^~~~~~~
s795898690
p03675
C
#include <stdio.h> #include <stdlib.h> #define N 200000 int main(void){ int a[N]; int i, n; scanf("%d", &n); for(i=0; i<n; i++){ scanf("%d", &a[i]); } for(i=n-1; i>=0; i=i-2){ printf("%d ", b[i]); } for(i=n-2; i>=0; i=i-2){ printf("%d ", b[i]); } printf("\n"); return 0; }
main.c: In function 'main': main.c:16:31: error: 'b' undeclared (first use in this function) 16 | printf("%d ", b[i]); | ^ main.c:16:31: note: each undeclared identifier is reported only once for each function it appears in
s902651962
p03675
Java
import java.util.LinkedList; import java.util.Queue; import java.util.Scanner; import java.util.Stack; class AtCoder { public static void main(String[] args) { Scanner s = new Scanner(System.in); Queue<Long> queue = new LinkedList(); Stack<Long> stack = new Stack(); long n,in; n=s.nextLong(); for (long i=0;i<n;i++) { if((n-(i+1))%2==0) { in = s.nextLong(); stack.push(in); } else { in=s.nextLong(); queue.add(in); } } System.out.println(); while(!stack.empty()) { long t = stack.pop(); System.out.print(t); } while(!queue.isEmpty()) { long t = queue.remove(); System.out.print(t); } } }
Note: Main.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details.
s611431046
p03675
Java
import java.util.LinkedList; import java.util.Queue; import java.util.Scanner; import java.util.Stack; public class AtCoder { public static void main(String[] args) { Scanner s = new Scanner(System.in); Queue<Long> queue = new LinkedList(); Stack<Long> stack = new Stack(); long n,in; n=s.nextLong(); for (long i=0;i<n;i++) { if((n-(i+1))%2==0) { in = s.nextLong(); stack.push(in); } else { in=s.nextLong(); queue.add(in); } } System.out.println(); while(!stack.empty()) { long t = stack.pop(); System.out.print(t); } while(!queue.isEmpty()) { long t = queue.remove(); System.out.print(t); } } }
Main.java:6: error: class AtCoder is public, should be declared in a file named AtCoder.java public class AtCoder { ^ Note: Main.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 1 error
s923056626
p03675
C++
import java.io.*; import java.util.*; import static java.lang.Math.*; public class Main { public static void main(String[] args) { Main main = new Main(); main.solve(args); } public void solve(String[] args) { MyScanner scanner = new MyScanner(); int N = scanner.nextInt(); StringBuilder sb = new StringBuilder(); boolean end = true; for (int i = 0; i < N; i++) { int a = scanner.nextInt(); if (end) { sb.append(a); sb.append(" "); } else { sb.insert(0, " "); sb.insert(0, a); } end = !end; } if (!end) { sb.reverse(); } System.out.println(sb.toString().trim()); } private class MyScanner { String[] s; int i; BufferedReader br; String reg = " "; MyScanner () { s = new String[0]; i = 0; br = new BufferedReader(new InputStreamReader(System.in)); } public String next() { try { if (i < s.length) return s[i++]; String line = br.readLine(); while (line.equals("")) { line = br.readLine(); } s = line.split(reg, 0); i = 0; return s[i++]; } catch (Exception e) { e.printStackTrace(); } return null; } public int nextInt() { try { return Integer.parseInt(next()); } catch (Exception e) { e.printStackTrace(); } return -1; } public double nextDouble() { try { return Double.parseDouble(next()); } catch (Exception e) { e.printStackTrace(); } return -1; } public long nextLong() { try { return Long.parseLong(next()); } catch (Exception e) { e.printStackTrace(); } return -1; } } }
a.cc:1:1: error: 'import' does not name a type 1 | import java.io.*; | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:2:1: error: 'import' does not name a type 2 | import java.util.*; | ^~~~~~ a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:3:1: error: 'import' does not name a type 3 | import static java.lang.Math.*; | ^~~~~~ a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:5:1: error: expected unqualified-id before 'public' 5 | public class Main { | ^~~~~~
s107078619
p03675
C++
n = int(input()) a = list(map(int, input().split())) occur = [0 for i in range(n + 1)] MOD = 1000000007 for i in range(n + 1): if occur[a[i]] > 0: val = n - 1 - i + occur[a[i]] else: occur[a[i]] = i + 1 inv = [0 if i > 2 else 1 for i in range(n + 2)] pinv = [0 if i > 2 else 1 for i in range(n + 2)] perm = [0 if i > 2 else 1 for i in range(n + 2)] for i in range(2, n + 2): inv[i] = -int(MOD / i) * inv[MOD % i] + MOD pinv[i] = pinv[i - 1] * inv[i] % MOD perm[i] = perm[i - 1] * i % MOD def C(n, m): return (perm[m] * pinv[n] % MOD) * pinv[m - n] % MOD if n <= m else 0 for i in range(1, n + 2): temp = C(i, n + 1) - C(i - 1, val) if temp < 0: temp += MOD print(temp)
a.cc:1:1: error: 'n' does not name a type 1 | n = int(input()) | ^
s901742624
p03675
Java
import java.util.*; import java.io.*; public class Main{ public static void main(String[] args){ Scanner in = new Scanner(System.in); int n = in.nextInt(); Deque<Integer> dq = new LinkedList<>(); boolean flag = false; for (int i = 0; i < n; i++){ if (!flag){ dq.addLast(in.nextInt()); } else { dq.addFirst(in.nextInt()); } flag = !flag; } int begin = flag ? n - 1 : 0; int end = flag ? 0 : n - 1; int inc = flag ? -1 : 1; for (int i = begin; i >= 0 && i <= n - 1; i += inc){ System.out.print(dq.get(i) + " "); } } }
Main.java:23: error: cannot find symbol System.out.print(dq.get(i) + " "); ^ symbol: method get(int) location: variable dq of type Deque<Integer> 1 error
s252873303
p03675
Java
import java.util.*; import java.io.*; public class Main{ public static void main(String[] args){ Scanner in = new Scanner(System.in); int n = in.nextInt(); Deque<Integer> dq = new Deque<Integer>(); boolean flag = false; for (int i = 0; i < n; i++){ if (!flag){ dq.addLast(in.nextInt()); } else { dq.addFirst(in.nextInt()); } flag = !flag; } int begin = flag ? n - 1 : 0; int end = flag ? 0 : n - 1; int inc = flag ? -1 : 1; for (int i = begin; i >= 0 && i <= n - 1; i += inc){ system.out.print(dq.get(i) + " "); } } }
Main.java:9: error: Deque is abstract; cannot be instantiated Deque<Integer> dq = new Deque<Integer>(); ^ Main.java:23: error: cannot find symbol system.out.print(dq.get(i) + " "); ^ symbol: method get(int) location: variable dq of type Deque<Integer> Main.java:23: error: package system does not exist system.out.print(dq.get(i) + " "); ^ 3 errors
s414548837
p03675
Java
import java.util.*; import java.io.*; public class Main{ public static void main(String[] args){ Scanner in = new Scanner(System.in); int n = in.nextInt(); Deque<Integer> dq = new Deque<Integer>(); boolean flag = false; for (int i = 0; i < n; i++){ if (!flag){ dq.addLast(in.nextInt()); } else { dq.addFirst(in.nextInt()); } flag = !flag; } int begin = flag ? n - 1 : 0; int end = flag ? 0 : n - 1; int inc = flag ? -1 : 1; for (int i = begin; i += inc; i >= 0 && i <= n - 1){ system.out.print(dq.get(i) + " "); } } }
Main.java:22: error: not a statement for (int i = begin; i += inc; i >= 0 && i <= n - 1){ ^ 1 error
s378074729
p03675
Java
import java.util.*; import java.io.*; public class void Main{ public static void main(String[] args){ Scanner in = new Scanner(System.in); int n = in.nextInt(); Deque<Integer> dq = new Deque<Integer>(); boolean flag = false; for (int i = 0; i < n; i++){ if (!flag){ dq.addLast(in.nextInt()); } else { dq.addFirst(in.nextInt()); } flag = !flag; } int begin = flag ? n - 1 ; 0; int end = flag ? 0 : n - 1; int inc = flag ? -1 : 1; for (int i = begin; i += inc; i >= 0 && i <= n - 1){ system.out.print(dq.get(i) + " "); } } }
Main.java:4: error: <identifier> expected public class void Main{ ^ Main.java:19: error: not a statement int begin = flag ? n - 1 ; 0; ^ Main.java:22: error: not a statement for (int i = begin; i += inc; i >= 0 && i <= n - 1){ ^ Main.java:6: error: unnamed classes are a preview feature and are disabled by default. public static void main(String[] args){ ^ (use --enable-preview to enable unnamed classes) Main.java:19: error: : expected int begin = flag ? n - 1 ; 0; ^ Main.java:19: error: illegal start of expression int begin = flag ? n - 1 ; 0; ^ Main.java:26: error: class, interface, enum, or record expected } ^ 7 errors
s789746671
p03675
C++
#include <stdio.h> int main() { int n, a[200001], i; scanf("%d", &n); for(i = 0; i < n; i++) scanf("%d", &a[i]); printf("%d", a[n-1]); for(i = n-3; i >= 0; i-=2) printf(" %d", a[i]); if(n&1) for (i = 1; i <= n-2; i+=2) printf(" %d", a[i]); else for(i = 0; i <= n-2; i+=2) printf(" %d", a[i]) }
a.cc: In function 'int main()': a.cc:13:56: error: expected ';' before '}' token 13 | else for(i = 0; i <= n-2; i+=2) printf(" %d", a[i]) | ^ | ; 14 | } | ~
s564169580
p03675
C++
#include <stdio.h> #include<iostream> int main() { int n, a[200001], i; scanf("%d", &n); for(i = 0; i < n; i++) scanf("%d", &a[i]); printf("%d", a[n-1]); for(i = n-3; i >= 0; i-=2) printf(" %d", a[i]); if(n&1) for (i = 1; i <= n-2; i+=2) printf(" %d", a[i]); else for(i = 0; i <= n-2; i+=2) printf(" %d", a[i])
a.cc: In function 'int main()': a.cc:14:56: error: expected ';' at end of input 14 | else for(i = 0; i <= n-2; i+=2) printf(" %d", a[i]) | ^ | ; a.cc:14:56: error: expected '}' at end of input a.cc:4:1: note: to match this '{' 4 | { | ^
s746746583
p03675
C++
#include <stdio.h> int main() { int n, a[200001], i; scanf("%d", &n); for(i = 0; i < n; i++) scanf("%d", &a[i]); printf("%d", a[n-1]); for(i = n-3; i >= 0; i-=2) printf(" %d", a[i]); if(n&1) for (i = 1; i <= n-2; i+=2) printf(" %d", a[i]); else for(i = 0; i <= n-2; i+=2) printf(" %d", a[i])
a.cc: In function 'int main()': a.cc:13:56: error: expected ';' at end of input 13 | else for(i = 0; i <= n-2; i+=2) printf(" %d", a[i]) | ^ | ; a.cc:13:56: error: expected '}' at end of input a.cc:3:1: note: to match this '{' 3 | { | ^
s715656304
p03675
C
#include <stdio.h> int main() { int n, a[200001], i; scanf("%d", &n); for(i = 0; i < n; i++) scanf("%d", &a[i]); printf("%d", a[n-1]); for(i = n-3; i >= 0; i-=2) printf(" %d", a[i]); if(n&1) for (i = 1; i <= n-2; i+=2) printf(" %d", a[i]); else for(i = 0; i <= n-2; i+=2) printf(" %d", a[i])
main.c: In function 'main': main.c:13:56: error: expected ';' at end of input 13 | else for(i = 0; i <= n-2; i+=2) printf(" %d", a[i]) | ^ | ; main.c:13:5: error: expected declaration or statement at end of input 13 | else for(i = 0; i <= n-2; i+=2) printf(" %d", a[i]) | ^~~~
s791525814
p03675
Java
import java.io.*; import java.util.*; public class a_0701 { public static void main(String[] args) { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); List<Integer> b = new ArrayList<>(); int n=0; try { n = Integer.parseInt(br.readLine()); String str = br.readLine(); String a[] = str.split("\\s+"); for(int i=0;i<n;i++) { b.add(Integer.parseInt(a[i])); Collections.reverse(b); } } catch(IOException e) { e.printStackTrace(); } for(int i=0;i<n;i++) { if(i!=0) { System.out.print(" "); } System.out.print(b.get(i)); } } }
Main.java:4: error: class a_0701 is public, should be declared in a file named a_0701.java public class a_0701 ^ 1 error
s510666313
p03675
Java
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); Deque<Integer> dq = new Deque<Integer>(); for(int i = 1; i <= n; i++) { int a = sc.nextInt(); if((n - i) % 2 == 0) { dq.addFirst(a); } else { dq.addLast(a); } } for(int i = 0; i < n; i++) { System.out.println(dq.pollFirst()); } } }
Main.java:7: error: Deque is abstract; cannot be instantiated Deque<Integer> dq = new Deque<Integer>(); ^ 1 error
s849486764
p03675
C++
read = lambda: map(int, input().split()) n = int(input()) a = list(read()) from collections import deque b = deque() x = 1 for i in range(n): if x: b.append(a[i]) else: b.appendleft(a[i]) x ^= 1 ans = list(b) if not x: ans = ans[::-1] print(*ans)
a.cc:1:1: error: 'read' does not name a type 1 | read = lambda: map(int, input().split()) | ^~~~
s071703420
p03675
C++
include<cstdio> #include<cstdlib> #include<cstring> #include<algorithm> #include<vector> #include<queue> using namespace std; int main(void){ int a[200000]; int c, d; int k; int n, m; int s, t; int x, y, z; scanf("%d", &n); for (int i = 0; i < n; i++){ scanf("%d", &a[i]); } for (k=n-1; k >=0; k=k-2)printf("%d ", a[k]); k = (k + 3) % 2; for (; k<n-2; k=k+2)printf("%d ", a[k]); if(k<n)printf("%d\n", a[k]); return 0; }
a.cc:1:1: error: 'include' does not name a type 1 | 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/stdlib.h:32, from /usr/include/c++/14/cstdlib:79, 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_traits.h:156:47: error: 'ptrdiff_t' was not declared in this scope 15
s871159160
p03675
C++
#include<iostream> #include<vector> using namespace std; int main(){ vector <long long> d; int n; long long a; cin >> n; for(int i = 0;i < n;i++){ cin >> a; d.push_back(a); } if(d.size()%2 == 0){ for(int i = d.size() - 1;i >= 1; i = i - 2){ cout << d[i] << " "; } for(int i = 0; i <= d.size() - 2;i = i + 2){ cout << d[i] << " "; } } if(d.size()%2 == 1){ if(d.size() == 1){ cout << d[0]; } else{ for(int i = d.size() - 1;i >= 0; i = i - 2){ cout << d[i] << " "; } for(int i = 1; i <= d.size() - 2;i = i + 2){ cout << d[i] << " "; } }
a.cc: In function 'int main()': a.cc:37:6: error: expected '}' at end of input 37 | } | ^ a.cc:26:22: note: to match this '{' 26 | if(d.size()%2 == 1){ | ^ a.cc:37:6: error: expected '}' at end of input 37 | } | ^ a.cc:6:11: note: to match this '{' 6 | int main(){ | ^
s974162835
p03675
C++
#include <iostream> #include <vector> #include <string> using namespace std; int main(){ int n; int num; vector<int> a; vector<int> b; cin >> n; for(int i = 0; i < n; i++){ cin >> num; a.push_back(num); } for(int i = 0; i < n; i++){ b.push_back(a[i]); reverse(b.begin(), b.end()); } cout << b[0]; for(int i = 1; i < n; i++) cout << " " << b[i]; cout << endl; return 0; }
a.cc: In function 'int main()': a.cc:22:5: error: 'reverse' was not declared in this scope 22 | reverse(b.begin(), b.end()); | ^~~~~~~
s912670681
p03675
C++
import java.io.PrintWriter; import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); PrintWriter pw = new PrintWriter(System.out); int N = sc.nextInt(); LinkedList<Integer> q = new LinkedList<>(); for(int i=0; i<N; i++) if((N-i)%2==1) q.addFirst(sc.nextInt()); else q.addLast(sc.nextInt()); for(int i=0; i<N; i++) pw.print(q.get(i) + (i==N-1 ? "\n" : " ")); sc.close(); pw.close(); } }
a.cc:1:1: error: 'import' does not name a type 1 | import java.io.PrintWriter; | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:2:1: error: 'import' does not name a type 2 | import java.util.*; | ^~~~~~ a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:4:1: error: expected unqualified-id before 'public' 4 | public class Main { | ^~~~~~
s382119544
p03675
C++
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @author HossamDoma */ public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStream); TaskC solver = new TaskC(); solver.solve(1, in, out); out.close(); } static class TaskC { public void solve(int testNumber, InputReader in, PrintWriter out) { int n = in.nextInt(); int[] a = new int[n]; for (int i = 0; i < n; ++i) a[i] = in.nextInt(); int[] b = new int[n]; for (int i = n - 1, j = 0; i >= 0; i -= 2, j++) { b[j] = a[i]; } for (int i = n - 2, j = n - 1; i >= 0; i -= 2) { b[j--] = a[i]; } for (int i = 0; i < n; ++i) out.print(b[i] + " "); } } static class InputReader { public BufferedReader reader; public StringTokenizer tokenizer; public InputReader(InputStream stream) { reader = new BufferedReader(new InputStreamReader(stream), 32768); tokenizer = null; } public String next() { while (tokenizer == null || !tokenizer.hasMoreTokens()) { try { tokenizer = new StringTokenizer(reader.readLine()); } catch (IOException e) { throw new RuntimeException(e); } } return tokenizer.nextToken(); } public int nextInt() { return Integer.parseInt(next()); } } }
a.cc:1:1: error: 'import' does not name a type 1 | import java.io.OutputStream; | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:2:1: error: 'import' does not name a type 2 | import java.io.IOException; | ^~~~~~ a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:3:1: error: 'import' does not name a type 3 | import java.io.InputStream; | ^~~~~~ a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:4:1: error: 'import' does not name a type 4 | import java.io.PrintWriter; | ^~~~~~ a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:5:1: error: 'import' does not name a type 5 | import java.util.StringTokenizer; | ^~~~~~ a.cc:5:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:6:1: error: 'import' does not name a type 6 | import java.io.IOException; | ^~~~~~ a.cc:6:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:7:1: error: 'import' does not name a type 7 | import java.io.BufferedReader; | ^~~~~~ a.cc:7:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:8:1: error: 'import' does not name a type 8 | import java.io.InputStreamReader; | ^~~~~~ a.cc:8:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:9:1: error: 'import' does not name a type 9 | import java.io.InputStream; | ^~~~~~ a.cc:9:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:17:1: error: expected unqualified-id before 'public' 17 | public class Main { | ^~~~~~
s141586746
p03675
C++
#ifdef __APPLE__ #include "bits:stdc++.h" #else #include <bits\stdc++.h> #endif #define SZ(X) ((int)(X).size()) #define ALL(X) (X).begin(), (X).end() #define REP(I, N) for (LL I = 0; I < (N); ++I) #define REPP(I, A, B) for (LL I = (A); I < (B); ++I) #define RI(X) scanf("%lld", &(X)) #define RII(X, Y) scanf("%lld%lld", &(X), &(Y)) #define RIII(X, Y, Z) scanf("%lld%lld%lld", &(X), &(Y), &(Z)) #define DRI(X) LL (X); scanf("%lld", &X) #define DRII(X, Y) LL X, Y; scanf("%lld%lld", &X, &Y) #define DRIII(X, Y, Z) LL X, Y, Z; scanf("%lld%lld%lld", &X, &Y, &Z) #define RS(X) scanf("%s", (X)) #define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0) #define MP make_pair #define PB push_back #define MS0(X) memset((X), 0, sizeof((X))) #define MS1(X) memset((X), -1, sizeof((X))) #define LEN(X) strlen(X) #define PII pair<int,int> #define VI vector<int> #define VPII vector<pair<int,int> > #define PLL pair<long long,long long> #define VPLL vector<pair<long long,long long> > #define F first #define S second typedef long long LL; using namespace std; LL A[(int)2.5e5],ans[(int)2.5e5]; int main(){ DRI(n); REP(i,n)RI(A[i]); reverse(A,A+n); LL l=0,r=n-1; REP(i,n){ if(i%2==0){ ans[l++]=A[i]; }else{ ans[r--]=A[i]; } }REP(i,n)printf("%lld%c",ans[i]," \n"[i==n-1]); }
a.cc:4:10: fatal error: bits\stdc++.h: No such file or directory 4 | #include <bits\stdc++.h> | ^~~~~~~~~~~~~~~ compilation terminated.
s527916749
p03676
Java
// copied #include <bits/stdc++.h> using namespace std; typedef long long LL; typedef double DB; typedef unsigned int UI; typedef pair<int, int> PII; const int inf = 0x7f7f7f7f; #define rdi() read<int>() #define rdl() read<LL>() #define rds(a) scanf("%s", a) #define mk(i, j) make_pair(i, j) #define pb push_back #define fi first #define se second #define For(i, j, k) for (int i = j; i <= k; i ++) #define Rep(i, j, k) for (int i = j; i >= k; i --) #define Edge(i, u) for (int i = head[u]; i; i = e[i].nxt) template<typename t> t read() { t x = 0; int f = 1; char c = getchar(); while (c > '9' || c < '0') f = c == '-' ? -1 : 1 , c = getchar(); while (c >= '0' && c <= '9') x = x * 10 + c - 48 , c = getchar(); return x * f; } template<typename t> void write(t x) { if (x < 0){ putchar('-'), write(-x); return; } if (x >= 10) write(x / 10); putchar(x % 10 + 48); } const int P = 1e9 + 7; const int N = 1e5 + 10; int fac[N], facinv[N], a[N], n, pos, vis[N], id; int power(int a, int b) { int c = 1; for (; b; b >>= 1, a = 1ll * a * a % P) if (b & 1) c = 1ll * c * a % P; return c; } int C(int x, int y) { return 1ll * fac[x] * facinv[y] % P * facinv[x - y] % P; } int main() { n = rdi() + 1; for (int i = 1; i <= n; i ++) a[i] = rdi(); fac[0] = fac[1] = 1; for (int i = 2; i <= n; i ++) fac[i] = 1ll * fac[i - 1] * i % P; facinv[n] = power(fac[n], P - 2); for (int i = n - 1; i >= 0; i --) facinv[i] = 1ll * facinv[i + 1] * (i + 1) % P; for (int i = 1; i <= n; i ++) { if (vis[a[i]]) { pos = i; id = a[i]; break; } vis[a[i]] = i; } int len = n - pos + 1; for (int i = 1; i <= n; i ++) { int ans = C(n, i); if (i - 1 <= len - 1 + vis[id] - 1) ans -= C(len - 1 + vis[id] - 1, i - 1); ans = (ans + P) % P; write(ans), putchar(10); } return 0; }
Main.java:2: error: illegal character: '#' #include <bits/stdc++.h> ^ Main.java:2: error: class, interface, enum, or record expected #include <bits/stdc++.h> ^ Main.java:6: error: class, interface, enum, or record expected typedef long long LL; ^ Main.java:7: error: class, interface, enum, or record expected typedef double DB; ^ Main.java:8: error: class, interface, enum, or record expected typedef unsigned int UI; ^ Main.java:9: error: class, interface, enum, or record expected typedef pair<int, int> PII; ^ Main.java:11: error: class, interface, enum, or record expected const int inf = 0x7f7f7f7f; ^ Main.java:13: error: illegal character: '#' #define rdi() read<int>() ^ Main.java:13: error: class, interface, enum, or record expected #define rdi() read<int>() ^ Main.java:14: error: illegal character: '#' #define rdl() read<LL>() ^ Main.java:15: error: illegal character: '#' #define rds(a) scanf("%s", a) ^ Main.java:16: error: illegal character: '#' #define mk(i, j) make_pair(i, j) ^ Main.java:17: error: illegal character: '#' #define pb push_back ^ Main.java:18: error: illegal character: '#' #define fi first ^ Main.java:19: error: illegal character: '#' #define se second ^ Main.java:20: error: illegal character: '#' #define For(i, j, k) for (int i = j; i <= k; i ++) ^ Main.java:20: error: class, interface, enum, or record expected #define For(i, j, k) for (int i = j; i <= k; i ++) ^ Main.java:20: error: class, interface, enum, or record expected #define For(i, j, k) for (int i = j; i <= k; i ++) ^ Main.java:21: error: illegal character: '#' #define Rep(i, j, k) for (int i = j; i >= k; i --) ^ Main.java:21: error: class, interface, enum, or record expected #define Rep(i, j, k) for (int i = j; i >= k; i --) ^ Main.java:21: error: class, interface, enum, or record expected #define Rep(i, j, k) for (int i = j; i >= k; i --) ^ Main.java:22: error: illegal character: '#' #define Edge(i, u) for (int i = head[u]; i; i = e[i].nxt) ^ Main.java:22: error: class, interface, enum, or record expected #define Edge(i, u) for (int i = head[u]; i; i = e[i].nxt) ^ Main.java:22: error: class, interface, enum, or record expected #define Edge(i, u) for (int i = head[u]; i; i = e[i].nxt) ^ Main.java:25: error: unnamed classes are a preview feature and are disabled by default. t x = 0; int f = 1; char c = getchar(); ^ (use --enable-preview to enable unnamed classes) Main.java:26: error: class, interface, enum, or record expected while (c > '9' || c < '0') f = c == '-' ? -1 : 1 , c = getchar(); ^ Main.java:27: error: class, interface, enum, or record expected while (c >= '0' && c <= '9') x = x * 10 + c - 48 , c = getchar(); ^ Main.java:28: error: class, interface, enum, or record expected return x * f; ^ Main.java:29: error: class, interface, enum, or record expected } ^ Main.java:34: error: class, interface, enum, or record expected return; ^ Main.java:35: error: class, interface, enum, or record expected } ^ Main.java:37: error: class, interface, enum, or record expected putchar(x % 10 + 48); ^ Main.java:38: error: class, interface, enum, or record expected } ^ Main.java:41: error: class, interface, enum, or record expected const int N = 1e5 + 10; ^ Main.java:42: error: class, interface, enum, or record expected int fac[N], facinv[N], a[N], n, pos, vis[N], id; ^ Main.java:46: error: not a statement for (; b; b >>= 1, a = 1ll * a * a % P) if (b & 1) c = 1ll * c * a % P; ^ Main.java:46: error: not a statement for (; b; b >>= 1, a = 1ll * a * a % P) if (b & 1) c = 1ll * c * a % P; ^ Main.java:46: error: ')' expected for (; b; b >>= 1, a = 1ll * a * a % P) if (b & 1) c = 1ll * c * a % P; ^ Main.java:46: error: ';' expected for (; b; b >>= 1, a = 1ll * a * a % P) if (b & 1) c = 1ll * c * a % P; ^ Main.java:46: error: ';' expected for (; b; b >>= 1, a = 1ll * a * a % P) if (b & 1) c = 1ll * c * a % P; ^ Main.java:51: error: not a statement return 1ll * fac[x] * facinv[y] % P * facinv[x - y] % P; ^ Main.java:51: error: ';' expected return 1ll * fac[x] * facinv[y] % P * facinv[x - y] % P; ^ Main.java:58: error: not a statement for (int i = 2; i <= n; i ++) fac[i] = 1ll * fac[i - 1] * i % P; ^ Main.java:60: error: not a statement for (int i = n - 1; i >= 0; i --) facinv[i] = 1ll * facinv[i + 1] * (i + 1) % P; ^ Main.java:58: error: ';' expected for (int i = 2; i <= n; i ++) fac[i] = 1ll * fac[i - 1] * i % P; ^ Main.java:60: error: ';' expected for (int i = n - 1; i >= 0; i --) facinv[i] = 1ll * facinv[i + 1] * (i + 1) % P; ^ Main.java:74: error: ';' expected write(ans), putchar(10); ^ 47 errors
s490764138
p03676
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int,int> P; typedef pair<ll, ll> Pll; #define debug(var) do{std::cout << #var << " : ";view(var);}while(0) template<typename T> void view(T e){std::cout << e << std::endl;} template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;} template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } } template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; } template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; } const int MOD = 1000000007; const int INF = 1e9; const int mod = 1000000007; const int inf = 1e9; #define PI acos(-1); int dx[4] = {1,-1,0,0}; int dy[4] = {0,0,1,-1}; int ddx[8] = {1,1,1,-1,-1,-1,0,0}; int ddy[8] = {0,1,-1,0,1,-1,1,-1}; const ll MAX = 200000; ll inv[MAX], fac[MAX], finv[MAX]; void settable() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i <=MAX ; i++){ fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } ll choose(ll n, ll k){ if (n < k) return 0; if (n <= 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } ll modpow(ll n, ll k){ ll rtn = 1; while(k > 0){ if(k&1) rtn = rtn * n % MOD; n = n * n % MOD; k = k >> 1; } return rtn; } int main(){ settable(); int n; cin >> n; vector<int> a(n+1); map<int, int> mp; for(int i = 0; i < n+1; i++) { cin >> a[i]; mp[a[i]]++; } int p[2]; for(auto w : mp) { if(w.second == 2) { int f = 0; for(int i = 0; i < n+1; i++) { if(w.first == a[i]) p[f] = i, f++; if(f == 2) break; } } } cout << p[0] << " " << p[1] << endl; for(int i = 1; i <= n+1; i++) { ll ans = choose(n+1, i); if(p[0]+n-p[2] >= i-1) ans -= choose(p[0]+n-p[1], i-1); (ans + MOD) %= MOD; cout << ans << endl; } }
a.cc: In function 'int main()': a.cc:78:14: error: lvalue required as left operand of assignment 78 | (ans + MOD) %= MOD; | ~~~~~^~~~~~
s300787039
p03676
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int,int> P; typedef pair<ll, ll> Pll; #define debug(var) do{std::cout << #var << " : ";view(var);}while(0) template<typename T> void view(T e){std::cout << e << std::endl;} template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;} template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } } template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; } template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; } const int MOD = 1000000007; const int INF = 1e9; const int mod = 1000000007; const int inf = 1e9; #define PI acos(-1); int dx[4] = {1,-1,0,0}; int dy[4] = {0,0,1,-1}; int ddx[8] = {1,1,1,-1,-1,-1,0,0}; int ddy[8] = {0,1,-1,0,1,-1,1,-1}; const ll MAX = 200000; ll inv[MAX], fac[MAX], finv[MAX]; void settable() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i <=MAX ; i++){ fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } ll choose(ll n, ll k){ if (n < k) return 0; if (n <= 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } ll modpow(ll n, ll k){ ll rtn = 1; while(k > 0){ if(k&1) rtn = rtn * n % MOD; n = n * n % MOD; k = k >> 1; } return rtn; } int main(){ settable(); int n; cin >> n; vector<int> a(n+1); map<int, int> mp; for(int i = 0; i < n+1; i++) { cin >> a[i]; mp[a[i]]++; } int p[2]; for(auto w : mp) { if(w.second == 2) { int f = 0; for(int i = 0; i < n+1; i++) { if(w.first == a[i]) p[f] = i, f++; if(f == 2) break; } } } cout << p[0] << " " << p[1] << endl; for(int i = 1; i <= n+1; i++) { ll ans = choose(n+1, i); if(p[0]+n-p[2] >= i-1) ans -= choose(p[0]+n-p[1], i-1); (ans + MOD) %= MOD; cout << ans << endl; } }
a.cc: In function 'int main()': a.cc:78:14: error: lvalue required as left operand of assignment 78 | (ans + MOD) %= MOD; | ~~~~~^~~~~~
s320062902
p03676
C++
/* * Welcome to my code! *---------------------------------------------* * author : lynmisakura(twitter : @andoreiji11) */ #include <iostream> #include <limits.h> #include <algorithm> #include <bitset> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <list> #include <map> #include <numeric> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> #include <queue> #include <unordered_map> #include <unordered_set> #include <cassert> using namespace std; #define rep(i,n) for(int i=0;i<n;i++) #define rrep(i,n) for(int i=n-1;i>=0;i--) #define repn for(int i = 0;i < n;i++) #define ain(a) for(auto& i : a)cin >> i; #define all(x) (x).begin(),(x).end() #define sz(x) (int)(x.size()) #define mp make_pair #define pb push_back #define eb emplace_back #define cont continue using ll = long long; using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using pi = pair<int,int>; using vpi = vector<pi>; using pl = pair<ll,ll>; using vpl = vector<pl>; template<class T> bool chmin(T& a,T b){if(a > b){a = b;return true;}else return false;} template<class T> bool chmax(T& a,T b){if(a < b){a = b;return true;}else return false;} template<class T> void print(std::vector<T> a){ int sz = a.size(); for(int i=0;i<a.size();i++)cout << a[i] << (i < sz-1 ? ' ' : '\n'); } void ioboost(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);} /////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// /* * Modint struct * library author : @snuke * */ const int mod = 1e9 + 7; struct mint { long long x; // typedef long long ll; mint(long long x=0):x((x%mod+mod)%mod){} mint& operator+=(const mint a) { if((x+=a.x)>=mod)x-=mod;return *this;} mint& operator-=(const mint a) { if((x+=mod-a.x)>=mod)x-=mod; return *this;} mint& operator*=(const mint a) { (x *=a.x)%=mod; return *this;} mint operator+(const mint a) const { mint res(*this);return res+=a;} mint operator-(const mint a) const { mint res(*this);return res-=a;} mint operator*(const mint a) const { mint res(*this);return res*=a;} mint pow(ll t) const { if (!t) return 1;mint a = pow(t>>1);a*=a; if (t&1) a *= *this;return a; } // for prime mod mint inv() const { return pow(mod-2);} mint& operator/=(const mint a) { return (*this) *= a.inv();} }; istream& operator>>(istream& is, const mint& a) { return is >> a.x;} ostream& operator<<(ostream& os, const mint& a) { return os << a.x;} namespace ModintUtil{ mint mod_pow(long long p,long long q){mint res = p;return res.pow(q);} mint frac(long long p,long long q){ mint P = (mint)p; P /= (mint)q; return P; } // p/q mint frac(mint p,mint q){ p /= q; return p; } vector<mint> make_facl(long long N){ vector<mint> ret(N+1); for(int i = 0;i <= N;i++){ if(i == 0)ret[i] = (mint)1; else ret[i] = ret[i-1] * (mint)i; } return ret; } } using namespace ModintUtil; ///////////////////////////////////////////////////////////////////////////// /* modの値は1e9 + 7か998244353か任意modか、要チェック!! */ struct Combination{ const int MAX = 100050; vector<mint> fact; Combination(){ fact.resize(MAX); for(int i = 0;i < MAX;i++){ if(i == 0)fact[i] = (mint)1; else fact[i] = fact[i-1]*(mint)i; } } mint comb(int n,int r){ if(n<0||r<0||n<r)return 0; else return fact[n]*fact[r].inv()*fact[n-r].inv(); } }; int main(){ ioboost(); int n;cin >> n; vl a(n); vector<vector<int> > pos(n+1,vector<int>()); rep(i,n+1){ cin >> a[i]; pos[a[i]].pb(i); } int l,r; rep(i,n){ if(pos[i+1].size() == 2)l = pos[i+1][0],r = pos[i+1][1]; } // cerr << l << ' ' << r << '\n'; Combination C; for(ll k = 1;k <= n + 1;k++){ mint ans = C.comb(n + 1,k); if(k == 1)ans--; else if(n+1-(r-l+1))ans -= C.comb(n + 1 - (r - l + 1),k - 1); cout << ans << '\n'; } }
a.cc: In function 'int main()': a.cc:139:18: error: no 'operator--(int)' declared for postfix '--' [-fpermissive] 139 | if(k == 1)ans--; | ~~~^~
s791112488
p03676
C++
/* * Welcome to my code! *---------------------------------------------* * author : lynmisakura(twitter : @andoreiji11) */ #include <iostream> #include <limits.h> #include <algorithm> #include <bitset> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <list> #include <map> #include <numeric> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> #include <queue> #include <unordered_map> #include <unordered_set> #include <cassert> using namespace std; #define rep(i,n) for(int i=0;i<n;i++) #define rrep(i,n) for(int i=n-1;i>=0;i--) #define repn for(int i = 0;i < n;i++) #define ain(a) for(auto& i : a)cin >> i; #define all(x) (x).begin(),(x).end() #define sz(x) (int)(x.size()) #define mp make_pair #define pb push_back #define eb emplace_back #define cont continue using ll = long long; using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using pi = pair<int,int>; using vpi = vector<pi>; using pl = pair<ll,ll>; using vpl = vector<pl>; template<class T> bool chmin(T& a,T b){if(a > b){a = b;return true;}else return false;} template<class T> bool chmax(T& a,T b){if(a < b){a = b;return true;}else return false;} template<class T> void print(std::vector<T> a){ int sz = a.size(); for(int i=0;i<a.size();i++)cout << a[i] << (i < sz-1 ? ' ' : '\n'); } void ioboost(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);} /////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// /* * Modint struct * library author : @snuke * */ const int mod = 1e9 + 7; struct mint { long long x; // typedef long long ll; mint(long long x=0):x((x%mod+mod)%mod){} mint& operator+=(const mint a) { if((x+=a.x)>=mod)x-=mod;return *this;} mint& operator-=(const mint a) { if((x+=mod-a.x)>=mod)x-=mod; return *this;} mint& operator*=(const mint a) { (x *=a.x)%=mod; return *this;} mint operator+(const mint a) const { mint res(*this);return res+=a;} mint operator-(const mint a) const { mint res(*this);return res-=a;} mint operator*(const mint a) const { mint res(*this);return res*=a;} mint pow(ll t) const { if (!t) return 1;mint a = pow(t>>1);a*=a; if (t&1) a *= *this;return a; } // for prime mod mint inv() const { return pow(mod-2);} mint& operator/=(const mint a) { return (*this) *= a.inv();} }; istream& operator>>(istream& is, const mint& a) { return is >> a.x;} ostream& operator<<(ostream& os, const mint& a) { return os << a.x;} namespace ModintUtil{ mint mod_pow(long long p,long long q){mint res = p;return res.pow(q);} mint frac(long long p,long long q){ mint P = (mint)p; P /= (mint)q; return P; } // p/q mint frac(mint p,mint q){ p /= q; return p; } vector<mint> make_facl(long long N){ vector<mint> ret(N+1); for(int i = 0;i <= N;i++){ if(i == 0)ret[i] = (mint)1; else ret[i] = ret[i-1] * (mint)i; } return ret; } } using namespace ModintUtil; ///////////////////////////////////////////////////////////////////////////// /* modの値は1e9 + 7か998244353か任意modか、要チェック!! */ struct Combination{ const int MAX = 500050; vector<mint> fact; Combination(){ fact.resize(MAX); for(int i = 0;i < MAX;i++){ if(i == 0)fact[i] = (mint)1; else fact[i] = fact[i-1]*(mint)i; } } mint comb(int n,int r){ if(n<0||r<0||n<r)return 0; else return fact[n]*fact[r].inv()*fact[n-r].inv(); } }; int main(){ ioboost(); int n;cin >> n; vl a(n); vector<vector<int> > pos(n+1,vector<int>()); rep(i,n+1){ cin >> a[i]; pos[a[i]].pb(i); } int l,r; rep(i,n){ if(pos[i+1].size() == 2)l = pos[i+1][0],r = pos[i+1][1]; } // cerr << l << ' ' << r << '\n'; Combination C; for(ll k = 1;k <= n + 1;k++){ mint ans = C.comb(n + 1,k); if(k == 1)ans--; else if(n+1-(r-l+1))ans -= C.comb(n + 1 - (r - l + 1),k - 1); cout << ans << '\n'; } }
a.cc: In function 'int main()': a.cc:139:18: error: no 'operator--(int)' declared for postfix '--' [-fpermissive] 139 | if(k == 1)ans--; | ~~~^~
s523173817
p03676
C++
#include <bits/stdc++.h> using namespace std; #define fi first #define endl "\n" #define se second #define ls( s) (s&(-s)) #define ll long long #define inf 0x3f3f3f3f #define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); const ll N = 103000; #define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) const ll mod = 1e9+7; ll n; ll fact[N]; ll arr[N]; ll ifact[N]; ll po(ll x,ll y) { ll res=1; while(y) { if(y%2) res=res*x%mod; y/=2; x=x*x%mod; } return res; } int main() { fast int z; fact[0]=1; for(int i=1;i<N;i++) fact[i]=fact[i-1]*i%mod; ifact[N-1]=po(fact[N-1],mod-2); for(int i=N-2;i>=0;i--) ifact[i]=ifact[i+1]*(i+1)%mod; cin>>n; vector<int> v(n+1); for(int i=1;i<=n+1;i++) { int x; cin>>x; v[i-1]=x; if(arr[x]) { arr[x]++; z=i;} arr[x]++; } int r; for(int i=0;i<=n;i++) { if(v[i]==v[z-1]) { r=i; break; } } z=n+1-(z-r); r=z; //01 1 1 cout<<r<<endl; ll ans=0; cout<<n<<endl; if(n==1) {cout<<1<<endl; return 0; } for(int i=2;i<=n+1;i++) {ans=0; ans+=(((fact[n+1]*ifact[i])%mod)*ifact[n+1-i])%mod; if(r>=i-1) ans-=(((fact[r]*ifact[i-1])%mod)*ifact[r-i+1])%mod; cout<<ans<<endl; } }
a.cc: In function 'int main()': a.cc:65:2: error: expected ';' before numeric constant 65 | 1 1 cout<<r<<endl; | ^~ | ;
s142149875
p03676
C++
You are given an integer sequence of length n+1, a1,a2,…,an+1, which consists of the n integers 1,…,n. It is known that each of the n integers 1,…,n appears at least once in this sequence. For each integer k=1,…,n+1, find the number of the different subsequences (not necessarily contiguous) of the given sequence with length k, modulo 109+7. Notes If the contents of two subsequences are the same, they are not separately counted even if they originate from different positions in the original sequence. A subsequence of a sequence a with length k is a sequence obtained by selecting k of the elements of a and arranging them without changing their relative order. For example, the sequences 1,3,5 and 1,2,3 are subsequences of 1,2,3,4,5, while 3,1,2 and 1,10,100 are not. Constraints 1≤n≤105 1≤ai≤n Each of the integers 1,…,n appears in the sequence. n and ai are integers. Input Input is given from Standard Input in the following format: n a1 a2 ... an+1
a.cc:1:56: error: extended character … is not valid in an identifier 1 | You are given an integer sequence of length n+1, a1,a2,…,an+1, which consists of the n integers 1,…,n. It is known that each of the n integers 1,…,n appears at least once in this sequence. | ^ a.cc:1:99: error: extended character … is not valid in an identifier 1 | You are given an integer sequence of length n+1, a1,a2,…,an+1, which consists of the n integers 1,…,n. It is known that each of the n integers 1,…,n appears at least once in this sequence. | ^ a.cc:1:146: error: extended character … is not valid in an identifier 1 | You are given an integer sequence of length n+1, a1,a2,…,an+1, which consists of the n integers 1,…,n. It is known that each of the n integers 1,…,n appears at least once in this sequence. | ^ a.cc:2:22: error: extended character … is not valid in an identifier 2 | For each integer k=1,…,n+1, find the number of the different subsequences (not necessarily contiguous) of the given sequence with length k, modulo 109+7. | ^ a.cc:9:1: error: extended character ≤ is not valid in an identifier 9 | 1≤n≤105 | ^ a.cc:9:1: error: extended character ≤ is not valid in an identifier a.cc:10:1: error: extended character ≤ is not valid in an identifier 10 | 1≤ai≤n | ^ a.cc:10:1: error: extended character ≤ is not valid in an identifier a.cc:11:24: error: extended character … is not valid in an identifier 11 | Each of the integers 1,…,n appears in the sequence. | ^ a.cc:1:1: error: 'You' does not name a type 1 | You are given an integer sequence of length n+1, a1,a2,…,an+1, which consists of the n integers 1,…,n. It is known that each of the n integers 1,…,n appears at least once in this sequence. | ^~~