submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s267260981
p04020
C++
#include <bits/stdc++.h> #define LL long long #define N 1000005 using namespace std; LL int n,ar[N],sum; char c[N]; int main() { scanf("%lld",&n); for(int i=1;i<=n;i++ scanf("%d",&ar[i]); for(int i=1;i<=n;i++) { sum+=ar[i]/2; if(ar[i]%2 && ar[i+1]) sum++,ar[i+1]--; } //~ for(int i=1;i<=n;i++) //~ { //~ if(ar[i]==1 && ar[i+1]==1) //~ sum++,ar[i+1]=0,ar[i]=0; //~ } printf("%lld",sum); }
a.cc: In function 'int main()': a.cc:10:29: error: expected ')' before 'scanf' 10 | for(int i=1;i<=n;i++ | ~ ^ | ) 11 | scanf("%d",&ar[i]); | ~~~~~
s340665849
p04020
C++
#include<iostream> #include<vector> #include<string> #include<array> #include<cmath> #include<algorithm> #include<map> #include<set> #include<queue> #include<numeric> #include<iomanip> #include<utility> #include<cstdlib> #include<typeinfo> using namespace std; #define INF 1000000005 int main() { int n; std::vector<int> a; std::cin >> n; std::vector<int> b(n,0); std::vector<int> c(n,0); for(int i = 0; i < n; i++){ int temp; std::cin >> temp; a.push_back(temp); } for(int i = 0; i < n; i++){ b[i] = a[i]; c[i] = a[i]; } long long int suma = 0; for(int i = 0; i < n - 1; i++){ if(a[i] % 2 == 1){ if(a[i + 1] > 0){ a[i]--; a[i + 1]--; suma++; } } } for(int i = 0; i < n; i++){ if(a[i] >= 2){ int temp = a[i] / 2; suma += temp; } if(b[i] >= 2){ int temp = b[i] / 2; sumb += temp; } } std::cout << suma << std::endl; return 0; }
a.cc: In function 'int main()': a.cc:55:9: error: 'sumb' was not declared in this scope; did you mean 'suma'? 55 | sumb += temp; | ^~~~ | suma
s408699243
p04020
C++
#pragma GCC optimize(2) #include<bits/stdc++.h> typedef long long ll; using namespace std; int main() { int n,a[100005]; bool vis[100005]; while(scanf("%d",&n)!=EOF) { LL ans=0; memset(vis,false,sizeof(vis)); for(int i=0; i<n; i++) { scanf("%d",&a[i]); if(a[i])vis[i]=true; ans+=a[i]/2; a[i]%=2; } for(int i=1; i<n; i++) { if(a[i]&&a[i-1]) { a[i]=0; a[i-1]=0; ans++; } else if(a[i]==0&&a[i-1]) if(vis[i]) a[i]++,a[i-1]--; } printf("%lld\n",ans); } return 0; }
a.cc: In function 'int main()': a.cc:9:17: error: 'LL' was not declared in this scope; did you mean 'll'? 9 | LL ans=0; | ^~ | ll a.cc:14:25: error: 'ans' was not declared in this scope; did you mean 'abs'? 14 | ans+=a[i]/2; | ^~~ | abs a.cc:21:33: error: 'ans' was not declared in this scope; did you mean 'abs'? 21 | ans++; | ^~~ | abs a.cc:25:33: error: 'ans' was not declared in this scope; did you mean 'abs'? 25 | printf("%lld\n",ans); | ^~~ | abs
s657219657
p04020
C++
#include<bits/stdc++.h> #define int long long using namespace std; const int N=1e5+20; inline int read() { int x=0,f=1;char ch=getchar(); while(!isdigit(ch)){if(ch=='-') f=-1;ch=getchar();} while(isdigit(ch)){x=(x<<3)+(x<<1)+(ch&15);ch=getchar();} return x*f; } int n,a[N];ll ans; int main() { n=read(); for(int i=1;i<=n;i++) a[i]=read(); for(int i=1;i<n;i++) { ans+=a[i]/2;a[i]%=2; if(a[i] && a[i+1]) ans++,a[i+1]--; } printf("%lld\n",ans);return 0; }
a.cc:14:12: error: 'll' does not name a type 14 | int n,a[N];ll ans; | ^~ cc1plus: error: '::main' must return 'int' a.cc: In function 'int main()': a.cc:22:17: error: 'ans' was not declared in this scope; did you mean 'abs'? 22 | ans+=a[i]/2;a[i]%=2; | ^~~ | abs a.cc:25:25: error: 'ans' was not declared in this scope; did you mean 'abs'? 25 | printf("%lld\n",ans);return 0; | ^~~ | abs
s222089694
p04020
C++
#pragma comment(linker, "/stack:200000000") #pragma GCC optimize("Ofast") #pragma GCC optimize(3) #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #pragma GCC target("sse3","sse2","sse") #pragma GCC target("avx","sse4","sse4.1","sse4.2","ssse3") #pragma GCC target("f16c") #pragma GCC optimize("inline","fast-math","unroll-loops","no-stack-protector") #pragma GCC diagnostic error "-fwhole-program" #pragma GCC diagnostic error "-fcse-skip-blocks" #pragma GCC diagnostic error "-funsafe-loop-optimizations" #pragma GCC diagnostic error "-std=c++14" #include "bits/stdc++.h" //#include "ext/pb_ds/tree_policy.hpp" //#include "ext/pb_ds/assoc_container.hpp" #define PB push_back #define PF push_front #define LB lower_bound #define UB upper_bound #define fr(x) freopen(x,"r",stdin) #define fw(x) freopen(x,"w",stdout) #define iout(x) printf("%d\n",x) #define lout(x) printf("%lld\n",x) #define REP(x,l,u) for(ll x = l;x<u;x++) #define RREP(x,l,u) for(ll x = l;x>=u;x--) #define complete_unique(a) a.erase(unique(a.begin(),a.end()),a.end()) #define mst(x,a) memset(x,a,sizeof(x)) #define all(a) a.begin(),a.end() #define PII pair<int,int> #define PLL pair<ll,ll> #define MP make_pair #define sqr(x) ((x)*(x)) #define lowbit(x) (x&(-x)) #define lson (ind<<1) #define rson (ind<<1|1) #define se second #define fi first #define dbg(x) cerr<<#x<<" = "<<(x)<<endl; #define sz(x) ((int)x.size()) #define EX0 exit(0); typedef long long ll; typedef unsigned long long ull; typedef double db; typedef long double ld; using namespace std; typedef vector<ll> VLL; typedef vector<int> VI; const int block_size = 320; typedef complex<ll> point; const ll mod = 1e9+7; const ll inf = 1e9+7; const ld eps = 1e-9; const db PI = atan(1)*4; template<typename T> inline int sign(const T&a) { if(a<0)return -1; if(a>0)return 1; return 0; } template<typename T,typename S>inline bool upmin(T&a,const S&b){return a>b?a=b,1:0;} template<typename T,typename S>inline bool upmax(T&a,const S&b){return a<b?a=b,1:0;} template<typename T> inline void in(T &x) { x = 0; T f = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); } while (isdigit(ch)) { x = x * 10 + ch - '0'; ch = getchar(); } x *= f; } ll twop(int x) { return 1LL<<x; } template<typename A,typename B > inline void in(A&x,B&y) { in(x); in(y); } template<typename A,typename B,typename C>inline void in(A&x,B&y,C&z) { in(x); in(y); in(z); } template<typename A,typename B,typename C,typename D> inline void in(A&x,B&y,C&z,D&d) { in(x); in(y); in(z); in(d); } deque<ll>q; ll sum = 0; void solve(){ if(!sz(q))return; REP(i,0,sz(q)-1){ if(q[i]%2==1){ q[i]--; q[i+1]--; sum++; } sum+=q[i]/2; } sum+=q.back()/2; q.clear(); } int main(){ int n;in(n); REP(i,0,n){ ll c;in(c); if(c == 0){ solve(); }else{ q.PB(c); } } solve(); cout<<ans; return 0; }
a.cc:9:30: warning: '-fwhole-program' is not an option that controls warnings [-Wpragmas] 9 | #pragma GCC diagnostic error "-fwhole-program" | ^~~~~~~~~~~~~~~~~ a.cc:10:30: warning: '-fcse-skip-blocks' is not an option that controls warnings [-Wpragmas] 10 | #pragma GCC diagnostic error "-fcse-skip-blocks" | ^~~~~~~~~~~~~~~~~~~ a.cc:11:30: warning: '-funsafe-loop-optimizations' is not an option that controls warnings [-Wpragmas] 11 | #pragma GCC diagnostic error "-funsafe-loop-optimizations" | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:12:30: warning: '-std=c++14' is not an option that controls warnings [-Wpragmas] 12 | #pragma GCC diagnostic error "-std=c++14" | ^~~~~~~~~~~~ a.cc: In function 'int main()': a.cc:127:11: error: 'ans' was not declared in this scope; did you mean 'abs'? 127 | cout<<ans; | ^~~ | abs
s811172890
p04020
C++
#include<bits/stdc++.h> #define ll long long #define pb push_back using namespace std; const int mnx = 3e5 + 9; const int mod = 1e9 + 7; ll n; ll a[mnx]; int main(){ cin>>n; for(int i=1; i<=n; i++){ cin>>a[i]; } for(int i=1; i<=n; i++){ ans += a[i] / 2; if(a[i] % 2 != 0 && a[i+1] != 0){ ans++; a[i+1]--; } } cout<<ans<<'\n'; return 0; }
a.cc: In function 'int main()': a.cc:21:5: error: 'ans' was not declared in this scope; did you mean 'abs'? 21 | ans += a[i] / 2; | ^~~ | abs a.cc:25:7: error: 'ans' was not declared in this scope; did you mean 'abs'? 25 | cout<<ans<<'\n'; | ^~~ | abs
s696110723
p04020
C++
#include "stdafx.h" #include <cstdio> #include <cstdlib> #include <cmath> #include <climits> #include <cfloat> #include <map> #include <utility> #include <set> #include <iostream> #include <memory> #include <string> #include <vector> #include <algorithm> #include <functional> #include <sstream> #include <complex> #include <stack> #include <queue> #include <iomanip> using namespace std; #define INF 1e9 #define PI acos(-1) typedef long long ll; typedef pair<int, int> p_ii; int main() { int i, n; cin >> n; vector<int> a(n); ll ans = 0; for (i = 0; i < n; i++)cin >> a[i]; for (i = 1; i < n; i++) { if (i != n - 1 && a[i] % 2 == 0 && a[i - 1] % 2 == 1 && a[i + 1] % 2 == 1 && a[i] > 0 && a[i - 1] > 0 && a[i + 1] > 0) { ans += (a[i - 1] - 1) / 2; ans += (a[i + 1] - 1) / 2; ans += 2; a[i - 1] = 0; a[i + 1] = 0; ans += (a[i] - 2) / 2; a[i] = 0; i++; } else if (a[i] % 2 == 1 && a[i - 1] % 2 == 0 ) { ans += a[i - 1]/2; a[i - 1] = 0; ans += a[i] / 2; a[i] = 1; } else if (i != n - 1 && a[i] % 2 == 0 && a[i - 1] % 2 == 1 && a[i + 1] % 2 == 0 ) { ans += a[i - 1] / 2; a[i - 1] = 1; ans += a[i] / 2; a[i] = 0; ans += a[i + 1] / 2; a[i + 1] = 0; i++; } else if (a[i] % 2 == 0 && a[i - 1] % 2 == 0 ) { ans += a[i] / 2; a[i] = 0; ans += a[i - 1] / 2; a[i - 1] = 0; } else if (a[i] % 2 == 1 && a[i - 1] % 2 == 1 ) { ans += a[i] / 2; a[i] = 1; ans += a[i - 1] / 2; a[i - 1] = 1; } else if (a[i] % 2 == 0 && a[i - 1] % 2 == 1) { ans += a[i] / 2; a[i] = 0; ans += a[i - 1] / 2; a[i - 1] = 1; } } cout << ans << endl; return 0; }
a.cc:1:10: fatal error: stdafx.h: No such file or directory 1 | #include "stdafx.h" | ^~~~~~~~~~ compilation terminated.
s728713650
p04020
C++
#include <bits/stdc++.h> using namespace std; const int N = 100005; int n, num, a[N], b[N]; ll cnt; int main () { cin >> n, cnt = 0; for (int i = 1; i <= n; ++i) scanf("%d", &a[i]); for (int i = 1; i <= n; ++i) cnt += a[i] >> 1, a[i] &= 1; for (int i = 1; i <= n; ++i) if (a[i]) b[++num] = i; for (int i = 1; i < num; ++i) if (b[i + 1] - b[i] == 1) ++cnt, ++i; cout << cnt << endl; return 0; }
a.cc:5:25: error: 'll' does not name a type 5 | int n, num, a[N], b[N]; ll cnt; | ^~ a.cc: In function 'int main()': a.cc:7:19: error: 'cnt' was not declared in this scope; did you mean 'int'? 7 | cin >> n, cnt = 0; | ^~~ | int
s793265317
p04020
C++
#include <bits/stdc++.h> using namespace std; const int N = 100005; int n, num, a[N], b[N]; ll cnt; int main () { cin >> n, cnt = 0; for (int i = 1; i <= n; ++i) scanf("%d", &a[i]); for (int i = 1; i <= n; ++i) cnt += a[i] >> 1, a[i] &= 1; for (int i = 1; i <= n; ++i) if (a[i]) b[++num] = i; for (int i = 1; i < num; ++i) if (b[i + 1] - b[i] == 1) ++cnt, ++i; cout << cnt << endl; return 0; }
a.cc:5:25: error: 'll' does not name a type 5 | int n, num, a[N], b[N]; ll cnt; | ^~ a.cc: In function 'int main()': a.cc:7:19: error: 'cnt' was not declared in this scope; did you mean 'int'? 7 | cin >> n, cnt = 0; | ^~~ | int
s621654482
p04020
C++
#include <bits/stdc++.h> using namespace std; int main(){ long long ans=0,a,cnt=0; int n; cin>>n; for(int i=0;i<n;i++){ cin>>a; if(a)cnt+=a[i]; else{ ans+=cnt/2; cnt=0; } } cout<<ans+(cnt/2)<<endl; return 0; }
a.cc: In function 'int main()': a.cc:9:20: error: invalid types 'long long int[int]' for array subscript 9 | if(a)cnt+=a[i]; | ^
s237306650
p04020
C++
#include <bits/stdc++.h> using namespace std; int main(){ long long ans=0; int n,a[100000],int cnt=0; cin>>n; for(int i=0;i<n;i++){ cin>>a[i]; if(a[i])cnt+=a[i]; else{ ans+=cnt/2; cnt=0; } } cout<<ans+(cnt/2)<<endl; return 0; }
a.cc: In function 'int main()': a.cc:5:21: error: expected unqualified-id before 'int' 5 | int n,a[100000],int cnt=0; | ^~~ a.cc:9:17: error: 'cnt' was not declared in this scope; did you mean 'int'? 9 | if(a[i])cnt+=a[i]; | ^~~ | int a.cc:11:18: error: 'cnt' was not declared in this scope; did you mean 'int'? 11 | ans+=cnt/2; | ^~~ | int a.cc:15:16: error: 'cnt' was not declared in this scope; did you mean 'int'? 15 | cout<<ans+(cnt/2)<<endl; | ^~~ | int
s469979320
p04020
C++
#include <iostream> #include<bits/stdc++.h> using namespace std; int solve(vector<int>&a) { int n=a.size(); int d=0; for(int i=0;i<n;i++){ if(a==0)continue; if(!(a[i]%2)) { d+=a[i]/2; } else { d+=a[i]/2; if(i+1<n&&a[i+1]!=0){ d++; a[i+1]--; } } } return d; } int main() { int n; cin>>n; int i=0; vector<int>a(n); while(n--) { cin>>a[i++]; } int d=solve(a); cout<<d; return 0; }
a.cc: In function 'int solve(std::vector<int>&)': a.cc:10:17: error: no match for 'operator==' (operand types are 'std::vector<int>' and 'int') 10 | if(a==0)continue; | ~^~~ | | | | | int | std::vector<int> In file included from /usr/include/c++/14/regex:68, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181, from a.cc:2: /usr/include/c++/14/bits/regex.h:1103:5: note: candidate: 'template<class _BiIter> bool std::__cxx11::operator==(const sub_match<_BiIter>&, const sub_match<_BiIter>&)' 1103 | operator==(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1103:5: note: template argument deduction/substitution failed: a.cc:10:19: note: 'std::vector<int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 10 | if(a==0)continue; | ^ /usr/include/c++/14/bits/regex.h:1199:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator==(__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const sub_match<_BiIter>&)' 1199 | operator==(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1199:5: note: template argument deduction/substitution failed: a.cc:10:19: note: 'std::vector<int>' is not derived from 'std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>' 10 | if(a==0)continue; | ^ /usr/include/c++/14/bits/regex.h:1274:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator==(const sub_match<_BiIter>&, __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)' 1274 | operator==(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1274:5: note: template argument deduction/substitution failed: a.cc:10:19: note: 'std::vector<int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 10 | if(a==0)continue; | ^ /usr/include/c++/14/bits/regex.h:1366:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const typename std::iterator_traits<_Iter>::value_type*, const sub_match<_BiIter>&)' 1366 | operator==(typename iterator_traits<_Bi_iter>::value_type const* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1366:5: note: template argument deduction/substitution failed: a.cc:10:19: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'int' 10 | if(a==0)continue; | ^ /usr/include/c++/14/bits/regex.h:1441:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)' 1441 | operator==(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1441:5: note: template argument deduction/substitution failed: a.cc:10:19: note: 'std::vector<int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 10 | if(a==0)continue; | ^ /usr/include/c++/14/bits/regex.h:1534:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const typename std::iterator_traits<_Iter>::value_type&, const sub_match<_BiIter>&)' 1534 | operator==(typename iterator_traits<_Bi_iter>::value_type const& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1534:5: note: template argument deduction/substitution failed: a.cc:10:19: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'int' 10 | if(a==0)continue; | ^ /usr/include/c++/14/bits/regex.h:1613:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&)' 1613 | operator==(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1613:5: note: template argument deduction/substitution failed: a.cc:10:19: note: 'std::vector<int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 10 | if(a==0)continue; | ^ /usr/include/c++/14/bits/regex.h:2186:5: note: candidate: 'template<class _Bi_iter, class _Alloc> bool std::__cxx11::operator==(const match_results<_BiIter, _Alloc>&, const match_results<_BiIter, _Alloc>&)' 2186 | operator==(const match_results<_Bi_iter, _Alloc>& __m1, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:2186:5: note: template argument deduction/substitution failed: a.cc:10:19: note: 'std::vector<int>' is not derived from 'const std::__cxx11::match_results<_BiIter, _Alloc>' 10 | if(a==0)continue; | ^ In file included from /usr/include/c++/14/iosfwd:42, from /usr/include/c++/14/ios:40, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/postypes.h:192:5: note: candidate: 'template<class _StateT> bool std::operator==(const fpos<_StateT>&, const fpos<_StateT>&)' 192 | operator==(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/postypes.h:192:5: note: template argument deduction/substitution failed: a.cc:10:19: note: 'std::vector<int>' is not derived from 'const std::fpos<_StateT>' 10 | if(a==0)continue; | ^ In file included from /usr/include/c++/14/string:43, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44: /usr/include/c++/14/bits/allocator.h:235:5: note: candidate: 'template<class _T1, class _T2> bool std::operator==(const allocator<_CharT>&, const allocator<_T2>&)' 235 | operator==(const allocator<_T1>&, const allocator<_T2>&) | ^~~~~~~~ /usr/include/c++/14/bits/allocator.h:235:5: note: template argument deduction/substitution failed: a.cc:10:19: note: 'std::vector<int>' is not derived from 'const std::allocator<_CharT>' 10 | if(a==0)continue; | ^ In file included from /usr/include/c++/14/string:48: /usr/include/c++/14/bits/stl_iterator.h:441:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 441 | operator==(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:441:5: note: template argument deduction/substitution failed: a.cc:10:19: note: 'std::vector<int>' is not derived from 'const std::reverse_iterator<_Iterator>' 10 | if(a==0)continue; | ^ /usr/include/c++/14/bits/stl_iterator.h:486:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 486 | operator==(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:486:5: note: template argument deduction/substitution failed: a.cc:10:19: note: 'std::vector<int>' is not derived from 'const std::reverse_iterator<_Iterator>' 10 | if(a==0)continue; | ^ /usr/include/c++/14/bits/stl_iterator.h:1667:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1667 | operator==(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1667:5: note: template argument deduction/substitution failed: a.cc:10:19: note: 'std::vector<int>' is not derived from 'const std::move_iterator<_IteratorL>' 10 | if(a==0)continue; | ^ /usr/include/c++/14/bits/stl_iterator.h:1737:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)' 1737 | operator==(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1737:5: note: template argument deduction/substitution failed: a.cc:10:19: note: 'std::vector<int>' is not derived from 'const std::move_iterator<_IteratorL>' 10 | if(a==0)continue; | ^ In file included from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/string:51: /usr/include/c++/14/bits/stl_pair.h:1033:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator==(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1033 | operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1033:5: note: template argument deduction/substitution failed: a.cc:10:19: note: 'std::vector<int>' is not derived from 'const std::pair<_T1, _T2>' 10 | if(a==0)continue; | ^ In file included from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54: /usr/include/c++/14/string_view:629:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)' 629 | operator==(basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:629:5: note: template argument deduction/substitution failed: a.cc:10:19: note: 'std::vector<int>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 10 | if(a==0)continue; | ^ /usr/include/c++/14/string_view:637:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(basic_string_view<_CharT, _Traits>, basic_
s970447932
p04020
C++
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; #define MOD 1000000007 int main(){ int n; cin>>n; ll a[n]; for(int i=0;i<n;i++) cin>>a[i]; ll ans=0; for(int i=0;i<n-1;i++){ ans+=a[i]/2; if(a[i]%2==1&&a[i+1]>=1){ a[i+1]--; ans++; } } ans+=a[n-1]/2; cout<<ans<<endl; return
a.cc: In function 'int main()': a.cc:22:9: error: expected primary-expression at end of input 22 | return | ^ a.cc:22:9: error: expected ';' at end of input 22 | return | ^ | ; a.cc:22:9: error: expected '}' at end of input a.cc:7:11: note: to match this '{' 7 | int main(){ | ^
s434070288
p04020
C++
#include <bits/stdc++.h> #define ll long long using namespace std; int n; ll a[100005]; ll kilk(int l,int r) { ll s1=0; for(int i=l;i<=r;i++) s1+=a[i]; return s1/2; } int main()a { cin>>n; for(int i=1;i<=n;i++) cin>>a[i]; a[n+1]=0; int pos1=1,pos2=1; ll s=0; for(int i=1;i<=n+1;i++) { if(a[i]==0) { s+=kilk(pos1,pos2); pos1=-1; pos2=-1; continue; } if(pos1==-1) { pos1=i; pos2=i; } else { pos2++; } } cout<<s; }
a.cc:17:11: error: expected initializer before 'a' 17 | int main()a | ^
s126269103
p04020
C++
#include <iostream> using namespace std; int main() { int n; cin >> n; int a[n]; int ans = 0; bool r = false; for (int i = 0,i < n,i++) { cin >> a[i]; ans += a[i] / 2; a[i] = a[i] % 2; } for (int i = 0,i < n,i++) { if (a[i] == 1) { if (r) { ans++; r = false; } else { r = true; } } else { r = false; } } cout << ans; }
a.cc: In function 'int main()': a.cc:11:25: error: expected ';' before '<' token 11 | for (int i = 0,i < n,i++) { | ^~ | ; a.cc:11:26: error: expected primary-expression before '<' token 11 | for (int i = 0,i < n,i++) { | ^ a.cc:11:33: error: expected ';' before ')' token 11 | for (int i = 0,i < n,i++) { | ^ | ; a.cc:16:25: error: expected ';' before '<' token 16 | for (int i = 0,i < n,i++) { | ^~ | ; a.cc:16:26: error: expected primary-expression before '<' token 16 | for (int i = 0,i < n,i++) { | ^ a.cc:16:33: error: expected ';' before ')' token 16 | for (int i = 0,i < n,i++) { | ^ | ;
s497053821
p04020
C++
#include <iostream> #include <cmath> #include <algorithm> using namespace std; int tree[100010]; int root(int x) { return tree[x] == x ? x : tree[x] = root(tree[x]); } int main() { int N, A[100010]; cin >> N; int d = 0; int a,b; for (int i = 0; i < N; i++) { cin >> A[i]; } for (int i = 0; i < N; i++) { d += A[i] / 2; A[i] = A[i] % 2; } for (int i = 0; i < N-1; i++) { a = min(A[i], A[i + 1]); d += a; A[i] -= a; A[i + 1] -= a; } cout << d << endl; return 0;
a.cc: In function 'int main()': a.cc:33:18: error: expected '}' at end of input 33 | return 0; | ^ a.cc:13:12: note: to match this '{' 13 | int main() { | ^
s668554816
p04020
C++
#include <iostream> #include <algorithm> #include <string> #include <regex> using namespace std; int main() { int N,A[100010]; cin >> N; for (int i = 0; i < N; i++)cin >> A[i]; int d = 0; for (int i = 0; i < N - 1; i++) { while (A[i] > 0 && A[i + 1] > 0) { d++; A[i]--; A[i + 1]--; } } for (int i = 0; i < N; i++) { d += A[i] / 2; } cout << d << endl;
a.cc: In function 'int main()': a.cc:23:27: error: expected '}' at end of input 23 | cout << d << endl; | ^ a.cc:8:1: note: to match this '{' 8 | { | ^
s129706111
p04020
C++
#include <bits/stdc++.h> using namespace std; typedef long longll; int main() { int n; cin >> n; ll res = 0; ll keep = 0; for(int i=0; i<n; i++) { ll a; cin >> a; if(keep==1 && a>0) { res++; a--; } res+= a / 2; keep = a % 2; } cout << res << endl; }
a.cc: In function 'int main()': a.cc:10:9: error: 'll' was not declared in this scope 10 | ll res = 0; | ^~ a.cc:11:11: error: expected ';' before 'keep' 11 | ll keep = 0; | ^~~~~ | ; a.cc:14:19: error: expected ';' before 'a' 14 | ll a; | ^~ | ; a.cc:15:24: error: 'a' was not declared in this scope 15 | cin >> a; | ^ a.cc:16:20: error: 'keep' was not declared in this scope 16 | if(keep==1 && a>0) | ^~~~ a.cc:18:25: error: 'res' was not declared in this scope 18 | res++; | ^~~ a.cc:21:17: error: 'res' was not declared in this scope 21 | res+= a / 2; | ^~~ a.cc:22:17: error: 'keep' was not declared in this scope 22 | keep = a % 2; | ^~~~ a.cc:24:17: error: 'res' was not declared in this scope 24 | cout << res << endl; | ^~~
s653179434
p04020
C++
import java.util.Scanner; public class Main { public static void main(String[] args) { new Main().solve(); } void solve(){ 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(); int pair_count=0; for(int i=0;i<n;i++){ if(a[i]%2==0){ pair_count+=a[i]/2-1; a[i]=2; }else{ pair_count+=a[i]/2; a[i]=a[i]%2; } } for(int i=0;i<n-2;i++){ if(a[i]==1 && a[i+1]==2 && a[i+2]==1){ pair_count+=2; a[i]=a[i+1]=a[i+2]=0; } } for(int i=0;i<n;i++){ if(a[i]==2)pair_count++; } System.out.println(pair_count); } }
a.cc:1:1: error: 'import' does not name a type 1 | import java.util.Scanner; | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:3:1: error: expected unqualified-id before 'public' 3 | public class Main { | ^~~~~~
s749531659
p04020
C++
#include<bits/stdc++.h> using namespace std; int main() { long long t=0,c=0; int n,i,k; cin>>n; for(i=0,i<n;i++) { cin>>k; if(k==0) { t+=c/2; c=0; } c+=k; } t+=c/2; cout<<t<<endl; return 0; }
a.cc: In function 'int main()': a.cc:8:24: error: expected ';' before ')' token 8 | for(i=0,i<n;i++) { | ^ | ;
s662378958
p04020
C++
# include <stdio.h> # include <string.h> # include <stdlib.h> # include <queue> # include <stack> # include <map> # include <math.h> # include <algorithm> using namespace std; # define MAXN 55 # define MAXM 100005 # define INF 1000000000 # define MIN(a,b) (a)>(b)?(b):(a) # define MAX(a,b) (a)<(b)?(b):(a) # define mem(a,b) memset(a,b,sizeof(a)) # define FOR(i,a,n) for(int i=a; i<=n; ++i) # define FO(i,a,n) for(int i=a; i<n; ++i) # define bug puts("H"); typedef __int64 LL; int _MAX(int a, int b){return a>b?a:b;} int _MIN(int a, int b){return a>b?b:a;} int a[100005]; int main() { int n; LL ans=0; scanf("%d",&n); FO(i,0,n) scanf("%d",a+i), ans+=a[i]/2, a[i]%=2; FO(i,1,n) { if (a[i]>0&&a[i-1]>0) ans+=MIN(a[i],a[i-1]), a[i]-=MIN(a[i],a[i-1]); } printf("%I64d\n",ans); return 0; }
a.cc:19:9: error: '__int64' does not name a type; did you mean '__int64_t'? 19 | typedef __int64 LL; | ^~~~~~~ | __int64_t a.cc: In function 'int main()': a.cc:28:5: error: 'LL' was not declared in this scope 28 | LL ans=0; | ^~ a.cc:30:32: error: 'ans' was not declared in this scope; did you mean 'abs'? 30 | FO(i,0,n) scanf("%d",a+i), ans+=a[i]/2, a[i]%=2; | ^~~ | abs a.cc:32:31: error: 'ans' was not declared in this scope; did you mean 'abs'? 32 | if (a[i]>0&&a[i-1]>0) ans+=MIN(a[i],a[i-1]), a[i]-=MIN(a[i],a[i-1]); | ^~~ | abs a.cc:34:22: error: 'ans' was not declared in this scope; did you mean 'abs'? 34 | printf("%I64d\n",ans); | ^~~ | abs
s545894998
p04020
C++
#include <bits/stdc++.h> using namespace std; const int MAX_N = 100000; const int INF = 1e9; #define int long long; int n; int a[MAX_N+10]; signed main(){ cin>>n; for(int i=1;i<=n;i++)cin>>a[i]; int ans=0; for(int i=1;i<=n;i++){ ans+=a[i]/2; a[i]%=2; if(a[i]==1 && a[i+1]!=0 && i!=n){ a[i+1]--; ans++; } } cout<<ans<<endl; return 0; }
a.cc:7:18: error: declaration does not declare anything [-fpermissive] 7 | #define int long long; | ^~~~ a.cc:9:1: note: in expansion of macro 'int' 9 | int n; | ^~~ a.cc:9:5: error: 'n' does not name a type 9 | int n; | ^ a.cc:7:18: error: declaration does not declare anything [-fpermissive] 7 | #define int long long; | ^~~~ a.cc:10:1: note: in expansion of macro 'int' 10 | int a[MAX_N+10]; | ^~~ a.cc:10:5: error: 'a' does not name a type 10 | int a[MAX_N+10]; | ^ a.cc: In function 'int main()': a.cc:14:8: error: 'n' was not declared in this scope; did you mean 'yn'? 14 | cin>>n; | ^ | yn a.cc:7:18: error: declaration does not declare anything [-fpermissive] 7 | #define int long long; | ^~~~ a.cc:15:7: note: in expansion of macro 'int' 15 | for(int i=1;i<=n;i++)cin>>a[i]; | ^~~ a.cc:15:11: error: 'i' was not declared in this scope 15 | for(int i=1;i<=n;i++)cin>>a[i]; | ^ a.cc:15:19: error: expected ')' before ';' token 15 | for(int i=1;i<=n;i++)cin>>a[i]; | ~ ^ | ) a.cc:15:20: error: 'i' was not declared in this scope 15 | for(int i=1;i<=n;i++)cin>>a[i]; | ^ a.cc:7:18: error: declaration does not declare anything [-fpermissive] 7 | #define int long long; | ^~~~ a.cc:17:3: note: in expansion of macro 'int' 17 | int ans=0; | ^~~ a.cc:17:7: error: 'ans' was not declared in this scope; did you mean 'abs'? 17 | int ans=0; | ^~~ | abs a.cc:7:18: error: declaration does not declare anything [-fpermissive] 7 | #define int long long; | ^~~~ a.cc:18:7: note: in expansion of macro 'int' 18 | for(int i=1;i<=n;i++){ | ^~~ a.cc:18:19: error: expected ')' before ';' token 18 | for(int i=1;i<=n;i++){ | ~ ^ | )
s687428289
p04020
C++
#include <bits/stdc++.h> using namespace std; const int MAX_N = 100000; const int INF = 1e9; #define int ll; int n; int a[MAX_N+10]; signed main(){ cin>>n; for(int i=1;i<=n;i++)cin>>a[i]; int ans=0; for(int i=1;i<=n;i++){ ans+=a[i]/2; a[i]%=2; if(a[i]==1 && a[i+1]!=0 && i!=n){ a[i+1]--; ans++; } } cout<<ans<<endl; return 0; }
a.cc:7:13: error: 'll' does not name a type 7 | #define int ll; | ^~ a.cc:9:1: note: in expansion of macro 'int' 9 | int n; | ^~~ a.cc:9:5: error: 'n' does not name a type 9 | int n; | ^ a.cc:7:13: error: 'll' does not name a type 7 | #define int ll; | ^~ a.cc:10:1: note: in expansion of macro 'int' 10 | int a[MAX_N+10]; | ^~~ a.cc:10:5: error: 'a' does not name a type 10 | int a[MAX_N+10]; | ^ a.cc: In function 'int main()': a.cc:14:8: error: 'n' was not declared in this scope; did you mean 'yn'? 14 | cin>>n; | ^ | yn a.cc:7:13: error: 'll' was not declared in this scope 7 | #define int ll; | ^~ a.cc:15:7: note: in expansion of macro 'int' 15 | for(int i=1;i<=n;i++)cin>>a[i]; | ^~~ a.cc:15:11: error: 'i' was not declared in this scope 15 | for(int i=1;i<=n;i++)cin>>a[i]; | ^ a.cc:15:19: error: expected ')' before ';' token 15 | for(int i=1;i<=n;i++)cin>>a[i]; | ~ ^ | ) a.cc:15:20: error: 'i' was not declared in this scope 15 | for(int i=1;i<=n;i++)cin>>a[i]; | ^ a.cc:7:13: error: 'll' was not declared in this scope 7 | #define int ll; | ^~ a.cc:17:3: note: in expansion of macro 'int' 17 | int ans=0; | ^~~ a.cc:17:7: error: 'ans' was not declared in this scope; did you mean 'abs'? 17 | int ans=0; | ^~~ | abs a.cc:18:19: error: expected ')' before ';' token 18 | for(int i=1;i<=n;i++){ | ~ ^ | )
s451089086
p04020
C++
#include <stdio.h> int main(void){ int i,n,s=0; scanf("%d",&n); int a[n]; for(i=0;i<n;i++){ scanf("%d",&a[i]); } for(i=0;i<n;i++){ if(a[i]%2==0){ s+=a[i]/2; } else if(a[i]%2==1){ s+=(a[i]-1)/2; if(a[i+1]>=1&&i+1<n){ s+=1; a[i+1]-=1; } } } printf("%d\n",s); return 0; }#include <stdio.h> int main(void){ int i,n,s=0; scanf("%d",&n); int a[n]; for(i=0;i<n;i++){ scanf("%d",&a[i]); } for(i=0;i<n;i++){ if(a[i]%2==0){ s+=a[i]/2; } else if(a[i]%2==1){ s+=(a[i]-1)/2; if(a[i+1]>=1&&i+1<n){ s+=1; a[i+1]-=1; } } } printf("%d\n",s); return 0; }
a.cc:25:2: error: stray '#' in program 25 | }#include <stdio.h> | ^ a.cc:25:3: error: 'include' does not name a type 25 | }#include <stdio.h> | ^~~~~~~
s678972159
p04020
Java
public class Main { void run() { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] a = new int[n + 1]; for (int i = 0; i < n; i++) { a[i] = sc.nextInt(); } long sum = 0; for (int i = 0; i < n; i++) { sum += a[i] / 2; a[i] %= 2; if (0 < a[i] && 0 < a[i + 1]) { sum++; a[i]--; a[i + 1]--; } } System.out.println(sum); } public static void main(String[] args) { new Main().run(); } }
Main.java:3: error: cannot find symbol Scanner sc = new Scanner(System.in); ^ symbol: class Scanner location: class Main Main.java:3: error: cannot find symbol Scanner sc = new Scanner(System.in); ^ symbol: class Scanner location: class Main 2 errors
s123928965
p04020
Java
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.*; public class Main { int N; int[] A; public void solve() { N = nextInt(); A = new int[N]; for(int i = 0;i < N;i++){ A[i] = nextInt(); } long ans = 0; for(int i = 0;i < N - 1;i++){ int min = Math.min(A[i],A[i + 1]); if(min != 0){ ans += min; A[i] -= min; A[i + 1] -= min; } ans += A[i] / 2; } ans += A[N - 1] / 2; out.println(ans9); } public static void main(String[] args) { out.flush(); new Main().solve(); out.close(); } /* Input */ private static final InputStream in = System.in; private static final PrintWriter out = new PrintWriter(System.out); private final byte[] buffer = new byte[2048]; private int p = 0; private int buflen = 0; private boolean hasNextByte() { if (p < buflen) return true; p = 0; try { buflen = in.read(buffer); } catch (IOException e) { e.printStackTrace(); } if (buflen <= 0) return false; return true; } public boolean hasNext() { while (hasNextByte() && !isPrint(buffer[p])) { p++; } return hasNextByte(); } private boolean isPrint(int ch) { if (ch >= '!' && ch <= '~') return true; return false; } private int nextByte() { if (!hasNextByte()) return -1; return buffer[p++]; } public String next() { if (!hasNext()) throw new NoSuchElementException(); StringBuilder sb = new StringBuilder(); int b = -1; while (isPrint((b = nextByte()))) { sb.appendCodePoint(b); } return sb.toString(); } public int nextInt() { return Integer.parseInt(next()); } public long nextLong() { return Long.parseLong(next()); } public double nextDouble() { return Double.parseDouble(next()); } }
Main.java:30: error: cannot find symbol out.println(ans9); ^ symbol: variable ans9 location: class Main 1 error
s034558449
p04020
C
#include <stdio.h> int n, data[100001], tmp; int main(void) { int i, j; long long int ans; scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%d", &data[i]); } tmp = 0; for (i = 0; i < n; i++) { if (data[i] != 0) { data[i] += tmp; ans += data[i] / 2; tmp = data[i] % 2; } else { tmp = 0; } } printf("%lld\n", ans); return 0 }
main.c: In function 'main': main.c:24:13: error: expected ';' before '}' token 24 | return 0 | ^ | ; 25 | } | ~
s554516322
p04020
C++
#include <stdio.h> unsigned long long int min(unsigned long long int a,unsigned long long int b){ if(a > b) return a; else return b; } int main(void) { unsigned long long int N = 0,A[100000] = {0}; int i = 0,j = 0,k = 0,l = 0; unsigned long long int ans = 0; scanf("%d",&N); for(i = 0;i < N;i++) scanf("%d",&A[i]); for(i = 0;i < N;i++){ while(1){ if(A[i] > 1){ ans += A[i] / 2; A[i] %= 2; }else if(A[i] > 0 && A[i + 1] > 0){ ans += min(A[i],A[i + 1]) / 2; l = min(A[i],A[i + 1]); A[i] -= l A[i + 1] -= l; }else{ break; } } } printf("%lld\n",ans); return 0; }
a.cc: In function 'int main()': a.cc:28:42: error: expected ';' before 'A' 28 | A[i] -= l | ^ | ; 29 | A[i + 1] -= l; | ~
s523014565
p04020
C++
unsigned long long int min(unsigned long long int a,unsigned long long int b){ if(a < b) return a; else return b; } int main(void) { unsigned long long int N = 0,A[100000] = {0}; int i = 0,j = 0,k = 0,l = 0; unsigned long long int ans = 0; scanf("%d",&N); for(i = 0;i < N;i++) scanf("%d",&A[i]); for(i = 0;i < N;i++){ while(1){ if(A[i] > 1){ ans += A[i] / 2; A[i] %= 2; }else if(A[i] > 0 && A[i + 1] > 0){ ans += min(A[i],A[i + 1]) / 2; A[i] -= min(A[i],A[i + 1]); A[i + 1] -= min(A[i],A[i + 1]); }else{ break; } } } printf("%lld\n",ans); return 0; }
a.cc: In function 'int main()': a.cc:14:9: error: 'scanf' was not declared in this scope 14 | scanf("%d",&N); | ^~~~~ a.cc:32:9: error: 'printf' was not declared in this scope 32 | printf("%lld\n",ans); | ^~~~~~ a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>' +++ |+#include <cstdio> 1 | unsigned long long int min(unsigned long long int a,unsigned long long int b){
s907495364
p04020
C++
8 2 0 1 6 0 8 2 1
a.cc:1:1: error: expected unqualified-id before numeric constant 1 | 8 | ^
s160180691
p04020
Java
import java.util.*; import java.io.*; public class Main{ static final Reader sc = new Reader(); static final PrintWriter out = new PrintWriter(System.out,false); public static void main(String[] args) throws Exception { int n = sc.nextInt(); long[] a = new long[n]; for(int i=0;i<n;i++){ a[i] = sc.nextLong(); } long count = 0; for(int i=0;i<n;i++){ count += a[i]/2; a[i] -= a[i]/2*2; if(i==0 && a[i]==1 && a[i+1]%2==1){ count++; a[i]-=0 a[i+1]-=1; } else if(i!=0 && a[i]==1 && a[i-1]==1){ count++; a[i]-=1; a[i-1]-=1; } else if(i!=0 && a[i]==1 && a[i+1]%2==1){ count++; a[i]-=1; a[i+1]-=1; } } out.println(count); out.flush(); sc.close(); out.close(); } static void trace(Object... o) { System.out.println(Arrays.deepToString(o));} } class Reader { private final InputStream in; private final byte[] buf = new byte[1024]; private int ptr = 0; private int buflen = 0; public Reader() { this(System.in);} public Reader(InputStream source) { this.in = source;} private boolean hasNextByte() { if (ptr < buflen) return true; ptr = 0; try{ buflen = in.read(buf); }catch (IOException e) {e.printStackTrace();} if (buflen <= 0) return false; return true; } private int readByte() { if (hasNextByte()) return buf[ptr++]; else return -1;} private boolean isPrintableChar(int c) { return 33 <= c && c <= 126;} private void skip() { while(hasNextByte() && !isPrintableChar(buf[ptr])) ptr++;} public boolean hasNext() {skip(); return hasNextByte();} public String next() { if (!hasNext()) throw new NoSuchElementException(); StringBuilder sb = new StringBuilder(); int b = readByte(); while (isPrintableChar(b)) { sb.appendCodePoint(b); b = readByte(); } return sb.toString(); } public long nextLong() { if (!hasNext()) throw new NoSuchElementException(); boolean minus = false; long num = readByte(); if(num == '-'){ num = 0; minus = true; }else if (num < '0' || '9' < num){ throw new NumberFormatException(); }else{ num -= '0'; } while(true){ int b = readByte(); if('0' <= b && b <= '9') num = num * 10 + (b - '0'); else if(b == -1 || !isPrintableChar(b)) return minus ? -num : num; else throw new NoSuchElementException(); } } public int nextInt() { long num = nextLong(); if (num < Integer.MIN_VALUE || Integer.MAX_VALUE < num) throw new NumberFormatException(); return (int)num; } public double nextDouble() { return Double.parseDouble(next()); } public char nextChar() { if (!hasNext()) throw new NoSuchElementException(); return (char)readByte(); } public String nextLine() { while (hasNextByte() && (buf[ptr] == '\n' || buf[ptr] == '\r')) ptr++; if (!hasNextByte()) throw new NoSuchElementException(); StringBuilder sb = new StringBuilder(); int b = readByte(); while (b != '\n' && b != '\r') { sb.appendCodePoint(b); b = readByte(); } return sb.toString(); } public int[] nextIntArray(int n) { int[] res = new int[n]; for (int i=0; i<n; i++) res[i] = nextInt(); return res; } public char[] nextCharArray(int n) { char[] res = new char[n]; for (int i=0; i<n; i++) res[i] = nextChar(); return res; } public void close() {try{ in.close();}catch(IOException e){ e.printStackTrace();}}; }
Main.java:21: error: ';' expected a[i]-=0 ^ 1 error
s492342809
p04020
C++
\#include<cstdio> #include<iostream> #include<cmath> #include<ctype.h> #include<vector> #include<cstdlib> #include<cstdlib> #include<string> #include<algorithm> #include<stack> #include<queue> #include<map> #include<set> #include<time.h> #define ll long long #define LL long long #define ULL unsigned long long #define ull unsigned long long #define FOR(i,a,b) for(int i=a;i<b;i++) #define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--) #define REP(i,n) for(int i=0;i<n;i++) #define RREP(i,n) for(int i=(n)-1;i>=0;i--) const int INF = 100000000; using namespace std; ll dp[10000][10000] = {}; ll memo[10000][10000] = {}; ll N; ll A[100000] = {}; int main() { bool tmp=0; int ans = 0; cin >> N; REP(i, N) { cin >> A[i]; } for (int i = 0; i < N; i++) { if (A[i] == 0) { tmp == false; } else { if (tmp == true) { A[i]++; } ans += A[i] / 2; if (A[i] % 2 != 0) { tmp = true; } else tmp = false; } } cout << ans << endl; return 0; }
a.cc:1:1: error: stray '\' in program 1 | \#include<cstdio> | ^ a.cc:1:2: error: stray '#' in program 1 | \#include<cstdio> | ^ a.cc:1:3: error: 'include' does not name a type 1 | \#include<cstdio> | ^~~~~~~ In file included from /usr/include/c++/14/iosfwd:42, from /usr/include/c++/14/ios:40, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:2: /usr/include/c++/14/bits/postypes.h:68:11: error: 'ptrdiff_t' does not name a type 68 | typedef ptrdiff_t streamsize; // Signed integral type | ^~~~~~~~~ /usr/include/c++/14/bits/postypes.h:41:1: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' 40 | #include <cwchar> // For mbstate_t +++ |+#include <cstddef> 41 | In file included from /usr/include/c++/14/bits/exception_ptr.h:38, from /usr/include/c++/14/exception:166, from /usr/include/c++/14/ios:41: /usr/include/c++/14/new:131:26: error: declaration of 'operator new' as non-function 131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc) | ^~~~~~~~ /usr/include/c++/14/new:131:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc) | ^~~~~~ In file included from /usr/include/wchar.h:35, from /usr/include/c++/14/cwchar:44, from /usr/include/c++/14/bits/postypes.h:40: /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/new:132:41: error: attributes after parenthesized initializer ignored [-fpermissive] 132 | __attribute__((__externally_visible__)); | ^ /usr/include/c++/14/new:133:26: error: declaration of 'operator new []' as non-function 133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc) | ^~~~~~~~ /usr/include/c++/14/new:133:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc) | ^~~~~~ /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/new:134:41: error: attributes after parenthesized initializer ignored [-fpermissive] 134 | __attribute__((__externally_visible__)); | ^ /usr/include/c++/14/new:140:29: error: 'std::size_t' has not been declared 140 | void operator delete(void*, std::size_t) _GLIBCXX_USE_NOEXCEPT | ^~~ /usr/include/c++/14/new:142:31: error: 'std::size_t' has not been declared 142 | void operator delete[](void*, std::size_t) _GLIBCXX_USE_NOEXCEPT | ^~~ /usr/include/c++/14/new:145:26: error: declaration of 'operator new' as non-function 145 | _GLIBCXX_NODISCARD void* operator new(std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT | ^~~~~~~~ /usr/include/c++/14/new:145:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 145 | _GLIBCXX_NODISCARD void* operator new(std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT | ^~~~~~ /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/new:145:52: error: expected primary-expression before 'const' 145 | _GLIBCXX_NODISCARD void* operator new(std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT | ^~~~~ /usr/include/c++/14/new:147:26: error: declaration of 'operator new []' as non-function 147 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT | ^~~~~~~~ /usr/include/c++/14/new:147:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 147 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT | ^~~~~~ /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/new:147:54: error: expected primary-expression before 'const' 147 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT | ^~~~~ /usr/include/c++/14/new:154:26: error: declaration of 'operator new' as non-function 154 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t) | ^~~~~~~~ /usr/include/c++/14/new:154:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 154 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t) | ^~~~~~ /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/new:154:68: error: expected primary-expression before ')' token 154 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t) | ^ /usr/include/c++/14/new:155:73: error: attributes after parenthesized initializer ignored [-fpermissive] 155 | __attribute__((__externally_visible__, __alloc_size__ (1), __malloc__)); | ^ /usr/include/c++/14/new:156:26: error: declaration of 'operator new' as non-function 156 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&) | ^~~~~~~~ /usr/include/c++/14/new:156:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 156 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&) | ^~~~~~ /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/new:156:68: error: expected primary-expression before ',' token 156 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&) | ^ /usr/include/c++/14/new:156:70: error: expected primary-expression before 'const' 156 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&) | ^~~~~ /usr/include/c++/14/new:162:26: error: declaration of 'operator new []' as non-function 162 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t) | ^~~~~~~~ /usr/include/c++/14/new:162:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 162 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t) | ^~~~~~ /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/new:162:70: error: expected primary-expression before ')' token 162 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t) | ^ /usr/include/c++/14/new:163:73: error: attributes after parenthesized initializer ignored [-fpermissive] 163 | __attribute__((__externally_visible__, __alloc_size__ (1), __malloc__)); | ^ /usr/include/c++/14/new:164:26: error: declaration of 'operator new []' as non-function 164 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&) | ^~~~~~~~ /usr/include/c++/14/new:164:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 164 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&) | ^~~~~~ /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/new:164:70: error: expected primary-expression before ',' token 164 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&) | ^ /usr/include/c++/14/new:164:72: error: expected primary-expression before 'const' 164 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&) | ^~~~~ /usr/include/c++/14/new:171:29: error: 'std::size_t' has not been declared 171 | void operator delete(void*, std::size_t, std::align_val_t) | ^~~ /usr/include/c++/14/new:173:31: error: 'std::size_t' has not been declared 173 | void operator delete[](void*, std::size_t, std::align_val_t) | ^~~ /usr/include/c++/14/new:179:33: error: declaration of 'operator new' as non-function 179 | _GLIBCXX_NODISCARD inline void* operator new(std::size_t, void* __p) _GLIBCXX_USE_NOEXCEPT |
s773988125
p04020
Java
import java.util.Scanner; public class B { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); long[] cards = new long[n]; for (int i = 0; i < n; i++) { cards[i] = sc.nextInt(); } int pairCount = 0; for (int i = 0; i < n; i++) { long prevMin = 0, nextMin = 0; long prevPair = 0, prevCurrentPair = 0, nextCurrentPair = 0, nextPair = 0; if (i > 0) { prevMin = Math.min(cards[i - 1], cards[i]); prevMin = prevMin > 0 ? prevMin : 0; prevPair = (cards[i - 1] - prevMin) / 2; prevCurrentPair = (cards[i] - prevMin) / 2; } if(i < n - 1) { nextMin = Math.min(cards[i], cards[i + 1]); nextMin = nextMin > 0 ? nextMin : 0; nextPair = (cards[i + 1] - nextMin) / 2; nextCurrentPair = (cards[i] - nextMin) / 2; } long prev = prevMin + prevPair + prevCurrentPair; long next = nextMin + nextPair + nextCurrentPair; if(prev == 0 && next == 0) continue; if (prev > next) { cards[i - 1] -= prevMin + prevPair * 2; cards[i] -= prevMin + prevCurrentPair * 2; pairCount += prev; } else if (next > prev) { cards[i] -= nextMin + nextCurrentPair * 2; cards[i + 1] -= nextMin + nextPair * 2; pairCount += next; } } if(n == 1) { pairCount = (int) (cards[0] / 2); } System.out.println(pairCount); } }
Main.java:3: error: class B is public, should be declared in a file named B.java public class B { ^ 1 error
s997744933
p04020
C++
#include<iostream> #include<queue> #include<cstring> #include<vector> using namespace std; typedef long long ll; int main() { int n; cin>>n; vector<ll> v; for(int i=0;i<n;i++) { ll a; cin>>a; v.push_back(a); } ll dp1[n+1]; ll dp2[n+1]; memset(dp1,0,sizeof(dp1)); memset(dp2,0,sizeof(dp2)); dp1[0]=v[0]/2; dp2[0]=0; for(int i=1;i<n;i++) { dp1[i]=max((dp1[i-1]+(v[i]/2)),(dp2[i-1]+(v[i]/2))); dp2[i]=max(dp2[i-1],((dp1[i-1]-(v[i-1]/2))+((v[i-1]+(v[i]/2)))); } cout<<max(dp1[n-1],dp2[n-1])<<endl; return 0; }
a.cc: In function 'int main()': a.cc:27:72: error: expected ')' before ';' token 27 | dp2[i]=max(dp2[i-1],((dp1[i-1]-(v[i-1]/2))+((v[i-1]+(v[i]/2)))); | ~ ^ | )
s254322890
p04020
C++
#include<cstdio> #include<cstring> long long int a[100010]; int main(){ int n long long int ans=0; scanf("%d",&n); for(int i=1;i<=n;i++){ scanf("%lld",&a[i]); if(a[i]!=0 && a[i]%2==0){ ans+=(a[i]/2-1); a[i]=2; } else if(a[i]!=0){ ans+=(a[i]/2); a[i]=1; } //printf("ans1:%d\n",ans); } int tmp=0; for(int i=1;i<n;i++){ if(a[i]==1 && (a[i+1]==1 || a[i+1]==2)){ ans++; a[i]--; a[i+1]--; } } //printf("ans2:%d\n",ans); for(int i=1;i<=n;i++){ if(a[i]==2){ ans++; a[i]=0; } } printf("%lld",ans); return 0; }
a.cc: In function 'int main()': a.cc:9:9: error: expected initializer before 'long' 9 | long long int ans=0; | ^~~~ a.cc:10:21: error: 'n' was not declared in this scope 10 | scanf("%d",&n); | ^ a.cc:14:25: error: 'ans' was not declared in this scope 14 | ans+=(a[i]/2-1); | ^~~ a.cc:18:25: error: 'ans' was not declared in this scope 18 | ans+=(a[i]/2); | ^~~ a.cc:27:25: error: 'ans' was not declared in this scope 27 | ans++; | ^~~ a.cc:37:25: error: 'ans' was not declared in this scope 37 | ans++; | ^~~ a.cc:41:23: error: 'ans' was not declared in this scope 41 | printf("%lld",ans); | ^~~
s467952214
p04020
Java
import java.util.Scanner; public class B { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); long[] cards = new long[n]; for (int i = 0; i < n; i++) { cards[i] = sc.nextInt(); } int pairCount = 0; for (int i = 0; i < n; i++) { long prevMin = 0, nextMin = 0; long prevPair = 0, prevCurrentPair = 0, nextCurrentPair = 0, nextPair = 0; if (i > 0) { prevMin = Math.min(cards[i - 1], cards[i]); prevMin = prevMin > 0 ? prevMin : 0; prevPair = (cards[i - 1] - prevMin) / 2; prevCurrentPair = (cards[i] - prevMin) / 2; } if(i < n - 1) { nextMin = Math.min(cards[i], cards[i + 1]); nextMin = nextMin > 0 ? nextMin : 0; nextPair = (cards[i + 1] - nextMin) / 2; nextCurrentPair = (cards[i] - nextMin) / 2; } long prev = prevMin + prevPair + prevCurrentPair; long next = nextMin + nextPair + nextCurrentPair; if(prev == 0 && next == 0) continue; if (prev > next) { cards[i - 1] -= prevMin + prevPair * 2; cards[i] -= prevMin + prevCurrentPair * 2; pairCount += prev; } else if (next > prev) { cards[i] -= nextMin + nextCurrentPair * 2; cards[i + 1] -= nextMin + nextPair * 2; pairCount += next; } } System.out.println(pairCount); } }
Main.java:3: error: class B is public, should be declared in a file named B.java public class B { ^ 1 error
s671574268
p04020
C++
//ここからテンプレート //#define PLASMA_NO_BOOST #if 1 #include<iostream> #include<list> #include<algorithm> #include<utility> #include<type_traits> #include<tuple> #include<memory> #include<iterator> #include<string> #include<functional> #include<list> #include<array> #include<complex> #include<numeric> #include<iomanip> #include<vector> #include<queue> #include<random> #include<map> #include<chrono> #include<stack> #include<set> #ifndef PLASMA_NO_BOOST #include<boost/optional.hpp> #include<boost/optional/optional_io.hpp> #include<boost/variant.hpp> #include<boost/range/adaptor/transformed.hpp> #include<boost/range/adaptor/indexed.hpp> #include<boost/range/adaptor/filtered.hpp> #include<boost/range/algorithm.hpp> #include<boost/range/irange.hpp> #include<boost/multi_array.hpp> #include<boost/preprocessor.hpp> #endif typedef long long int int64; typedef unsigned long long uint64; typedef long double double64; #ifdef PLASMA_NO_BOOST struct none_t {}; constexpr none_t none{}; template<class T>class optional { union inside_t { T value; none_t ignore; constexpr inside_t(T const& v) :value(v) {} constexpr inside_t(T&& v) : value(std::move(v)) {} constexpr inside_t(none_t) : ignore(none) {} constexpr inside_t() : ignore(none) {} constexpr inside_t(inside_t const&) = default; inside_t(inside_t&&) = default; inside_t& operator=(inside_t const&) = default; inside_t& operator=(inside_t&&) = default; ~inside_t() = default; }; inside_t inside; bool flag; public: void swap(optional&& v) { std::swap(this->inside, v.inside); std::swap(this->flag, v.flag); } void reset() { if (flag) { inside.value.~T(); inside.ignore = none; flag = false; } } constexpr optional(T const& v) :inside(v), flag(true) {} constexpr optional(T&& v) : inside(std::move(v)), flag(true) {} constexpr optional(none_t) : inside(), flag(false) {} constexpr optional() : inside(), flag(false) {} constexpr optional(optional const& v) : inside(v.inside), flag(v.flag) {} optional(optional&& v) : optional() { swap(std::move(v)); } optional& operator=(optional const& v) { this->inside = v.inside; this->flag = v.flag; return *this; } optional& operator=(optional&& v) { swap(std::move(v)); v.reset(); return *this; } optional& operator=(T const& v) { reset(); inside.value = v; flag = true; return *this; } optional& operator=(T&& v) { reset(); inside.value = std::move(v); flag = true; return *this; } optional& operator=(none_t) { reset(); return *this; } constexpr operator bool()const { return flag; } constexpr T const& operator*()const { return flag ? inside.value : throw std::domain_error("optional error: dont have value"); } }; template<class T>constexpr optional<typename std::remove_reference<typename std::remove_const<T>::type>::type>make_optional(T&& v) { return optional<std::remove_reference_t<std::remove_const_t<T>>>(std::forward<T>(v)); } #else using boost::optional; using boost::none_t; using boost::none; #endif #ifndef PLASMA_NO_BOOST namespace adaptor { using namespace boost::adaptors; } namespace algorithm { using namespace boost::range; template<class SinglePassRange, class Pred>bool any_of(SinglePassRange const& range, Pred pred) { return std::any_of(std::begin(range), std::end(range), pred); } template<class SinglePassRange, class Pred>bool all_of(SinglePassRange const& range, Pred pred) { return std::all_of(std::begin(range), std::end(range), pred); } } #endif namespace math { template<class T>constexpr T pow(T p, int n) { return n == 0 ? T(1) : n == 1 ? p : n == 2 ? p*p : n % 2 == 0 ? pow(pow(p, n / 2), 2) : pow(pow(p, n / 2), 2)*p; } int log(long long int p, int n) { int64 t = n; for (int i = 0;;++i) { if (t > p) return i; t *= n; } } constexpr double pi = 3.141592653589793; namespace detail { int gcd(int larger, int less) { return less == 0 ? larger : gcd(less, larger%less); } } int gcd(int lhs, int rhs) { return lhs < rhs ? detail::gcd(rhs, lhs) : detail::gcd(lhs, rhs); } void fourier_transform( std::vector<std::complex<double>>& vec, std::size_t N) { std::vector<std::complex<double>> butterfly; vec.resize(N); butterfly.resize(N); std::complex<double> half(std::cos(pi), std::sin(pi)); for (uint64 i = 1, k = N / 2;i < N;[&]() {i *= 2;k /= 2;}())//i*k == N/4 { std::complex<double> circle(std::cos(pi / i), std::sin(pi / i)); std::complex<double> c(1.0, 0); for (auto count = 0ull; count < i;++count) { for (auto j = 0ull;j < k;++j) { butterfly[count*k + j] = vec[2 * count*k + j] + vec[2 * count*k + j + k] * c; butterfly[count*k + j + N / 2] = vec[2 * count*k + j] + vec[2 * count*k + j + k] * c*half; } c *= circle; } std::swap(vec, butterfly); } } class polynomial { std::vector<std::complex<double>> value; void swap(polynomial&& p) { std::swap(value, p.value); } public: polynomial() :value{ 0.0 } {} polynomial(polynomial const&) = default; polynomial(std::vector<std::complex<double>>&& vec) :value(std::move(vec)) {} polynomial(polynomial&& p) :polynomial() { swap(std::move(p)); } polynomial(std::initializer_list<std::complex<double>> lis) :value(lis) {} polynomial(std::complex<double> c) :polynomial({ c }) {} polynomial& operator=(polynomial const&) = default; polynomial& operator=(polynomial&& p) { value = std::vector<std::complex<double>>{ 0.0 }; swap(std::move(p)); return *this; } ~polynomial() = default; std::complex<double> operator[](std::size_t deg)const { return deg >= value.size() ? 0.0 : value[deg]; } std::size_t degree()const { return value.size() - 1; } void strict_degree_set() { std::size_t N = degree(); for (;N > 0;--N) { if (value[N] != 0.0) break; } value.resize(N + 1); } void integer_degree_set() { std::size_t N = degree(); for (;N > 0;--N) { std::cout << value[N] << " " << (std::norm(value[N]) > (1.0e-20)) << std::endl; if (std::norm(value[N]) > (1.0e-20)) break; } value.resize(N + 1); } friend polynomial operator*(polynomial const& lhs, polynomial const& rhs) { std::size_t N = 1; while (true) { N *= 2; if (N > (lhs.degree() + rhs.degree())) break; } auto lhs_ = lhs.value; auto rhs_ = rhs.value; fourier_transform(lhs_, N); fourier_transform(rhs_, N); std::vector<std::complex<double>> vec; vec.reserve(N); for (std::size_t i = 0;i < N;++i) { vec.push_back(lhs_[i] * rhs_[i]); } for (auto& v : vec) { v = 2 * v.real() - v; } fourier_transform(vec, N); for (auto& v : vec) { v = (2 * v.real() - v)*(1.0 / N); } std::size_t k = N; for (;k > 0;--k) { if (std::norm(vec[k]) > 1.0e-23) break; } vec.resize(k + 1); return polynomial(std::move(vec)); } }; int real_integer(std::complex<double> c) { int v = static_cast<int>(c.real()); double u = c.real() - v; return v + static_cast<int>(2 * u); } template<class T>polynomial make_poly(std::vector<T> const& vec) { auto range = vec | adaptor::transformed([](T const& v) {return static_cast<std::complex<double>>(v);}); std::vector<std::complex<double>> ret(std::begin(range), std::end(range)); return polynomial(std::move(ret)); } polynomial make_poly(std::initializer_list<double>init) { std::vector<std::complex<double>> vec; for (auto v : init) { vec.emplace_back(v); } return polynomial(std::move(vec)); } polynomial make_poly(std::initializer_list<int> init) { std::vector<std::complex<double>> vec; for (auto v : init) { vec.emplace_back(v); } return polynomial(std::move(vec)); } template<class T>class infinite_value { optional<T> val; public: infinite_value(T const& v) :val(v) {} infinite_value(T&& v) :val(std::move(v)) {} infinite_value(none_t = none) :val() {} infinite_value(infinite_value const&) = default; infinite_value(infinite_value&&) = default; ~infinite_value() = default; infinite_value& operator=(T const& v) { val = v; return *this; } infinite_value& operator=(T&& v) { val = std::move(v); return *this; } infinite_value& operator=(none_t) { val = boost::none; return *this; } infinite_value& operator=(infinite_value const&) = default; infinite_value& operator=(infinite_value&&) = default; operator bool()const { return static_cast<bool>(val); } T const& operator*()const { return *val; } friend infinite_value operator+(infinite_value const& lhs, infinite_value const& rhs) { return lhs&&rhs ? infinite_value<T>(*lhs + *rhs) : infinite_value<T>(none); } friend infinite_value operator+(infinite_value const& lhs, T const& rhs) { return lhs ? infinite_value<T>(*lhs + rhs) : infinite_value<T>(none); } friend infinite_value operator+(T const& lhs, infinite_value const& rhs) { return lhs&&rhs ? infinite_value<T>(*lhs + *rhs) : infinite_value<T>(none); } friend bool operator==(infinite_value const& lhs, infinite_value const& rhs) { return (!lhs && !rhs) || (lhs&&rhs && (*lhs == *rhs)); } friend bool operator==(infinite_value const& lhs, T const& rhs) { return lhs && (*lhs == rhs); } friend bool operator==(T const& lhs, infinite_value const& rhs) { return rhs && (lhs == *rhs); } friend bool operator<(infinite_value const& lhs, infinite_value const& rhs) { return !lhs ? false : !rhs ? true : *lhs < *rhs; } friend bool operator<(infinite_value const& lhs, T const& rhs) { return !lhs ? false : *lhs < rhs; } friend bool operator<(T const& lhs, infinite_value const& rhs) { return !rhs ? true : lhs < *rhs; } friend bool operator<=(infinite_value const& lhs, infinite_value const& rhs) { return (lhs < rhs) || (lhs == rhs); } friend bool operator<=(infinite_value const& lhs, T const& rhs) { return (lhs < rhs) || (lhs == rhs); } friend bool operator<=(T const& lhs, infinite_value const& rhs) { return (lhs < rhs) || (lhs == rhs); } friend bool operator>(infinite_value const& lhs, infinite_value const& rhs) { return !rhs ? false : !lhs ? true : *lhs > *rhs; } friend bool operator>(infinite_value const& lhs, T const& rhs) { return !lhs ? true : *lhs > rhs; } friend bool operator>(T const& lhs, infinite_value const& rhs) { return !rhs ? false : lhs > *rhs; } friend bool operator>=(infinite_value const& lhs, infinite_value const& rhs) { return (lhs > rhs) || (lhs == rhs); } friend bool operator>=(infinite_value const& lhs, T const& rhs) { return (lhs > rhs) || (lhs == rhs); } friend bool operator>=(T const& lhs, infinite_value const& rhs) { return (lhs > rhs) || (lhs == rhs); } }; template<std::size_t Mod>class modulo_number { uint64 val = {}; static constexpr uint64 abs(int64 n) { return n <= -1 ? n + Mod : n; } public: modulo_number(modulo_number const&) = default; modulo_number(modulo_number&&) = default; modulo_number& operator=(modulo_number const&) = default; modulo_number& operator=(modulo_number&&) = default; ~modulo_number() = default; constexpr modulo_number(uint64 num = {}) : val(num%Mod) {} constexpr modulo_number(unsigned int num) : val(num%Mod) {} constexpr modulo_number(int64 num) : val(abs(num%Mod)) {} constexpr modulo_number(int num) : val(abs(num%Mod)) {} modulo_number& operator=(uint64 num) { val = num%Mod; return *this; } modulo_number& operator=(int64 num) { val = abs(num%Mod); return *this; } modulo_number& operator=(unsigned int num) { val = num%Mod; return *this; } modulo_number& operator=(int num) { val = abs(num%Mod); return *this; } constexpr uint64 get()const { return val; } friend constexpr modulo_number<Mod> operator+(modulo_number<Mod>const& lhs, modulo_number<Mod>const& rhs) { return modulo_number<Mod>((lhs.val + rhs.val) % Mod); } friend constexpr modulo_number<Mod> operator+(modulo_number<Mod>const& lhs, int const& rhs) { return lhs + modulo_number<Mod>(rhs); } friend constexpr modulo_number<Mod> operator+(modulo_number<Mod>const& lhs, unsigned int const& rhs) { return lhs + modulo_number<Mod>(rhs); } friend constexpr modulo_number<Mod> operator+(modulo_number<Mod>const& lhs, int64 const& rhs) { return lhs + modulo_number<Mod>(rhs); } friend constexpr modulo_number<Mod> operator+(modulo_number<Mod>const& lhs, uint64 const& rhs) { return lhs + modulo_number<Mod>(rhs); } friend constexpr modulo_number<Mod> operator+(int const& lhs, modulo_number<Mod>const& rhs) { return modulo_number<Mod>(lhs) + rhs; } friend constexpr modulo_number<Mod> operator+(unsigned int const& lhs, modulo_number<Mod>const& rhs) { return modulo_number<Mod>(lhs) + rhs; } friend constexpr modulo_number<Mod> operator+(int64 const& lhs, modulo_number<Mod>const& rhs) { return modulo_number<Mod>(lhs) + rhs; } friend constexpr modulo_number<Mod> operator+(uint64 const& lhs, modulo_number<Mod>const& rhs) { return modulo_number<Mod>(lhs) + rhs; } friend constexpr modulo_number<Mod> operator-(modulo_number<Mod>const& lhs, modulo_number<Mod>const& rhs) { return modulo_number<Mod>((lhs.val + Mod - rhs.val) % Mod); } friend constexpr modulo_number<Mod> operator-(modulo_number<Mod>const& lhs, int const& rhs) { return lhs - modulo_number<Mod>(rhs); } friend constexpr modulo_number<Mod> operator-(modulo_number<Mod>const& lhs, unsigned int const& rhs) { return lhs - modulo_number<Mod>(rhs); } friend constexpr modulo_number<Mod> operator-(modulo_number<Mod>const& lhs, int64 const& rhs) { return lhs - modulo_number<Mod>(rhs); } friend constexpr modulo_number<Mod> operator-(modulo_number<Mod>const& lhs, uint64 const& rhs) { return lhs - modulo_number<Mod>(rhs); } friend constexpr modulo_number<Mod> operator-(int const& lhs, modulo_number<Mod>const& rhs) { return modulo_number<Mod>(lhs) - rhs; } friend constexpr modulo_number<Mod> operator-(unsigned int const& lhs, modulo_number<Mod>const& rhs) { return modulo_number<Mod>(lhs) - rhs; } friend constexpr modulo_number<Mod> operator-(int64 const& lhs, modulo_number<Mod>const& rhs) { return modulo_number<Mod>(lhs) - rhs; } friend constexpr modulo_number<Mod> operator-(uint64 const& lhs, modulo_number<Mod>const& rhs) { return modulo_number<Mod>(lhs) - rhs; } friend constexpr modulo_number<Mod> operator*(modulo_number<Mod>const& lhs, modulo_number<Mod>const& rhs) { return modulo_number<Mod>((lhs.val*rhs.val) % Mod); } friend constexpr modulo_number<Mod> operator*(modulo_number<Mod>const& lhs, int const& rhs) { return lhs * modulo_number<Mod>(rhs); } friend constexpr modulo_number<Mod> operator*(modulo_number<Mod>const& lhs, unsigned int const& rhs) { return lhs * modulo_number<Mod>(rhs); } friend constexpr modulo_number<Mod> operator*(modulo_number<Mod>const& lhs, int64 const& rhs) { return lhs * modulo_number<Mod>(rhs); } friend constexpr modulo_number<Mod> operator*(modulo_number<Mod>const& lhs, uint64 const& rhs) { return lhs * modulo_number<Mod>(rhs); } friend constexpr modulo_number<Mod> operator*(int const& lhs, modulo_number<Mod>const& rhs) { return modulo_number<Mod>(lhs) * rhs; } friend constexpr modulo_number<Mod> operator*(unsigned int const& lhs, modulo_number<Mod>const& rhs) { return modulo_number<Mod>(lhs) * rhs; } friend constexpr modulo_number<Mod> operator*(int64 const& lhs, modulo_number<Mod>const& rhs) { return modulo_number<Mod>(lhs) * rhs; } friend constexpr modulo_number<Mod> operator*(uint64 const& lhs, modulo_number<Mod>const& rhs) { return modulo_number<Mod>(lhs) * rhs; } friend constexpr modulo_number<Mod> operator/(modulo_number<Mod>const& lhs, modulo_number<Mod>const& rhs) { return lhs*math::pow(rhs, Mod - 2); } friend constexpr modulo_number<Mod> operator/(modulo_number<Mod>const& lhs, int const& rhs) { return lhs / modulo_number<Mod>(rhs); } friend constexpr modulo_number<Mod> operator/(modulo_number<Mod>const& lhs, unsigned int const& rhs) { return lhs / modulo_number<Mod>(rhs); } friend constexpr modulo_number<Mod> operator/(modulo_number<Mod>const& lhs, int64 const& rhs) { return lhs / modulo_number<Mod>(rhs); } friend constexpr modulo_number<Mod> operator/(modulo_number<Mod>const& lhs, uint64 const& rhs) { return lhs / modulo_number<Mod>(rhs); } friend constexpr modulo_number<Mod> operator/(int const& lhs, modulo_number<Mod>const& rhs) { return modulo_number<Mod>(lhs) / rhs; } friend constexpr modulo_number<Mod> operator/(unsigned int const& lhs, modulo_number<Mod>const& rhs) { return modulo_number<Mod>(lhs) / rhs; } friend constexpr modulo_number<Mod> operator/(int64 const& lhs, modulo_number<Mod>const& rhs) { return modulo_number<Mod>(lhs) / rhs; } friend constexpr modulo_number<Mod> operator/(uint64 const& lhs, modulo_number<Mod>const& rhs) { return modulo_number<Mod>(lhs) / rhs; } template<class Rhs>decltype(auto) operator+=(Rhs const& rhs) { return *this = *this + rhs; } template<class Rhs>decltype(auto) operator*=(Rhs const& rhs) { return *this = *this * rhs; } template<class Rhs>decltype(auto) operator-=(Rhs const& rhs) { return *this = *this - rhs; } template<class Rhs>decltype(auto) operator/=(Rhs const& rhs) { return *this = *this / rhs; } }; template<class T>constexpr T factorial(std::size_t n, std::size_t goal = 1) { return n == goal ? T(n) : n == 0 ? T(1) : factorial<T>(n, (n + goal) / 2 + 1)*factorial<T>((n + goal) / 2, goal); } namespace detail { constexpr uint64 integral_sqrt_i(uint64 v, uint64 start, uint64 end) { return start == end ? start : pow((start + end) / 2 + 1, 2) <= v ? integral_sqrt_i(v, (start + end) / 2 + 1, end) : integral_sqrt_i(v, start, (start + end) / 2); } } constexpr uint64 integral_sqrt(uint64 v) { return v == 0 ? 0 : v == 1 ? 1 : detail::integral_sqrt_i(v, 1, 0b100000000000000000000000000000000ull); } namespace detail { constexpr bool is_prime_i(uint64 v, uint64 start, uint64 end) { return start == end ? v%end != 0 : is_prime_i(v, start, (start + end) / 2) && is_prime_i(v, (start + end) / 2 + 1, end); } } constexpr bool is_prime(uint64 v) { return v == 0 ? false : v == 1 ? false : v == 2 ? true : v == 3 ? true : detail::is_prime_i(v, 2, integral_sqrt(v)); } class dynamic_modulo { uint64 value; uint64 mod; static constexpr uint64 abs(int64 v, uint64 mod) { return v <= -1 ? v + mod : v; } public: constexpr dynamic_modulo() :value(), mod(2) {} constexpr dynamic_modulo(uint64 v, uint64 m) : value(v), mod(m) {} dynamic_modulo(dynamic_modulo const&) = default; dynamic_modulo(dynamic_modulo&&) = default; dynamic_modulo& operator=(dynamic_modulo const&) = default; dynamic_modulo& operator=(dynamic_modulo&&) = default; ~dynamic_modulo() = default; constexpr uint64 get()const { return value; } constexpr friend auto operator+(dynamic_modulo const& lhs, dynamic_modulo const& rhs) { return lhs.mod != rhs.mod ? throw std::logic_error("math::dynamic_modulo mod number error") : dynamic_modulo((lhs.value + rhs.value) % lhs.mod, lhs.mod); } constexpr friend auto operator+(dynamic_modulo const& lhs, uint64 const& rhs) { return dynamic_modulo((lhs.value + rhs) % lhs.mod, lhs.mod); } constexpr friend auto operator+(dynamic_modulo const& lhs, int64 const& rhs) { return dynamic_modulo(abs((lhs.value + rhs) % lhs.mod, lhs.mod), lhs.mod); } constexpr friend auto operator+(dynamic_modulo const& lhs, unsigned int const& rhs) { return dynamic_modulo((lhs.value + rhs) % lhs.mod, lhs.mod); } constexpr friend auto operator+(dynamic_modulo const& lhs, int const& rhs) { return dynamic_modulo(abs((lhs.value + rhs) % lhs.mod, lhs.mod), lhs.mod); } constexpr friend auto operator+(uint64 const& rhs, dynamic_modulo const& lhs) { return dynamic_modulo((lhs.value + rhs) % lhs.mod, lhs.mod); } constexpr friend auto operator+(int64 const& rhs, dynamic_modulo const& lhs) { return dynamic_modulo(abs((lhs.value + rhs) % lhs.mod, lhs.mod), lhs.mod); } constexpr friend auto operator+(unsigned int const& rhs, dynamic_modulo const& lhs) { return dynamic_modulo((lhs.value + rhs) % lhs.mod, lhs.mod); } constexpr friend auto operator+(int const& rhs, dynamic_modulo const& lhs) { return dynamic_modulo(abs((lhs.value + rhs) % lhs.mod, lhs.mod), lhs.mod); } constexpr friend auto operator*(dynamic_modulo const& lhs, dynamic_modulo const& rhs) { return lhs.mod != rhs.mod ? throw std::logic_error("math::dynamic_modulo mod number error") : dynamic_modulo((lhs.value * rhs.value) % lhs.mod, lhs.mod); } constexpr friend auto operator*(dynamic_modulo const& lhs, uint64 const& rhs) { return dynamic_modulo((lhs.value * rhs) % lhs.mod, lhs.mod); } constexpr friend auto operator*(dynamic_modulo const& lhs, int64 const& rhs) { return dynamic_modulo(abs((lhs.value * rhs) % lhs.mod, lhs.mod), lhs.mod); } constexpr friend auto operator*(dynamic_modulo const& lhs, unsigned int const& rhs) { return dynamic_modulo((lhs.value * rhs) % lhs.mod, lhs.mod); } constexpr friend auto operator*(dynamic_modulo const& lhs, int const& rhs) { return dynamic_modulo(abs((lhs.value * rhs) % lhs.mod, lhs.mod), lhs.mod); } constexpr friend auto operator*(uint64 const& rhs, dynamic_modulo const& lhs) { return dynamic_modulo((lhs.value * rhs) % lhs.mod, lhs.mod); } constexpr friend auto operator*(int64 const& rhs, dynamic_modulo const& lhs) { return dynamic_modulo(abs((lhs.value * rhs) % lhs.mod, lhs.mod), lhs.mod); } constexpr friend auto operator*(unsigned int const& rhs, dynamic_modulo const& lhs) { return dynamic_modulo((lhs.value * rhs) % lhs.mod, lhs.mod); } constexpr friend auto operator*(int const& rhs, dynamic_modulo const& lhs) { return dynamic_modulo(abs((lhs.value * rhs) % lhs.mod, lhs.mod), lhs.mod); } constexpr friend auto operator-(dynamic_modulo const& lhs, dynamic_modulo const& rhs) { return lhs.mod != rhs.mod ? throw std::logic_error("math::dynamic_modulo mod number error") : dynamic_modulo(abs((lhs.value - rhs.value) % lhs.mod, lhs.mod), lhs.mod); } constexpr friend auto operator-(dynamic_modulo const& lhs, uint64 const& rhs) { return dynamic_modulo(abs((lhs.value - rhs) % lhs.mod, lhs.mod), lhs.mod); } constexpr friend auto operator-(dynamic_modulo const& lhs, int64 const& rhs) { return dynamic_modulo(abs((lhs.value - rhs) % lhs.mod, lhs.mod), lhs.mod); } constexpr friend auto operator-(dynamic_modulo const& lhs, unsigned int const& rhs) { return dynamic_modulo(abs((lhs.value - rhs) % lhs.mod, lhs.mod), lhs.mod); } constexpr friend auto operator-(dynamic_modulo const& lhs, int const& rhs) { return dynamic_modulo(abs((lhs.value - rhs) % lhs.mod, lhs.mod), lhs.mod); } constexpr friend auto operator-(uint64 const& rhs, dynamic_modulo const& lhs) { return dynamic_modulo(abs((lhs.value - rhs) % lhs.mod, lhs.mod), lhs.mod); } constexpr friend auto operator-(int64 const& rhs, dynamic_modulo const& lhs) { return dynamic_modulo(abs((lhs.value - rhs) % lhs.mod, lhs.mod), lhs.mod); } constexpr friend auto operator-(unsigned int const& rhs, dynamic_modulo const& lhs) { return dynamic_modulo(abs((lhs.value - rhs) % lhs.mod, lhs.mod), lhs.mod); } constexpr friend auto operator-(int const& rhs, dynamic_modulo const& lhs) { return dynamic_modulo(abs((lhs.value - rhs) % lhs.mod, lhs.mod), lhs.mod); } template<class Rhs>dynamic_modulo& operator+=(Rhs const& rhs) { return *this = *this + rhs; } template<class Rhs>dynamic_modulo& operator-=(Rhs const& rhs) { return *this = *this - rhs; } template<class Rhs>dynamic_modulo& operator*=(Rhs const& rhs) { return *this = *this * rhs; } }; } namespace geometry { template<class Type>struct point { Type x, y; }; template<class Type>auto make_point(Type x, Type y) { return point<Type>{x, y}; } template<class Type>auto operator+(point<Type>const& lhs, point<Type>const& rhs) { return make_point(lhs.x + rhs.x, lhs.y + rhs.y); } template<class Type>auto operator-(point<Type>const& lhs, point<Type>const& rhs) { return make_point(lhs.x - rhs.x, lhs.y - rhs.y); } template<class Point>struct box { Point small, large; }; template<class Point>auto make_box(Point a, Point b) { return box<Point>{ make_point(std::min(a.x, b.x), std::min(a.y, b.y)), make_point(std::max(a.x, b.x), std::max(a.y, b.y))}; } #ifndef PLASMA_NO_BOOST template<class Point>boost::optional<box<Point>> hit_check(box<Point> a, box<Point> b) { if (a.small.x > b.small.x) std::swap(a, b); if (a.large.x < b.small.x) return boost::none; auto small_x = b.small.x; auto large_x = std::min(b.large.x, a.large.x); if (a.small.y < b.small.y) { if (b.small.y < a.large.y) return make_box( make_point(small_x, b.small.y), make_point(large_x, std::min(a.large.y, b.large.y))); else return boost::none; } else { if (a.small.y < b.large.y) return make_box( make_point(small_x, a.small.y), make_point(large_x, std::min(a.large.y, b.large.y))); else return boost::none; } } #endif } namespace graph_traits { class graph { std::vector<int64> node_data; std::vector<std::vector<std::pair<int, int64>>> edge_data; public: graph() = default; graph(std::vector<int64>&& n) :node_data(std::move(n)), edge_data{} { edge_data.resize(node_data.size()); } graph(std::size_t size) :node_data(size), edge_data{} { } void resize(int size) { node_data.resize(size); edge_data.resize(size); } void edge_reserve(int size) { for (auto& v : edge_data) { v.reserve(size); } } void add_node(int64 data) { node_data.emplace_back(data); edge_data.emplace_back(); } void add_edge(int from, int to, int64 data) { edge_data[from].emplace_back(to, data); } std::vector<math::infinite_value<int64>> dijkstra(int from)const { struct compare { bool operator()( std::pair<int, math::infinite_value<int64>>const& lhs, std::pair<int, math::infinite_value<int64>>const& rhs)const { return lhs.second > rhs.second; } }; std::priority_queue< std::pair<int, math::infinite_value<int64>>, std::vector<std::pair<int, math::infinite_value<int64>>>, compare>nodes; std::vector<math::infinite_value<int64>> ret(node_data.size()); for (int i{};i < node_data.size();++i) { nodes.emplace(i, math::infinite_value<int64>()); } nodes.emplace(from, int()); while (nodes.size()) { auto p = nodes.top(); nodes.pop(); if (ret[p.first] <= p.second) continue; ret[p.first] = p.second; for (auto const& d : edge_data[p.first]) { nodes.emplace(d.first, std::min(ret[d.first], ret[p.first] + d.second)); } } return ret; } int64 operator[](int n)const { return node_data[n]; } }; } namespace container { template<class T>using p_queue = std::priority_queue<T, std::vector<T>, std::greater<T>>; } void Main(std::integral_constant<int, 1>); void Main(std::integral_constant<int, 2>); void Main(std::integral_constant<int, 3>); void Main(std::integral_constant<int, 4>); void Main(std::integral_constant<int, 5>); #endif//テンプレートここまで //ここを書き換える constexpr int problem = 2; //ここは書き換えない int main() { std::cin.sync_with_stdio(false); std::cout << std::setprecision(std::numeric_limits<long double>::digits10 + 1); Main(std::integral_constant<int, problem>{}); } void Main(std::integral_constant<int, 1>) { std::string str; std::cin >> str; bool count[4] = {}; for (int i{};i < str.size();++i) { if (str[i] == 'N') { count[0] = true; } else if (str[i] == 'W') { count[1] = true; } else if (str[i] == 'S') { count[2] = true; } else if (str[i] == 'E') { count[3] = true; } } if (count[0] ^ count[2]) { std::cout << "No" << std::endl; } else if (count[1] ^ count[3]) { std::cout << "No" << std::endl; } else { std::cout << "Yes" << std::endl; } } void Main(std::integral_constant<int, 2>) { int N; std::cin >> N; std::vector<int> data(N); for (auto& v : data) { std::cin >> v; } int64 count{}; for (int i{};i < N - 1;++i) { auto c = std::min(data[i], data[i + 1]); count += c; data[i] -= c; data[i + 1] -= c; } for (auto const& v : data) { count += v / 2; } std::cout << count << std::endl; } void Main(std::integral_constant<int, 3>) { int N; std::cin >> N; std::vector<std::pair<int, int>> vec(N); int index{}; for (auto& v : vec) { std::cin >> v.first; v.second = index++; } algorithm::sort(vec); int count{}; for (int i{};i < vec.size();i += 2) { if (vec[i].second % 2 == 1) { ++count; } } std::cout << count << std::endl; } void Main(std::integral_constant<int, 4>) { std::vector<int> primes = { 2,3,5,7 }; for (int i = 11;i < 100000;i += 2) { for (auto p : primes) { if (i < p*p) { break; } if (i%p) { goto next; } } primes.emplace_back(i); next:; } int N; std::cin >> N; std::vector<int> vec(N); for (auto& v : vec) { std::cin >> v; } std::vector<std::vector<std::pair<int, int>>> factor(N); for (int i{};i < N;++i) { auto v = vec[i]; for (auto p : primes) { if (v == 1) { break; } if (v < p*p) { factor[i].emplace_back(v, 1); break; } if (v%p == 0) { factor.emplace_back(p, 0); while (v%p == 0) { v /= p; ++(factor[i].back().second); } } } } } void Main(std::integral_constant<int, 5>) { }
a.cc:29:9: fatal error: boost/optional.hpp: No such file or directory 29 | #include<boost/optional.hpp> | ^~~~~~~~~~~~~~~~~~~~ compilation terminated.
s784502730
p04020
C++
#include <sstream> #include <string> #include <vector> #include <algorithm> #include <numeric> #include <set> #include <map> #include <queue> #include <iostream> #include <cstdio> #include <cmath> #include <cstring> using namespace std; int main(){ int N,ret=0; long long int tmp; vector<long long int> A; cin>>N; for(int i=0;i<N;i++){ cin>>tmp; A.push_back(tmp); } for(int i=0;i<N;i++){ for(int j=0;j<N;j++){ if(j>0 && A[j]>0 && A[j-1]>0){ if(A[j-1]>A[j]){ ret+=A[j]; A[j-1]-=A[j]; A[j]=0; }else{ ret+=A[j-1]; A[j]-=A[j-1]; A[j-1]=0; } }else if(A[j]>1){ if(A[j]%2==0){ ret+=A[j]/2; A[j]=0; }else { ret+=(A[j]-1)/2; A[j]=1; } }else if(j<N-1 && A[j]>0 && A[j+1]>0){ if(A[j+1]>A[j]){ ret+=A[j]; A[j+1]-=A[j]; A[j]=0; }else{ ret+=A[j+1]; A[j]-=A[j+1]; A[j+1]=0; } } } cout<<ret<<endl; return 0; }
a.cc: In function 'int main()': a.cc:65:2: error: expected '}' at end of input 65 | } | ^ a.cc:16:11: note: to match this '{' 16 | int main(){ | ^
s079693158
p04020
Java
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; import java.math.*; public class Main { public static void main(String[] args)throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringBuilder sb = new StringBuilder(); int n = Integer.parseInt(br.readLine()); long cnt = 0; int[] a = new int[n]; for(int i = 0; i < n; i++){ long v = Long.parseLong(br.readLine()); if(v==0){ a[i] = 0; continue; } long e = v%2==0 ? v/2 -1 : v/2; cnt += e; a[i] = v-e*2; } for(int i = 1; i < n-1; i++){ int v1 = a[i-1]; int v2 = a[i]; int v3 = a[i+1]; if(v1==1 && v2==1){ a[i-1]--; a[i]--; cnt++; }else if(v2==1 && v3==1){ a[i]--; a[i+1]--; cnt++; }else if(v1==1 && v2==2 && v3==1){ a[i-1]--; a[i]-=2; a[i+1]--; cnt+=2; } } for(int i = 0; i < n; i++){ if(a[i]==2) cnt++; } sb.append(cnt); System.out.println(sb); } }
Main.java:22: error: incompatible types: possible lossy conversion from long to int a[i] = v-e*2; ^ 1 error
s077470554
p04020
C
#include<stdio.h> int main(void){ int i=0,j=0; int x=0,y[10000000000]; scanf("%d",&x); for (j= 1; j<= x; ++j) { scanf("%d",&y[j]) } for (i = 1; i <= x; ++i) { j+=y[i]/2;y[i+1]=y[i]%2; } printf("%d\n",j); return 0; }
main.c: In function 'main': main.c:10:34: error: expected ';' before '}' token 10 | scanf("%d",&y[j]) | ^ | ; 11 | } | ~
s040122631
p04020
C++
#include <bits/stdc++.h> using namespace std; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<string> vs; typedef vector<bool> vb; typedef vector<vb> vvb; typedef pair<int, int> pii; typedef long long ll; typedef unsigned long long ull; #define all(a) (a).begin(),(a).end() #define rall(a) (a).rbegin(), (a).rend() #define pb push_back #define mp make_pair #define loop(i,a,b) for(ull i=(a);i<ull(b);++i) #define rep(i,n) loop(i,0,n) #define iter(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i) #define riter(i,c) for(auto i=(c).rbegin(); i!=(c).rend(); ++i) const double eps = 1e-10; const double pi = acos(-1.0); const double inf = (int)1e8; #define clr(a,i) memset((a), (i) ,sizeof(a)) int main(){ long long n,ans=0; std::cin >> n; std::vector<long long> v; a(n); rep(i,n){ std::cin >> a[i]; } long long tmp=0; rep(i,n){ if(a[i]==0){ ans+=tmp/2; tmp=0; }else{ tmp+=a[i]; } } ans+=tmp/2; // rep(i,n-1){ // if(a[i]%2==1&&a[i+1]%2==1){ // ans++; // a[i]--;a[i+1]--; // } // } // rep(i,n-1){ // if(a[i]%2==1&&a[i+1]>1){ // a[i]--;a[i+1]--; // ans++; // } // } // // rep(i,n-2){ // // if(a[i]%2==1&&a[i+2]%2==1&&a[i+1]>1){ // // a[i]--;a[i+1]-=2;a[i+2]--; // // ans+=2; // // } // // } // rep(i,n){ // if(a[i]>1) { // ans+=a[i]/2; // a[i]=a[i]%2; // } // } std::cout << ans << std::endl; }
a.cc: In function 'int main()': a.cc:31:29: error: 'a' was not declared in this scope 31 | std::vector<long long> v; a(n); | ^
s600117957
p04020
Java
import java.util.Scanner; public class B { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); long[] cards = new long[n]; for (int i = 0; i < n; i++) { cards[i] = sc.nextInt(); } int pairCount = 0; for (int i = 0; i < n; i++) { long prevMin = 0, nextMin = 0; long prevPair = 0, prevCurrentPair = 0, nextCurrentPair = 0, nextPair = 0; if (i > 0) { prevMin = Math.min(cards[i - 1], cards[i]); prevMin = prevMin > 0 ? prevMin : 0; prevPair = (cards[i - 1] - prevMin) / 2; prevCurrentPair = (cards[i] - prevMin) / 2; } else if(i < n - 1) { nextMin = Math.min(cards[i], cards[i + 1]); nextMin = nextMin > 0 ? nextMin : 0; nextPair = (cards[i + 1] - nextMin) / 2; nextCurrentPair = (cards[i] - nextMin) / 2; } long prev = prevMin + prevPair + prevCurrentPair; long next = nextMin + nextPair + nextCurrentPair; if (prev >= next) { cards[i - 1] -= prevMin + prevPair * 2; cards[i] -= prevMin + prevCurrentPair * 2; pairCount += prev; } else if (next > prev) { cards[i] -= nextMin + nextCurrentPair * 2; cards[i + 1] -= nextMin + nextPair * 2; pairCount += next; } } System.out.println(pairCount); } }
Main.java:3: error: class B is public, should be declared in a file named B.java public class B { ^ 1 error
s056785172
p04020
C++
//VS2015エラー回避用 #define _CRT_SECURE_NO_WARNINGS 0 //include #include<stdio.h> #include<stdlib.h> //関数プロトタイプ宣言 void probremA(void); void probremB(void); void probremC(void); void probremD(void); //メイン関数 int main(void) { //A問題 //probremA(); //B問題 probremB(); //C問題 //probremC(); //D問題 //probremD(); // getchar(); // getchar(); //終了 return 0; } //A問題 void probremA(void) { char s[1001]; //入力文字列 int pos[4] = {0,0,0,0}; //場所:N,S,E,W int count = 0; //ループ用カウンタ //入力処理 scanf("%s", s); //個数の計算 while(s[count]!='\0') { // if (s[count] == 'N') { pos[0]=1; }else if (s[count] == 'S') { pos[1]=1; }else if (s[count] == 'E') { pos[2]=1; }else if (s[count] == 'W') { pos[3]=1; } //カウンタを増やす count++; } //出力処理 if (pos[0] == 1 && pos[1] == 1 && pos[2] == 1 && pos[3] == 1) { printf("Yes"); }else if (pos[0] == 1 && pos[1] == 1 && pos[2] == 0 && pos[3] == 0) { printf("Yes"); }else if (pos[0] == 0 && pos[1] == 0 && pos[2] == 1 && pos[3] == 1) { printf("Yes"); }else { printf("No"); } return; } //B問題 void probremB(void) { long n = 0; long *a; long pairs=0; //入力処理 scanf("%d", &n); //メモリ確保 a = (long*)malloc(sizeof(long)*n); //入力処理2 long* lp; lp = a; for (long i = 0; i < n; i++) { scanf("%ld", lp); lp++; } //計算過程 if (n >= 2) { if (a[0] > 0 && a[1] > 0) { long temp = 0; temp = a[0] <= a[1] ? a[0] : a[1]; pairs += temp; a[0] -= temp; a[1] -= temp; } if (a[0] > 0) { long temp = 0; temp = a[0] / 2; pairs += temp; a[0] -= temp*2; } for (long i = 1; i < n - 1; i++) { if (a[i - 1] > 0 && a[i] > 0) { long temp = 0; temp = a[i - 1] <= a[i] ? a[i - 1] : a[i]; pairs += temp; a[i - 1] -= temp; a[i] -= temp; } if (a[i + 1] > 0 && a[i] > 0) { long temp = 0; temp = a[i + 1] <= a[i] ? a[i + 1] : a[i]; pairs += temp; a[i + 1] -= temp; a[i] -= temp; } if (a[i] > 0) { long temp = 0; temp = a[i] / 2; pairs += temp; a[i] -= temp*2; } } if (a[n - 1] > 0 && a[n - 2] > 0) { long temp = 0; temp = a[n - 2] <= a[n - 1] ? a[n - 2] : a[n - 1]; pairs += temp; a[n - 2] -= temp; a[n - 1] -= temp; } if (a[n - 1] > 0) { long temp = 0; temp = a[n - 1] / 2; pairs += temp; a[n - 1] -= temp*2; } } //サイズが1の時 else { pairs = (long)(a[0] / 2); } //出力処理 printf("%ld", pairs); //メモリ開放 free(a); //終了 return; } //C問題 void probremC(void) { long n = 0; long *a; long ope1 = 0; //入力処理 scanf("%d", &n); //メモリ確保 a = (long*)malloc(sizeof(long)*n); //入力処理2 long* lp; lp = a; for (long i = 0; i < n; i++) { scanf("%ld", lp); lp++; } //出力処理 printf("%ld", pairs); //メモリ開放 free(ope1); //終了 return; } //D問題 void probremD(void) { return; }
a.cc: In function 'void probremC()': a.cc:166:23: error: 'pairs' was not declared in this scope 166 | printf("%ld", pairs); | ^~~~~ a.cc:168:14: error: invalid conversion from 'long int' to 'void*' [-fpermissive] 168 | free(ope1); | ^~~~ | | | long int In file included from /usr/include/c++/14/cstdlib:79, from /usr/include/c++/14/stdlib.h:36, from a.cc:5: /usr/include/stdlib.h:687:25: note: initializing argument 1 of 'void free(void*)' 687 | extern void free (void *__ptr) __THROW; | ~~~~~~^~~~~
s815695235
p04020
C++
#include<bits/stdc++.h> #define range(i,a,b) for(int i = (a); i < (b); i++) #define rep(i,b) range(i,0,b) #define all(a) (a).begin(), (a).end() #define debug(x) cout << "debug " << x << endl; #define INF (1 << 30) using namespace std; int main(){ long long a[200005]; long longn; long long ans = 0; cin >> n; rep(i,n) cin >> a[i]; /* rep(i,n - 1){ if(a[i] > 0 && a[i + 1] > 0){ if(a[i] >= a[i + 1]){ ans+=a[i + 1]; a[i]-=a[i + 1]; a[i + 1] = 0; }else{ ans+=a[i]; a[i + 1]-=a[i]; a[i] = 0; } } } rep(i,n){ ans+=(a[i] / 2); } */ rep(i,n - 1){ if(a[i] / 2 >= min(a[i], a[i + 1])){ ans+=a[i] / 2; }else{ if(a[i] >= a[i + 1]){ ans+=a[i + 1]; a[i]-=a[i + 1]; a[i + 1] = 0; }else{ ans+=a[i]; a[i + 1]-=a[i]; a[i] = 0; } } } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:14:12: error: 'n' was not declared in this scope 14 | cin >> n; | ^
s003377755
p04020
C++
#include <vector> #include <cstdlib> using namespace std; int main() { int n,d,cnt=0; vector<long long> a; cin >> n; for (int i = 0; i < n; i++) { cin >> d; a.push_back(d); } for (int i = 0; i < n; i++) { cnt += a[i] / 2; if (i != n - 1) { if (a[i] % 2 == 1) { if (abs(a[i + 1] - a[i]) <= 1) { cnt++; a[i + 1]--; } } } } cout << cnt << endl; }
a.cc: In function 'int main()': a.cc:7:9: error: 'cin' was not declared in this scope 7 | cin >> n; | ^~~ a.cc:3:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 2 | #include <cstdlib> +++ |+#include <iostream> 3 | using namespace std; a.cc:24:9: error: 'cout' was not declared in this scope 24 | cout << cnt << endl; | ^~~~ a.cc:24:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:24:24: error: 'endl' was not declared in this scope 24 | cout << cnt << endl; | ^~~~ a.cc:3:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' 2 | #include <cstdlib> +++ |+#include <ostream> 3 | using namespace std;
s165504069
p04020
C++
#include <iostream> #include <fstream> #include <typeinfo> #include <vector> #include <cmath> #include <map> #include <string> #include <algorithm> #include <cstdio> #include <queue> #include <iomanip> #include <cctype> #define syosu(x) fixed<<setprecision(x) using namespace std; using namespace std; typedef long long ll; typedef pair<int,int> P; typedef pair<double,double> pdd; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<P> vp; typedef vector<vp> vvp; typedef pair<int,P> pip; typedef vector<pip> vip; const int inf=1<<30; const double pi=acos(-1); const double eps=1e-8; ll n,ans=0; vector<ll> num; int main(){ cin>>n; num=vi(n); for(int i=0;i<n;i++) cin>>num[i]; for(int i=0;i<n;i++){ int tmp=num[i]/2; ans+=tmp; num[i]-=tmp*2; if(num[i]==1&&i+1!=n&&num[i+1]){ num[i+1]--; ans++; } } cout<<ans<<endl; }
a.cc: In function 'int main()': a.cc:34:17: error: no match for 'operator=' (operand types are 'std::vector<long long int>' and 'vi' {aka 'std::vector<int>'}) 34 | num=vi(n); | ^ In file included from /usr/include/c++/14/vector:72, from a.cc:4: /usr/include/c++/14/bits/vector.tcc:210:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]' 210 | vector<_Tp, _Alloc>:: | ^~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/vector.tcc:211:42: note: no known conversion for argument 1 from 'vi' {aka 'std::vector<int>'} to 'const std::vector<long long int>&' 211 | operator=(const vector<_Tp, _Alloc>& __x) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ In file included from /usr/include/c++/14/vector:66: /usr/include/c++/14/bits/stl_vector.h:766:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]' 766 | operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move()) | ^~~~~~~~ /usr/include/c++/14/bits/stl_vector.h:766:26: note: no known conversion for argument 1 from 'vi' {aka 'std::vector<int>'} to 'std::vector<long long int>&&' 766 | operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move()) | ~~~~~~~~~^~~ /usr/include/c++/14/bits/stl_vector.h:788:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = long long int; _Alloc = std::allocator<long long int>]' 788 | operator=(initializer_list<value_type> __l) | ^~~~~~~~ /usr/include/c++/14/bits/stl_vector.h:788:46: note: no known conversion for argument 1 from 'vi' {aka 'std::vector<int>'} to 'std::initializer_list<long long int>' 788 | operator=(initializer_list<value_type> __l) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
s269317627
p04020
Java
import java.io.BufferedReader; import java.io.InputStreamReader; public class B { public static void main(String[] args) throws Exception{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int N = Integer.parseInt(br.readLine()); int[] A = new int[N]; int sum = 0; for(int i=0;i<N;i++){ A[i] = Integer.parseInt(br.readLine()); if(A[i]>=2){ sum += A[i]/2; A[i] = A[i]%2; } } for(int i=0;i<N-1;i++){ if(A[i]>0 && A[i+1]>0){ sum += Math.min(A[i], A[i+1]); A[i] = A[i+1] -= Math.min(A[i], A[i+1]); } } System.out.println(sum); } }
Main.java:4: error: class B is public, should be declared in a file named B.java public class B { ^ 1 error
s583585324
p04020
C++
#include "stdio.h" int i = 0; int num; long long int figure[100000]; long long int box[100000]; long long int ans=0; long long int sum = 0; int main() { sscanf("%d", &num); for (i = 0; i < num; i++) { figure[i] = 0; box[i] = 0; sscanf("%lld", &figure[i]); box[i] = figure[i]; } for (i = 0; i < num-1; i++) { if (box[i] >= box[i + 1]) { ans += box[i + 1]; box[i] -= box[i + 1]; box[i + 1] = 0; } else { ans += box[i]; box[i + 1] -= box[i]; box[i] = 0; } } for (i = 0; i < num; i++) { ans += box[i] / 2; } for (i = num; i > 0; i--) { if (figure[i] >= figure[i - 1]) { sum += figure[i - 1]; figure[i] -= figure[i - 1]; figure[i - 1] = 0; } else { sum += figure[i]; figure[i - 1] -= figure[i]; figure[i] = 0; } } if (ans > sum) { printf("%lld", ans); } else printf("%lld", sum); return 0; }
a.cc: In function 'int main()': a.cc:12:22: error: cannot convert 'int*' to 'const char*' 12 | sscanf("%d", &num); | ^~~~ | | | int* In file included from a.cc:1: /usr/include/stdio.h:431:43: note: initializing argument 2 of 'int sscanf(const char*, const char*, ...)' 431 | const char *__restrict __format, ...) __THROW; | ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~ a.cc:16:32: error: cannot convert 'long long int*' to 'const char*' 16 | sscanf("%lld", &figure[i]); | ^~~~~~~~~~ | | | long long int* /usr/include/stdio.h:431:43: note: initializing argument 2 of 'int sscanf(const char*, const char*, ...)' 431 | const char *__restrict __format, ...) __THROW; | ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
s504963175
p04020
C++
#include <iostream> using namespace std; long long n; unsigned long long a[1000000]; unsigned long long dp[1000000][3]; int main() { cin >> n; for(int i = 1 ; i <= n ; i++) { cin >> a[i]; } dp[1][0] = a[1] / 2; dp[1][1] = (a[1] + a[2]) / 2; for(int i = 2 ; i <= n ; i++) { dp[i][0] = max(dp[i-1][0] + (a[i]/2) , dp[i-1][1]); if(i != n) dp[i][1] = max(dp[i-1][0] + ((a[i] + a[i+1])/2) , dp[i-1][1] ); else dp[i][1] = max(dp[i-1][0] + ((a[i]/2) , dp[i-1][1] )); } cout << max(dp[n][0] , dp[n][1]) << '\n'; return 0; }
a.cc: In function 'int main()': a.cc:23:28: error: no matching function for call to 'max(long long unsigned int)' 23 | else dp[i][1] = max(dp[i-1][0] + ((a[i]/2) , dp[i-1][1] )); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 1 provided
s522307769
p04020
C++
#include <iostream> using namespace std; long long n; unsigned long long a[1000000]; unsigned long long dp[1000000][3]; int main() { cin >> n; for(int i = 1 ; i <= n ; i++) { cin >> a[i]; } dp[1][0] = a[1] / 2; dp[1][1] = (a[1] + a[2]) / 2; for(int i = 2 ; i <= n ; i++) { dp[i][0] = max(dp[i-1][0] + (a[i]/2) , dp[i-1][1]); if(i != n) dp[i][1] = max(dp[i-1][0] + ((a[i] + a[i+1])/2) , dp[i-1][1] ); else dp[i][1] = max(dp[i-1][0] + ((a[i]/2) , dp[i-1][1] ); } cout << max(dp[n][0] , dp[n][1]) << '\n'; return 0; }
a.cc: In function 'int main()': a.cc:23:66: error: expected ')' before ';' token 23 | else dp[i][1] = max(dp[i-1][0] + ((a[i]/2) , dp[i-1][1] ); | ~ ^ | )
s062235520
p04020
C++
#include <bits/stdc++.h> using namespace std; LL q,rs,n,a; int main() { cin>>n; for(int i=1; i<=n; ++i) { cin>>a; if(a%2==1) { rs+=a/2; if(q) { q=0; rs++; }else { q=1; } }else { if(a>=2){ rs+=a/2; }else q=0; } } cout<<rs; }
a.cc:4:1: error: 'LL' does not name a type 4 | LL q,rs,n,a; | ^~ a.cc: In function 'int main()': a.cc:7:14: error: 'n' was not declared in this scope; did you mean 'yn'? 7 | cin>>n; | ^ | yn a.cc:10:22: error: 'a' was not declared in this scope 10 | cin>>a; | ^ a.cc:14:25: error: 'rs' was not declared in this scope 14 | rs+=a/2; | ^~ a.cc:15:28: error: 'q' was not declared in this scope 15 | if(q) | ^ a.cc:27:25: error: 'rs' was not declared in this scope 27 | rs+=a/2; | ^~ a.cc:30:25: error: 'q' was not declared in this scope 30 | q=0; | ^ a.cc:33:15: error: 'rs' was not declared in this scope 33 | cout<<rs; | ^~
s603785230
p04020
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main(){ int n,a; cin>>n; int arr[n]; for(int i=0; i<n; ++i){ arr[i]=0; } for(int i=0; i<n; ++i){ cin>>a; arr[i-1]=a; } int x=0; for(int i=0; i<n; ++i){ int b=arr[i]; while(1){ if(b<2){ arr[i]=b; } b-=2; x++; } } for(int i=0; i<n-1; ++i){ if(arr[i]==1 && arr[i+1]==1){ arr[i]--; arr[i-1]-; x++; } } cout<<x<<endl; return 0; }
a.cc: In function 'int main()': a.cc:30:16: error: expected primary-expression before ';' token 30 | arr[i-1]-; | ^
s235871497
p04020
C++
#include <iostream> using namespace std ; int main() { int t ; cin>>t ; long int a[t], z ; long long int ans = 0 ; for (int i=0;i<t;i++) cin>>a[i] ; for (int i=0;i<t-1;i++) { z = min(a[i],a[i+1]) ; ans += z ; a[i+1] -= z ; a[i] -= z ; ans += a[i]/2 ; } ans += a[n-1]/2 ; cout<<ans<<endl ; return 0 ; }
a.cc: In function 'int main()': a.cc:18:12: error: 'n' was not declared in this scope 18 | ans += a[n-1]/2 ; | ^
s965422920
p04020
C++
#include <iostream> #include <vector> #include <algorithm> #include <string> #include <ctype.h> #include <deque> #include <queue> #include <cstring> #include <set> #include <list> #include <map> #include <random> #include <unordered_map> #include <stdio.h> using namespace std; typedef long long ll; typedef std::vector<int> vi; typedef std::vector<bool> vb; typedef std::vector<string> vs; typedef std::vector<double> vd; typedef std::vector<long long> vll; typedef std::vector<std::vector<int> > vvi; typedef vector<vvi> vvvi; typedef vector<vll> vvll; typedef std::vector<std::pair<int, int> > vpi; typedef vector<vpi> vvpi; typedef std::pair<int, int> pi; typedef std::pair<ll, ll> pll; typedef std::vector<pll> vpll; const long long mod = 1000000007; #define all(c) (c).begin(),(c).end() #define sz(c) (int)(c).size() #define forn(i, a, b) for(int i = a; i < b; i++) #define pb push_back #define mp make_pair int main() { #ifndef ONLINE_JUDGE freopen("input.txt", "rt", stdin); freopen("output.txt", "wt", stdout); #endif int n; cin>>n; vi a(n); forn(i,0,n) { cin>>a[i]; } sort(all(a)); int cur = 0; int ans = 0; while(cur<n) { if(a[i+1]-a[i] < 2) { ans++; cur+=2; } else cur++; } cout<<ans<<endl; }
a.cc: In function 'int main()': a.cc:58:14: error: 'i' was not declared in this scope 58 | if(a[i+1]-a[i] < 2) { | ^
s177523586
p04021
C++
#include "bits/stdc++.h" using namespace std; using ll=long long; using vll=vector< ll>; using vvll=vector< vll>; using vvvll=vector< vvll>; using vvvvll=vector<vvvll>; using dd=double; using vdd=vector< dd>; using vvdd=vector< vdd>; using pll=pair<ll,ll>; using tll=tuple<ll,ll,ll>; using qll=tuple<ll,ll,ll,ll>; constexpr ll INF = 1LL << 60; struct Fast{ Fast(){ cin.tie(0); ios::sync_with_stdio(false); cout<<fixed<<setprecision(numeric_limits<double>::max_digits10); } } fast; #define REPS(i, S, E) for (ll i = (S); i <= (E); i++) #define REP(i, N) REPS(i, 0, (N)-1) #define DEPS(i, S, E) for (ll i = (E); i >= (S); i--) #define DEP(i, N) DEPS(i, 0, (N)-1) #define rep(i, S, E) for (ll i = (S); i <= (E); i++) #define dep(i, E, S) for (ll i = (E); i >= (S); i--) #define each(e, v) for (auto&& e : v) #define ALL(v) (v).begin(), (v).end() #define RALL(v) (v).rbegin(), (v).rend() template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; }return false; } template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; }return false; } template<class T> inline T MaxE(vector<T>&v,ll S,ll E){ T m=v[S]; rep(i,S,E)chmax(m,v[i]); return m; } template<class T> inline T MinE(vector<T>&v,ll S,ll E){ T m=v[S]; rep(i,S,E)chmin(m,v[i]); return m; } template<class T> inline T MaxE(vector<T> &v) { return MaxE(v,0,(ll)v.size()-1); } template<class T> inline T MinE(vector<T> &v) { return MinE(v,0,(ll)v.size()-1); } template<class T> inline T Sum(vector<T> &v,ll S,ll E){ T s=T(); rep(i,S,E)s+=v[i]; return s; } template<class T> inline T Sum(vector<T> &v) { return Sum(v,0,v.size()-1); } template<class T> inline ll sz(T &v){ return (ll)v.size(); } inline ll CEIL(ll a,ll b){ return (a<0) ? -(-a/b) : (a+b-1)/b; } inline ll FLOOR(ll a,ll b){ return -CEIL(-a,b); } //vector用テンプレート template<class T> inline vector<T>& operator+=(vector<T> &a,const vector<T> &b){ for (ll i=0; i<(ll)a.size(); i++) a[i]+=b[i]; return a; } template<class T> inline vector<T>& operator-=(vector<T> &a,const vector<T> &b){ for (ll i=0; i<(ll)a.size(); i++) a[i]-=b[i]; return a; } template<class T> inline vector<T>& operator*=(vector<T> &a,const vector<T> &b){ for (ll i=0; i<(ll)a.size(); i++) a[i]*=b[i]; return a; } template<class T> inline vector<T>& operator/=(vector<T> &a,const vector<T> &b){ for (ll i=0; i<(ll)a.size(); i++) a[i]/=b[i]; return a; } template<class T> inline vector<T>& operator%=(vector<T> &a,const vector<T> &b){ for (ll i=0; i<(ll)a.size(); i++) a[i]%=b[i]; return a; } template<class T,class S> inline vector<T>& operator+=(vector<T> &a,S b){ for (T &e: a) e+=b; return a; } template<class T,class S> inline vector<T>& operator-=(vector<T> &a,S b){ for (T &e: a) e-=b; return a; } template<class T,class S> inline vector<T>& operator*=(vector<T> &a,S b){ for (T &e: a) e*=b; return a; } template<class T,class S> inline vector<T>& operator/=(vector<T> &a,S b){ for (T &e: a) e/=b; return a; } template<class T,class S> inline vector<T>& operator%=(vector<T> &a,S b){ for (T &e: a) e%=b; return a; } template<class T,class S> inline vector<T> operator+(const vector<T> &a,S b){ vector<T> c=a; return c+=b; } template<class T,class S> inline vector<T> operator-(const vector<T> &a,S b){ vector<T> c=a; return c-=b; } template<class T,class S> inline vector<T> operator*(const vector<T> &a,S b){ vector<T> c=a; return c*=b; } template<class T,class S> inline vector<T> operator/(const vector<T> &a,S b){ vector<T> c=a; return c/=b; } template<class T,class S> inline vector<T> operator%(const vector<T> &a,S b){ vector<T> c=a; return c%=b; } template<class T,class S> inline vector<T> operator-(S b,const vector<T> &a){ vector<T> c=-a; return c+=b; } template<class T> inline vector<T> operator-(const vector<T> &a){ vector<T> c=a; return c*=(-1); } template<class T> inline ostream &operator<<(ostream &os,const vector<T> &a){ for (ll i=0; i<(ll)a.size(); i++) os<<(i>0?" ":"")<<a[i]; return os; } //pair用テンプレート using vpll=vector< pll>; using vvpll=vector<vpll>; template<class T,class S> inline pair<T,S>& operator+=(pair<T,S> &a,const pair<T,S> &b){ a.first+=b.first; a.second+=b.second; return a; } template<class T,class S> inline pair<T,S>& operator-=(pair<T,S> &a,const pair<T,S> &b){ a.first-=b.first; a.second-=b.second; return a; } template<class T,class S> inline pair<T,S>& operator*=(pair<T,S> &a,const pair<T,S> &b){ a.first*=b.first; a.second*=b.second; return a; } template<class T,class S> inline pair<T,S>& operator/=(pair<T,S> &a,const pair<T,S> &b){ a.first/=b.first; a.second/=b.second; return a; } template<class T,class S> inline pair<T,S>& operator%=(pair<T,S> &a,const pair<T,S> &b){ a.first%=b.first; a.second%=b.second; return a; } template<class T,class S,class R> inline pair<T,S>& operator+=(pair<T,S> &a,R b){ a.first+=b; a.second+=b; return a; } template<class T,class S,class R> inline pair<T,S>& operator-=(pair<T,S> &a,R b){ a.first-=b; a.second-=b; return a; } template<class T,class S,class R> inline pair<T,S>& operator*=(pair<T,S> &a,R b){ a.first*=b; a.second*=b; return a; } template<class T,class S,class R> inline pair<T,S>& operator/=(pair<T,S> &a,R b){ a.first/=b; a.second/=b; return a; } template<class T,class S,class R> inline pair<T,S>& operator%=(pair<T,S> &a,R b){ a.first%=b; a.second%=b; return a; } template<class T,class S,class R> inline pair<T,S> operator+(const pair<T,S> &a,R b){ pair<T,S> c=a; return c+=b; } template<class T,class S,class R> inline pair<T,S> operator-(const pair<T,S> &a,R b){ pair<T,S> c=a; return c-=b; } template<class T,class S,class R> inline pair<T,S> operator*(const pair<T,S> &a,R b){ pair<T,S> c=a; return c*=b; } template<class T,class S,class R> inline pair<T,S> operator/(const pair<T,S> &a,R b){ pair<T,S> c=a; return c/=b; } template<class T,class S,class R> inline pair<T,S> operator%(const pair<T,S> &a,R b){ pair<T,S> c=a; return c%=b; } template<class T,class S,class R> inline pair<T,S> operator-(R b,const pair<T,S> &a){ pair<T,S> c=-a; return c+=b; } template<class T,class S> inline pair<T,S> operator-(const pair<T,S> &a){ pair<T,S> c=a; return c*=(-1); } template<class T,class S> inline ostream &operator<<(ostream &os,const pair<T,S> &a){ return os << a.first << ' ' << a.second; } #if 1 #include <atcoder/all> using namespace atcoder; #endif void solve() { ll n; cin >> n; vector<ll> a(n); rep(i,0,n-1){ ll a_; cin>>a_; a[i]=a_; } vll idxes(n); iota(ALL(idxes),0); sort(ALL(idxes),[&](auto &i,auto &j){return a[i] < a[j];}); vll b(n); rep(r,0,n-1) b[idxes[r]]=r; ll ans=0; rep(i,0,n-1){ if (i%2==0 and b[i]%2==1)ans++; if (i%2==1 and b[i]%2==0)ans++; } cout << ans/2 << '\n'; } int main(){ #if 1 solve(); #else ll t; cin >> t; rep(i, 0, t-1){ solve(); } #endif return 0; }
a.cc:81:10: fatal error: atcoder/all: No such file or directory 81 | #include <atcoder/all> | ^~~~~~~~~~~~~ compilation terminated.
s537492541
p04021
C++
#include <bits/stdc++.h> #include<atcoder/all> #define ll long long #define ld long double #define rep(i, n) for(ll i = 0; i < n; ++i) #define rep2(i, a, b) for(ll i = a; i <= b; ++i) #define rrep(i, a, b) for(ll i = a; i >= b; --i) #define pii pair<int, int> #define pll pair<ll, ll> #define fi first #define se second #define pb push_back #define eb emplace_back #define vi vector<int> #define vll vector<ll> #define vpii vector<pii> #define vpll vector<pll> #define all(a) a.begin(), a.end() #define endl '\n' using namespace std; using namespace atcoder; template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } const ll MOD=10000007;//998244353 const ll INF=1e18; const int inf=1e9; const double PI=acos(-1); int dx[8] = {1,0,-1,0,1,1,-1,-1}; int dy[8] = {0,1,0,-1,-1,1,1,-1}; const int MAX=1e6+10; int main(){ cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; vi a(n); rep(i,n) cin >> a[i]; vi b((n+1)/2),c(n/2); rep(i,n){ if(i%2==0)b[i/2]=a[i]; else c[i/2]=a[i]; } sort(all(b)); sort(all(c)); int ans = 0; int cur = 0; while(cur<n/2){ if(b[cur]<c[cur]){ cur++; } else{ ans++; swap(b[cur],c[cur]); } } cout << ans << endl; return 0; }
a.cc:2:9: fatal error: atcoder/all: No such file or directory 2 | #include<atcoder/all> | ^~~~~~~~~~~~~ compilation terminated.
s046509319
p04021
C++
#include <algorithm> #include <bitset> #include <cassert> #include <chrono> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <iterator> #include <limits> #include <list> #include <map> #include <numeric> #include <queue> #include <random> #include <ratio> #include <set> #include <sstream> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> #include <climits> #define ll long long #define ld long double #define mp make_pair #define pb push_back #define in insert #define vll vector<ll> #define endl "\n" #define pll pair<ll,ll> #define f first #define s second #define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++) #define int ll #define sz(x) (ll)x.size() #define all(x) (x.begin(),x.end()) using namespace std; const ll INF = 1e12; const ll N =(1e5+5); // TODO : change value as per problem const ll MOD = 1e9+7; int a[N],arr[N]; // 2 4 3 1 map<int,int> pos; void solve(){ int n; cin >> n; for(int i =1;i <= n;i++) cin >> a[i],arr[i] = a[i]; sort(arr+1,arr+n+1); for(int i = 1;i<=n;i++) pos[arr[i]] = i; int ans =0; for(int i =1;i<=n;i++){ int dis = abs(pos[a[i]] - i); ans += (dis&1); } cout << ans>>1ll << endl; } signed main(){ ios_base::sync_with_stdio(0); cin.tie(NULL); // freopen(".in","r",stdin);freopen(".out","w",stdout); ll tt=1; // cin >> tt; while(tt--){ solve(); } }
a.cc: In function 'void solve()': a.cc:69:20: error: no match for 'operator>>' (operand types are 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} and 'long long int') 69 | cout << ans>>1ll << endl; | ~~~~~~~~~~~^~~~~ | | | | | long long int | std::basic_ostream<char>::__ostream_type {aka std::basic_ostream<char>} a.cc:69:20: note: candidate: 'operator>>(int, long long int)' (built-in) 69 | cout << ans>>1ll << endl; | ~~~~~~~~~~~^~~~~ a.cc:69:20: note: no known conversion for argument 1 from 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} to 'int' In file included from /usr/include/c++/14/string:55, from /usr/include/c++/14/bitset:52, from a.cc:2: /usr/include/c++/14/bits/basic_string.tcc:835:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::basic_istream<_CharT, _Traits>& std::operator>>(basic_istream<_CharT, _Traits>&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 835 | operator>>(basic_istream<_CharT, _Traits>& __in, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.tcc:835:5: note: template argument deduction/substitution failed: a.cc:69:22: note: 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<_CharT, _Traits>' 69 | cout << ans>>1ll << endl; | ^~~ In file included from /usr/include/c++/14/bits/memory_resource.h:38, from /usr/include/c++/14/string:68: /usr/include/c++/14/cstddef:131:5: note: candidate: 'template<class _IntegerType> constexpr std::__byte_op_t<_IntegerType> std::operator>>(byte, _IntegerType)' 131 | operator>>(byte __b, _IntegerType __shift) noexcept | ^~~~~~~~ /usr/include/c++/14/cstddef:131:5: note: template argument deduction/substitution failed: a.cc:69:14: note: cannot convert 'std::cout.std::basic_ostream<char>::operator<<(ans)' (type 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'}) to type 'std::byte' 69 | cout << ans>>1ll << endl; | ~~~~~^~~~~~ /usr/include/c++/14/bitset:1597:5: note: candidate: 'template<class _CharT, class _Traits, long unsigned int _Nb> std::basic_istream<_CharT, _Traits>& std::operator>>(basic_istream<_CharT, _Traits>&, bitset<_Nb>&)' 1597 | operator>>(std::basic_istream<_CharT, _Traits>& __is, bitset<_Nb>& __x) | ^~~~~~~~ /usr/include/c++/14/bitset:1597:5: note: template argument deduction/substitution failed: a.cc:69:22: note: 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<_CharT, _Traits>' 69 | cout << ans>>1ll << endl; | ^~~ In file included from /usr/include/c++/14/istream:1109, from /usr/include/c++/14/sstream:40, from /usr/include/c++/14/complex:45, from a.cc:5: /usr/include/c++/14/bits/istream.tcc:978:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(basic_istream<_CharT, _Traits>&, _CharT&)' 978 | operator>>(basic_istream<_CharT, _Traits>& __in, _CharT& __c) | ^~~~~~~~ /usr/include/c++/14/bits/istream.tcc:978:5: note: template argument deduction/substitution failed: a.cc:69:22: note: 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<_CharT, _Traits>' 69 | cout << ans>>1ll << endl; | ^~~ /usr/include/c++/14/istream:849:5: note: candidate: 'template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(basic_istream<char, _Traits>&, unsigned char&)' 849 | operator>>(basic_istream<char, _Traits>& __in, unsigned char& __c) | ^~~~~~~~ /usr/include/c++/14/istream:849:5: note: template argument deduction/substitution failed: a.cc:69:22: note: 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<char, _Traits>' 69 | cout << ans>>1ll << endl; | ^~~ /usr/include/c++/14/istream:854:5: note: candidate: 'template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(basic_istream<char, _Traits>&, signed char&)' 854 | operator>>(basic_istream<char, _Traits>& __in, signed char& __c) | ^~~~~~~~ /usr/include/c++/14/istream:854:5: note: template argument deduction/substitution failed: a.cc:69:22: note: 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<char, _Traits>' 69 | cout << ans>>1ll << endl; | ^~~ /usr/include/c++/14/istream:896:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(basic_istream<_CharT, _Traits>&, _CharT*)' 896 | operator>>(basic_istream<_CharT, _Traits>& __in, _CharT* __s) | ^~~~~~~~ /usr/include/c++/14/istream:896:5: note: template argument deduction/substitution failed: a.cc:69:22: note: 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<_CharT, _Traits>' 69 | cout << ans>>1ll << endl; | ^~~ /usr/include/c++/14/istream:939:5: note: candidate: 'template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(basic_istream<char, _Traits>&, unsigned char*)' 939 | operator>>(basic_istream<char, _Traits>& __in, unsigned char* __s) | ^~~~~~~~ /usr/include/c++/14/istream:939:5: note: template argument deduction/substitution failed: a.cc:69:22: note: 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<char, _Traits>' 69 | cout << ans>>1ll << endl; | ^~~ /usr/include/c++/14/istream:945:5: note: candidate: 'template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(basic_istream<char, _Traits>&, signed char*)' 945 | operator>>(basic_istream<char, _Traits>& __in, signed char* __s) | ^~~~~~~~ /usr/include/c++/14/istream:945:5: note: template argument deduction/substitution failed: a.cc:69:22: note: 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<char, _Traits>' 69 | cout << ans>>1ll << endl; | ^~~ /usr/include/c++/14/istream:1099:5: note: candidate: 'template<class _Istream, class _Tp> _Istream&& std::operator>>(_Istream&&, _Tp&&)' 1099 | operator>>(_Istream&& __is, _Tp&& __x) | ^~~~~~~~ /usr/include/c++/14/istream:1099:5: note: template argument deduction/substitution failed: /usr/include/c++/14/istream: In substitution of 'template<class _Istream, class _Tp> _Istream&& std::operator>>(_Istream&&, _Tp&&) [with _Istream = std::basic_ostream<char>&; _Tp = long long int]': a.cc:69:15: required from here 69 | cout << ans>>1ll << endl; | ^~~ /usr/include/c++/14/istream:1099:5: error: no type named 'type' in 'struct std::enable_if<false, void>' 1099 | operator>>(_Istream&& __is, _Tp&& __x) | ^~~~~~~~ /usr/include/c++/14/complex:509:5: note: candidate: 'template<class _Tp, class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(basic_istream<_CharT, _Traits>&, complex<_Tp>&)' 509 | operator>>(basic_istream<_CharT, _Traits>& __is, complex<_Tp>& __x) | ^~~~~~~~ /usr/include/c++/14/complex:509:5: note: template argument deduction/substitution failed: a.cc:69:22: note: 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<_CharT, _Traits>' 69 | cout << ans>>1ll << endl; | ^~~ In file included from a.cc:12: /usr/include/c++/14/iomanip:76:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(basic_istream<_CharT, _Traits>&, _Resetiosflags)' 76 | operator>>(basic_istream<_CharT, _Traits>& __is, _Resetiosflags __f) | ^~~~~~~~ /usr/include/c++/14/iomanip:76:5: note: template argument deduction/substitution failed: a.cc:69:22: note: 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<_CharT, _Traits>' 69 | cout << ans>>1ll << endl; | ^~~ /usr/include/c++/14/iomanip:106:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(basic_istream<_CharT, _Traits>&, _Setiosflags)' 106 | operator>>(basic_istream<_CharT, _Traits>& __is, _Setiosflags __f) | ^~~~~~~~ /usr/include/c++/14/iomanip:106:5: note: template argument deduction/substitution failed: a.cc:69:22: note: 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<_CharT, _Traits>' 69 | cout << ans>>1ll << endl; | ^~~ /usr/include/c++/14/iomanip:137:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(basic_istream<_CharT, _Traits>&, _Setbase)' 137 | operator>>(basic_istream<_CharT, _Traits>& __is, _Setbase __f) | ^~~~~~~~ /usr/include/c++/14/iomanip:137:5: note: template argument deduction/substitution failed: a.cc:69:22: note: 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<_CharT, _Traits>' 69 | cout << ans>>1ll << endl; | ^~~ /usr/include/c++/14/iomanip:177:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(basic_istream<_CharT, _Traits>&, _Setfill<_CharT>)' 177 | operator>>(basic_istream<_CharT, _Traits>& __is, _Setfill<_CharT>
s715604469
p04021
Java
import java.util.*; import java.io.*; import java.math.*; public class Main{ //Don't have to see. start------------------------------------------ static class InputIterator{ ArrayList<String> inputLine = new ArrayList<String>(1024); int index = 0; int max; String read; InputIterator(){ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); try{ while((read = br.readLine()) != null){ inputLine.add(read); } }catch(IOException e){} max = inputLine.size(); } boolean hasNext(){return (index < max);} String next(){ if(hasNext()){ return inputLine.get(index++); }else{ throw new IndexOutOfBoundsException("There is no more input"); } } } static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>(); static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem. static PrintWriter out = new PrintWriter(System.out); static void flush(){out.flush();} static void myout(Object t){out.println(t);} static void myerr(Object t){System.err.print("debug:");System.err.println(t);} static String next(){return ii.next();} static boolean hasNext(){return ii.hasNext();} static int nextInt(){return Integer.parseInt(next());} static long nextLong(){return Long.parseLong(next());} static double nextDouble(){return Double.parseDouble(next());} static ArrayList<String> nextStrArray(){return myconv(next(), 8);} static ArrayList<String> nextCharArray(){return myconv(next(), 0);} static ArrayList<Integer> nextIntArray(){ ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size()); for(int i = 0; i < input.size(); i++){ ret.add(Integer.parseInt(input.get(i))); } return ret; } static ArrayList<Long> nextLongArray(){ ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size()); for(int i = 0; i < input.size(); i++){ ret.add(Long.parseLong(input.get(i))); } return ret; } static String myconv(Object list, int no){//only join String joinString = CONVSTR.get(no); if(list instanceof String[]){ return String.join(joinString, (String[])list); }else if(list instanceof ArrayList){ return String.join(joinString, (ArrayList)list); }else{ throw new ClassCastException("Don't join"); } } static ArrayList<String> myconv(String str, int no){//only split String splitString = CONVSTR.get(no); return new ArrayList<String>(Arrays.asList(str.split(splitString))); } public static void main(String[] args){ CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, ""); solve();flush(); } //Don't have to see. end------------------------------------------ static void solve(){//Here is the main function int N = nextInt(); int output = 0; int[] list = new int[N]; HashSet<Integer> oddSet = new HashSet<Integer>(); HashSet<Integer> evenSet = new HashSet<Integer>(); for(int i = 0; i < N; i++){ int tmp = nextInt(); list[i] = tmp; if(i % 2 == 0){ oddSet.add(tmp); }else{ evenSet.add(tmp); } } Arrays.fill(list); for(int i = 0; i < N; i++){ if(i % 2 == 0){ if(oddSet.contains(list[i])){ output++; } }else{ if(evenSet.contains(list[i])){ output++; } } } myout(output / 2); } //Method addition frame start //Method addition frame end }
Main.java:86: error: no suitable method found for fill(int[]) Arrays.fill(list); ^ method Arrays.fill(long[],long) is not applicable (actual and formal argument lists differ in length) method Arrays.fill(long[],int,int,long) is not applicable (actual and formal argument lists differ in length) method Arrays.fill(int[],int) is not applicable (actual and formal argument lists differ in length) method Arrays.fill(int[],int,int,int) is not applicable (actual and formal argument lists differ in length) method Arrays.fill(short[],short) is not applicable (actual and formal argument lists differ in length) method Arrays.fill(short[],int,int,short) is not applicable (actual and formal argument lists differ in length) method Arrays.fill(char[],char) is not applicable (actual and formal argument lists differ in length) method Arrays.fill(char[],int,int,char) is not applicable (actual and formal argument lists differ in length) method Arrays.fill(byte[],byte) is not applicable (actual and formal argument lists differ in length) method Arrays.fill(byte[],int,int,byte) is not applicable (actual and formal argument lists differ in length) method Arrays.fill(boolean[],boolean) is not applicable (actual and formal argument lists differ in length) method Arrays.fill(boolean[],int,int,boolean) is not applicable (actual and formal argument lists differ in length) method Arrays.fill(double[],double) is not applicable (actual and formal argument lists differ in length) method Arrays.fill(double[],int,int,double) is not applicable (actual and formal argument lists differ in length) method Arrays.fill(float[],float) is not applicable (actual and formal argument lists differ in length) method Arrays.fill(float[],int,int,float) is not applicable (actual and formal argument lists differ in length) method Arrays.fill(Object[],Object) is not applicable (actual and formal argument lists differ in length) method Arrays.fill(Object[],int,int,Object) is not applicable (actual and formal argument lists differ in length) Note: Main.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 1 error
s695995099
p04021
C++
#include <bits/stdc++.h> #include <cstdlib> #include <cmath> #include <algorithm> using namespace std; using ll = long long; using P = pair<int,int>; using Graph= vector<vector<ll>>; #define rep(i,n) for (ll i=0; i < (n); ++i) #define rep2(i,n,m) for(ll i=n;i<=m;i++) #define rep3(i,n,m) for(ll i=n;i>=m;i--) #define pb push_back #define eb emplace_back #define ppb pop_back const ll INF=1e18 ; inline void chmax(ll& a,ll b){a=max(a,b);} inline void chmin(ll& a,ll b){a=min(a,b);} int main(){ ll n; cin>> n ; vector<ll> A(n) ; rep(i,n) cin>> A[i] ; map<ll ,ll> mp ; rep(i,n){ mp[A[i]] = i ; } sort(A.begin(),A.end()) ; rep(i,n){ if((mp[A[i]]-i)%2==1) ans++ ; } cout << ans <<endl ; return 0; }
a.cc: In function 'int main()': a.cc:30:27: error: 'ans' was not declared in this scope; did you mean 'abs'? 30 | if((mp[A[i]]-i)%2==1) ans++ ; | ^~~ | abs a.cc:32:13: error: 'ans' was not declared in this scope; did you mean 'abs'? 32 | cout << ans <<endl ; | ^~~ | abs
s511787907
p04021
C++
#include <iostream> #include <algorithm> #define int long long signed main() { int n; std::cin >> n; std::pair<int, int> a[n]; for(int i = 0; i < n; i++) { std::cin >> a[i].first; a[i].second = i%2; } std::sort(a, a+n); int ans = 0; for(int i = 0; i < n; i++) ans += (i%2 != a[i].second); std::cout << ans/2 << std::endl return 0; }
a.cc: In function 'int main()': a.cc:23:34: error: expected ';' before 'return' 23 | std::cout << ans/2 << std::endl | ^ | ; 24 | return 0; | ~~~~~~
s268574591
p04021
C++
#include <Bits/stdc++.h> using namespace std; const int maxn=1e5+5; const long long sg=1e10; long long a,b,c,d,e,f,g,n,m,i,j,sdg[maxn],lili,t; long long x[maxn][10],z[maxn],v[101][101],h[maxn]; string p[maxn],s[maxn]; queue<int>q; bool mark[maxn]; vector<long long> o[maxn],sgd; map<long long,long long> mp; char l[10][10],y; int main(){ ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0); cin>>a; for(i=0;i<a;i++){ cin>>z[i]; mp[z[i]]=i; } sort(z,z+a); b=0; for(i=0;i<a;i++){ if(i%2!=mp[z[i]]%2){ b++; } } cout<<b/2<<endl; return 0;}
a.cc:1:10: fatal error: Bits/stdc++.h: No such file or directory 1 | #include <Bits/stdc++.h> | ^~~~~~~~~~~~~~~ compilation terminated.
s864366569
p04021
C++
#include<Bits/stdc++.h> using namespace std; const int maxn=1e5+5; const long long sg=1e10; long long a,b,c,d,e,f,g,n,m,i,j,sdg[maxn],lili,t; long long x[maxn][10],z[maxn],v[101][101],h[maxn]; string p[maxn],s[maxn]; queue<int>q; bool mark[maxn]; vector<long long> o[maxn],sgd; map<long long,long long> mp; char l[10][10],y; int main(){ ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0); cin>>a; for(i=0;i<a;i++){ cin>>z[i]; mp[z[i]]=i; } sort(z,z+a); b=0; for(i=0;i<a;i++){ if(i%2!=mp[z[i]]%2){ b++; } } cout<<b/2<<endl; return 0;}
a.cc:1:9: fatal error: Bits/stdc++.h: No such file or directory 1 | #include<Bits/stdc++.h> | ^~~~~~~~~~~~~~~ compilation terminated.
s249125446
p04021
C++
#include<Bits/stdc++.h> using namespace std; const int maxn=1e5+5; const long long sg=1e10; long long a,b,c,d,e,f,g,n,m,i,j,sdg[maxn],lili,t; long long x[maxn][10],z[maxn],v[101][101],h[maxn]; string p[maxn],s[maxn]; queue<int>q; bool mark[maxn]; vector<long long> o[maxn],sgd; map<long long,long long> mp; char l[10][10],y; int main(){ ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0); cin>>a; for(i=0;i<a;i++){ cin>>z[i]; mp[z[i]]=i; } sort(z,z+a); b=0; for(i=0;i<a;i++){ if(i%2!=mp[z[i]]%2){ b++; } } cout<<b/2<<endl; return 0;}
a.cc:1:9: fatal error: Bits/stdc++.h: No such file or directory 1 | #include<Bits/stdc++.h> | ^~~~~~~~~~~~~~~ compilation terminated.
s256276490
p04021
C++
#include<bits\stdc++.h> using namespace std; const int maxn=1e5+5; const long long sg=1e10; long long a,b,c,d,e,f,g,n,m,i,j,sdg[maxn],lili,t; long long x[maxn][10],z[maxn],v[101][101],h[maxn]; string p[maxn],s[maxn]; queue<int>q; bool mark[maxn]; vector<long long> o[maxn],sgd; map<long long,long long> mp; char l[10][10],y; int main(){ ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0); cin>>a; for(i=0;i<a;i++){ cin>>z[i]; mp[z[i]]=i; } sort(z,z+a); b=0; for(i=0;i<a;i++){ if(i%2!=mp[z[i]]%2){ b++; } } cout<<b/2<<endl; return 0;}
a.cc:1:9: fatal error: bits\stdc++.h: No such file or directory 1 | #include<bits\stdc++.h> | ^~~~~~~~~~~~~~~ compilation terminated.
s095874074
p04021
C++
#include<bits\stdc++.h> using namespace std; const int maxn=10e5+5; const long long sg=1e10; long long a,b,c,d,e,f,g,n,m,i,j,sdg[maxn],lili,t; long long x[maxn][10],z[maxn],v[101][101],h[maxn]; string p[maxn],s[maxn]; queue<int>q; bool mark[maxn]; vector<long long> o[maxn],sgd; map<long long,long long> mp; char l[10][10],y; int main(){ ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0); cin>>a; for(i=0;i<a;i++){ cin>>z[i]; mp[z[i]]=i; } sort(z,z+a); b=0; for(i=0;i<a;i++){ if(i%2!=mp[z[i]]%2){ b++; } } cout<<b/2<<endl; return 0;}
a.cc:1:9: fatal error: bits\stdc++.h: No such file or directory 1 | #include<bits\stdc++.h> | ^~~~~~~~~~~~~~~ compilation terminated.
s948789661
p04021
C++
#include<bits\stdc++.h> using namespace std; const int maxn=10e5+5; const long long sg=1e10; long long a,b,c,d,e,f,g,n,m,i,j,sdg[maxn],lili,t; long long x[maxn][10],z[maxn],v[101][101],h[maxn]; string p[maxn],s[maxn]; queue<int>q; bool mark[maxn]; vector<long long> o[maxn],sgd; map<long long,long long> mp; char l[10][10],y; int main(){ ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0); cin>>a; for(i=0;i<a;i++){ cin>>z[i]; mp[z[i]]=i; } sort(z,z+a); b=0; for(i=0;i<a;i++){ if(i%2!=mp[z[i]]%2){ b++; } } cout<<b/2<<endl; return 0;}
a.cc:1:9: fatal error: bits\stdc++.h: No such file or directory 1 | #include<bits\stdc++.h> | ^~~~~~~~~~~~~~~ compilation terminated.
s800974390
p04021
C++
#include<bits\stdc++.h> using namespace std; const int maxn=10e5+5; const long long sg=1e10; long long a,b,c,d,e,f,g,n,m,i,j,sdg[maxn],lili,t; long long x[maxn][10],z[maxn],v[101][101],h[maxn]; string p[maxn],s[maxn]; queue<int>q; bool mark[maxn]; vector<long long> o[maxn],sgd; map<long long,long long> mp; char l[10][10],y; int main(){ ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0); cin>>a; for(i=0;i<a;i++){ cin>>z[i]; mp[z[i]]=i; } sort(z,z+a); b=0; for(i=0;i<a;i++){ if(i%2!=mp[z[i]]%2){ b++; } } cout<<b/2<<endl; return 0;}
a.cc:1:9: fatal error: bits\stdc++.h: No such file or directory 1 | #include<bits\stdc++.h> | ^~~~~~~~~~~~~~~ compilation terminated.
s566257137
p04021
C++
#include <bits/stdc++.h> using ll = long long; using namespace std; #define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++) #define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++) #define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--) #define rreps(i,n) for(int i=((int)(n));i>0;i--) #define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++) #define all(x) (x).begin(), (x).end() #define F first #define S second #define mp make_pair #define pb push_back #define solve(a) ((a)?"Yes":"No") typedef vector<int> Vi; typedef vector<Vi> VVi; typedef pair<int , int> Pi; typedef vector<Pi> VPi; typedef vector<long long> V; typedef vector<V> VV; typedef pair<long long , long long> P; typedef vector<P> VP; template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;} template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;} const long long INFLL = 1LL<<60; const int INF = 1<<30; const double PI=acos(-1); int main(){ int n; int ans=0; cin >>n; Vi a(n); Vi o, e; rep(i,n){ cin>>a[i]; if(i%2){ o.pb(a[i]); }else{ e.pb(a[i]); } } if(n==1){ cout<<0<<endl; return 0; } sort(all(a)); sort(all(e)); auto ter; for(int i=0;i<n/2;i++){ ter = lower_bound(all(e), a[i * 2]) if(ter==e.end()){ ans++; } else if (a[i * 2] != *ter) { ans++; } } cout<<ans<<endl; } /* 5 4 3 2 1 3 4 5 2 1 3 4 1 2 5 3 2 1 4 5 1 2 3 4 5 2 4 3 1 2 1 3 4 2 3 1 1 3 2 -> 1 6 5 4 3 2 1 6 4 2 5 3 1 1 2 3 4 5 6 2 1 4 3 6 5 4 1 2 5 6 3 4 1 6 5 2 3 6 1 4 5 2 3 6 5 4 1 2 3 1 5 3 4 2 6 1 5 2 4 3 6 1 4 2 5 3 6 1 4 5 2 3 6 1 2 5 4 3 6 11 2 3 4 5 1 6 3 4 5 2 1 4 3 6 5 2 1 4 3 2 5 6 1 2 3 4 */
a.cc: In function 'int main()': a.cc:49:9: error: declaration of 'auto ter' has no initializer 49 | auto ter; | ^~~~ a.cc:54:19: error: 'else' without a previous 'if' 54 | } else if (a[i * 2] != *ter) | ^~~~
s898488895
p04021
C++
#include<bits/stdc++.h> using namespace std; #define int long long #define double long double #define fo(a,b) for(int a=0;a<b;a++) #define Sort(a) sort(a.begin(),a.end()) #define rev(a) reverse(a.begin(),a.end()) #define fi first #define se second #define sz size() #define bgn begin() #define en end() #define pb push_back #define pp() pop_back() #define V vector #define P pair #define yuko(a) setprecision(a) #define uni(a) a.erase(unique(a.begin(),a.end()),a.end()) #define Q queue #define pri priority_queue #define Pri priority_queue<int,vector<int>,greater<int>> #define PriP priority_queue<P<int,int>,vector<P<int,int>>,greater<P<int,int>>> #define ff first.first #define fs first.second #define sf second.first #define ss second.second #define all(a) (a).begin(),(a).end() #define elif else if int low(V<int> a,int b){ decltype(a)::iterator c=lower_bound(a.begin(),a.end(),b); int d=c-a.bgn; return d; } int upp(V<int> a,int b){ decltype(a)::iterator c=upper_bound(a.begin(),a.end(),b); int d=c-a.bgn; return d; } template<class T> void cou(vector<vector<T>> a){ int b=a.size(); int c=a[0].size(); fo(i,b){ fo(j,c){ cout<<a[i][j]; if(j==c-1) cout<<endl; else cout<<' '; } } } int wari(int a,int b) { if(a%b==0) return a/b; else return a/b+1; } int keta(int a){ double b=a; b=log10(b); int c=b; return c+1; } int souwa(int a){ return a*(a+1)/2; } int gcm(int a,int b){ if(a%b==0) return b; return gcm(b,a%b); } bool prime(int a){ if(a<2) return false; else if(a==2) return true; else if(a%2==0) return false; for(int i=3;i<=sqrt(a)+1;i+=2){ if (a%i==0) return false; } return true; } struct Union{ vector<int> par; Union(int a){ par=vector<int>(a,-1); } int find(int a){ if(par[a]<0) return a; else return par[a]=find(par[a]); } bool same(int a,int b){ return find(a)==find(b); } int Size(int a){ return -par[find(a)]; } void unite(int a,int b){ a=find(a); b=find(b); if(a==b) return; if(Size(b)>Size(a)) swap<int>(a,b); par[a]+=par[b]; par[b]=a; } }; int ketas(int a){ string b=to_string(a); int c=0; fo(i,keta(a)){ c+=b[i]-'0'; } return c; } bool fe(int a,int b){ a%=10; b%=10; if(a==0) a=10; if(b==0) b=10; if(a>b) return true; else return false; } int INF=1000000007; struct edge{int s,t,d; }; V<int> mojisyu(string a){ V<int> b(26,0); fo(i,a.sz){ b[a[i]-'a']++; } return b; } int wa2(int a){ if(a%2==1) return a/2; return a/2-1; } /*signed main(){ int a,b,c; cin>>a>>b>>c; V<V<edge>> d(a); fo(i,b){ edge e; cin>>e.s>>e.t>>e.d; d[e.s].pb(e); } V<int> e(a,INF); e[c]=0; priority_queue<P<int,int>,V<P<int,int>>,greater<P<int,int>>> f; f.push({0,c}); int h=INF; while(!f.empty()){ P<int,int> g; g=f.top(); f.pop(); int v = g.second, i = g.first; for(edge l : d[v]){ if(e[l.t] > i + l.d){ e[l.t] = i + l.d; f.push({i+l.d , l.t}); } } } fo(i,a){ if(e[i]==INF) cout<<"INF"<<endl; else cout<<e[i]<<endl; } } ?*/ int nCr(int n,int r){ int a=1; r=min(r,n-r); for(int i=n;i>n-r;i--){ a*=i; a/=n-i+1; } return a; } /*void sea(int x,int y){ if(x<0||a<=x||y<0||b<=y||c[x][y]=='#') return; if(d[x][y]) return; d[x][y]++; sea(x+1,y); sea(x-1,y); sea(x,y+1); sea(x,y-1); }*/ int kaijou(int a){ int b=1; fo(i,a) b*=i+1; return b; } int nPr(int a,int b){ if(a<b) return 0; if(b==0) return 1; int c=1; for(int i=a;i>a-b;i--){ c*=i; c%=INF; } return c; } int modinv(int a,int m){ int b=m,u=1,v=0; while(b){ int t=a/b; a-=t*b; swap(a,b); u-=t*v; swap(u,v); } u%=m; if(u<0) u+=m; return u; } int lcm(int a,int b){ int c=modinv(gcm(a,b),INF); return ((a*c)%INF)*(b%INF)%INF; } int MOD=INF; int fac[1000010], finv[1000010], inv[1000010]; // テーブルを作る前処理 //先にCOMinit()で前処理をする //ABC145D void COMinit() { fac[0]=fac[1]=1; finv[0]=finv[1]=1; inv[1]=1; for(int i=2;i<1000010;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; } } // 二項係数計算 int COM(int n,int k){ if(n<k) return 0; if(n<0||k<0) return 0; return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD; } bool naka(int a,int b,V<V<char>> c){ return (a>=0&&b>=0&&a<c.sz&&b<c[0].sz); } V<P<int,int>> mawari8={{0,-1},{0,1},{1,0},{-1,0},{-1,-1},{1,1},{1,-1},{-1,-1}}; int inf=1000000000000000007; /* signed main(){ int a,b,c; cin>>a>>b>>c; V<V<edge>> d(a); fo(i,b){ edge e; cin>>e.s>>e.t>>e.d; d[e.s].pb(e); } V<int> e(a,INF); e[c]=0; priority_queue<P<int,int>,V<P<int,int>>,greater<P<int,int>>> f; f.push({0,c}); int h=INF; while(!f.empty()){ P<int,int> g; g=f.top(); f.pop(); int v = g.second, i = g.first; for(edge l : d[v]){ if(e[l.t] > i + l.d){ e[l.t] = i + l.d; f.push({i+l.d , l.t}); } } } fo(i,a){ if(e[i]==INF) cout<<"INF"<<endl; else cout<<e[i]<<endl; } }*/ V<P<int,int>> mawari4={{0,-1},{0,1},{1,0},{-1,0}}; //最短経路の表 a(全部INFで初期化) //縦横 x,y //迷路 f //スタートsx,sy //ゴールgx,gy //文字はgから使おうね /*int bfs_haba(){ Q<P<int,int>> b; a[sx][sy]=0; b.push({sx,sy}); while(!b.empty()){ P<int,int> c=b.front(); b.pop(); if(c.fi==gx&&c.se==gy){ break; } fo(i,4){ int d=c.fi+mawari4[i].fi; int e=c.se+mawari4[i].se; if(0<=d&&0<=e&&d<x&&e<y&&f[d][e]!='#'&&a[d][e]==INF){ b.push({d,e}); a[d][e]=1+a[c.fi][c.se]; } } } return a[gx][gy]; }*/ V<int> onajibubun(string a){ V<int> b(a.sz); for(int i=1,j=0;i<a.sz;i++){ if(i+b[i-j]<j+b[j]) b[i]=b[i-j]; else{ int c=max<int>(0,j+b[j]-i); while(i+c<a.sz&&a[c]==a[i+c]) c++; b[i]=c; j=i; } } b[0]=a.sz; return b; } //各頂点ごとにどこに辺が出てるかの表がc //各頂点ごとの色を表すV<int>(頂点数max)のcolorを用意する //aはどこ塗るか、bは何で塗るかなので、(0,1,c)でよぶとおけ V<int> color(205); bool nibu_hantei(int a,int b,V<V<int>> c){ color[a]=b; fo(i,c[a].sz){ if(b==color[c[a][i]]) return false; if(color[c[a][i]]==0&&!nibu_hantei(c[a][i],-b,c)) return false; } return true; } //aは頂点数 //nibu_hanteiの上にcolorを用意する //各頂点ごとにどこに辺が出てるかの表がc bool renketujanai_nibu_hantei(int a,V<V<int>> c){ fo(i,a){ if(color[i]==0){ if(!nibu_hantei(i,1,c)) return false; } } return true; } signed main(){ int a; cin>>a; V<P<int,P<int,int>>> b(a),c; fo(i,a){ cin>>b[i].fi; b[i].sf=i%2; } c=b; Sort(c); int e=0,d=0; fo(i,b){ if(i%2!=b[c[i].ss].sf){ if(i) e++; else d++; } } cout<<max(e,d)<<endl; }
a.cc: In function 'int main()': a.cc:5:30: error: no match for 'operator<' (operand types are 'long long int' and 'std::vector<std::pair<long long int, std::pair<long long int, long long int> > >') 5 | #define fo(a,b) for(int a=0;a<b;a++) | ^ a.cc:382:3: note: in expansion of macro 'fo' 382 | fo(i,b){ | ^~ In file included from /usr/include/c++/14/regex:68, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181, from a.cc:1: /usr/include/c++/14/bits/regex.h:1143:5: note: candidate: 'template<class _BiIter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const sub_match<_BiIter>&)' 1143 | operator<(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1143:5: note: template argument deduction/substitution failed: a.cc:382:8: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'long long int' 382 | fo(i,b){ | ^ a.cc:5:31: note: in definition of macro 'fo' 5 | #define fo(a,b) for(int a=0;a<b;a++) | ^ /usr/include/c++/14/bits/regex.h:1224:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator<(__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const sub_match<_BiIter>&)' 1224 | operator<(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1224:5: note: template argument deduction/substitution failed: a.cc:382:8: note: mismatched types 'std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>' and 'long long int' 382 | fo(i,b){ | ^ a.cc:5:31: note: in definition of macro 'fo' 5 | #define fo(a,b) for(int a=0;a<b;a++) | ^ /usr/include/c++/14/bits/regex.h:1317:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator<(const sub_match<_BiIter>&, __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)' 1317 | operator<(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1317:5: note: template argument deduction/substitution failed: a.cc:382:8: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'long long int' 382 | fo(i,b){ | ^ a.cc:5:31: note: in definition of macro 'fo' 5 | #define fo(a,b) for(int a=0;a<b;a++) | ^ /usr/include/c++/14/bits/regex.h:1391:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const typename std::iterator_traits<_Iter>::value_type*, const sub_match<_BiIter>&)' 1391 | operator<(typename iterator_traits<_Bi_iter>::value_type const* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1391:5: note: template argument deduction/substitution failed: a.cc:382:8: note: 'std::vector<std::pair<long long int, std::pair<long long int, long long int> > >' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 382 | fo(i,b){ | ^ a.cc:5:31: note: in definition of macro 'fo' 5 | #define fo(a,b) for(int a=0;a<b;a++) | ^ /usr/include/c++/14/bits/regex.h:1485:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)' 1485 | operator<(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1485:5: note: template argument deduction/substitution failed: a.cc:382:8: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'long long int' 382 | fo(i,b){ | ^ a.cc:5:31: note: in definition of macro 'fo' 5 | #define fo(a,b) for(int a=0;a<b;a++) | ^ /usr/include/c++/14/bits/regex.h:1560:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const typename std::iterator_traits<_Iter>::value_type&, const sub_match<_BiIter>&)' 1560 | operator<(typename iterator_traits<_Bi_iter>::value_type const& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1560:5: note: template argument deduction/substitution failed: a.cc:382:8: note: 'std::vector<std::pair<long long int, std::pair<long long int, long long int> > >' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 382 | fo(i,b){ | ^ a.cc:5:31: note: in definition of macro 'fo' 5 | #define fo(a,b) for(int a=0;a<b;a++) | ^ /usr/include/c++/14/bits/regex.h:1660:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&)' 1660 | operator<(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1660:5: note: template argument deduction/substitution failed: a.cc:382:8: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'long long int' 382 | fo(i,b){ | ^ a.cc:5:31: note: in definition of macro 'fo' 5 | #define fo(a,b) for(int a=0;a<b;a++) | ^ In file included from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51: /usr/include/c++/14/bits/stl_pair.h:1045:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator<(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1045 | operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1045:5: note: template argument deduction/substitution failed: a.cc:382:8: note: mismatched types 'const std::pair<_T1, _T2>' and 'long long int' 382 | fo(i,b){ | ^ a.cc:5:31: note: in definition of macro 'fo' 5 | #define fo(a,b) for(int a=0;a<b;a++) | ^ In file included from /usr/include/c++/14/bits/stl_algobase.h:67: /usr/include/c++/14/bits/stl_iterator.h:448:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 448 | operator<(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:448:5: note: template argument deduction/substitution failed: a.cc:382:8: note: mismatched types 'const std::reverse_iterator<_Iterator>' and 'long long int' 382 | fo(i,b){ | ^ a.cc:5:31: note: in definition of macro 'fo' 5 | #define fo(a,b) for(int a=0;a<b;a++) | ^ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 493 | operator<(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: template argument deduction/substitution failed: a.cc:382:8: note: mismatched types 'const std::reverse_iterator<_Iterator>' and 'long long int' 382 | fo(i,b){ | ^ a.cc:5:31: note: in definition of macro 'fo' 5 | #define fo(a,b) for(int a=0;a<b;a++) | ^ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1694 | operator<(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: template argument deduction/substitution failed: a.cc:382:8: note: mismatched types 'const std::move_iterator<_IteratorL>' and 'long long int' 382 | fo(i,b){ | ^ a.cc:5:31: note: in definition of macro 'fo' 5 | #define fo(a,b) for(int a=0;a<b;a++) | ^ /usr/include/c++/14/bits/stl_iterator.h:1760:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)' 1760 | operator<(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1760:5: note: template argument deduction/substitution failed: a.cc:382:8: note: mismatched types 'const std::move_iterator<_IteratorL>' and 'long long int' 382 | fo(i,b){ | ^ a.cc:5:31: note: in definition of macro 'fo' 5 | #define fo(a,b) for(int a=0;a<b;a++) | ^ In file included from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52: /usr/include/c++/14/string_view:673:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)' 673 | operator< (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:673:5: note: template argument deduction/substitution failed: a.cc:382:8: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'long long int' 382 | fo(i,b){ | ^ a.cc:5:31: note: in definition of macro 'fo' 5 | #define fo(a,b) for(int a=0;a<b;a++) | ^ /usr/include/c++/14/string_view:680:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)' 680 | operator< (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:680:5: note: template argument deduction/substitution failed: a.cc:382:8: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'long long int' 382 | fo(i,b){ | ^ a.cc:5:31: note: in definition of mac
s329441063
p04021
C++
#include<bits/stdc++.h> using namespace std; #define int long long #define double long double #define fo(a,b) for(int a=0;a<b;a++) #define Sort(a) sort(a.begin(),a.end()) #define rev(a) reverse(a.begin(),a.end()) #define fi first #define se second #define sz size() #define bgn begin() #define en end() #define pb push_back #define pp() pop_back() #define V vector #define P pair #define yuko(a) setprecision(a) #define uni(a) a.erase(unique(a.begin(),a.end()),a.end()) #define Q queue #define pri priority_queue #define Pri priority_queue<int,vector<int>,greater<int>> #define PriP priority_queue<P<int,int>,vector<P<int,int>>,greater<P<int,int>>> #define ff first.first #define fs first.second #define sf second.first #define ss second.second #define all(a) (a).begin(),(a).end() #define elif else if int low(V<int> a,int b){ decltype(a)::iterator c=lower_bound(a.begin(),a.end(),b); int d=c-a.bgn; return d; } int upp(V<int> a,int b){ decltype(a)::iterator c=upper_bound(a.begin(),a.end(),b); int d=c-a.bgn; return d; } template<class T> void cou(vector<vector<T>> a){ int b=a.size(); int c=a[0].size(); fo(i,b){ fo(j,c){ cout<<a[i][j]; if(j==c-1) cout<<endl; else cout<<' '; } } } int wari(int a,int b) { if(a%b==0) return a/b; else return a/b+1; } int keta(int a){ double b=a; b=log10(b); int c=b; return c+1; } int souwa(int a){ return a*(a+1)/2; } int gcm(int a,int b){ if(a%b==0) return b; return gcm(b,a%b); } bool prime(int a){ if(a<2) return false; else if(a==2) return true; else if(a%2==0) return false; for(int i=3;i<=sqrt(a)+1;i+=2){ if (a%i==0) return false; } return true; } struct Union{ vector<int> par; Union(int a){ par=vector<int>(a,-1); } int find(int a){ if(par[a]<0) return a; else return par[a]=find(par[a]); } bool same(int a,int b){ return find(a)==find(b); } int Size(int a){ return -par[find(a)]; } void unite(int a,int b){ a=find(a); b=find(b); if(a==b) return; if(Size(b)>Size(a)) swap<int>(a,b); par[a]+=par[b]; par[b]=a; } }; int ketas(int a){ string b=to_string(a); int c=0; fo(i,keta(a)){ c+=b[i]-'0'; } return c; } bool fe(int a,int b){ a%=10; b%=10; if(a==0) a=10; if(b==0) b=10; if(a>b) return true; else return false; } int INF=1000000007; struct edge{int s,t,d; }; V<int> mojisyu(string a){ V<int> b(26,0); fo(i,a.sz){ b[a[i]-'a']++; } return b; } int wa2(int a){ if(a%2==1) return a/2; return a/2-1; } /*signed main(){ int a,b,c; cin>>a>>b>>c; V<V<edge>> d(a); fo(i,b){ edge e; cin>>e.s>>e.t>>e.d; d[e.s].pb(e); } V<int> e(a,INF); e[c]=0; priority_queue<P<int,int>,V<P<int,int>>,greater<P<int,int>>> f; f.push({0,c}); int h=INF; while(!f.empty()){ P<int,int> g; g=f.top(); f.pop(); int v = g.second, i = g.first; for(edge l : d[v]){ if(e[l.t] > i + l.d){ e[l.t] = i + l.d; f.push({i+l.d , l.t}); } } } fo(i,a){ if(e[i]==INF) cout<<"INF"<<endl; else cout<<e[i]<<endl; } } ?*/ int nCr(int n,int r){ int a=1; r=min(r,n-r); for(int i=n;i>n-r;i--){ a*=i; a/=n-i+1; } return a; } /*void sea(int x,int y){ if(x<0||a<=x||y<0||b<=y||c[x][y]=='#') return; if(d[x][y]) return; d[x][y]++; sea(x+1,y); sea(x-1,y); sea(x,y+1); sea(x,y-1); }*/ int kaijou(int a){ int b=1; fo(i,a) b*=i+1; return b; } int nPr(int a,int b){ if(a<b) return 0; if(b==0) return 1; int c=1; for(int i=a;i>a-b;i--){ c*=i; c%=INF; } return c; } int modinv(int a,int m){ int b=m,u=1,v=0; while(b){ int t=a/b; a-=t*b; swap(a,b); u-=t*v; swap(u,v); } u%=m; if(u<0) u+=m; return u; } int lcm(int a,int b){ int c=modinv(gcm(a,b),INF); return ((a*c)%INF)*(b%INF)%INF; } int MOD=INF; int fac[1000010], finv[1000010], inv[1000010]; // テーブルを作る前処理 //先にCOMinit()で前処理をする //ABC145D void COMinit() { fac[0]=fac[1]=1; finv[0]=finv[1]=1; inv[1]=1; for(int i=2;i<1000010;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; } } // 二項係数計算 int COM(int n,int k){ if(n<k) return 0; if(n<0||k<0) return 0; return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD; } bool naka(int a,int b,V<V<char>> c){ return (a>=0&&b>=0&&a<c.sz&&b<c[0].sz); } V<P<int,int>> mawari8={{0,-1},{0,1},{1,0},{-1,0},{-1,-1},{1,1},{1,-1},{-1,-1}}; int inf=1000000000000000007; /* signed main(){ int a,b,c; cin>>a>>b>>c; V<V<edge>> d(a); fo(i,b){ edge e; cin>>e.s>>e.t>>e.d; d[e.s].pb(e); } V<int> e(a,INF); e[c]=0; priority_queue<P<int,int>,V<P<int,int>>,greater<P<int,int>>> f; f.push({0,c}); int h=INF; while(!f.empty()){ P<int,int> g; g=f.top(); f.pop(); int v = g.second, i = g.first; for(edge l : d[v]){ if(e[l.t] > i + l.d){ e[l.t] = i + l.d; f.push({i+l.d , l.t}); } } } fo(i,a){ if(e[i]==INF) cout<<"INF"<<endl; else cout<<e[i]<<endl; } }*/ V<P<int,int>> mawari4={{0,-1},{0,1},{1,0},{-1,0}}; //最短経路の表 a(全部INFで初期化) //縦横 x,y //迷路 f //スタートsx,sy //ゴールgx,gy //文字はgから使おうね /*int bfs_haba(){ Q<P<int,int>> b; a[sx][sy]=0; b.push({sx,sy}); while(!b.empty()){ P<int,int> c=b.front(); b.pop(); if(c.fi==gx&&c.se==gy){ break; } fo(i,4){ int d=c.fi+mawari4[i].fi; int e=c.se+mawari4[i].se; if(0<=d&&0<=e&&d<x&&e<y&&f[d][e]!='#'&&a[d][e]==INF){ b.push({d,e}); a[d][e]=1+a[c.fi][c.se]; } } } return a[gx][gy]; }*/ V<int> onajibubun(string a){ V<int> b(a.sz); for(int i=1,j=0;i<a.sz;i++){ if(i+b[i-j]<j+b[j]) b[i]=b[i-j]; else{ int c=max<int>(0,j+b[j]-i); while(i+c<a.sz&&a[c]==a[i+c]) c++; b[i]=c; j=i; } } b[0]=a.sz; return b; } //各頂点ごとにどこに辺が出てるかの表がc //各頂点ごとの色を表すV<int>(頂点数max)のcolorを用意する //aはどこ塗るか、bは何で塗るかなので、(0,1,c)でよぶとおけ V<int> color(205); bool nibu_hantei(int a,int b,V<V<int>> c){ color[a]=b; fo(i,c[a].sz){ if(b==color[c[a][i]]) return false; if(color[c[a][i]]==0&&!nibu_hantei(c[a][i],-b,c)) return false; } return true; } //aは頂点数 //nibu_hanteiの上にcolorを用意する //各頂点ごとにどこに辺が出てるかの表がc bool renketujanai_nibu_hantei(int a,V<V<int>> c){ fo(i,a){ if(color[i]==0){ if(!nibu_hantei(i,1,c)) return false; } } return true; } signed main(){ int a; cin>>a; V<P<int,P<int,int>>> b(a),c; fo(i,a){ cin>>b[i].fi; b[i].sf=i%2; } c=b; Sort(c); int c=0,d=0; fo(i,b){ if(i%2!=b[c[i].ss].sf){ if(i) c++; else d++; } } cout<<max(c,d)<<endl; }
a.cc: In function 'int main()': a.cc:381:7: error: conflicting declaration 'long long int c' 381 | int c=0,d=0; | ^ a.cc:374:29: note: previous declaration as 'std::vector<std::pair<long long int, std::pair<long long int, long long int> > > c' 374 | V<P<int,P<int,int>>> b(a),c; | ^ a.cc:5:30: error: no match for 'operator<' (operand types are 'long long int' and 'std::vector<std::pair<long long int, std::pair<long long int, long long int> > >') 5 | #define fo(a,b) for(int a=0;a<b;a++) | ^ a.cc:382:3: note: in expansion of macro 'fo' 382 | fo(i,b){ | ^~ In file included from /usr/include/c++/14/regex:68, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181, from a.cc:1: /usr/include/c++/14/bits/regex.h:1143:5: note: candidate: 'template<class _BiIter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const sub_match<_BiIter>&)' 1143 | operator<(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1143:5: note: template argument deduction/substitution failed: a.cc:382:8: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'long long int' 382 | fo(i,b){ | ^ a.cc:5:31: note: in definition of macro 'fo' 5 | #define fo(a,b) for(int a=0;a<b;a++) | ^ /usr/include/c++/14/bits/regex.h:1224:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator<(__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const sub_match<_BiIter>&)' 1224 | operator<(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1224:5: note: template argument deduction/substitution failed: a.cc:382:8: note: mismatched types 'std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>' and 'long long int' 382 | fo(i,b){ | ^ a.cc:5:31: note: in definition of macro 'fo' 5 | #define fo(a,b) for(int a=0;a<b;a++) | ^ /usr/include/c++/14/bits/regex.h:1317:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator<(const sub_match<_BiIter>&, __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)' 1317 | operator<(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1317:5: note: template argument deduction/substitution failed: a.cc:382:8: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'long long int' 382 | fo(i,b){ | ^ a.cc:5:31: note: in definition of macro 'fo' 5 | #define fo(a,b) for(int a=0;a<b;a++) | ^ /usr/include/c++/14/bits/regex.h:1391:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const typename std::iterator_traits<_Iter>::value_type*, const sub_match<_BiIter>&)' 1391 | operator<(typename iterator_traits<_Bi_iter>::value_type const* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1391:5: note: template argument deduction/substitution failed: a.cc:382:8: note: 'std::vector<std::pair<long long int, std::pair<long long int, long long int> > >' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 382 | fo(i,b){ | ^ a.cc:5:31: note: in definition of macro 'fo' 5 | #define fo(a,b) for(int a=0;a<b;a++) | ^ /usr/include/c++/14/bits/regex.h:1485:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)' 1485 | operator<(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1485:5: note: template argument deduction/substitution failed: a.cc:382:8: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'long long int' 382 | fo(i,b){ | ^ a.cc:5:31: note: in definition of macro 'fo' 5 | #define fo(a,b) for(int a=0;a<b;a++) | ^ /usr/include/c++/14/bits/regex.h:1560:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const typename std::iterator_traits<_Iter>::value_type&, const sub_match<_BiIter>&)' 1560 | operator<(typename iterator_traits<_Bi_iter>::value_type const& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1560:5: note: template argument deduction/substitution failed: a.cc:382:8: note: 'std::vector<std::pair<long long int, std::pair<long long int, long long int> > >' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 382 | fo(i,b){ | ^ a.cc:5:31: note: in definition of macro 'fo' 5 | #define fo(a,b) for(int a=0;a<b;a++) | ^ /usr/include/c++/14/bits/regex.h:1660:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&)' 1660 | operator<(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1660:5: note: template argument deduction/substitution failed: a.cc:382:8: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'long long int' 382 | fo(i,b){ | ^ a.cc:5:31: note: in definition of macro 'fo' 5 | #define fo(a,b) for(int a=0;a<b;a++) | ^ In file included from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51: /usr/include/c++/14/bits/stl_pair.h:1045:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator<(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1045 | operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1045:5: note: template argument deduction/substitution failed: a.cc:382:8: note: mismatched types 'const std::pair<_T1, _T2>' and 'long long int' 382 | fo(i,b){ | ^ a.cc:5:31: note: in definition of macro 'fo' 5 | #define fo(a,b) for(int a=0;a<b;a++) | ^ In file included from /usr/include/c++/14/bits/stl_algobase.h:67: /usr/include/c++/14/bits/stl_iterator.h:448:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 448 | operator<(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:448:5: note: template argument deduction/substitution failed: a.cc:382:8: note: mismatched types 'const std::reverse_iterator<_Iterator>' and 'long long int' 382 | fo(i,b){ | ^ a.cc:5:31: note: in definition of macro 'fo' 5 | #define fo(a,b) for(int a=0;a<b;a++) | ^ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 493 | operator<(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: template argument deduction/substitution failed: a.cc:382:8: note: mismatched types 'const std::reverse_iterator<_Iterator>' and 'long long int' 382 | fo(i,b){ | ^ a.cc:5:31: note: in definition of macro 'fo' 5 | #define fo(a,b) for(int a=0;a<b;a++) | ^ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1694 | operator<(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: template argument deduction/substitution failed: a.cc:382:8: note: mismatched types 'const std::move_iterator<_IteratorL>' and 'long long int' 382 | fo(i,b){ | ^ a.cc:5:31: note: in definition of macro 'fo' 5 | #define fo(a,b) for(int a=0;a<b;a++) | ^ /usr/include/c++/14/bits/stl_iterator.h:1760:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)' 1760 | operator<(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1760:5: note: template argument deduction/substitution failed: a.cc:382:8: note: mismatched types 'const std::move_iterator<_IteratorL>' and 'long long int' 382 | fo(i,b){ | ^ a.cc:5:31: note: in definition of macro 'fo' 5 | #define fo(a,b) for(int a=0;a<b;a++) | ^ In file included from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52: /usr/include/c++/14/string_view:673:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)' 673 | operator< (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:673:5: note: template argument deduction/substitution failed: a.cc:382:8: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'long long int' 382 | fo(i,b){ | ^ a.cc:5:31: note: in definition of macro 'fo' 5 | #define fo(a,b) for(int a=0;a<b;a++) | ^ /usr/include/c++/14/string_view:680:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)' 680 | operator< (basic_string_view<_CharT
s929385455
p04021
C++
#include <iostream> #include<algorithm> #include<vector> #define int long long using namespace std; int re(int i){return (i/2)*2;} int solve(int i,int j,int l){ return re(i)+re(j)+re(l); } #define vel vector<long long> #define rep(i,n) for(int i=0;i<n;i++) signed main(void){ int n;cin >>n; vel a(n); rep(i,n){cin >>a[i];} vel s=a;sort(s.begin(),s.end()); int ans=0; for(int i=0;i<n;i+=2){ int x=lower_bound(s.begin(),s.end(),a[i])-s.begin()); ans+=(x%2); } cout <<ans<<endl; }
a.cc: In function 'int main()': a.cc:19:60: error: expected ',' or ';' before ')' token 19 | int x=lower_bound(s.begin(),s.end(),a[i])-s.begin()); | ^
s901032789
p04021
C++
#include <iostream> #include<algorithm> #include<vector> #define int long long using namespace std; int re(int i){return (i/2)*2;} int solve(int i,int j,int l){ return re(i)+re(j)+re(l); } #define vel vector<long long> signed main(void){ int n;cin >>n; vel a(n); rep(i,n){cin >>a[i];} vel s=a;sort(s.begin(),s.end()); int ans=0; for(int i=0;i<n;i+=2){ int x=lower_bound(s.begin(),s.end(),a[i])-s.begin()); ans+=(x%2); } cout <<ans<<endl; }
a.cc: In function 'int main()': a.cc:14:9: error: 'i' was not declared in this scope 14 | rep(i,n){cin >>a[i];} | ^ a.cc:14:5: error: 'rep' was not declared in this scope; did you mean 're'? 14 | rep(i,n){cin >>a[i];} | ^~~ | re a.cc:18:60: error: expected ',' or ';' before ')' token 18 | int x=lower_bound(s.begin(),s.end(),a[i])-s.begin()); | ^
s724534261
p04021
C++
#include <bits/stdc++.h> using namespace std; int main(){ int n; cin >> n; priority_queue<int> kisu,gusu; int a; for(int i=0;i<n;i++){ cin >> a; if(i%2 == 0){ kisu.push(a); }else{ gusu.push(a); } } int ans = 0; for(int i=0;i<n;i++){ if(i%2 == 0){ if(kisu.empty()){ ans++; gusu.pop(); continue; } if(kisu.top() > gusu.top()){ kisu.pop(); }else{ gusu.pop(); ans++; } }else{ if(gusu.empty()){ ans++; kisu.pop(); continue; } if(gusu.top() > kisu.top()){ gusu.pop(); }else{ kisu.pop(); ans++; } } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:45:2: error: expected '}' at end of input 45 | } | ^ a.cc:4:11: note: to match this '{' 4 | int main(){ | ^
s074557168
p04021
C++
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(ll i=0; i<n; i++) typedef long long ll; typedef long long unsigned int llu; ll MOD = 1000000007; ll INF = 1000000009; /* 操作1は連続する2整数を、操作2はひとつ飛ばしの2整数を逆順にする 本来の位置とずれている距離が奇数なら1を足す 51234 21435 */ void solve(){ int n; cin >> n; int a[n+10]; int b[n+10]; rep(i,n){ cin >> a[i]; b[i] = a[i]; } sort(a,a+n); unordered_map<int,int> um; //各値が何番目に小さい値かを保持する rep(i,n){ um.emplace(b[i],i); } int dist = 0; rep(i,n){ //cout << "a[i]:" << a[i] << " um[a[i]]:" << um[a[i]] << " i:" << i << endl; dist += (abs(um[a[i]] - i)%2); } //cout << dist << endl; /* sort(a,a+n, greater<int>()); unordered_map<int,int> um2; //各値が何番目に小さい値かを保持する rep(i,n){ um2.emplace(b[i],i); } int dist2 = 0; rep(i,n){ dist2 += (abs(um2[a[i]] - i)%2); } */ cout << min(dist,dist2)/2 << endl; } int main(){ cin.tie(0); ios::sync_with_stdio(false); solve(); return 0; }
a.cc: In function 'void solve()': a.cc:54:22: error: 'dist2' was not declared in this scope; did you mean 'dist'? 54 | cout << min(dist,dist2)/2 << endl; | ^~~~~ | dist
s556292974
p04021
C++
#include <iostream> #include <vector> using namespace std; int main () { int n; cin >> n; vector<pair<int, int> > a(n); for (int i = 0; i < n; i++) { cin >> a.at(i).first; a.at(i).second = i; } sort(a.begin(), a.end()); int ans = 0; for (int i = 0; i < n; i += 2) { ans += (a.at(i).second - i) % 2; } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:13:3: error: 'sort' was not declared in this scope; did you mean 'short'? 13 | sort(a.begin(), a.end()); | ^~~~ | short
s085459896
p04021
C++
#include <iostream> #include <cstring> #include <algorithm> #include <vector> #include <string> #include <math.h> #include <stdio.h> #include <iomanip> #include <limits> #include <list> #include <queue> #include <tuple> #include <map> #include <sstream> using namespace std; #define MOD (long long int)(1e9+7) #define ll long long int #define rep(i,n) for(int i=0; i<(int)(n); i++) #define reps(i,n) for(int i=1; i<=(int)(n); i++) #define REP(i,n) for(int i=n-1; i>=0; i--) #define REPS(i,n) for(int i=n; i>0; i--) #define FOR(i,a,b) for(int i=a; i<(int)(b); i++) #define ALL(x) (x).begin(),(x).end() #define RALL(a) (a).rbegin(), (a).rend() #define SORT(c) sort(ALL(x)) #define CLR(a) memset((a), 0 ,sizeof(a)) #define PB push_back #define MP make_pair #define SP << " " << const int INF = 1001001001; const ll LINF = 100100100100100100; const double EPS = 1e-10; const double PI = acos(-1.0); typedef pair<int,int> PII; typedef vector<int> VI; typedef vector<VI> VVI; template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ std::fill( (T*)array, (T*)(array+N), val ); } __attribute__((constructor)) void initial(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } const int lim = 100100; // int guuki[INF]; signed main(){ int n; cin>>n; int a; VI A,B; memset(guuki, -1, sizeof(guuki)); rep(i,n){ int a; cin>>a; A.PB(a); //B.PB(a); } VI C,D; rep(i,n){ if(i%2) C.PB(A[i]); } sort(ALL(A)); rep(i,n){ if(i%2) D.PB(A[i]); } sort(ALL(C)); int ans= 0; rep(i,C.size()){ if(C[i]!=D[i]) ans++; } // sort(ALL(B)); // // rep(i,n){ // if(i%2) guuki[B[i]]=1; // else guuki[B[i]]=0; // } // int ans = 0; // rep(i,n){ // if(i%2!=guuki[A[i]]) ans++; // } cout << ans/2 << endl; return 0; }
a.cc: In function 'int main()': a.cc:58:10: error: 'guuki' was not declared in this scope 58 | memset(guuki, -1, sizeof(guuki)); | ^~~~~
s201766377
p04021
C++
#include <iostream> #include <cstring> #include <algorithm> #include <vector> #include <string> #include <math.h> #include <stdio.h> #include <iomanip> #include <limits> #include <list> #include <queue> #include <tuple> #include <map> #include <sstream> using namespace std; #define MOD (long long int)(1e9+7) #define ll long long int #define rep(i,n) for(int i=0; i<(int)(n); i++) #define reps(i,n) for(int i=1; i<=(int)(n); i++) #define REP(i,n) for(int i=n-1; i>=0; i--) #define REPS(i,n) for(int i=n; i>0; i--) #define FOR(i,a,b) for(int i=a; i<(int)(b); i++) #define ALL(x) (x).begin(),(x).end() #define RALL(a) (a).rbegin(), (a).rend() #define SORT(c) sort(ALL(x)) #define CLR(a) memset((a), 0 ,sizeof(a)) #define PB push_back #define MP make_pair #define SP << " " << const int INF = 1001001001; const ll LINF = 100100100100100100; const double EPS = 1e-10; const double PI = acos(-1.0); typedef pair<int,int> PII; typedef vector<int> VI; typedef vector<VI> VVI; template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ std::fill( (T*)array, (T*)(array+N), val ); } __attribute__((constructor)) void initial(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } const int lim = 100100; int guuki[INF]; signed main(){ int n; cin>>n; int a; VI A(lim), B(lim); memset(guuki, -1, sizeof(guuki)); rep(i,n){ cin>>a; A[i] = a; B[i] = a; } B.sort(); rep(i,n){ if(i%2) guuki[B[i]]=1; else guuki[B[i]]=0; } int ans = 0; rep(i,n){ if(i%2!=guuki[A[i]]) ans++; } cout << ans/2 << endl; return 0; }
a.cc: In function 'int main()': a.cc:63:5: error: 'VI' {aka 'class std::vector<int>'} has no member named 'sort' 63 | B.sort(); | ^~~~
s981908401
p04021
C++
#include <iostream> #include <cstring> #include <algorithm> #include <vector> #include <string> #include <math.h> #include <stdio.h> #include <iomanip> #include <limits> #include <list> #include <queue> #include <tuple> #include <map> #include <sstream> using namespace std; #define MOD (long long int)(1e9+7) #define ll long long int #define rep(i,n) for(int i=0; i<(int)(n); i++) #define reps(i,n) for(int i=1; i<=(int)(n); i++) #define REP(i,n) for(int i=n-1; i>=0; i--) #define REPS(i,n) for(int i=n; i>0; i--) #define FOR(i,a,b) for(int i=a; i<(int)(b); i++) #define ALL(x) (x).begin(),(x).end() #define RALL(a) (a).rbegin(), (a).rend() #define SORT(c) sort(ALL(x)) #define CLR(a) memset((a), 0 ,sizeof(a)) #define PB push_back #define MP make_pair #define SP << " " << const int INF = 1001001001; const ll LINF = 100100100100100100; const double EPS = 1e-10; const double PI = acos(-1.0); typedef pair<int,int> PII; typedef vector<int> VI; typedef vector<VI> VVI; template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ std::fill( (T*)array, (T*)(array+N), val ); } __attribute__((constructor)) void initial(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } const int lim = 100100; int guuki[INF], signed main(){ int n; cin>>n; int a; VI A(lim), B(lim); memset(guuki, -1, sizeof(guuki)); rep(i,n){ cin>>a; A[i] = a; B[i] = a; } B.sort(); rep(i,n){ if(i%2) guuki[B[i]]=1; else guuki[B[i]]=0; } int ans = 0; rep(i,n){ if(i%2!=guuki[A[i]]) ans++; } cout << ans/2 << endl; return 0; }
a.cc:55:1: error: expected unqualified-id before 'signed' 55 | signed main(){ | ^~~~~~
s857225043
p04021
C++
#include <iostream> #include <cstring> #include <algorithm> #include <vector> #include <string> #include <math.h> #include <stdio.h> #include <iomanip> #include <limits> #include <list> #include <queue> #include <tuple> #include <map> #include <sstream> using namespace std; #define MOD (long long int)(1e9+7) #define ll long long int #define rep(i,n) for(int i=0; i<(int)(n); i++) #define reps(i,n) for(int i=1; i<=(int)(n); i++) #define REP(i,n) for(int i=n-1; i>=0; i--) #define REPS(i,n) for(int i=n; i>0; i--) #define FOR(i,a,b) for(int i=a; i<(int)(b); i++) #define ALL(x) (x).begin(),(x).end() #define RALL(a) (a).rbegin(), (a).rend() #define SORT(c) sort(ALL(x)) #define CLR(a) memset((a), 0 ,sizeof(a)) #define PB push_back #define MP make_pair #define SP << " " << const int INF = 1001001001; const ll LINF = 100100100100100100; const double EPS = 1e-10; const double PI = acos(-1.0); typedef pair<int,int> PII; typedef vector<int> VI; typedef vector<VI> VVI; template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ std::fill( (T*)array, (T*)(array+N), val ); } __attribute__((constructor)) void initial(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } const int lim = 100100; int guuki[INF], VI A(lim), B(lim); signed main(){ int n; cin>>n; int a; memset(guuki, -1, sizeof(guuki)); rep(i,n){ cin>>a; A[i] = a; B[i] = a; } B.sort(); rep(i,n){ if(i%2) guuki[B[i]]=1; else guuki[B[i]]=0; } int ans = 0; rep(i,n){ if(i%2!=guuki[A[i]]) ans++; } cout << ans/2 << endl; return 0; }
a.cc:52:4: error: expected initializer before 'A' 52 | VI A(lim), B(lim); | ^ a.cc: In function 'int main()': a.cc:61:5: error: 'A' was not declared in this scope 61 | A[i] = a; B[i] = a; | ^ a.cc:61:15: error: 'B' was not declared in this scope 61 | A[i] = a; B[i] = a; | ^ a.cc:63:3: error: 'B' was not declared in this scope 63 | B.sort(); | ^ a.cc:71:19: error: 'A' was not declared in this scope 71 | if(i%2!=guuki[A[i]]) ans++; | ^
s036432681
p04021
C++
#include <iostream> #include <cstring> #include <algorithm> #include <vector> #include <string> #include <math.h> #include <stdio.h> #include <iomanip> #include <limits> #include <list> #include <queue> #include <tuple> #include <map> #include <sstream> using namespace std; #define MOD (long long int)(1e9+7) #define ll long long int #define rep(i,n) for(int i=0; i<(int)(n); i++) #define reps(i,n) for(int i=1; i<=(int)(n); i++) #define REP(i,n) for(int i=n-1; i>=0; i--) #define REPS(i,n) for(int i=n; i>0; i--) #define FOR(i,a,b) for(int i=a; i<(int)(b); i++) #define ALL(x) (x).begin(),(x).end() #define RALL(a) (a).rbegin(), (a).rend() #define SORT(c) sort(ALL(x)) #define CLR(a) memset((a), 0 ,sizeof(a)) #define PB push_back #define MP make_pair #define SP << " " << const int INF = 1001001001; const ll LINF = 100100100100100100; const double EPS = 1e-10; const double PI = acos(-1.0); typedef pair<int,int> PII; typedef vector<int> VI; typedef vector<VI> VVI; template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ std::fill( (T*)array, (T*)(array+N), val ); } __attribute__((constructor)) void initial(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } const int lim = 100100; int guuki[INF], A[lim], B[lim]; signed main(){ int n; cin>>n; int a; memset(guuki, -1, sizeof(guuki)); rep(i,n){ cin>>a; A[i] = a; B[i] = a; } B.sort(); rep(i,n){ if(i%2) guuki[B[i]]=1; else guuki[B[i]]=0; } int ans = 0; rep(i,n){ if(i!=guuki[a[i]]) ans++; } cout << ans/2 << endl; return 0; }
a.cc: In function 'int main()': a.cc:62:5: error: request for member 'sort' in 'B', which is of non-class type 'int [100100]' 62 | B.sort(); | ^~~~ a.cc:70:18: error: invalid types 'int[int]' for array subscript 70 | if(i!=guuki[a[i]]) ans++; | ^
s474015864
p04021
C++
#include <bits/stdc++.h> #define REP(i,n) for(int i=0;i<n;i++) #define REPP(i,n) for(int i=1;i<=n;i++) const double PI = acos(-1); const double EPS = 1e-15; long long INF=(long long)1E17; #define i_7 (long long)(1E9+7) long mod(long a){ long long c=a%i_7; if(c>=0)return c; return c+i_7; } using namespace std; bool prime(int n){ if(n==1){ return false; }else if(n==2){ return true; }else{ for(int i=2;i<=sqrt(n);i++){ if(n%i==0){ return false; } } return true; } } long long gcd(long long a, long long b){ if(a<b){ swap(a,b); } if(a%b==0){ return b; }else{ return gcd(b,a%b); } } long long lcm(long long x, long long y){ return (x/gcd(x,y))*y; } class UnionFind { public: //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。 vector<int> Parent; //クラスを作るときは、Parentの値を全て-1にする。 //以下のようにすると全てバラバラの頂点として解釈できる。 UnionFind(int N) { Parent = vector<int>(N, -1); } //Aがどのグループに属しているか調べる int root(int A) { if (Parent[A] < 0) return A; return Parent[A] = root(Parent[A]); } //自分のいるグループの頂点数を調べる int size(int A) { return -Parent[root(A)];//先祖をrootで取っておきたい。 } //AとBをくっ付ける bool connect(int A, int B) { //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける A = root(A); B = root(B); if (A == B) { //すでにくっついてるからくっ付けない return false; } //大きい方(A)に小さいほう(B)をくっ付けたい //大小が逆だったらAとBをひっくり返す。 if (size(A) < size(B)) swap(A, B); //Aのサイズを更新する Parent[A] += Parent[B]; //Bの親をAに変更する Parent[B] = A; return true; } }; int main(){ int n; cin>>n; vector<int> a(n); map<int,int> mp; REP(i,n){ cin>>a[i]; map[a[i]] = i%2; } int ans=0; sort(a.begin(),a.end()); for(int i=0;i<n;i+=2){ if(mp[a[i]]==0)continue; ans++; } cout<<ans<<endl; return 0; }
a.cc: In function 'int main()': a.cc:99:10: error: expected ']' before '[' token 99 | map[a[i]] = i%2; | ^ | ] a.cc:99:19: error: class template argument deduction failed: 99 | map[a[i]] = i%2; | ^ a.cc:99:19: error: no matching function for call to 'map(int)' In file included from /usr/include/c++/14/map:63, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:152, from a.cc:1: /usr/include/c++/14/bits/stl_map.h:1473:5: note: candidate: 'template<class _InputIterator, class _Compare, class _Allocator, class, class, class> std::map(_InputIterator, _InputIterator, _Compare, _Allocator)-> map<typename remove_const<typename iterator_traits< <template-parameter-1-1> >::value_type::first_type>::type, typename iterator_traits< <template-parameter-1-1> >::value_type::second_type, _Compare, _Allocator>' 1473 | map(_InputIterator, _InputIterator, | ^~~ /usr/include/c++/14/bits/stl_map.h:1473:5: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/bits/stl_map.h:1482:5: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Allocator, class, class> std::map(initializer_list<pair<_T1, _T2> >, _Compare, _Allocator)-> map<_Key, _Tp, _Compare, _Allocator>' 1482 | map(initializer_list<pair<_Key, _Tp>>, | ^~~ /usr/include/c++/14/bits/stl_map.h:1482:5: note: template argument deduction/substitution failed: a.cc:99:19: note: mismatched types 'std::initializer_list<std::pair<_T1, _T2> >' and 'int' 99 | map[a[i]] = i%2; | ^ /usr/include/c++/14/bits/stl_map.h:1489:5: note: candidate: 'template<class _InputIterator, class _Allocator, class, class> std::map(_InputIterator, _InputIterator, _Allocator)-> map<typename remove_const<typename iterator_traits< <template-parameter-1-1> >::value_type::first_type>::type, typename iterator_traits< <template-parameter-1-1> >::value_type::second_type, less<typename remove_const<typename iterator_traits< <template-parameter-1-1> >::value_type::first_type>::type>, _Allocator>' 1489 | map(_InputIterator, _InputIterator, _Allocator) | ^~~ /usr/include/c++/14/bits/stl_map.h:1489:5: note: candidate expects 3 arguments, 1 provided /usr/include/c++/14/bits/stl_map.h:1495:5: note: candidate: 'template<class _Key, class _Tp, class _Allocator, class> std::map(initializer_list<pair<_T1, _T2> >, _Allocator)-> map<_Key, _Tp, less<_Key>, _Allocator>' 1495 | map(initializer_list<pair<_Key, _Tp>>, _Allocator) | ^~~ /usr/include/c++/14/bits/stl_map.h:1495:5: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/bits/stl_map.h:102:11: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc> map(std::map<_Key, _Tp, _Compare, _Alloc>)-> std::map<_Key, _Tp, _Compare, _Alloc>' 102 | class map | ^~~ /usr/include/c++/14/bits/stl_map.h:102:11: note: template argument deduction/substitution failed: a.cc:99:19: note: mismatched types 'std::map<_Key, _Tp, _Compare, _Alloc>' and 'int' 99 | map[a[i]] = i%2; | ^ /usr/include/c++/14/bits/stl_map.h:197:7: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc> map()-> std::map<_Key, _Tp, _Compare, _Alloc>' 197 | map() = default; | ^~~ /usr/include/c++/14/bits/stl_map.h:197:7: note: candidate expects 0 arguments, 1 provided /usr/include/c++/14/bits/stl_map.h:219:7: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc> map(const std::map<_Key, _Tp, _Compare, _Allocator>&)-> std::map<_Key, _Tp, _Compare, _Alloc>' 219 | map(const map&) = default; | ^~~ /usr/include/c++/14/bits/stl_map.h:219:7: note: template argument deduction/substitution failed: a.cc:99:19: note: mismatched types 'const std::map<_Key, _Tp, _Compare, _Allocator>' and 'int' 99 | map[a[i]] = i%2; | ^ /usr/include/c++/14/bits/stl_map.h:227:7: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc> map(std::map<_Key, _Tp, _Compare, _Allocator>&&)-> std::map<_Key, _Tp, _Compare, _Alloc>' 227 | map(map&&) = default; | ^~~ /usr/include/c++/14/bits/stl_map.h:227:7: note: template argument deduction/substitution failed: a.cc:99:19: note: mismatched types 'std::map<_Key, _Tp, _Compare, _Allocator>' and 'int' 99 | map[a[i]] = i%2; | ^ /usr/include/c++/14/bits/stl_map.h:240:7: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc> map(std::initializer_list<std::pair<const _Key, _Val> >, const _Compare&, const _Alloc&)-> std::map<_Key, _Tp, _Compare, _Alloc>' 240 | map(initializer_list<value_type> __l, | ^~~ /usr/include/c++/14/bits/stl_map.h:240:7: note: template argument deduction/substitution failed: a.cc:99:19: note: mismatched types 'std::initializer_list<std::pair<const _Key, _Val> >' and 'int' 99 | map[a[i]] = i%2; | ^ /usr/include/c++/14/bits/stl_map.h:252:7: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc> map(const std::map<_Key, _Tp, _Compare, _Allocator>&, std::__type_identity_t<_Alloc>&)-> std::map<_Key, _Tp, _Compare, _Alloc>' 252 | map(const map& __m, const __type_identity_t<allocator_type>& __a) | ^~~ /usr/include/c++/14/bits/stl_map.h:252:7: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/bits/stl_map.h:256:7: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc> map(std::map<_Key, _Tp, _Compare, _Allocator>&&, std::__type_identity_t<_Alloc>&)-> std::map<_Key, _Tp, _Compare, _Alloc>' 256 | map(map&& __m, const __type_identity_t<allocator_type>& __a) | ^~~ /usr/include/c++/14/bits/stl_map.h:256:7: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/bits/stl_map.h:262:7: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc> map(std::initializer_list<std::pair<const _Key, _Val> >, const _Alloc&)-> std::map<_Key, _Tp, _Compare, _Alloc>' 262 | map(initializer_list<value_type> __l, const allocator_type& __a) | ^~~ /usr/include/c++/14/bits/stl_map.h:262:7: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/bits/stl_map.h:268:9: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc, class _InputIterator> map(_InputIterator, _InputIterator, const _Alloc&)-> std::map<_Key, _Tp, _Compare, _Alloc>' 268 | map(_InputIterator __first, _InputIterator __last, | ^~~ /usr/include/c++/14/bits/stl_map.h:268:9: note: candidate expects 3 arguments, 1 provided /usr/include/c++/14/bits/stl_map.h:285:9: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc, class _InputIterator> map(_InputIterator, _InputIterator)-> std::map<_Key, _Tp, _Compare, _Alloc>' 285 | map(_InputIterator __first, _InputIterator __last) | ^~~ /usr/include/c++/14/bits/stl_map.h:285:9: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/bits/stl_map.h:302:9: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc, class _InputIterator> map(_InputIterator, _InputIterator, const _Compare&, const _Alloc&)-> std::map<_Key, _Tp, _Compare, _Alloc>' 302 | map(_InputIterator __first, _InputIterator __last, | ^~~ /usr/include/c++/14/bits/stl_map.h:302:9: note: candidate expects 3 arguments, 1 provided a.cc:99:19: note: explicit deduction guides not considered for copy-initialization 99 | map[a[i]] = i%2; | ^
s800538922
p04021
C++
#include<iostream> #include<map> using namespace std; const int N=1e5+4; map<int,int> pos1,pos2; int a[N]; int main(){ int n; cin>>n; for(int i=0;i<n;++i) cin>>a[i]; for(int i=0;i<n;++i){ pos1[a[i]]=i; } sort(a,a+n); for(int i=0;i<n;++i){ pos2[a[i]]=i; } int ans=0; for(int i=0;i<n;++i){ int diff=abs(pos1[a[i]]-pos2[a[i]]); ans+=(diff&1); } cout<<ans/2<<endl; }
a.cc: In function 'int main()': a.cc:16:9: error: 'sort' was not declared in this scope; did you mean 'short'? 16 | sort(a,a+n); | ^~~~ | short
s585893397
p04021
C++
#include<bits/stdc++.h> using namespace std; int main(){ int N; cin >> N; vector<pair<int, int>> A; for(int i=0; i<N; i++){ int a; cin >> a; A.push_back({a, i}) } sort(A.begin(), A.end()); int ans = 0; for(int i=0; i<N; i++){ if((A[i].second - i) % 2 == 0) ans++; } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:9:24: error: expected ';' before '}' token 9 | A.push_back({a, i}) | ^ | ; 10 | } | ~
s020993410
p04021
C++
#include<bits/stdc++.h> using namespace std; #define IL inline #define rep(i,j,k) for(int i=j;i<=k;++i) #define repd(i,j,k) for(int i=j;i>=k;--i) #define pb push_back #define db double #define mp make_pair #define mp3(a,b,c) mp(mp(a,b),c) #define pii pair<int,int> #define piii pair<pii,int> #define fr first #define se second #define ll long long #define ull unsigned long long #define pbc(x) __builtin_popcount(x) #define clr(x) memset(x,0,sizeof x) #define SIZE(x) (int)(x.size()) const int mod=1e9+7; IL int pls(int x,int y){x+=y;return x>=mod?x-mod:x;} IL int dec(int x,int y){x-=y;return x<0?x+mod:x;} IL int mul(int x,int y){return 1ll*x*y%mod;} IL int mul(int x,int y,int z){return mul(mul(x,y),z);} IL int mul(int x,int y,int z,int p){return mul(mul(x,y),mul(z,p));} IL void add(int &x,int y){x+=y;x=(x>=mod)?x-mod:x;} IL int fpw(int x,int y,int r=1){for(;y;y>>=1,x=mul(x,x))if(y&1)r=mul(r,x);return r;} IL int inv(int x){return fpw(x,mod-2);} IL int gi(){int x;int _w=scanf("%d",&x);return x;} IL void gi(int &x){int _w=scanf("%d",&x);} IL void write(int x){printf("%d\n",x);} void chkmax(int &x,int y){x=(x>y)?x:y;} void chkmin(int &x,int y){x=(x<y)?x:y;} const int INF=0x3f3f3f3f; template<typename T>IL void debug(T x){cerr<<x;return;} /* --------------------------------------------------------------------------------------------------------- */ const int maxn=1e5+10; int n,a[maxn],b[maxn]; int main(){ n=gi(); rep(i,1,n)a[i]=gi(),b[i]=a[i]; sort(b+1,b+1+n); int cnt=0; rep(i,1,n){ if((i-lower_bound(b+1,b+1+n,a[i])-b)%2==1)cnt++; }cout<<cnt/2<<endl; return 0; }
a.cc: In function 'int main()': a.cc:44:22: error: invalid operands of types 'int' and 'int*' to binary 'operator-' 44 | if((i-lower_bound(b+1,b+1+n,a[i])-b)%2==1)cnt++; | ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | | int int*
s180661297
p04021
C++
#include<iostream> #include<vector> using namespace std; pair<int, int> temp; int main(){ cin >> N; vector<pair<int, int>> A[N]; int a, b; for (int i = 0; i < N; i ++) { cin >> a; temp.first = i; temp.second = a A.push_back(temp); }
a.cc: In function 'int main()': a.cc:9:10: error: 'N' was not declared in this scope 9 | cin >> N; | ^ a.cc:17:20: error: expected ';' before 'A' 17 | temp.second = a | ^ | ; 18 | A.push_back(temp); | ~ a.cc:20:2: error: expected '}' at end of input 20 | } | ^ a.cc:8:11: note: to match this '{' 8 | int main(){ | ^
s176863350
p04021
C++
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i=0;i<n;i++) #define int long long int n,a[100010],cnt; map<int,int>mp; int main(){ cin>> n; rep(i,n){ cin>>a[i]; mp[a[i]]=i; } sort(a,a+n); rep(i,n)cnt+=abs(mp[a[i]]-i); cout<<(cnt%4)/2<<endl; return 0; }
cc1plus: error: '::main' must return 'int'
s407254714
p04021
C++
5 10 8 5 3 2
a.cc:1:1: error: expected unqualified-id before numeric constant 1 | 5 | ^
s084262378
p04021
C++
#include<bits/stdc++.h> using namespace std; #define rep(i, n) for(int (i)=0; (i)<(n); (i)++) #define reps(i, A, n) for(int (i)=(A); (i)<(n); (i)++) #define pb emplace_back #define all(p) (p).begin(), (p).end() using LL = long long; const LL MOD = 1e9+7; int N; vector<int> B[2]; vector<int> A, C; LL BIT[114514]; void Add(int k , int x) { k++; while (k <= 114510) { BIT[k] += x; k += k&-k; } } LL Sum(int k) { k++; LL ret = 0; while (k > 0) { ret += BIT[k]; k -= k&-k; } return ret; } int main() { scanf("%d", &N); A.resize(N); rep(i, N) { scanf("%d", &A[i]); B[i%2].pb(A[i]); } sort(all(A)); sort(all(B[0]); sort(all(B[1]); rep(i, N) { C.pb(B[i%2][i/2]); } LL ans = 0; rep(i, N) { int v = lower_bound(all(A), C[i]) - A.begin(); ans += Sum(v); Add(v, 1); } printf("%lld\n", ans); }
a.cc: In function 'int main()': a.cc:43:17: error: expected ')' before ';' token 43 | sort(all(B[0]); | ~ ^ a.cc:44:17: error: expected ')' before ';' token 44 | sort(all(B[1]); | ~ ^
s364801617
p04021
C++
#include <iostream> #include <map> using namespace std; int main(){ int n; long long int a[100000]; int count = 0; map<long int, int> m; cin >> n; for(int i = 0;i < n;i++){ cin >> a[i]; m[a[i]] = i; } sort(a, a + n); for(int i = 0;i < n;i++){ if((m[a[i]] - i) % 2){ count++; } } cout << (count / 2) << endl; }
a.cc: In function 'int main()': a.cc:14:9: error: 'sort' was not declared in this scope; did you mean 'short'? 14 | sort(a, a + n); | ^~~~ | short
s774073059
p04021
C++
#include <iostream> #include <map> using namespace std; int main(){ int n; long int int a[100000]; int count = 0; map<long int, int> m; cin >> n; for(int i = 0;i < n;i++){ cin >> a[i]; m[a[i]] = i; } sort(a, a + n); for(int i = 0;i < n;i++){ if((m[a[i]] - i) % 2){ count++; } } cout << (count / 2) << endl; }
a.cc: In function 'int main()': a.cc:6:14: error: two or more data types in declaration of 'a' 6 | long int int a[100000]; | ^~~ a.cc:11:24: error: 'a' was not declared in this scope 11 | cin >> a[i]; | ^ a.cc:14:14: error: 'a' was not declared in this scope 14 | sort(a, a + n); | ^ a.cc:14:9: error: 'sort' was not declared in this scope; did you mean 'short'? 14 | sort(a, a + n); | ^~~~ | short
s379546479
p04021
C++
#include <bits/stdc++.h> #define pb push_back #define ppb pop_back #define fi first #define se second #define mid ((x + y) / 2) #define left (ind * 2) #define right (ind * 2 + 1) #define mp make_pair #define timer ((double)clock() / CLOCKS_PER_SEC) #define endl "\n" #define spc " " #define d1(x) cerr<<#x<<":"<<x<<endl #define d2(x, y) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<endl #define d3(x, y, z) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<" "<<#z<<":"<<z<<endl #define fast_io() ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0) using namespace std; typedef long long int lli; typedef pair<int, int> ii; typedef pair<ii, int> iii; typedef pair<double, double> dd; const int N = (int)(1e6 + 5); const int LOG = (int)(20); int main() { fast_io(); //freopen("inp.in", "r", stdin); cin >> n; assert(n >= 5); if(n >= 5) cout << 0; }
a.cc: In function 'int main()': a.cc:33:16: error: 'n' was not declared in this scope 33 | cin >> n; | ^
s337294335
p04021
C++
#include <iostream> #include <vector> #include <math.h> #include <cmath> #include <algorithm> #include <numeric> #include <string> #include <cstring> #include <regex> #include <bits/stdc++.h> using namespace std; using ll = long long; using dbl = double; using pii = pair<int, int>; using pl4 = pair<ll, ll>; using vi = vector<int>; using vvi = vector<vi>; using vs = vector<string>; using vvs = vector<vs>; using vll = vector<ll>; using vvll = vector<vll>; using vvvll = vector<vvll>; using vpii = vector<pii>; using vvpii = vector<vpii>; using vpl4 = vector<pl4>; using vvpl4 = vector<vpl4>; using vd = vector<dbl>; using vvd = vector<vd>; #define fi first #define se second #define mp make_pair #define pb push_back #define pob pop_back() #define sz size() #define be begin() #define en end() #define asn assign #define emp empty() #define ft front() #define bk back() #define clr clear() #define ins insert #define ers erase #define res resize #define tp top() #define p_q priority_queue #define REP(i,a) for(int i=0;i<(a);i++) #define REP1(i,a) for(int i=1;i<=(a);i++) #define rREP(i,a) for(int i=(a-1);i>=0;i--) #define rREP1(i,a) for(int i=(a);i>0;i--) #define FOR(i,a,b) for(int i=(a);i<=(b);i++) #define rFOR(i,a,b) for(int i=(b);i>=(a);i--) #define ROR(v,i) for(auto &(i):(v)) #define IOTA(a,n) iota((a).be,(a).en,(n)) #define SORT(a) sort((a).be,(a).en) #define rSORT(a) sort((a).rbegin(),(a).rend()) #define UNIQUE(a) (a).erase(unique((a).be,(a).en),(a).en) #define PREVP(a) prev_permutation((a).be,(a).en) #define NEXTP(a) next_permutation((a).be,(a).en) #define BINS(a,b) binary_search((a).be,(a).en,(b)) #define LOWB(a,b) (lower_bound((a).be,(a).en,(b))-(a).be) #define UPB(a,b) (upper_bound((a).be,(a).en,(b))-(a).be) #define CNT(a,b) count((a).be,(a).en,b) #define SUM(a) accumulate((a).be,(a).en,0) #define REV(a) reverse((a).be,(a).en) #define REGS(a,b) regex_search((a),regex(b)) #define REGM(a,b) regex_match((a),regex(b)) #define yn(a) cout <<((a)?"yes":"no")<<endl; #define Yn(a) cout <<((a)?"Yes":"No")<<endl; #define YN(a) cout <<((a)?"YES":"NO")<<endl; #define Imp(a) cout <<((a)?"Possible":"Impossible")<<endl; #define say(a) cout <<(a); #define sal(a) cout <<(a)<<endl; #define sak cout <<endl; #define sas cout <<" "; #define sat cout <<"\t"; #define dbg(a) cout <<(#a)<<": "<<(a)<<endl; #define c2l(a) ((ll)(a-48)) #define a2l(a) ((ll)(a-97)) #define A2l(a) ((ll)(a-65)) #define l2c(a) ((char)(a+48)) #define l2a(a) ((char)(a+97)) #define l2A(a) ((char)(a+65)) #define DigN2(a) ((llabs(a)==0)?(1):((ll)(log2(double(llabs(a))))+1)) #define DigN10(a) ((llabs(a)==0)?(1):((ll)(log10(double(llabs(a))))+1)) #define Dig2(a,b) (((a)>>(b))&1) #define Dig10(a,b) (ll)(((a)/((ll)(pow(10.0,(double)(b)))))%10) #define Pow2(a) (1<<(a)) #define Pow10(a) ((ll)(pow(10.0,double(a)))) #define llin(a) ll (a);cin >>(a); #define stin(a) string (a);cin >>(a); #define vin(v) ROR((v),(i)){cin >>(i);}; #define vllin(v,N) vll (v)((N));vin(v); #define vsin(v,N) vs (v)((N));vin(v); #define rdn(a,b) ((a)/(b)) #define rou(a,b) ((((double(a)/double(b))-((a)/(b)))<0.5)?((a)/(b)):(((a)/(b))+1)) #define rup(a,b) ((((a)%(b))==0)?((a)/(b)):(((a)/(b))+1)) #define min(a,b) ((a<b)?(a):(b)) #define max(a,b) ((a>b)?(a):(b)) #define powll(a,b) (ll)(pow((double)(a),(double)(b))) #define Triangle(x1,y1,x2,y2,x3,y3) (((x1)-(x2))*((y1)-(y3))-((x1)-(x3))*((y1)-(y2))) #define int ll const ll MOD = 1e9 + 7; const ll N = 1e5 + 20; //const ll MOD = 998244353; //const ll MOD = 9007199254740881; const ll INF = 1LL << 60; const string alp = "abcdefghijklmnopqrstuvwxyz"; const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; ll gcd(ll a, ll b) { if (b == 0)return a; return gcd(b, a%b); } ll lcm(ll a, ll b) { return a / gcd(a, b)*b; } ll inverse[N]; void init_inverse() { inverse[1] = 1; for (int i = 2; i < N; i++) inverse[i] = (MOD - MOD / i) * inverse[MOD%i] % MOD; } pl4 Bezout(ll a, ll b) { if (b != 0) { pl4 xy; xy = Bezout(b, a%b); return mp(xy.se, xy.fi - ((a / b)*xy.se)); } if (b == 0) { return mp(1, 0); } } pl4 Bez(ll a, ll b, ll c) { pl4 xy; ll x, y, z, gc; xy = Bezout(a, b); gc = gcd(a, b); if (c%gc != 0) return mp(-1, -1); x = xy.fi*(c / gc); y = xy.se*(c / gc); if (x < 0) z = rup(-x, (b / gc)); if (x >= 0) z = -x / (b / gc); x += z * (b / gc); y -= z * (a / gc); return mp(x, y); } void salv(vll v) { say("{"); FOR(i, 0, v.sz - 1) { say(v[i]); if (i != v.sz - 1) say(","); } sal("}") } ll DigS10(ll n) { ll m = 0; FOR(i, 0, DigN10(n) - 1) { m += (ll)((llabs(n) % (ll)(pow(10.0, (double)(i + 1)))) / (ll)(pow(10.0, (double)i))); } return m; } ll isP(ll n) { if (n <= 1) return 0; FOR(i, 2, (ll)sqrt(n)) { if (n%i == 0) return 0; } return 1; } vll FactM(1, 1); vll FactMI(1, 1); ll PowM(ll a, ll b) { ll ans = 1, x = (a%MOD); FOR(i, 0, DigN2(b) - 1) { if (Dig2(b, i) == 1) ans = (ans*x) % MOD; if (i != (DigN2(b) - 1)) x = (x*x) % MOD; } return ans; } void CFactM(ll n) { if (FactM.sz <= n) { FOR(i, FactM.sz, n) { FactM.pb((FactM[i - 1] * (i%MOD)) % MOD); } } return; } void CFactMI(ll n) { CFactM(n); if (FactMI.sz < (n + 1)) FactMI.res(n + 1, -1); if (FactMI[n] == -1) FactMI[n] = PowM(FactM[n], MOD - 2); rFOR(i, 1, n - 1) { if (FactMI[i] != -1) break; FactMI[i] = ((FactMI[i + 1] * ((i + 1) % MOD)) % MOD); } return; } ll CombM(ll n, ll k) { if ((n < 0) || (k < 0)) return 0; if (n < k) return 0; if (n + 1 > FactMI.sz) CFactMI(n); return ((((FactMI[k] * FactMI[n - k]) % MOD)*FactM[n]) % MOD); } ll LIS(vll v, ll m) { if (v.sz > 0) { ll ans = 0; vll dp(v.sz, INF); FOR(i, 0, v.sz - 1) { dp[m ? UPB(dp, v[i]) : LOWB(dp, v[i])] = v[i]; } FOR(i, 0, v.sz - 1) { if (dp[i] == INF) break; ans++; } return ans; } else { return 0; } } signed main() { ll n,aa,r=0; vll a,b; cin >> n; REP(i,n){ cin >> aa; a.pb(aa); } b = a; SORT(a); aa = a.be%2; REP(i,n){ if((find(a.be,a.en,b[i])+aa+i)%2)r++; } cout << r/2; return 0; }
a.cc: In function 'int main()': a.cc:244:12: error: no match for 'operator%' (operand types are 'std::vector<long long int>::iterator' and 'int') 244 | aa = a.be%2; | ^~ | | | int In file included from /usr/include/c++/14/valarray:605, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166, from a.cc:10: /usr/include/c++/14/bits/valarray_after.h:409:5: note: candidate: 'template<class _Dom1, class _Dom2> std::_Expr<std::__detail::_BinClos<std::__modulus, std::_Expr, std::_Expr, _Dom1, _Dom2>, typename std::__fun<std::__modulus, typename _Dom1::value_type>::result_type> std::operator%(const _Expr<_Dom1, typename _Dom1::value_type>&, const _Expr<_Dom2, typename _Dom2::value_type>&)' 409 | _DEFINE_EXPR_BINARY_OPERATOR(%, struct std::__modulus) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:409:5: note: template argument deduction/substitution failed: a.cc:244:13: note: 'std::vector<long long int>::iterator' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>' 244 | aa = a.be%2; | ^ /usr/include/c++/14/bits/valarray_after.h:409:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__modulus, std::_Expr, std::_Constant, _Dom, typename _Dom::value_type>, typename std::__fun<std::__modulus, typename _Dom1::value_type>::result_type> std::operator%(const _Expr<_Dom1, typename _Dom1::value_type>&, const typename _Dom::value_type&)' 409 | _DEFINE_EXPR_BINARY_OPERATOR(%, struct std::__modulus) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:409:5: note: template argument deduction/substitution failed: a.cc:244:13: note: 'std::vector<long long int>::iterator' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>' 244 | aa = a.be%2; | ^ /usr/include/c++/14/bits/valarray_after.h:409:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__modulus, std::_Constant, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__modulus, typename _Dom1::value_type>::result_type> std::operator%(const typename _Dom::value_type&, const _Expr<_Dom1, typename _Dom1::value_type>&)' 409 | _DEFINE_EXPR_BINARY_OPERATOR(%, struct std::__modulus) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:409:5: note: template argument deduction/substitution failed: a.cc:244:13: note: mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'int' 244 | aa = a.be%2; | ^ /usr/include/c++/14/bits/valarray_after.h:409:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__modulus, std::_Expr, std::_ValArray, _Dom, typename _Dom::value_type>, typename std::__fun<std::__modulus, typename _Dom1::value_type>::result_type> std::operator%(const _Expr<_Dom1, typename _Dom1::value_type>&, const valarray<typename _Dom::value_type>&)' 409 | _DEFINE_EXPR_BINARY_OPERATOR(%, struct std::__modulus) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:409:5: note: template argument deduction/substitution failed: a.cc:244:13: note: 'std::vector<long long int>::iterator' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>' 244 | aa = a.be%2; | ^ /usr/include/c++/14/bits/valarray_after.h:409:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__modulus, std::_ValArray, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__modulus, typename _Dom1::value_type>::result_type> std::operator%(const valarray<typename _Dom::value_type>&, const _Expr<_Dom1, typename _Dom1::value_type>&)' 409 | _DEFINE_EXPR_BINARY_OPERATOR(%, struct std::__modulus) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:409:5: note: template argument deduction/substitution failed: a.cc:244:13: note: mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'int' 244 | aa = a.be%2; | ^ /usr/include/c++/14/valarray:1200:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__modulus, std::_ValArray, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__modulus, _Tp>::result_type> std::operator%(const valarray<_Tp>&, const valarray<_Tp>&)' 1200 | _DEFINE_BINARY_OPERATOR(%, __modulus) | ^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/valarray:1200:1: note: template argument deduction/substitution failed: a.cc:244:13: note: 'std::vector<long long int>::iterator' is not derived from 'const std::valarray<_Tp>' 244 | aa = a.be%2; | ^ /usr/include/c++/14/valarray:1200:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__modulus, std::_ValArray, std::_Constant, _Tp, _Tp>, typename std::__fun<std::__modulus, _Tp>::result_type> std::operator%(const valarray<_Tp>&, const typename valarray<_Tp>::value_type&)' 1200 | _DEFINE_BINARY_OPERATOR(%, __modulus) | ^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/valarray:1200:1: note: template argument deduction/substitution failed: a.cc:244:13: note: 'std::vector<long long int>::iterator' is not derived from 'const std::valarray<_Tp>' 244 | aa = a.be%2; | ^ /usr/include/c++/14/valarray:1200:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__modulus, std::_Constant, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__modulus, _Tp>::result_type> std::operator%(const typename valarray<_Tp>::value_type&, const valarray<_Tp>&)' 1200 | _DEFINE_BINARY_OPERATOR(%, __modulus) | ^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/valarray:1200:1: note: template argument deduction/substitution failed: a.cc:244:13: note: mismatched types 'const std::valarray<_Tp>' and 'int' 244 | aa = a.be%2; | ^ a.cc:246:35: error: no match for 'operator%' (operand types are '__gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >' and 'int') 246 | if((find(a.be,a.en,b[i])+aa+i)%2)r++; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~ | | | | | int | __gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> > /usr/include/c++/14/bits/valarray_after.h:409:5: note: candidate: 'template<class _Dom1, class _Dom2> std::_Expr<std::__detail::_BinClos<std::__modulus, std::_Expr, std::_Expr, _Dom1, _Dom2>, typename std::__fun<std::__modulus, typename _Dom1::value_type>::result_type> std::operator%(const _Expr<_Dom1, typename _Dom1::value_type>&, const _Expr<_Dom2, typename _Dom2::value_type>&)' 409 | _DEFINE_EXPR_BINARY_OPERATOR(%, struct std::__modulus) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:409:5: note: template argument deduction/substitution failed: a.cc:246:36: note: '__gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>' 246 | if((find(a.be,a.en,b[i])+aa+i)%2)r++; | ^ /usr/include/c++/14/bits/valarray_after.h:409:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__modulus, std::_Expr, std::_Constant, _Dom, typename _Dom::value_type>, typename std::__fun<std::__modulus, typename _Dom1::value_type>::result_type> std::operator%(const _Expr<_Dom1, typename _Dom1::value_type>&, const typename _Dom::value_type&)' 409 | _DEFINE_EXPR_BINARY_OPERATOR(%, struct std::__modulus) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:409:5: note: template argument deduction/substitution failed: a.cc:246:36: note: '__gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>' 246 | if((find(a.be,a.en,b[i])+aa+i)%2)r++; | ^ /usr/include/c++/14/bits/valarray_after.h:409:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__modulus, std::_Constant, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__modulus, typename _Dom1::value_type>::result_type> std::operator%(const typename _Dom::value_type&, const _Expr<_Dom1, typename _Dom1::value_type>&)' 409 | _DEFINE_EXPR_BINARY_OPERATOR(%, struct std::__modulus) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:409:5: note: template argument deduction/substitution failed: a.cc:246:36: note: mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'int' 246 | if((find(a.be,a.en,b[i])+aa+i)%2)r++; | ^ /usr/include/c++/14/bits/valarray_after.h:409:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__modulus, std::_Expr, std::_ValArray, _Dom, typename _Dom::value_type>, typename std::__fun<std::__modulus, typename _Dom1::value_type>::result_type> std::operator%(const _Expr<_Dom1, typename _Dom1::value_type>&, const valarray<typename _Dom::value_type>&)' 409 | _DEFINE_EXPR_BINARY_OPERATOR(%, struct std::__modulus) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:409:5: note: template argument deduction/substitution failed: a.cc:246:36: note: '__gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>' 246 | if((find(a.be,a.en,b[i])+aa+i)%2)r++; | ^ /usr/include/c++/14/bits/valarray_after.h:409:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__modulus, std::_ValArray, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__modulus, typename _Dom1::value_type>::result_type> std::operator%(const valarray<typename _Dom::value_type>&, const _Expr<_Dom1, t
s604251878
p04021
C++
#include<cstdio> #include<cctype> #include<map> #include<algorithm> using namespace std; const int maxn=1e5+7; int a[maxn],b[maxn]; inline int read() { int f = 1, num = 0; char ch = getchar(); while(0 == isdigit(ch)) { if(ch == '-')f = -1; ch = getchar(); } while(0 != isdigit(ch)) num = (num << 1) + (num << 3) + ch - '0', ch = getchar(); return num * f; } map<int,int> rank; int main() { int n=read(); for(int i=1;i<=n;i++){ a[i]=read(); b[i]=a[i]; } sort(a+1,a+1+n); for(int i=1;i<=n;i++) rank[a[i]]=i; for(int i=1;i<=n;i++) b[i]=rank[b[i]]; int ans=0; for(int i=1;i<=n;i++){ if(b[i]%2!=i%2) ans++; } printf("%d",ans>>1); }
a.cc: In function 'int main()': a.cc:27:9: error: reference to 'rank' is ambiguous 27 | rank[a[i]]=i; | ^~~~ In file included from /usr/include/c++/14/bits/stl_pair.h:60, from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/bits/stl_tree.h:63, from /usr/include/c++/14/map:62, from a.cc:3: /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:18:14: note: 'std::map<int, int> rank' 18 | map<int,int> rank; | ^~~~ a.cc:29:14: error: reference to 'rank' is ambiguous 29 | b[i]=rank[b[i]]; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:18:14: note: 'std::map<int, int> rank' 18 | map<int,int> rank; | ^~~~
s548529457
p04021
C++
#include<bits/stdc++.h> #define SC scanf using namespace std; struct data { long long ywz,num; } tong[100001]; long long n,ans; bool cmp1(data x,data y) { return x.num < y.num; } int main() { SC("%lld",&n); for(long long i = 1; i <= n; i++) { SC("%lld",&tong[i].num); tong[i].ywz = i; } sort(tong+1,tong+n+1,cmp1); for(int i = 1; i <= n; i++) if((tong[i].ywz%2 == i%2) ans++; printf("%lld",ans); }
a.cc:11:11: error: reference to 'data' is ambiguous 11 | bool cmp1(data x,data y) | ^~~~ In file included from /usr/include/c++/14/string:53, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52, from a.cc:1: /usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)' 344 | data(initializer_list<_Tp> __il) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])' 334 | data(_Tp (&__array)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)' 323 | data(const _Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ /usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)' 312 | data(_Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ a.cc:5:8: note: 'struct data' 5 | struct data | ^~~~ a.cc:11:18: error: reference to 'data' is ambiguous 11 | bool cmp1(data x,data y) | ^~~~ /usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)' 344 | data(initializer_list<_Tp> __il) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])' 334 | data(_Tp (&__array)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)' 323 | data(const _Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ /usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)' 312 | data(_Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ a.cc:5:8: note: 'struct data' 5 | struct data | ^~~~ a.cc:11:24: error: expression list treated as compound expression in initializer [-fpermissive] 11 | bool cmp1(data x,data y) | ^ a.cc: In function 'int main()': a.cc:26:42: error: expected ';' before 'ans' 26 | if((tong[i].ywz%2 == i%2) | ^ | ; 27 | ans++; | ~~~ a.cc:28:27: error: expected ')' before ';' token 28 | printf("%lld",ans); | ^ | ) a.cc:26:19: note: to match this '(' 26 | if((tong[i].ywz%2 == i%2) | ^ In file included from /usr/include/c++/14/bits/stl_algobase.h:71, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51: /usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'constexpr bool __gnu_cxx::__ops::_Iter_comp_iter<_Compare>::operator()(_Iterator1, _Iterator2) [with _Iterator1 = data*; _Iterator2 = data*; _Compare = bool]': /usr/include/c++/14/bits/stl_algo.h:1777:14: required from 'void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool>]' 1777 | if (__comp(__i, __first)) | ~~~~~~^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1817:25: required from 'void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool>]' 1817 | std::__insertion_sort(__first, __first + int(_S_threshold), __comp); | ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1908:31: required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool>]' 1908 | std::__final_insertion_sort(__first, __last, __comp); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:4805:18: required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = data*; _Compare = bool]' 4805 | std::__sort(__first, __last, __gnu_cxx::__ops::__iter_comp_iter(__comp)); | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:24:6: required from here 24 | sort(tong+1,tong+n+1,cmp1); | ~~~~^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h:158:30: error: expression cannot be used as a function 158 | { return bool(_M_comp(*__it1, *__it2)); } | ~~~~~~~^~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Val_comp_iter<_Compare>::operator()(_Value&, _Iterator) [with _Value = data; _Iterator = data*; _Compare = bool]': /usr/include/c++/14/bits/stl_algo.h:1757:20: required from 'void std::__unguarded_linear_insert(_RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Val_comp_iter<bool>]' 1757 | while (__comp(__val, __next)) | ~~~~~~^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1785:36: required from 'void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool>]' 1785 | std::__unguarded_linear_insert(__i, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~ 1786 | __gnu_cxx::__ops::__val_comp_iter(__comp)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1817:25: required from 'void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool>]' 1817 | std::__insertion_sort(__first, __first + int(_S_threshold), __comp); | ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1908:31: required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool>]' 1908 | std::__final_insertion_sort(__first, __last, __comp); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:4805:18: required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = data*; _Compare = bool]' 4805 | std::__sort(__first, __last, __gnu_cxx::__ops::__iter_comp_iter(__comp)); | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:24:6: required from here 24 | sort(tong+1,tong+n+1,cmp1); | ~~~~^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h:240:30: error: expression cannot be used as a function 240 | { return bool(_M_comp(__val, *__it)); } | ~~~~~~~^~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_comp_val<_Compare>::operator()(_Iterator, _Value&) [with _Iterator = data*; _Value = data; _Compare = bool]': /usr/include/c++/14/bits/stl_heap.h:140:48: required from 'void std::__push_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare&) [with _RandomAccessIterator = data*; _Distance = long int; _Tp = data; _Compare = __gnu_cxx::__ops::_Iter_comp_val<bool>]' 140 | while (__holeIndex > __topIndex && __comp(__first + __parent, __value)) | ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_heap.h:247:23: required from 'void std::__adjust_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare) [with _RandomAccessIterator = data*; _Distance = long int; _Tp = data; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool>]' 247 | std::__push_heap(__first, __holeIndex, __topIndex, | ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 248 | _GLIBCXX_MOVE(__value), __cmp); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_heap.h:356:22: required from 'void std::__make_heap(_RandomAccessIterator, _RandomAccessIterator, _Compare&) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool>]' 356 | std::__adjust_heap(__first, __parent, __len, _GLIBCXX_MOVE(__value), | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 357 | __comp); | ~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1593:23: required from 'void std::__heap_select(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool>]' 1593 | std::__make_heap(__first, __middle, __comp); | ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1868:25: required from 'void std::__partial_sort(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool>]' 1868 | std::__heap_select(__first, __middle, __last, __comp); | ~~~~~~~~~~~~~~~~~
s399559009
p04021
C++
#include<cstdio> #include<cstring> #include<algorithm> using namespace std; struct node { int x=0,p=0; }; bool cmp(node a,node b) { return a.x<b.x; } int main() { data a[100005]; data b[100005]; int l=1,n,i; scanf("%d",&n); for(i=1;i<=n;i++) { scanf("%d",&a[i].x); a[i].p=i; } sort(a+1,a+n+1,cmp); int ans=0; for(i=1;i<=n;i++) { if(abs(a[i].p-i)%2!=0) { ans++; } } printf("%d\n",ans/2); return 0; }
a.cc: In function 'int main()': a.cc:14:5: error: 'data' was not declared in this scope 14 | { data a[100005]; | ^~~~ a.cc:15:9: error: expected ';' before 'b' 15 | data b[100005]; | ^~ | ; a.cc:20:21: error: 'a' was not declared in this scope 20 | scanf("%d",&a[i].x); | ^ a.cc:23:10: error: 'a' was not declared in this scope 23 | sort(a+1,a+n+1,cmp); | ^
s016283125
p04021
C++
#include <iostream> using namespace std; const int N = 1e6 + 10; typedef pair <int, int> pii; int n; pii a[N]; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> a[i].first; a[i].second = i; } int ans = 0; sort (a, a + n); for (int i = 0; i < n; i += 2) if ((i % 2) != (a[i].second % 2)) ans ++; cout << ans << endl; }
a.cc: In function 'int main()': a.cc:18:9: error: 'sort' was not declared in this scope; did you mean 'short'? 18 | sort (a, a + n); | ^~~~ | short
s861595591
p04021
C
#include<iostream> #include<algorithm> #include<iomanip> #include <stdio.h> #include <string.h> #include <vector> #include <map> #include <set> #include <queue> #include <new> #include <cmath> #include<fstream> using namespace std; #define Precision(i) cout << fixed << setprecision(i) #define endl '\n' typedef long long ll; typedef long double ld; typedef pair <int, int> pii; typedef pair <long long, long long> pll; const ll N = 1e5 + 100, MOD = 1e9 + 7, INF = 1e17, SQ = 350, LOG = 20; ll n, m, x1, x2, d, z , t, sum,y, maxi,mini, ans, ptr, x, q, a[N], b[N], k; map <ll, int> mp; int main() { //ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; b[i] = a[i]; } sort(a, a + n); for (int i = 0; i < n; i++) { mp[a[i]] = i % 2; } for (int i = 0; i < n; i++) { if (mp[b[i]] != i % 2) ans++; } cout << ans / 2; }
main.c:1:9: fatal error: iostream: No such file or directory 1 | #include<iostream> | ^~~~~~~~~~ compilation terminated.
s467947947
p04021
C
// IN THE NAME OF GOD #include <bits/stdc++.h> #define ll long long #define pb push_back #define ff first #define ss second using namespace std; const int MAXN = 1e5 + 15; int n, a[MAXN], ans; map <int, int> pos; vector <int> vect; int main(){ //ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); cin >> n; for(int i = 0; i < n; i++) cin >> a[i], vect.pb(a[i]); sort(vect.begin(), vect.end()); for(int i = 0; i < vect.size(); i++) pos[vect[i]] = i; for(int i = 0; i < n; i++) if(abs(i - pos[a[i]]) % 2) ans++; cout << ans / 2 << endl; }
main.c:2:10: fatal error: bits/stdc++.h: No such file or directory 2 | #include <bits/stdc++.h> | ^~~~~~~~~~~~~~~ compilation terminated.
s644520736
p04021
C
// IN THE NAME OF GOD #include <bits/stdc++.h> #define ll long long #define pb push_back #define ff first #define ss second using namespace std; const int MAXN = 1e5 + 15; int n, a[MAXN], ans; map <int, int> pos; vector <int> vect; int main(){ //ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); cin >> n; for(int i = 0; i < n; i++) cin >> a[i], vect.pb(a[i]); sort(vect.begin(), vect.end()); for(int i = 0; i < (int)vect.size(); i++) pos[vect[i]] = i; for(int i = 0; i < n; i++) if(abs(i - pos[a[i]]) % 2) ans++; cout << ans / 2 << endl; }
main.c:2:10: fatal error: bits/stdc++.h: No such file or directory 2 | #include <bits/stdc++.h> | ^~~~~~~~~~~~~~~ compilation terminated.
s874797731
p04021
C++
#include<bits/stdc++.h> using namespace std; #define fs first #define sc second #define mp make_pair #define pb push_back #define eb emplace_back #define ALL(A) A.begin(),A.end() #define RALL(A) A.rbegin(),A.rend() typedef long long LL; typedef pair<LL,LL> P; const LL mod=1e9+7; const LL LINF=1LL<<62; int main(){ int N; cic >> N; LL A[N],t[N]; for(int i=0;i<N;i++){ cin >> A[i]; t[i]=A[i]; } sort(t,t+N); map<LL,int> ma; for(int i=0;i<N;i++) ma[t[i]]=i; int ans=0; for(int i=0;i<N;i++) if(i%2!=ma[A[i]]%2) ans++; cout << ans/2 << endl; return 0; }
a.cc: In function 'int main()': a.cc:18:3: error: 'cic' was not declared in this scope 18 | cic >> N; | ^~~