submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s656765882
p03821
C++
#include<string> #include<iostream> #include<algorithm> #include<set> #include<math.h> #include<vector> #include<sstream> #include<queue> #include<functional> #include<bitset> #include<cstdio> #include<iomanip> #include <cstring> #include <climits> using namespace std; #define REP(i,n) for(int i=0;i < n; i++) #define RREP(i,n) for(int i=n-1;i >=0; i--) #define p(a) (a) * (a) #define p2(a,b) p((a) - (b)) #define MAX 101 #define MAX_V 15 int n, i, j, k; inline bool cmp(const int &a, const int &b) { return f[a]>f[b]; } int f[100005], son[100005], Next[100005]; int id[100005]; void dfs(int x) { if (!son[x])return; int i, j, k = 0; for (i = son[x]; i; i = Next[i])dfs(i); for (i = son[x]; i; i = Next[i])id[++k] = i; sort(id + 1, id + k + 1, cmp); for (i = 1; i <= k; ++i) { j = f[id[i]] + i; if (j>f[x])f[x] = j; } } int main() { cin >> n; for (int i = 2; i <= n; i++) { cin >> k; Next[i] = son[k]; son[k] = i; } dfs(1); cout << f[i] << endl; return 0; }
a.cc: In function 'bool cmp(const int&, const int&)': a.cc:23:54: error: 'f' was not declared in this scope 23 | inline bool cmp(const int &a, const int &b) { return f[a]>f[b]; } | ^
s487779099
p03821
C
#include <stdio.h> int main(){ int count = 0; int N=0; int i,j; scanf("%d\n",&N); int A[N]; int B[N]; for(i=0;i<N;i++){ scanf("%d %d\n",&A[i],&B[i]); } int d=0; for(i = N-1;i>=0;i--){ d = B[i] - (A[i]%B[i]); if(A[i]%B[i]==0) continue; for(j=0;j<=i;j++){ A[j]+=d; } count += d; } printf("%d\n",count); return 0; } #include <stdio.h> int main(){ int count = 0; int N=0; int i,j; scanf("%d\n",&N); int A[N]; int B[N]; for(i=0;i<N;i++){ scanf("%d %d\n",&A[i],&B[i]); } int d=0; for(i = N-1;i>=0;i--){ d = B[i] - (A[i]%B[i]); if(A[i]%B[i]==0) continue; for(j=0;j<=i;j++){ A[j]+=d; } count += d; } printf("%d\n",count); return 0; }
main.c:25:5: error: redefinition of 'main' 25 | int main(){ | ^~~~ main.c:2:5: note: previous definition of 'main' with type 'int()' 2 | int main(){ | ^~~~
s967618306
p03821
C++
#include <iostream> #include <vector> #define int unsigned long long using namespace std; int n; int a[100000], b[100000]; unsigned main(void) { cin >> n; for (int i = 0; i < n; i++) { cin >> a[i] >> b[i]; } int ans = 0; for (int i = n - 1; i >= 0; i--) { a[i] += ans; if (a[i] % b[i] == 0) { continue; } int n = a[i] / b[i]; int d = b[i] * (n + 1) - a[i]; ans += d; } cout << ans << endl; return 0; }
cc1plus: error: '::main' must return 'int'
s408633477
p03821
C++
#include <iostream> #include <cstdio> #include <cstring> #include <cstdlib> #include <algorithm> #include <vector> #define rep(i, n) for (int i = 0; i < n; ++i) #define REP(i, m, n) for (int i = m, i < n; ++i) #define INF 1000 * 1000 using namespace std; int main() { long long a[100000], b[100000]; long long c; long long n; cin >> n; rep(i, n) cin >> a[i] >> b[i]; long long count = 0; for (int i = n - 1; i >= 0; --i) { c = a[i] % b[i]; if (a[i] < b[i]) { count += b[i] - a[i]; a[i] = b[i]; } else if (a[i] > b[i]) { if (a[i] % b[i] != 0) { a[i] += b[i] - c; count += b[i] - c; } } if (i > 0) a[i - 1] += count; } } cout << count << endl; return 0; }
a.cc:44:3: error: 'cout' does not name a type 44 | cout << count << endl; | ^~~~ a.cc:46:3: error: expected unqualified-id before 'return' 46 | return 0; | ^~~~~~ a.cc:48:1: error: expected declaration before '}' token 48 | } | ^
s409506769
p03821
Java
//package com.grand9; import java.util.Scanner; public class Main1 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); long A[] =new long [N]; long B[] = new long [N]; for(int i=0;i<N;i++){ A[i]= sc.nextInt(); B[i]=sc.nextInt(); } long ans = 0; for(int i =N-1;i>=0;i-- ){ if((A[i]+ans)%B[i]!=0L){ long plus = ((A[i]+ans)/B[i]+1L)*B[i]-A[i]-ans; ans += plus; } //System.out.println(ans); } System.out.println(ans); sc.close(); } }
Main.java:5: error: class Main1 is public, should be declared in a file named Main1.java public class Main1 { ^ 1 error
s106211357
p03821
C++
#include<stdio.h> #include<vector> #include<queue> #include<algorithm> #include<string.h> #include<string> #include<stack> #include<set> #include<map> #include<iostream> #include<assert.h> #include<unordered_map> //#define Min(a,b,c) min((a),min((b),(c))) #define mp(a,b) make_pair((a),(b)) #define pii pair<int,int> #define pll pair<LL,LL> #define pb(x) push_back(x) #define x first #define y second #define sqr(x) ((x)*(x)) #define EPS 1e-11 #define pi 3.14159265359 #define pmm pair<map<int,int>*,map<int,LL>*> typedef long long LL; using namespace std; const LL mod=1e9+7; int main(){ int n; LL a,b; scanf("%d %lld %lld",&n,&a,&b); LL s[100005]; for(int i=0;i<n;i++){ scanf("%lld",&s[i]); } queue<pair<pll,int> > q; q.push(mp(mp(-1e18,-1e18),1ll)); unordered_map<pll,int> m; for(int i=0;i<n;i++){ m.clear(); while(!q.empty()){ pair<pll,LL> p=q.front();q.pop(); if(s[i]-p.x.x>=a){ if(i!=n-1){ m[mp(max(s[i],s[i+1]-a),max(p.x.y,s[i+1]-b))]=(m[mp(max(s[i],s[i+1]-a),max(p.x.y,s[i+1]-b))]+p.y)%mod; } else m[mp(s[i],p.x.y)]=(m[mp(s[i],p.x.y)]+p.y)%mod; } if(s[i]-p.x.y>=b){ if(i!=n-1){ m[mp(max(p.x.x,s[i+1]-a),max(s[i],s[i+1]-b))]=(m[mp(max(p.x.x,s[i+1]-a),max(s[i],s[i+1]-b))]+p.y)%mod; } else m[mp(p.x.x,s[i])]=(m[mp(p.x.x,s[i])]+p.y)%mod; } } for(unordered_map<pll,int>::iterator it=m.begin();it!=m.end();it++) q.push(*it); } int ans=0; while(!q.empty()){ pair<pll,int> p=q.front();q.pop(); ans+=p.y; ans%=mod; } printf("%lld\n",ans); }
a.cc: In function 'int main()': a.cc:37:32: error: use of deleted function 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = std::pair<long long int, long long int>; _Tp = int; _Hash = std::hash<std::pair<long long int, long long int> >; _Pred = std::equal_to<std::pair<long long int, long long int> >; _Alloc = std::allocator<std::pair<const std::pair<long long int, long long int>, int> >]' 37 | unordered_map<pll,int> m; | ^ In file included from /usr/include/c++/14/unordered_map:41, from a.cc:12: /usr/include/c++/14/bits/unordered_map.h:148:7: note: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = std::pair<long long int, long long int>; _Tp = int; _Hash = std::hash<std::pair<long long int, long long int> >; _Pred = std::equal_to<std::pair<long long int, long long int> >; _Alloc = std::allocator<std::pair<const std::pair<long long int, long long int>, int> >]' is implicitly deleted because the default definition would be ill-formed: 148 | unordered_map() = default; | ^~~~~~~~~~~~~ /usr/include/c++/14/bits/unordered_map.h: At global scope: /usr/include/c++/14/bits/unordered_map.h:148:7: error: use of deleted function 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::pair<long long int, long long int>; _Value = std::pair<const std::pair<long long int, long long int>, int>; _Alloc = std::allocator<std::pair<const std::pair<long long int, long long int>, int> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<long long int, long long int> >; _Hash = std::hash<std::pair<long long int, long long int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' In file included from /usr/include/c++/14/bits/unordered_map.h:33: /usr/include/c++/14/bits/hashtable.h:539:7: note: 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::pair<long long int, long long int>; _Value = std::pair<const std::pair<long long int, long long int>, int>; _Alloc = std::allocator<std::pair<const std::pair<long long int, long long int>, int> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<long long int, long long int> >; _Hash = std::hash<std::pair<long long int, long long int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' is implicitly deleted because the default definition would be ill-formed: 539 | _Hashtable() = default; | ^~~~~~~~~~ /usr/include/c++/14/bits/hashtable.h:539:7: error: use of deleted function 'std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = std::pair<long long int, long long int>; _Value = std::pair<const std::pair<long long int, long long int>, int>; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<long long int, long long int> >; _Hash = std::hash<std::pair<long long int, long long int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' In file included from /usr/include/c++/14/bits/hashtable.h:35: /usr/include/c++/14/bits/hashtable_policy.h:1731:7: note: 'std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = std::pair<long long int, long long int>; _Value = std::pair<const std::pair<long long int, long long int>, int>; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<long long int, long long int> >; _Hash = std::hash<std::pair<long long int, long long int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' is implicitly deleted because the default definition would be ill-formed: 1731 | _Hashtable_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1731:7: error: use of deleted function 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_Hash_code_base() [with _Key = std::pair<long long int, long long int>; _Value = std::pair<const std::pair<long long int, long long int>, int>; _ExtractKey = std::__detail::_Select1st; _Hash = std::hash<std::pair<long long int, long long int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]' /usr/include/c++/14/bits/hashtable_policy.h: In instantiation of 'std::__detail::_Hashtable_ebo_helper<_Nm, _Tp, true>::_Hashtable_ebo_helper() [with int _Nm = 1; _Tp = std::hash<std::pair<long long int, long long int> >]': /usr/include/c++/14/bits/hashtable_policy.h:1328:7: required from here 1328 | _Hash_code_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1245:49: error: use of deleted function 'std::hash<std::pair<long long int, long long int> >::hash()' 1245 | _Hashtable_ebo_helper() noexcept(noexcept(_Tp())) : _Tp() { } | ^~~~~ In file included from /usr/include/c++/14/bits/stl_bvector.h:65, from /usr/include/c++/14/vector:67, from a.cc:2: /usr/include/c++/14/bits/functional_hash.h:102:12: note: 'std::hash<std::pair<long long int, long long int> >::hash()' is implicitly deleted because the default definition would be ill-formed: 102 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/14/bits/functional_hash.h:102:12: error: no matching function for call to 'std::__hash_enum<std::pair<long long int, long long int>, false>::__hash_enum()' /usr/include/c++/14/bits/functional_hash.h:83:7: note: candidate: 'std::__hash_enum<_Tp, <anonymous> >::__hash_enum(std::__hash_enum<_Tp, <anonymous> >&&) [with _Tp = std::pair<long long int, long long int>; bool <anonymous> = false]' 83 | __hash_enum(__hash_enum&&); | ^~~~~~~~~~~ /usr/include/c++/14/bits/functional_hash.h:83:7: note: candidate expects 1 argument, 0 provided /usr/include/c++/14/bits/functional_hash.h:102:12: error: 'std::__hash_enum<_Tp, <anonymous> >::~__hash_enum() [with _Tp = std::pair<long long int, long long int>; bool <anonymous> = false]' is private within this context 102 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/14/bits/functional_hash.h:84:7: note: declared private here 84 | ~__hash_enum(); | ^ /usr/include/c++/14/bits/hashtable_policy.h:1245:49: note: use '-fdiagnostics-all-candidates' to display considered candidates 1245 | _Hashtable_ebo_helper() noexcept(noexcept(_Tp())) : _Tp() { } | ^~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1328:7: note: 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_Hash_code_base() [with _Key = std::pair<long long int, long long int>; _Value = std::pair<const std::pair<long long int, long long int>, int>; _ExtractKey = std::__detail::_Select1st; _Hash = std::hash<std::pair<long long int, long long int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]' is implicitly deleted because the default definition would be ill-formed: 1328 | _Hash_code_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1328:7: error: use of deleted function 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<long long int, long long int> >, true>::~_Hashtable_ebo_helper()' /usr/include/c++/14/bits/hashtable_policy.h:1242:12: note: 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<long long int, long long int> >, true>::~_Hashtable_ebo_helper()' is implicitly deleted because the default definition would be ill-formed: 1242 | struct _Hashtable_ebo_helper<_Nm, _Tp, true> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1242:12: error: use of deleted function 'std::hash<std::pair<long long int, long long int> >::~hash()' /usr/include/c++/14/bits/functional_hash.h:102:12: note: 'std::hash<std::pair<long long int, long long int> >::~hash()' is implicitly deleted because the default definition would be ill-formed: 102 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/14/bits/functional_hash.h:102:12: error: 'std::__hash_enum<_Tp, <anonymous> >::~__hash_enum() [with _Tp = std::pair<long long int, long long int>; bool <anonymous> = false]' is private within this context /usr/include/c++/14/bits/functional_hash.h:84:7: note: declared private here 84 | ~__hash_enum(); | ^ /usr/include/c++/14/bits/hashtable_policy.h:1731:7: note: use '-fdiagnostics-all-candidates' to display considered candidates 1731 | _Hashtable_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1731:7: error: use of deleted function 'std::__detail::_Hash_code_base<std::pair<long long int, long long int>, std::pair<const std::pair<long long int, long long int>, int>, std::__detail::_Select1st, std::hash<std::pair<long long int, long long int> >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, true>::~_Hash_code_base()' /usr/include/c++/14/bits/hashtable_policy.h:1306:12: note: 'std::__detail::_Hash_code_base<std::pair<long long int, long long int>, std::pair<const std::pair<long long int, long long int>, int>, std::__detail::_Select1st, std::hash<std::pair<long long int, long long in
s891592443
p03821
C++
#include<stdio.h> #include<vector> #include<queue> #include<algorithm> #include<string.h> #include<string> #include<stack> #include<set> #include<map> #include<iostream> #include<assert.h> #include<unordered_map> //#define Min(a,b,c) min((a),min((b),(c))) #define mp(a,b) make_pair((a),(b)) #define pii pair<int,int> #define pll pair<LL,LL> #define pb(x) push_back(x) #define x first #define y second #define sqr(x) ((x)*(x)) #define EPS 1e-11 #define pi 3.14159265359 #define pmm pair<map<int,int>*,map<int,LL>*> typedef long long LL; using namespace std; const LL mod=1e9+7; int main(){ int n; LL a,b; scanf("%d %lld %lld",&n,&a,&b); LL s[100005]; for(int i=0;i<n;i++){ scanf("%lld",&s[i]); } queue<pair<pll,int> > q; q.push(mp(mp(-1e18,-1e18),1ll)); unordered_map<pll,int> m; for(int i=0;i<n;i++){ m.clear(); while(!q.empty()){ pair<pll,LL> p=q.front();q.pop(); if(s[i]-p.x.x>=a){ if(i!=n-1){ m[mp(max(s[i],s[i+1]-a),max(p.x.y,s[i+1]-b))]=(m[mp(max(s[i],s[i+1]-a),max(p.x.y,s[i+1]-b))]+p.y)%mod; } else m[mp(s[i],p.x.y)]=(m[mp(s[i],p.x.y)]+p.y)%mod; } if(s[i]-p.x.y>=b){ if(i!=n-1){ m[mp(max(p.x.x,s[i+1]-a),max(s[i],s[i+1]-b))]=(m[mp(max(p.x.x,s[i+1]-a),max(s[i],s[i+1]-b))]+p.y)%mod; } else m[mp(p.x.x,s[i])]=(m[mp(p.x.x,s[i])]+p.y)%mod; } } for(unordered_map<pll,int>::iterator it=m.begin();it!=m.end();it++) q.push(*it); } int ans=0; while(!q.empty()){ pair<pll,int> p=q.front();q.pop(); ans+=p.y; ans%=mod; } printf("%lld\n",ans); }
a.cc: In function 'int main()': a.cc:37:32: error: use of deleted function 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = std::pair<long long int, long long int>; _Tp = int; _Hash = std::hash<std::pair<long long int, long long int> >; _Pred = std::equal_to<std::pair<long long int, long long int> >; _Alloc = std::allocator<std::pair<const std::pair<long long int, long long int>, int> >]' 37 | unordered_map<pll,int> m; | ^ In file included from /usr/include/c++/14/unordered_map:41, from a.cc:12: /usr/include/c++/14/bits/unordered_map.h:148:7: note: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = std::pair<long long int, long long int>; _Tp = int; _Hash = std::hash<std::pair<long long int, long long int> >; _Pred = std::equal_to<std::pair<long long int, long long int> >; _Alloc = std::allocator<std::pair<const std::pair<long long int, long long int>, int> >]' is implicitly deleted because the default definition would be ill-formed: 148 | unordered_map() = default; | ^~~~~~~~~~~~~ /usr/include/c++/14/bits/unordered_map.h: At global scope: /usr/include/c++/14/bits/unordered_map.h:148:7: error: use of deleted function 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::pair<long long int, long long int>; _Value = std::pair<const std::pair<long long int, long long int>, int>; _Alloc = std::allocator<std::pair<const std::pair<long long int, long long int>, int> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<long long int, long long int> >; _Hash = std::hash<std::pair<long long int, long long int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' In file included from /usr/include/c++/14/bits/unordered_map.h:33: /usr/include/c++/14/bits/hashtable.h:539:7: note: 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::pair<long long int, long long int>; _Value = std::pair<const std::pair<long long int, long long int>, int>; _Alloc = std::allocator<std::pair<const std::pair<long long int, long long int>, int> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<long long int, long long int> >; _Hash = std::hash<std::pair<long long int, long long int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' is implicitly deleted because the default definition would be ill-formed: 539 | _Hashtable() = default; | ^~~~~~~~~~ /usr/include/c++/14/bits/hashtable.h:539:7: error: use of deleted function 'std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = std::pair<long long int, long long int>; _Value = std::pair<const std::pair<long long int, long long int>, int>; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<long long int, long long int> >; _Hash = std::hash<std::pair<long long int, long long int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' In file included from /usr/include/c++/14/bits/hashtable.h:35: /usr/include/c++/14/bits/hashtable_policy.h:1731:7: note: 'std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = std::pair<long long int, long long int>; _Value = std::pair<const std::pair<long long int, long long int>, int>; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<long long int, long long int> >; _Hash = std::hash<std::pair<long long int, long long int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' is implicitly deleted because the default definition would be ill-formed: 1731 | _Hashtable_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1731:7: error: use of deleted function 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_Hash_code_base() [with _Key = std::pair<long long int, long long int>; _Value = std::pair<const std::pair<long long int, long long int>, int>; _ExtractKey = std::__detail::_Select1st; _Hash = std::hash<std::pair<long long int, long long int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]' /usr/include/c++/14/bits/hashtable_policy.h: In instantiation of 'std::__detail::_Hashtable_ebo_helper<_Nm, _Tp, true>::_Hashtable_ebo_helper() [with int _Nm = 1; _Tp = std::hash<std::pair<long long int, long long int> >]': /usr/include/c++/14/bits/hashtable_policy.h:1328:7: required from here 1328 | _Hash_code_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1245:49: error: use of deleted function 'std::hash<std::pair<long long int, long long int> >::hash()' 1245 | _Hashtable_ebo_helper() noexcept(noexcept(_Tp())) : _Tp() { } | ^~~~~ In file included from /usr/include/c++/14/bits/stl_bvector.h:65, from /usr/include/c++/14/vector:67, from a.cc:2: /usr/include/c++/14/bits/functional_hash.h:102:12: note: 'std::hash<std::pair<long long int, long long int> >::hash()' is implicitly deleted because the default definition would be ill-formed: 102 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/14/bits/functional_hash.h:102:12: error: no matching function for call to 'std::__hash_enum<std::pair<long long int, long long int>, false>::__hash_enum()' /usr/include/c++/14/bits/functional_hash.h:83:7: note: candidate: 'std::__hash_enum<_Tp, <anonymous> >::__hash_enum(std::__hash_enum<_Tp, <anonymous> >&&) [with _Tp = std::pair<long long int, long long int>; bool <anonymous> = false]' 83 | __hash_enum(__hash_enum&&); | ^~~~~~~~~~~ /usr/include/c++/14/bits/functional_hash.h:83:7: note: candidate expects 1 argument, 0 provided /usr/include/c++/14/bits/functional_hash.h:102:12: error: 'std::__hash_enum<_Tp, <anonymous> >::~__hash_enum() [with _Tp = std::pair<long long int, long long int>; bool <anonymous> = false]' is private within this context 102 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/14/bits/functional_hash.h:84:7: note: declared private here 84 | ~__hash_enum(); | ^ /usr/include/c++/14/bits/hashtable_policy.h:1245:49: note: use '-fdiagnostics-all-candidates' to display considered candidates 1245 | _Hashtable_ebo_helper() noexcept(noexcept(_Tp())) : _Tp() { } | ^~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1328:7: note: 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_Hash_code_base() [with _Key = std::pair<long long int, long long int>; _Value = std::pair<const std::pair<long long int, long long int>, int>; _ExtractKey = std::__detail::_Select1st; _Hash = std::hash<std::pair<long long int, long long int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]' is implicitly deleted because the default definition would be ill-formed: 1328 | _Hash_code_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1328:7: error: use of deleted function 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<long long int, long long int> >, true>::~_Hashtable_ebo_helper()' /usr/include/c++/14/bits/hashtable_policy.h:1242:12: note: 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<long long int, long long int> >, true>::~_Hashtable_ebo_helper()' is implicitly deleted because the default definition would be ill-formed: 1242 | struct _Hashtable_ebo_helper<_Nm, _Tp, true> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1242:12: error: use of deleted function 'std::hash<std::pair<long long int, long long int> >::~hash()' /usr/include/c++/14/bits/functional_hash.h:102:12: note: 'std::hash<std::pair<long long int, long long int> >::~hash()' is implicitly deleted because the default definition would be ill-formed: 102 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/14/bits/functional_hash.h:102:12: error: 'std::__hash_enum<_Tp, <anonymous> >::~__hash_enum() [with _Tp = std::pair<long long int, long long int>; bool <anonymous> = false]' is private within this context /usr/include/c++/14/bits/functional_hash.h:84:7: note: declared private here 84 | ~__hash_enum(); | ^ /usr/include/c++/14/bits/hashtable_policy.h:1731:7: note: use '-fdiagnostics-all-candidates' to display considered candidates 1731 | _Hashtable_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1731:7: error: use of deleted function 'std::__detail::_Hash_code_base<std::pair<long long int, long long int>, std::pair<const std::pair<long long int, long long int>, int>, std::__detail::_Select1st, std::hash<std::pair<long long int, long long int> >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, true>::~_Hash_code_base()' /usr/include/c++/14/bits/hashtable_policy.h:1306:12: note: 'std::__detail::_Hash_code_base<std::pair<long long int, long long int>, std::pair<const std::pair<long long int, long long int>, int>, std::__detail::_Select1st, std::hash<std::pair<long long int, long long in
s896206165
p03821
C++
#include<iostream> #include<cstring> #include<cstdio> #include<algorithm> #include<map> using namespace std; int n; int a[100005]; int b[100005]; int c[100005]; long long ans=0; int main(){ scanf("%d",&n); for(int i=1;i<=n;i++){ scanf("%d%d",&a[i],&b[i]); } int s=0; for(int i=n;i>=1;i--){a[i]+=s; if(a[i]<b[i]){ans+=b[i]-a[i];s+=b[i]-a[i]; else{ s+=b[i]-(a[i]-1)%b[i]-1; ans+=b[i]-(a[i]-1)%b[i]-1;} } cout<<ans; return 0; }
a.cc: In function 'int main()': a.cc:20:17: error: expected '}' before 'else' 20 | else{ | ^~~~ a.cc:19:26: note: to match this '{' 19 | if(a[i]<b[i]){ans+=b[i]-a[i];s+=b[i]-a[i]; | ^
s389950141
p03821
C
#include <stdio.h> int main(){ int i, j, n; int counter = 0; scanf("%d", &n); int buttonA[n]; int buttonB[n]; for(i = 0; i < n; i++){ int a, b; scanf("%d %d", &a, &b); buttonA[i] = a; buttonB[i] = b; } for(i = n - 1; i >= 0; i--){ int diff = 0; if(buttonB[i] - buttonA[i] % buttonB[i] > 0){ diff = buttonB[i] - buttonA[i] % buttonB[i]; else if(buttonA[i] == 0) diff = buttonB[i]; counter += diff; for(j = i - 1; j >= 0; j--) buttonA[j] += diff; } printf("%d\n", counter); return 0; }
main.c: In function 'main': main.c:26:11: error: expected '}' before 'else' 26 | else if(buttonA[i] == 0) | ^~~~
s570595217
p03821
C++
#include <iostream> using namespace std; int main() { long long n,x,s=0; cin>>n; int a[n],b[n]; for(long long i=0;i<n;i++) cin>>a[i]>>b[i]; for(long long i=n-1;i>=0;i--){ x=a[i]+s; if(x<b[i])swap(b[i],x); int aux=x%b[i]; s+=(aux==0?0:b[i]-aux); //cout<<s; } cout<<s; return 0; }
a.cc: In function 'int main()': a.cc:14:23: error: no matching function for call to 'swap(int&, long long int&)' 14 | if(x<b[i])swap(b[i],x); | ~~~~^~~~~~~~ In file included from /usr/include/c++/14/exception:166, from /usr/include/c++/14/ios:41, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/exception_ptr.h:229:5: note: candidate: 'void std::__exception_ptr::swap(exception_ptr&, exception_ptr&)' 229 | swap(exception_ptr& __lhs, exception_ptr& __rhs) | ^~~~ /usr/include/c++/14/bits/exception_ptr.h:229:25: note: no known conversion for argument 1 from 'int' to 'std::__exception_ptr::exception_ptr&' 229 | swap(exception_ptr& __lhs, exception_ptr& __rhs) | ~~~~~~~~~~~~~~~^~~~~ In file included from /usr/include/c++/14/bits/exception_ptr.h:41: /usr/include/c++/14/bits/move.h:226:5: note: candidate: 'template<class _Tp> std::_Require<std::__not_<std::__is_tuple_like<_Tp> >, std::is_move_constructible<_Tp>, std::is_move_assignable<_Tp> > std::swap(_Tp&, _Tp&)' 226 | swap(_Tp& __a, _Tp& __b) | ^~~~ /usr/include/c++/14/bits/move.h:226:5: note: template argument deduction/substitution failed: a.cc:14:23: note: deduced conflicting types for parameter '_Tp' ('int' and 'long long int') 14 | if(x<b[i])swap(b[i],x); | ~~~~^~~~~~~~ /usr/include/c++/14/bits/move.h:250:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> std::__enable_if_t<((bool)std::__is_swappable<_Tp>::value)> std::swap(_Tp (&)[_Nm], _Tp (&)[_Nm])' 250 | swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm]) | ^~~~ /usr/include/c++/14/bits/move.h:250:5: note: template argument deduction/substitution failed: a.cc:14:23: note: mismatched types '_Tp [_Nm]' and 'int' 14 | if(x<b[i])swap(b[i],x); | ~~~~^~~~~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:64, 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: /usr/include/c++/14/bits/stl_pair.h:1089:5: note: candidate: 'template<class _T1, class _T2> typename std::enable_if<std::__and_<std::__is_swappable<_T1>, std::__is_swappable<_T2> >::value>::type std::swap(pair<_T1, _T2>&, pair<_T1, _T2>&)' 1089 | swap(pair<_T1, _T2>& __x, pair<_T1, _T2>& __y) | ^~~~ /usr/include/c++/14/bits/stl_pair.h:1089:5: note: template argument deduction/substitution failed: a.cc:14:23: note: mismatched types 'std::pair<_T1, _T2>' and 'int' 14 | if(x<b[i])swap(b[i],x); | ~~~~^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1106:5: note: candidate: 'template<class _T1, class _T2> typename std::enable_if<(! std::__and_<std::__is_swappable<_T1>, std::__is_swappable<_T2> >::value)>::type std::swap(pair<_T1, _T2>&, pair<_T1, _T2>&)' (deleted) 1106 | swap(pair<_T1, _T2>&, pair<_T1, _T2>&) = delete; | ^~~~ /usr/include/c++/14/bits/stl_pair.h:1106:5: note: template argument deduction/substitution failed: a.cc:14:23: note: mismatched types 'std::pair<_T1, _T2>' and 'int' 14 | if(x<b[i])swap(b[i],x); | ~~~~^~~~~~~~ In file included from /usr/include/c++/14/string:54: /usr/include/c++/14/bits/basic_string.h:4039:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> void std::swap(__cxx11::basic_string<_CharT, _Traits, _Allocator>&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 4039 | swap(basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~ /usr/include/c++/14/bits/basic_string.h:4039:5: note: template argument deduction/substitution failed: a.cc:14:23: note: mismatched types 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'int' 14 | if(x<b[i])swap(b[i],x); | ~~~~^~~~~~~~ In file included from /usr/include/c++/14/bits/memory_resource.h:47, from /usr/include/c++/14/string:68: /usr/include/c++/14/tuple:2805:5: note: candidate: 'template<class ... _Elements> typename std::enable_if<std::__and_<std::__is_swappable<_Elements>...>::value>::type std::swap(tuple<_UTypes ...>&, tuple<_UTypes ...>&)' 2805 | swap(tuple<_Elements...>& __x, tuple<_Elements...>& __y) | ^~~~ /usr/include/c++/14/tuple:2805:5: note: template argument deduction/substitution failed: a.cc:14:23: note: mismatched types 'std::tuple<_UTypes ...>' and 'int' 14 | if(x<b[i])swap(b[i],x); | ~~~~^~~~~~~~ /usr/include/c++/14/tuple:2823:5: note: candidate: 'template<class ... _Elements> typename std::enable_if<(! std::__and_<std::__is_swappable<_Elements>...>::value)>::type std::swap(tuple<_UTypes ...>&, tuple<_UTypes ...>&)' (deleted) 2823 | swap(tuple<_Elements...>&, tuple<_Elements...>&) = delete; | ^~~~ /usr/include/c++/14/tuple:2823:5: note: template argument deduction/substitution failed: a.cc:14:23: note: mismatched types 'std::tuple<_UTypes ...>' and 'int' 14 | if(x<b[i])swap(b[i],x); | ~~~~^~~~~~~~
s332697790
p03821
C
include <stdio.h> #include <string.h> #include <math.h> int main(){ int N,i; long long int A,B; long long int count=0; scanf("%lld",&N); for(i=0;i<N;i++){ scanf("%lld%lld",&A,&B); if((A+count)%B!=0) count+=(B-(A+count)%B); } printf("%lld\n",count); return 0; }
main.c:1:9: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token 1 | include <stdio.h> | ^ In file included from main.c:2: /usr/include/string.h:44:22: error: unknown type name 'size_t' 44 | size_t __n) __THROW __nonnull ((1, 2)); | ^~~~~~ /usr/include/string.h:34:1: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>' 33 | #include <stddef.h> +++ |+#include <stddef.h> 34 | /usr/include/string.h:47:56: error: unknown type name 'size_t' 47 | extern void *memmove (void *__dest, const void *__src, size_t __n) | ^~~~~~ /usr/include/string.h:47:56: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>' /usr/include/string.h:55:32: error: unknown type name 'size_t' 55 | int __c, size_t __n) | ^~~~~~ /usr/include/string.h:55:32: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>' /usr/include/string.h:61:42: error: unknown type name 'size_t' 61 | extern void *memset (void *__s, int __c, size_t __n) __THROW __nonnull ((1)); | ^~~~~~ /usr/include/string.h:61:42: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>' /usr/include/string.h:64:56: error: unknown type name 'size_t' 64 | extern int memcmp (const void *__s1, const void *__s2, size_t __n) | ^~~~~~ /usr/include/string.h:64:56: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>' /usr/include/string.h:80:60: error: unknown type name 'size_t' 80 | extern int __memcmpeq (const void *__s1, const void *__s2, size_t __n) | ^~~~~~ /usr/include/string.h:80:60: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>' /usr/include/string.h:107:48: error: unknown type name 'size_t' 107 | extern void *memchr (const void *__s, int __c, size_t __n) | ^~~~~~ /usr/include/string.h:107:48: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>' /usr/include/string.h:145:53: error: unknown type name 'size_t' 145 | const char *__restrict __src, size_t __n) | ^~~~~~ /usr/include/string.h:145:53: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>' /usr/include/string.h:153:23: error: unknown type name 'size_t' 153 | size_t __n) __THROW __nonnull ((1, 2)); | ^~~~~~ /usr/include/string.h:153:23: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>' /usr/include/string.h:159:57: error: unknown type name 'size_t' 159 | extern int strncmp (const char *__s1, const char *__s2, size_t __n) | ^~~~~~ /usr/include/string.h:159:57: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>' /usr/include/string.h:166:8: error: unknown type name 'size_t' 166 | extern size_t strxfrm (char *__restrict __dest, | ^~~~~~ /usr/include/string.h:166:8: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>' /usr/include/string.h:167:54: error: unknown type name 'size_t' 167 | const char *__restrict __src, size_t __n) | ^~~~~~ /usr/include/string.h:167:54: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>' /usr/include/string.h:179:8: error: unknown type name 'size_t' 179 | extern size_t strxfrm_l (char *__dest, const char *__src, size_t __n, | ^~~~~~ /usr/include/string.h:179:8: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>' /usr/include/string.h:179:59: error: unknown type name 'size_t' 179 | extern size_t strxfrm_l (char *__dest, const char *__src, size_t __n, | ^~~~~~ /usr/include/string.h:179:59: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>' /usr/include/string.h:195:45: error: unknown type name 'size_t' 195 | extern char *strndup (const char *__string, size_t __n) | ^~~~~~ /usr/include/string.h:195:45: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>' /usr/include/string.h:293:8: error: unknown type name 'size_t' 293 | extern size_t strcspn (const char *__s, const char *__reject) | ^~~~~~ /usr/include/string.h:293:8: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>' /usr/include/string.h:297:8: error: unknown type name 'size_t' 297 | extern size_t strspn (const char *__s, const char *__accept) | ^~~~~~ /usr/include/string.h:297:8: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>' /usr/include/string.h:389:46: error: unknown type name 'size_t' 389 | extern void *memmem (const void *__haystack, size_t __haystacklen, | ^~~~~~ /usr/include/string.h:389:46: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>' /usr/include/string.h:390:44: error: unknown type name 'size_t' 390 | const void *__needle, size_t __needlelen) | ^~~~~~ /usr/include/string.h:390:44: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>' /usr/include/string.h:398:55: error: unknown type name 'size_t' 398 | const void *__restrict __src, size_t __n) | ^~~~~~ /usr/include/string.h:398:55: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>' /usr/include/string.h:401:53: error: unknown type name 'size_t' 401 | const void *__restrict __src, size_t __n) | ^~~~~~ /usr/include/string.h:401:53: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>' /usr/include/string.h:407:8: error: unknown type name 'size_t' 407 | extern size_t strlen (const char *__s) | ^~~~~~ /usr/include/string.h:407:8: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>' /usr/include/string.h:413:8: error: unknown type name 'size_t' 413 | extern size_t strnlen (const char *__string, size_t __maxlen) | ^~~~~~ /usr/include/string.h:413:8: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>' /usr/include/string.h:413:46: error: unknown type name 'size_t' 413 | extern size_t strnlen (const char *__string, size_t __maxlen) | ^~~~~~ /usr/include/string.h:413:46: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>' In file included from /usr/include/features.h:523, from /usr/include/x86_64-linux-gnu/bits/libc-header-start.h:33, from /usr/include/string.h:26: /usr/include/string.h:432:12: error: unknown type name 'size_t' 432 | extern int __REDIRECT_NTH (strerror_r, | ^~~~~~~~~~~~~~ /usr/include/string.h:432:12: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>' In file included from /usr/include/string.h:462: /usr/include/strings.h:34:54: error: unknown type name 'size_t' 34 | extern int bcmp (const void *__s1, const void *__s2, size_t __n) | ^~~~~~ /usr/include/strings.h:24:1: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>' 23 | #include <stddef.h> +++ |+#include <stddef.h> 24 | /usr/include/strings.h:38:53: error: unknown type name 'size_t' 38 | extern void bcopy (const void *__src, void *__dest, size_t __n) | ^~~~~~ /usr/include/strings.h:38:53: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>' /usr/include/strings.h:42:31: error: unknown type name 'size_t' 42 | extern void bzero (void *__s, size_t __n) __THROW __nonnull ((1)); | ^~~~~~ /usr/include/strings.h:42:31: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>' /usr/include/strings.h:120:61: error: unknown type name 'size_t' 120 | extern int strncasecmp (const char *__s1, const char *__s2, size_t __n) | ^~~~~~ /usr/include/strings.h:120:61: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>' /usr/include/strings.h:134:27: error: unknown type name 'size_t' 134 | size_t __n, locale_t __loc) | ^~~~~~ /usr/include/strings.h:134:27: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>' /usr/include/string.h:466:40: error: unknown type na
s219565120
p03821
Java
import java.util.*; public class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); long[] a=new long[n]; long[] b=new long[n]; long ans=0; for(int i=0; i<n; i++){ a[i] = sc.nextLong(); b[i] = sc.nextLong(); } for(int i=n-1;i>=0;i--){ if( i == n-1 && a[i] == 0 && b[i] == 1 ){ ans++; }else if( (a[i]%b[i] + ans%b[i]) &b[i] != 0 ){ ans -= ans%b[i]; ans -= a[i]%b[i]; ans += b[i]; } } System.out.println(ans); return; } }
Main.java:18: error: bad operand types for binary operator '&' }else if( (a[i]%b[i] + ans%b[i]) &b[i] != 0 ){ ^ first type: long second type: boolean 1 error
s563577275
p03821
C++
#include<iostream> #include<cstring> #include<cstdio> #include<algorithm> #include<map> using namespace std; int n; int a[100005]; int b[100005]; int c[100005]; long long ans=0; int main(){ cin>>n; for(int i=1;i<=n;i++){ cin>>a[i]>>b[i]; } for(int i=1;i<=n;i++){ if(a[i]<b[i]){ c[i]=b[i]-a[i]; } else{ int x=a[i]/b[i]; if(x*b[i]>a[i]){ c[i]=x*b[i]-a[i] } else{ c[i]=(x+1)*b[i]-a[i]; } } } for(int i=1;i<=n;i++){ ans+=c[i]; } cout<<ans; return 0; }
a.cc: In function 'int main()': a.cc:24:49: error: expected ';' before '}' token 24 | c[i]=x*b[i]-a[i] | ^ | ; 25 | } | ~
s825784317
p03821
C++
/************************************************************************* > File Name: A.cpp > Author: yxg ************************************************************************/ #include<iostream> #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> #include<set> #include<map> #include<queue> #include<vector> #include<stack> using namespace std; typedef long long ll; const ll INF = 1e18; const int maxn = 1e9+10; int a[maxn],b[maxn],n; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n; for(int i=0; i<n; i++) cin>>a[i]>>b[i]; int ans = 0; for(int i=n-1; i>=0; i--){ if(a[i]%b[i] == 0) { if(i>=1) a[i-1]+=ans; continue; } if(a[i]<b[i]) ans += b[i]-a[i]; else ans += b[i]-(a[i]%b[i]); if(i>=1) a[i-1]+=ans; // cout << "aa " << ans << endl; } cout << ans << endl; }
/tmp/ccIKiBFd.o: in function `main': a.cc:(.text+0x29): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccIKiBFd.o a.cc:(.text+0x84): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccIKiBFd.o a.cc:(.text+0x9c): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccIKiBFd.o a.cc:(.text+0xae): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccIKiBFd.o a.cc:(.text+0xe5): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccIKiBFd.o a.cc:(.text+0x168): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccIKiBFd.o a.cc:(.text+0x183): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccIKiBFd.o a.cc:(.text+0x1b8): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccIKiBFd.o a.cc:(.text+0x1e7): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccIKiBFd.o collect2: error: ld returned 1 exit status
s957478559
p03821
C++
#include<iostream> #include<cstring> #include<cstdio> #include<algorithm> #include<map> using namespace std; int n; int a[100005]; int b[100005]; int c[100005]; long long ans=0; int main(){ scanf("%d",n); for(int i=1;i<=n;i++){ scanf("%d%d",&a[i],&b[i]); } for(int i=1;i<=n;i++){ if(a[i]<b[i]){ c[i]=b[i]-a[i]; } else{ int x=a[i]/b[i]; if(x*b[i]>a[i]){ c[i]=x*b[i]-a[i] } else{ c[i]=(x+1)*b[i]-a[i]; } } } for(int i=1;i<=n;i++){ ans+=c[i]; } cout<<ans; return 0; }
a.cc: In function 'int main()': a.cc:24:49: error: expected ';' before '}' token 24 | c[i]=x*b[i]-a[i] | ^ | ; 25 | } | ~
s514535338
p03821
C++
#include<iostream> #include<cstring> #include<cstdio> #include<algorithm> #include<map> using namespace std; int n; int a[100005]; int b[100005]; int c[100005]; long long ans=0; int main(){ scanf("%d",nd); for(int i=1;i<=n;i++){ scanf("%d%d",&a[i],&b[i]); } for(int i=1;i<=n;i++){ if(a[i]<b[i]){ c[i]=b[i]-a[i]; } else{ int x=a[i]/b[i]; if(x*b[i]>a[i]){ c[i]=x*b[i]-a[i] } else{ c[i]=(x+1)*b[i]-a[i]; } } } for(int i=1;i<=n;i++){ ans+=c[i]; } cout<<ans; return 0; }
a.cc: In function 'int main()': a.cc:13:20: error: 'nd' was not declared in this scope; did you mean 'n'? 13 | scanf("%d",nd); | ^~ | n a.cc:24:49: error: expected ';' before '}' token 24 | c[i]=x*b[i]-a[i] | ^ | ; 25 | } | ~
s824456252
p03821
C++
#include<iostream> #include<cstring> #include<cstdio> #include<algorithm> #include<map> using namespace std; int n; int a[100005]; int b[100005]; int c[100005]; long long ans=0; int main(){ scanf("%d",&d); for(int i=1;i<=n;i++){ scanf("%d%d",&a[i],&b[i]); } for(int i=1;i<=n;i++){ if(a[i]<b[i]){ c[i]=b[i]-a[i]; } else{ int x=a[i]/b[i]; if(x*b[i]>a[i]){ c[i]=x*b[i]-a[i] } else{ c[i]=(x+1)*b[i]-a[i]; } } } for(int i=1;i<=n;i++){ ans+=c[i]; } cout<<ans; return 0; }
a.cc: In function 'int main()': a.cc:13:21: error: 'd' was not declared in this scope 13 | scanf("%d",&d); | ^ a.cc:24:49: error: expected ';' before '}' token 24 | c[i]=x*b[i]-a[i] | ^ | ; 25 | } | ~
s685775547
p03821
C++
#include<iostream> #include<cstring> #include<cstdio> #include<algorithm> #include<map> using namespace std; int n; int a[100005]; int b[100005]; int c[100005]; long long ans=0; int main(){ scanf("%d",&d); for(int i=1;i<=n;i++){ scnaf("%d%d",&a[i],&b[i]); } for(int i=1;i<=n;i++){ if(a[i]<b[i]){ c[i]=b[i]-a[i]; } else{ int x=a[i]/b[i]; if(x*b[i]>a[i]){ c[i]=x*b[i]-a[i] } else{ c[i]=(x+1)*b[i]-a[i]; } } } for(int i=1;i<=n;i++){ ans+=c[i]; } cout<<ans; return 0; }
a.cc: In function 'int main()': a.cc:13:21: error: 'd' was not declared in this scope 13 | scanf("%d",&d); | ^ a.cc:15:17: error: 'scnaf' was not declared in this scope; did you mean 'scanf'? 15 | scnaf("%d%d",&a[i],&b[i]); | ^~~~~ | scanf a.cc:24:49: error: expected ';' before '}' token 24 | c[i]=x*b[i]-a[i] | ^ | ; 25 | } | ~
s570735525
p03821
C++
#include<iostream> #include<cstring> #include<ccstdio> #include<algorithm> #include<map> using namespace std; int n; int a[100005]; int b[100005]; int c[100005]; long long ans=0; int main(){ scanf("%d",&d); for(int i=1;i<=n;i++){ scnaf("%d%d",&a[i],&b[i]); } for(int i=1;i<=n;i++){ if(a[i]<b[i]){ c[i]=b[i]-a[i]; } else{ int x=a[i]/b[i]; if(x*b[i]>a[i]){ c[i]=x*b[i]-a[i] } else{ c[i]=(x+1)*b[i]-a[i]; } } } for(int i=1;i<=n;i++){ ans+=c[i]; } cout<<ans; return 0; }
a.cc:3:9: fatal error: ccstdio: No such file or directory 3 | #include<ccstdio> | ^~~~~~~~~ compilation terminated.
s412821075
p03821
C++
#include<iostream> #include<cstring> #include<ccstdio> #include<algorithm> #include<map> using namespace std; int n; int a[100005]; int b[100005]; int c[100005]; long long ans=0; int main(){ scanf("%d",&d); for(int i=1;i<=n;i++){ scnaf("%d%d",&a[i],&b[i]); } for(int i=1;i<=n;i++){ if(a[i]<b[i]){ c[i]=b[i]-a[i]; } else{ int x=a[i]\b[i]; if(x*b[i]>a[i]){ c[i]=x*b[i]-a[i] } else{ c[i]=(x+1)*b[i]-a[i]; } } } for(int i=1;i<=n;i++){ ans+=c[i]; } cout<<ans; return 0; }
a.cc:3:9: fatal error: ccstdio: No such file or directory 3 | #include<ccstdio> | ^~~~~~~~~ compilation terminated.
s637313839
p03821
Java
import java.util.*; public class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); long[] a=new long[n]; long[] b=new long[n]; long ans=0; for(int i=0; i<n; i++){ a[i] = sc.nextLong(); b[i] = sc.nextLong(); } for(int i=n-1;i>=0;i--){ a[i] += ans; if( a[i] == 0 && b[i] == 1 ){ ans++; }else if( a[i]%b[i] != 0 ){ ans -= a[i]%b[i] ans += b[i]; } } System.out.println(ans); return; } }
Main.java:20: error: ';' expected ans -= a[i]%b[i] ^ 1 error
s042803458
p03821
C++
#include<stdio.h> int a[100005],b[100005]; int main() { int t,i,j,c; while(scanf("%d",&n)!=EOF) { c=0; for(i=0;i<n;i++) scanf("%d%d",&a[i],&b[i]); for(i=n-1;i>=0;i--) { while(a[i]%b[i]!=0) { for(j=0;j<=i;j++) a[j]++; } c++; } printf("%d\n",c); } return 0; }
a.cc: In function 'int main()': a.cc:6:27: error: 'n' was not declared in this scope 6 | while(scanf("%d",&n)!=EOF) | ^
s625703891
p03821
Java
import java.util.*; public class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] a = new int[n]; boolean[] used = new boolean[n]; int[] appear = new int[n]; int ans = 0; int max = 0; int p = 0; for(int i=0; i<n; i++){ a[i] = sc.nextInt(); appear[ a[i]-1 ]++; if( appear[ a[i]-1 ] > max ){ p = } for(int i=n-1;i>=0;i--){ a[i] += ans; if( a[i] == 0 && b[i] == 1 ){ ans++; }else if( a[i]%b[i] != 0 ){ ans += (b[i] - a[i]%b[i]); } } System.out.println(ans); return; } }
Main.java:19: error: illegal start of expression } ^ Main.java:34: error: reached end of file while parsing } ^ 2 errors
s515228088
p03821
C++
#include<stdio.h> int a[100005],b[100005]; int main() { int t,i,j,c; while(scanf("%d",&n)!=EOF) { c=0; for(i=0;i<n;i++) scanf("%d%d",&a[i],&b[i]); for(i=n-1;i>=0;i++) { while(a[i]%b[i]!=0) { for(j=0;j<=i;j++) a[j]++; } c++; } printf("%d\n",c); } return 0; }
a.cc: In function 'int main()': a.cc:6:27: error: 'n' was not declared in this scope 6 | while(scanf("%d",&n)!=EOF) | ^
s707415861
p03821
C
#include<stdio.h> int main(void) { int i, j, count = 0,; long int a[100000], b[100000],n; scanf("%ld", &n); for (i = 0; i < n; i++) scanf("%ld %ld", &a[i], &b[i]); i = n - 1; while (i >= 0) { if (a[i] % b[i] == 0) { i--; } else { for (j = 0; j <= i; j++) { if (i == j)count++; a[j]++; } } } printf("%d\n", count); return 0; }
main.c: In function 'main': main.c:4:29: error: expected identifier or '(' before ';' token 4 | int i, j, count = 0,; | ^
s271016727
p03821
Java
import java.util.*; public class Main{ public static void main(String[] args){ int i,tmp; long ans=0l; Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int[] a=new int[n]; int[] b=new int[n]; for(i=0;i<n;i++){ a[i]=sc.nextInt(); b[i]=sc.nextInt(); } for(i=n-1;i>=0;i--){ tmp=(a[i]+ans)%b[i]; if(tmp!=0)ans+=(long)(b[i]-tmp); } System.out.println(ans); } }
Main.java:15: error: incompatible types: possible lossy conversion from long to int tmp=(a[i]+ans)%b[i]; ^ 1 error
s756436675
p03821
C++
#pragma GCC optimize ("O3"); #include <cstdlib> #include <iostream> #include <valarray> long long div_ceil(long long a, long long b) { return (a + b - 1) / b; } int main(){ std::cin.tie(nullptr); std::ios::sync_with_stdio(false); int n; std::cin >> n; std::valarray<long long> xs(n); std::valarray<long long> ys(n); for (int i = 0; i < n; i++) { std::cin >> xs[i] >> ys[i]; } long long ctr = 0; for (int i = n - 1; i >= 0; i--) { auto diff = div_ceil(xs[i], ys[i]) * ys[i] - xs[i]; ctr += diff; std::slice_array<long long> res = xs[std::slice(0, i + 1, 1)]; res += std::valarray<long long>(diff, i + 1); } std::cout << ctr << std::endl; return EXIT_SUCCESS; }
a.cc:1:28: error: '#pragma GCC optimize' string is badly formed 1 | #pragma GCC optimize ("O3"); | ^
s845181497
p03821
C
#include <stdio.h> int main(){ int i, n; scanf("%d", &n); int buttonA[n]; int buttonB[n]; for(i = 0; i < n; i++){ int a, b; scanf("%d %d", &a, &b); buttonA[i] = a; buttonB[i] = b; } int counter = 0; for(i = n - 1; i >= 0; i--){ int remaining = buttonA[i] % buttonB[i]; if(remaining > 0){ int diff = buttonB[i] - remaining; if(diff > 0){ counter += diff; int j; for(j = i - 1; j >= 0; j--) buttonA[j] += diff; } } } return counter }
main.c: In function 'main': main.c:37:20: error: expected ';' before '}' token 37 | return counter | ^ | ; 38 | } | ~
s878876814
p03821
C++
#include <stdio.h> #include <math.h> void main(){ int i, n; scanf("%d", &n); int buttonA[n]; int buttonB[n]; for(i = 0; i < n; i++){ int a, b; scanf("%d %d", &a, &b); buttonA[i] = a; buttonB[i] = b; } int counter = 0; for(i = n - 1; i >= 0; i--){ int remaining = buttonA[i] % buttonB[i]; if(remaining > 0){ int diff = buttonB[i] - remaining; if(diff > 0){ counter += diff; int j; for(j = i - 1; j >= 0; j--) buttonA[j] += diff; } } } printf("%d", counter); }
a.cc:3:1: error: '::main' must return 'int' 3 | void main(){ | ^~~~
s345031326
p03821
C++
#include <stdio.h> void main(){ int i, n; scanf("%d", &n); int buttonA[n]; int buttonB[n]; for(i = 0; i < n; i++){ int a, b; scanf("%d %d", &a, &b); buttonA[i] = a; buttonB[i] = b; } int counter = 0; for(i = n - 1; i >= 0; i--){ int remaining = buttonA[i] % buttonB[i]; if(remaining > 0){ int diff = buttonB[i] - remaining; if(diff > 0){ counter += diff; int j; for(j = i - 1; j >= 0; j--) buttonA[j] += diff; } } } printf("%d", counter); }
a.cc:3:1: error: '::main' must return 'int' 3 | void main(){ | ^~~~
s964984012
p03821
C++
#include<iostream> #include<cctype> #include<vector> #include<ctype.h> #include<algorithm> #include<queue> #include<string> #include<math.h> #include<iomanip> using namespace std; long long n, m; vector<long long> a; int main() { cin >> n; for (size_t i = 0; i < n + 1; i++) { a.push_back(0); } for (size_t i = 2; i < n+1; i++) { cin >> m; a[m]++; a[i]++; a[m] = max(a[m], a[i]); a[i] = max(a[m], a[i]); } sort(a.begin(), a.end()); cout << *(a.end()-1)<<endl; return 0;
a.cc: In function 'int main()': a.cc:29:18: error: expected '}' at end of input 29 | return 0; | ^ a.cc:12:12: note: to match this '{' 12 | int main() { | ^
s551353090
p03821
C++
#include<iostream> using namespace std; #define int __int64 signed main(){ int N; cin>> N; int a[N], b[N]; for(int i=0; i<N; i++){ cin>> a[i]>> b[i]; } int s=0, t=0; for(int i=N-1; i>=0; i--){ if(a[i]+s<=b[i]){ s+=b[i]-(a[i]+s); }else{ if(b[i]==1){ }else if((a[i]+s)%b[i]==0){ }else{ s+=b[i]-((a[i]+s)%b[i]); } } } cout<< s<< endl; return 0; }
a.cc: In function 'int main()': a.cc:4:13: error: '__int64' was not declared in this scope; did you mean '__int64_t'? 4 | #define int __int64 | ^~~~~~~ a.cc:8:4: note: in expansion of macro 'int' 8 | int N; | ^~~ a.cc:9:10: error: 'N' was not declared in this scope 9 | cin>> N; | ^ a.cc:10:8: error: expected ';' before 'a' 10 | int a[N], b[N]; | ^ a.cc:11:12: error: expected ';' before 'i' 11 | for(int i=0; i<N; i++){ | ^ a.cc:11:17: error: 'i' was not declared in this scope 11 | for(int i=0; i<N; i++){ | ^ a.cc:12:13: error: 'a' was not declared in this scope 12 | cin>> a[i]>> b[i]; | ^ a.cc:12:20: error: 'b' was not declared in this scope 12 | cin>> a[i]>> b[i]; | ^ a.cc:15:8: error: expected ';' before 's' 15 | int s=0, t=0; | ^ a.cc:16:12: error: expected ';' before 'i' 16 | for(int i=N-1; i>=0; i--){ | ^ a.cc:16:19: error: 'i' was not declared in this scope 16 | for(int i=N-1; i>=0; i--){ | ^ a.cc:17:10: error: 'a' was not declared in this scope 17 | if(a[i]+s<=b[i]){ | ^ a.cc:17:15: error: 's' was not declared in this scope 17 | if(a[i]+s<=b[i]){ | ^ a.cc:17:18: error: 'b' was not declared in this scope 17 | if(a[i]+s<=b[i]){ | ^ a.cc:30:11: error: 's' was not declared in this scope 30 | cout<< s<< endl; | ^
s405237904
p03821
C++
//インクルード #include <cstdlib> #include <iostream> #include <string> #include <vector> //メイン関数 int main() { //入力の取得 int N; std::cin >> N; std::vector<int> A; std::vector<int> B; for(int i=0; i<N; ++i) { int tempA; int tempB; std::cin >> tempA >> tempB; A.push_back(tempA); B.push_back(tempB); } //入力の反転 std::reverse(A.begin(), A.end()); std::reverse(B.begin(), B.end()); //答え auto answer = 0; //計算 for(int i=0; i<N; ++i) { int Ai = A.at(i) + answer; int Bi = B.at(i); int answerTemp = 0; for(;(Ai % Bi) != 0; ++answerTemp, ++Ai) { } answer += answerTemp; } //答えの出力 std::cout << answer << std::endl; //正常終了 return EXIT_SUCCESS; }
a.cc: In function 'int main()': a.cc:25:14: error: 'reverse' is not a member of 'std' 25 | std::reverse(A.begin(), A.end()); | ^~~~~~~ a.cc:26:14: error: 'reverse' is not a member of 'std' 26 | std::reverse(B.begin(), B.end()); | ^~~~~~~
s278865416
p03821
Java
import java.util.*; public class Main{ public static void main(String[] args){ int i,tmp; int ans=0; Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int[] a=new int[n]; int[] b=new int[n]; for(i=0;i<n;i++){ a[i]=sc.nextInt(); b[i]=sc.nextInt(); } for(i=n-1;i>=0;i--){ tmp=a[i]%b[i]; if(tmp!=0)ans+=n-tmp } System.out.println(ans); } }
Main.java:16: error: ';' expected if(tmp!=0)ans+=n-tmp ^ 1 error
s999100523
p03821
C++
int main(){ vector<int> A,B; int N; cin>>N; for(int i=0;i<N;i++){ int a,b; cin>>a>>b; A.push_back(a); B.push_back(b); } int ans=0; for(int i=N-1;i>=0;i--){ if (A[i]%B[i]!=0){ int d=(B[i]-(A[i]%B[i])); ans+=d; for(int j=0;j<i;j++) A[j]+=d; } } cout<<ans<<endl; return 0; }
a.cc: In function 'int main()': a.cc:2:9: error: 'vector' was not declared in this scope 2 | vector<int> A,B; | ^~~~~~ a.cc:2:16: error: expected primary-expression before 'int' 2 | vector<int> A,B; | ^~~ a.cc:4:9: error: 'cin' was not declared in this scope 4 | cin>>N; | ^~~ a.cc:8:17: error: 'A' was not declared in this scope 8 | A.push_back(a); | ^ a.cc:9:17: error: 'B' was not declared in this scope 9 | B.push_back(b); | ^ a.cc:13:21: error: 'A' was not declared in this scope 13 | if (A[i]%B[i]!=0){ | ^ a.cc:13:26: error: 'B' was not declared in this scope 13 | if (A[i]%B[i]!=0){ | ^ a.cc:19:9: error: 'cout' was not declared in this scope 19 | cout<<ans<<endl; | ^~~~ a.cc:19:20: error: 'endl' was not declared in this scope 19 | cout<<ans<<endl; | ^~~~
s294877569
p03821
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll big = 1000000007ll; ll n,m,k,x,y; vector<ll> A; vector<ll> B; ll mod(ll i , ll b){ if(i < 0)return mod(b - mod(-i),b); return i%b; } int main() { //freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout); ll c1,c2,c3,c4,c5; ll a,b,c; cin >> n; ll ans = 0; for(c1 = 0; c1 < n; c1++){ cin >> a >> b; A.push_back(a); B.push_back(b); } for(c1 = n-1; c1 >= 0; c1--){ a = A[c1]; b = B[c1]; ans += mod(- ans - a,b); } cout << ans << "\n"; return 0; }
a.cc: In function 'll mod(ll, ll)': a.cc:13:32: error: too few arguments to function 'll mod(ll, ll)' 13 | if(i < 0)return mod(b - mod(-i),b); | ~~~^~~~ a.cc:12:4: note: declared here 12 | ll mod(ll i , ll b){ | ^~~
s653428682
p03821
C++
#include<bits/stdc++.h> #define F first #define S second #define pb push_back #define ll long long #define int long long using namespace std ; const int MAXN = 101 * 1001 ; int a[MAXN] , b[MAXN] ; int32_t main() { ios::sync_with_stdio(0) ; cin.tie(0) ; int n ; cin >> n ; for(int i = 0 ; i < n; i ++ ) cin >> a[i] >> b[i] ; int m = 0 , ans = 0 ; for(int i = n - 1 ; i > -1 ; i -- ) { a[i] += ans ; if(b[i]==1||a[i]%b[i]==0) continue ; ans += (b[i]-a[i]%b[i]) ; } cout << ans << '\n' ; } ~
a.cc:32:2: error: expected class-name at end of input 32 | ~ | ^
s847420517
p03821
Java
import java.io.*; import java.math.*; import java.util.*; import static java.util.Arrays.*; public class A { private static final int mod = (int)924844033; final Random random = new Random(0); final IOFast io = new IOFast(); /// MAIN CODE public void run() throws IOException { // int TEST_CASE = Integer.parseInt(new String(io.nextLine()).trim()); int TEST_CASE = 1; while(TEST_CASE-- != 0) { int n = io.nextInt(); long[] A = new long[n]; long[] B = new long[n]; for (int i = 0; i < n; i++) { A[i] = io.nextLong(); B[i] = io.nextLong(); } long t = 0; for (int i = n - 1; i >= 0; i--) { long v = (A[i] + t + B[i] - 1) / B[i] * B[i]; long d = v - t - A[i]; t += d; // dump(A[i], B[i], v, d); } io.out.println(t); } } /// TEMPLATE static int gcd(int n, int r) { return r == 0 ? n : gcd(r, n%r); } static long gcd(long n, long r) { return r == 0 ? n : gcd(r, n%r); } static <T> void swap(T[] x, int i, int j) { T t = x[i]; x[i] = x[j]; x[j] = t; } static void swap(int[] x, int i, int j) { int t = x[i]; x[i] = x[j]; x[j] = t; } void printArrayLn(int[] xs) { for(int i = 0; i < xs.length; i++) io.out.print(xs[i] + (i==xs.length-1?"\n":" ")); } void printArrayLn(long[] xs) { for(int i = 0; i < xs.length; i++) io.out.print(xs[i] + (i==xs.length-1?"\n":" ")); } static void dump(Object... o) { System.err.println(Arrays.deepToString(o)); } void main() throws IOException { // IOFast.setFileIO("rle-size.in", "rle-size.out"); try { run(); } catch (EndOfFileRuntimeException e) { } io.out.flush(); } public static void main(String[] args) throws IOException { new A().main(); } static class EndOfFileRuntimeException extends RuntimeException { private static final long serialVersionUID = -8565341110209207657L; } static public class IOFast { private BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); private PrintWriter out = new PrintWriter(System.out); void setFileIn(String ins) throws IOException { in.close(); in = new BufferedReader(new FileReader(ins)); } void setFileOut(String outs) throws IOException { out.flush(); out.close(); out = new PrintWriter(new FileWriter(outs)); } void setFileIO(String ins, String outs) throws IOException { setFileIn(ins); setFileOut(outs); } private static int pos, readLen; private static final char[] buffer = new char[1024 * 8]; private static char[] str = new char[500*8*2]; private static boolean[] isDigit = new boolean[256]; private static boolean[] isSpace = new boolean[256]; private static boolean[] isLineSep = new boolean[256]; static { for(int i = 0; i < 10; i++) { isDigit['0' + i] = true; } isDigit['-'] = true; isSpace[' '] = isSpace['\r'] = isSpace['\n'] = isSpace['\t'] = true; isLineSep['\r'] = isLineSep['\n'] = true; } public int read() throws IOException { if(pos >= readLen) { pos = 0; readLen = in.read(buffer); if(readLen <= 0) { throw new EndOfFileRuntimeException(); } } return buffer[pos++]; } public int nextInt() throws IOException { int len = 0; str[len++] = nextChar(); len = reads(len, isSpace); int i = 0; int ret = 0; if(str[0] == '-') { i = 1; } for(; i < len; i++) ret = ret * 10 + str[i] - '0'; if(str[0] == '-') { ret = -ret; } return ret; } public long nextLong() throws IOException { int len = 0; str[len++] = nextChar(); len = reads(len, isSpace); int i = 0; long ret = 0; if(str[0] == '-') { i = 1; } for(; i < len; i++) ret = ret * 10 + str[i] - '0'; if(str[0] == '-') { ret = -ret; } return ret; } public char nextChar() throws IOException { while(true) { final int c = read(); if(!isSpace[c]) { return (char)c; } } } int reads(int len, boolean[] accept) throws IOException { try { while(true) { final int c = read(); if(accept[c]) { break; } if(str.length == len) { char[] rep = new char[str.length * 3 / 2]; System.arraycopy(str, 0, rep, 0, str.length); str = rep; } str[len++] = (char)c; } } catch(EndOfFileRuntimeException e) { ; } return len; } int reads(char[] cs, int len, boolean[] accept) throws IOException { try { while(true) { final int c = read(); if(accept[c]) { break; } cs[len++] = (char)c; } } catch(EndOfFileRuntimeException e) { ; } return len; } public char[] nextLine() throws IOException { int len = 0; str[len++] = nextChar(); len = reads(len, isLineSep); try { if(str[len-1] == '\r') { len--; read(); } } catch(EndOfFileRuntimeException e) { ; } return Arrays.copyOf(str, len); } public String nextString() throws IOException { return new String(next()); } public char[] next() throws IOException { int len = 0; str[len++] = nextChar(); len = reads(len, isSpace); return Arrays.copyOf(str, len); } // public int next(char[] cs) throws IOException { int len = 0; cs[len++] = nextChar(); len = reads(cs, len, isSpace); return len; } public double nextDouble() throws IOException { return Double.parseDouble(nextString()); } public long[] nextLongArray(final int n) throws IOException { final long[] res = new long[n]; for(int i = 0; i < n; i++) { res[i] = nextLong(); } return res; } public int[] nextIntArray(final int n) throws IOException { final int[] res = new int[n]; for(int i = 0; i < n; i++) { res[i] = nextInt(); } return res; } public int[][] nextIntArray2D(final int n, final int k) throws IOException { final int[][] res = new int[n][]; for(int i = 0; i < n; i++) { res[i] = nextIntArray(k); } return res; } public int[][] nextIntArray2DWithIndex(final int n, final int k) throws IOException { final int[][] res = new int[n][k+1]; for(int i = 0; i < n; i++) { for(int j = 0; j < k; j++) { res[i][j] = nextInt(); } res[i][k] = i; } return res; } public double[] nextDoubleArray(final int n) throws IOException { final double[] res = new double[n]; for(int i = 0; i < n; i++) { res[i] = nextDouble(); } return res; } } }
Main.java:8: error: class A is public, should be declared in a file named A.java public class A { ^ 1 error
s269091641
p03822
C++
#include <iostream> #include <vector> #include <tuple> #include <deque> #include <set> #include <map> #include <cmath> #include <string> #include <algorithm> #include <unordered_set> #define int long long #define all(x) (x).begin(), (x).end() #define allr(x) (x).rbegin(), (x).rend() using namespace std; const int MOD = 1e9 + 7; const int INF = 1e9; void fast() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } vector <vector <int> > g; vector <int> d; int dfs(int v, int dst = 0) { d[v] = dst; for (int e : g[v]) { dfs(e, dst + 1); } } signed main() { fast(); int n; cin >> n; g.resize(n); d.resize(n); for (int i = 1; i < n; ++i) { int a; cin >> a; g[a - 1].push_back(i); } dfs(0); int mx = 0; for (int i = 0; i < n; ++i) { mx = max(mx, d[i] + g[i].size()); } cout << mx << '\n'; return 0; }
a.cc: In function 'long long int dfs(long long int, long long int)': a.cc:37:1: warning: no return statement in function returning non-void [-Wreturn-type] 37 | } | ^ a.cc: In function 'int main()': a.cc:56:17: error: no matching function for call to 'max(long long int&, long long unsigned int)' 56 | mx = max(mx, d[i] + g[i].size()); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~ 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: template argument deduction/substitution failed: a.cc:56:17: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long long unsigned int') 56 | mx = max(mx, d[i] + g[i].size()); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~ /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, 2 provided In file included from /usr/include/c++/14/algorithm:61, from a.cc:9: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:56:17: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 56 | mx = max(mx, d[i] + g[i].size()); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~
s554997455
p03822
C++
#include<iostream> #include<iomanip> #include<cstdio> #include<algorithm> #include<cassert> #include<cmath> #include<vector> #include<map> #include<set> #include<string> #include<queue> #include<stack> #include<list> #include <cstring> #include <functional> #include<unordered_map> #include<unordered_set> #include<bitset> using namespace std; #define MOD 1000000007 #define MOD2 998244353 #define INF ((1<<30)-1) #define LINF ((Int)1<<60) #define EPS (1e-10) #define REP(i,n) for(int i=0; i<(int)(n); ++i) #define RREP(i,n) for(int i=1; i<=(int)(n); ++i) #define FOR(i,k,n) for(int i=(k);i<(int)(n);++i) typedef long long Int; typedef pair<Int, Int> PI; typedef pair<int, int> P; typedef vector<double> vec; typedef vector<vec> mat; const int N = 100005; ////////////////////////////// int n; unsigned int dp[N]; vector<int> e[N]; void dfs(int x, int last = -1) { vector<int> tmp; for (auto to : e[x]) { dfs(to, x); tmp.push_back(dp[to]); } if (tmp.size() == 0) { dp[x] = 1; return; } dp[x] = INF; for (int i = 0; i < tmp.size(); i++) { dp[x] = min(dp[x], (int)tmp[i] + tmp.size() + 1 - i); } } void solve() { cin >> n; REP(i, n - 1) { int x; cin >> x; e[x].push_back(i + 2); } dfs(1); cout << dp[1] << endl; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(13); solve(); return 0; }
a.cc: In function 'void dfs(int, int)': a.cc:51:28: error: no matching function for call to 'min(unsigned int&, std::vector<int>::size_type)' 51 | dp[x] = min(dp[x], (int)tmp[i] + tmp.size() + 1 - i); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:51:28: note: deduced conflicting types for parameter 'const _Tp' ('unsigned int' and 'std::vector<int>::size_type' {aka 'long unsigned int'}) 51 | dp[x] = min(dp[x], (int)tmp[i] + tmp.size() + 1 - i); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61, from a.cc:4: /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:51:28: note: mismatched types 'std::initializer_list<_Tp>' and 'unsigned int' 51 | dp[x] = min(dp[x], (int)tmp[i] + tmp.size() + 1 - i); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
s647854493
p03822
C++
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(i = 0;i < n;++i) #define all(v) v.begin(), v.end() using ll = long long; ll dfs(ll now, vector<vector<ll>>& graph) { int i; vector<ll> v; for(i = 0;i < graph.at(now).size();++i){ v.push_back(dfs(graph.at(now).at(i), graph)); } sort(all(v)); ll res = 0; for(i = 0;i < v.size();++i){ res = max(res, v.at(i) + v.size() - i); } return res; } int main() { ll i,j; ll n; cin >> n; vector<vector<ll>> graph(n); for(i = 1;i < n;++i){ ll a; cin >> a; --a; graph.at(a).push_back(i); } cout << dfs(0, graph) << endl; return 0; }
a.cc: In function 'll dfs(ll, std::vector<std::vector<long long int> >&)': a.cc:18:18: error: no matching function for call to 'max(ll&, long long unsigned int)' 18 | res = max(res, v.at(i) + v.size() - i); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:18:18: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long long unsigned int') 18 | res = max(res, v.at(i) + v.size() - i); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /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, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:18:18: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 18 | res = max(res, v.at(i) + v.size() - i); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
s554777876
p03822
C++
#include <bits/stdc++.h> //#include <boost/multiprecision/cpp_int.hpp> //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> #pragma GCC optimize("O3") #define REP(i,n) for(int i=0;i<n;i++) #define REPP(i,n) for(int i=1;i<=n;i++) #define ALL(obj) (obj).begin(), (obj).end() #define EPS (1e-9) #define INF (1e17) #define PI (acos(-1)) //const double PI = acos(-1); //const double EPS = 1e-15; //long long INF=(long long)1E17; #define i_7 (long long)(1e9+7) //#define i_7 998'244'353 long mod(long a){ long long c=a%i_7; if(c>=0)return c; return c+i_7; } long long po(long a, long b){ if(b==0){ return 1; } long long z = po(a,b/2); z = mod(z*z); if(b%2!=0){ z = mod(a*z); } return z; } bool prime_(int n){ if(n==1){ return false; }else if(n==2){ return true; }else{ for(int i=2;i<=std::sqrt(n);i++){ if(n%i==0){ return false; } } return true; } } long long gcd_(long long a, long long b){ if(a<b){ std::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; } using namespace std; //using namespace boost::multiprecision; //using namespace __gnu_pbds; vector<int> G[100'010]; int dfs(int v, vector<int>& dp, int p = -1){ if(dp[v] >= 0) return dp[v]; int deg = G[v].size(); if(v != 0 && deg == 1) return dp[v] = 0; vector<int> temp; for(int nv: G[v]){ if(nv == p) continue; temp.push_back(dfs(nv, dp, v)); } sort(ALL(temp), greater<int>); int res = -1; int k = temp.size(); REP(i, k) res = max(res, temp[i] + i + 1); return res; } int dfs() int main(){ //using namespace std; int n; cin>>n; int a[n]; for(int i = 1; i < n; i++){ cin>>a[i]; a[i]--; } for(int i = 1; i < n; i++){ G[i].push_back(a[i]); G[a[i]].push_back(i); } vector<int> dp(n, -1); dfs(0, dp); int ans = dp[0]; cout << ans << endl; return 0; }
a.cc: In function 'int dfs(int, std::vector<int>&, int)': a.cc:82:31: error: expected primary-expression before ')' token 82 | sort(ALL(temp), greater<int>); | ^ a.cc: At global scope: a.cc:90:1: error: expected initializer before 'int' 90 | int main(){ | ^~~
s452925512
p03822
C++
#include<bits/stdc++.h> using namespace std; #define rep(i,n) for(ll i=0;i<n;i++) #define repl(i,l,r) for(ll i=(l);i<(r);i++) #define per(i,n) for(ll i=n-1;i>=0;i--) #define perl(i,r,l) for(ll i=r-1;i>=l;i--) #define fi first #define se second #define pb push_back #define ins insert #define all(x) (x).begin(),(x).end() using ll=long long; using vl=vector<ll>; using vvl=vector<vector<ll>>; const ll MOD=1000000007; const ll MOD9=998244353; const int inf=1e9+10; const ll INF=4e18; const ll dy[8]={1,0,-1,0,1,1,-1,-1}; const ll dx[8]={0,-1,0,1,1,-1,1,-1}; using Graph = vector<vector<int>>; double nCk(int n, int k) { double res=1.0; for(int i=0; i<n; i++){ res*=0.5;} for(int i=0; i<k; i++){ res*=(double)(n-i); res/=(double)(k-i); } return res;} struct edge{ll to, cost;}; typedef pair<ll,ll> P; struct graph{ ll V; vector<vector<edge> > G; vector<ll> d; graph(ll n){ init(n); } void init(ll n){ V = n; G.resize(V); d.resize(V); rep(i,V){ d[i] = INF; } } void add_edge(ll s, ll t, ll cost){ edge e; e.to = t, e.cost = cost; G[s].push_back(e); } void dijkstra(ll s){ rep(i,V){ d[i] = INF; } d[s] = 0; priority_queue<P,vector<P>, greater<P> > que; que.push(P(0,s)); while(!que.empty()){ P p = que.top(); que.pop(); ll v = p.second; if(d[v]<p.first) continue; for(auto e : G[v]){ if(d[e.to]>d[v]+e.cost){ d[e.to] = d[v]+e.cost; que.push(P(d[e.to],e.to)); } } } } }; class UnionFind { public: int par[100005]; int depth[100005]; int nGroup[100005]; UnionFind(int n) { init(n); } void init(int n) { for(int i=0; i<n; i++) { par[i] = i; depth[i] = 0; nGroup[i] = 1; } } int root(int x) { if(par[x] == x) { return x; } else { return par[x] = root(par[x]); } } bool same(int x, int y) { return root(x) == root(y); } void unite(int x, int y) { x = root(x); y = root(y); if(x == y) return; if(depth[x] < depth[y]) { par[x] = y; nGroup[y] += nGroup[x]; nGroup[x] = 0; } else { par[y] = x; nGroup[x] += nGroup[y]; nGroup[y] = 0; if(depth[x] == depth[y]) depth[x]++; } } }; const ll MAX = 510000; ll fac[MAX], finv[MAX], inv[MAX]; // テーブルを作る前処理 void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < MAX; i++){ fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } // 二項係数計算 ll COM(ll n, ll k){ if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } vector<ll> depth; vector<ll> subtree_size; void dfs(const Graph &G, ll v, ll p, ll d) { depth[v] = d; for (auto nv : G[v]) { if (nv == p) continue; // nv が親 p だったらダメ dfs(G, nv, v, d+1); } // 帰りがけ時に、部分木サイズを求める subtree_size[v] = 0; // 自分自身 for (auto c : G[v]) { if (c == p) continue; subtree_size[v] = min(subtree_size[c]+G[v].size()-1,subtree_size[v]); // 子のサイズを加える } } int main() { // 頂点数 (木なので辺数は N-1 で確定) ll N; cin >> N; // グラフ入力受取 Graph G(N); for (int i = 1; i <N; ++i) { ll a; cin >> a; a--; G[a].push_back(i); G[i].push_back(a); } ll root = 0; // 仮に頂点 0 を根とする depth.assign(N, 0); subtree_size.assign(N, 0); dfs(G, root, -1, 0); ll ans = 0; rep(i,N){ if(depth[i]==0){ ans = max(ans,subtree_size[i]);} } cout << ans << endl; }
a.cc: In function 'void dfs(const Graph&, ll, ll, ll)': a.cc:161:30: error: no matching function for call to 'min(long long unsigned int, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type&)' 161 | subtree_size[v] = min(subtree_size[c]+G[v].size()-1,subtree_size[v]); // 子のサイズを加える | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:161:30: note: deduced conflicting types for parameter 'const _Tp' ('long long unsigned int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'}) 161 | subtree_size[v] = min(subtree_size[c]+G[v].size()-1,subtree_size[v]); // 子のサイズを加える | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:161:30: note: mismatched types 'std::initializer_list<_Tp>' and 'long long unsigned int' 161 | subtree_size[v] = min(subtree_size[c]+G[v].size()-1,subtree_size[v]); // 子のサイズを加える | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
s914347473
p03822
C++
#include<bits/stdc++.h> #define for0(i, n) for(int i = 0; i < (n); i++) #define all(x) x.begin(),x.end() #define puts(x) cout << x << "\n" using namespace std; int input() { int r; cin >> r; return r; } vector<int>v[123456]; int n; int f(int i) { vector<int>v1; for (int t : v[i])v1.push_back(f(t)); sort(all(v1), greater<int>()); int r = 0; for0(j, v1.size())r = max(r, v1[j] + j+1); return r; } signed main() { n = input(); for1(i, n)if (i != 1)v[input()].push_back(i); puts(f(1)); }
a.cc: In function 'int main()': a.cc:17:27: error: 'i' was not declared in this scope 17 | n = input(); for1(i, n)if (i != 1)v[input()].push_back(i); puts(f(1)); | ^ a.cc:17:22: error: 'for1' was not declared in this scope; did you mean 'fork'? 17 | n = input(); for1(i, n)if (i != 1)v[input()].push_back(i); puts(f(1)); | ^~~~ | fork
s057657281
p03822
C++
#include<bits/stdc++.h> #define for0(i, n) for(int i = 0; i < (n); i++) #define all(x) x.begin(),x.end() #define puts(x) cout << x << "\n" using namespace std; int input() { int r; cin >> r; return r; } vector<int>v[123456]; int n; int f(int i) { vector<int>v1; for (int t : v[i])v1.push_back(f(t)); sort(all(v1), greater<int>()); int r = 0; for0(j, v1.size())r = max(r, v1[j] + j+1); return r; } signed main() { n = input(); for1(i, n)if (i != 1)v[input()].push_back(i); puts(f(1)); }
a.cc: In function 'int main()': a.cc:17:27: error: 'i' was not declared in this scope 17 | n = input(); for1(i, n)if (i != 1)v[input()].push_back(i); puts(f(1)); | ^ a.cc:17:22: error: 'for1' was not declared in this scope; did you mean 'fork'? 17 | n = input(); for1(i, n)if (i != 1)v[input()].push_back(i); puts(f(1)); | ^~~~ | fork
s852035949
p03822
C++
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; #define REP(i,n) for (ll i = 0; i < (n); ++i) #define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i) #define ALL(v) (v).begin(), (v).end() void dfs(ll cur, vector<ll>& depth, vector<vector<ll>>& net){ for(ll nxt : net.at(cur)){ depth.at(nxt) = depth.at(cur) + 1; dfs(nxt, depth, net); } } int main(){ ll n; cin >> n; vector<ll> numwin(n, 0); vector<vector<ll>> net(n); for(ll i = 1; i < n; ++i){ ll ai; cin >> ai; ai--; net.at(ai).push_back(i); numwin.at(ai)++; } vector<ll> depth(n, 0); dfs(0, depth); ll ans = 0; REP(i, n){ ans = max(ans, depth.at(i) + numwin.at(i)); } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:30:8: error: too few arguments to function 'void dfs(ll, std::vector<long long int>&, std::vector<std::vector<long long int> >&)' 30 | dfs(0, depth); | ~~~^~~~~~~~~~ a.cc:9:6: note: declared here 9 | void dfs(ll cur, vector<ll>& depth, vector<vector<ll>>& net){ | ^~~
s313490539
p03822
C++
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for (ll i = 0; i < (ll)(n); i++) #define FOR(i, n, m) for (ll i = n; i < (ll)(m); i++) #define pb push_back #define all(a) (a).begin(), (a).end() typedef long long ll; typedef pair<int, int> p; #define MAX_N 100010 vector<int> child[MAX_N]; ll dfs(ll node) { vector<int> v; for (auto ch : child[node]) { v.pb(dfs(ch)); } sort(v.begin(), v.end()); //N log N ll tmp = 0; REP(i, v.size()) { tmp = max(tmp, 1 + (v.size()- 1 - i) + v[i]); } return tmp; } int main() { int N; cin >> N; REP(i, N - 1) { int a; cin >> a; child[--a].pb(i + 1); } cout << dfs(0) << endl; }
a.cc: In function 'll dfs(ll)': a.cc:30:18: error: no matching function for call to 'max(ll&, long long unsigned int)' 30 | tmp = max(tmp, 1 + (v.size()- 1 - i) + v[i]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:30:18: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long long unsigned int') 30 | tmp = max(tmp, 1 + (v.size()- 1 - i) + v[i]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /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, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:30:18: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 30 | tmp = max(tmp, 1 + (v.size()- 1 - i) + v[i]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
s373548561
p03822
C++
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for (ll i = 0; i < (ll)(n); i++) #define FOR(i, n, m) for (ll i = n; i < (ll)(m); i++) #define pb push_back #define all(a) (a).begin(), (a).end() typedef long long ll; typedef pair<int, int> p; #define MAX_N 100010 vector<int> child[MAX_N]; ll dfs(ll node) { vector<int> v; for (auto ch : child[node]) { v.pb(dfs(ch)); } sort(v.begin(), v.end()); //N log N ll tmp = 0; REP(i, v.size()) { tmp = max(tmp, 1 + (v.size()- 1 - i) + v[i]); } return tmp; } int main() { int N; cin >> N; REP(i, N - 1) { int a; cin >> a; child[--a].pb(i + 1); } cout << dfs(0) << endl; }
a.cc: In function 'll dfs(ll)': a.cc:30:18: error: no matching function for call to 'max(ll&, long long unsigned int)' 30 | tmp = max(tmp, 1 + (v.size()- 1 - i) + v[i]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:30:18: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long long unsigned int') 30 | tmp = max(tmp, 1 + (v.size()- 1 - i) + v[i]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /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, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:30:18: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 30 | tmp = max(tmp, 1 + (v.size()- 1 - i) + v[i]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
s434843502
p03822
C++
#include <cmath> #include <iostream> #include <vector> #include <algorithm> #include <string> #include <set> #include <map> #include <list> #include <time.h> #include <math.h> #include <random> #include <deque> #include <queue> #include <cassert> #include <unordered_map> #include <unordered_set> #include <iomanip> #include <bitset> #include <sstream> #include <chrono> #include <cstring> using namespace std; typedef long long ll; #ifdef iq mt19937 rnd(228); #else mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count()); #endif int main() { #ifdef iq freopen("a.in", "r", stdin); #endif ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; vector <int> a(n); set <int> q; a[0] = 0; vector<int>ans(n,-1); ans[0]=0; vector<vector<int>>g(n); for (int i = 1; i < n; i++) { int x; cin>>x; x--; g[x].push_back(i); } function<int(int)>solve=[&](int i){ vector<int>cur; for (int j:g[i]){ cur.push_back(solve(j)+1); } int mx = 0; sort(cur.begin(),cur.end()); for(int y:cur){ if(y==mx)mx++; if(y>mx)mx=y; } return mx; }; cout<<solve(0)<<endl; }
a.cc: In function 'int main()': a.cc:53:3: error: 'function' was not declared in this scope 53 | function<int(int)>solve=[&](int i){ | ^~~~~~~~ a.cc:22:1: note: 'std::function' is defined in header '<functional>'; this is probably fixable by adding '#include <functional>' 21 | #include <cstring> +++ |+#include <functional> 22 | a.cc:53:12: error: expected primary-expression before 'int' 53 | function<int(int)>solve=[&](int i){ | ^~~ a.cc:66:9: error: 'solve' was not declared in this scope 66 | cout<<solve(0)<<endl; | ^~~~~
s120751823
p03822
C++
#include<iostream> #include<string> #include<cstdio> #include<cstring> #include<vector> #include<cmath> #include<algorithm> #include<functional> #include<iomanip> #include<queue> #include<deque> #include<ciso646> #include<random> #include<map> #include<set> #include<complex> #include<bitset> #include<stack> #include<unordered_map> #include<utility> #include<cassert> using namespace std; typedef long long ll; typedef unsigned long long ul; typedef unsigned int ui; typedef long double ld; const int inf=1e9+7; const ll INF=1LL<<60 ; const ll mod=1e9+7 ; #define rep(i,n) for(int i=0;i<n;i++) #define per(i,n) for(int i=n-1;i>=0;i--) #define Rep(i,sta,n) for(int i=sta;i<n;i++) #define rep1(i,n) for(int i=1;i<=n;i++) #define per1(i,n) for(int i=n;i>=1;i--) #define Rep1(i,sta,n) for(int i=sta;i<=n;i++) typedef complex<ld> Point; const ld eps = 1e-8; const ld pi = acos(-1.0); typedef pair<int, int> P; typedef pair<ld, ld> LDP; typedef pair<ll, ll> LP; #define fr first #define sc second #define all(c) c.begin(),c.end() #define pb push_back #define debug(x) cout << #x << " = " << (x) << endl; 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; } //#define int long long int n; vector<int> G[100100]; int dfs(int v, int p) { vector<int> vec; if(G[v].size() == 0) return 0; for(auto& nv: G[v]) { if(nv == p) continue; int r = dfs(nv, v); ++r; vec.push_back(r); } sort(all(vec)); reverse(all(vec)); int res = vec[0]; int i = 0; for(auto& rec: vec) { chmax(res, rec + i); ++i; } return res; } void solve() { cin >> n; rep(i, n - 1) { int a; cin >> a; --a; G[i].push_bacK(a); G[a].push_back(i); } cout << dfs(0) << endl; } signed main() { ios::sync_with_stdio(false); cin.tie(0); //cout << fixed << setprecision(10); //init(); solve(); //cout << "finish" << endl; return 0; }
a.cc: In function 'void solve()': a.cc:79:14: error: 'class std::vector<int>' has no member named 'push_bacK'; did you mean 'push_back'? 79 | G[i].push_bacK(a); | ^~~~~~~~~ | push_back a.cc:82:16: error: too few arguments to function 'int dfs(int, int)' 82 | cout << dfs(0) << endl; | ~~~^~~ a.cc:55:5: note: declared here 55 | int dfs(int v, int p) { | ^~~
s630322622
p03822
C++
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for(int i = 0; i < n; i++) #define rep2(i, x, n) for(int i = x; i < n; i++) #define elif else if typedef long long ll; typedef pair<ll, ll> P; const ll MOD = 1e9+7; const ll MOD2 = 998244353; const ll INF = 1e15; int main(){ int N; cin >> N; int a[N+1]; vector<int> edge[N+1]; rep2(i, 2, N+1){ cin >> a[i]; edge[a[i]].push_back(i); } queue<int> que; int dep[N+1]; bool lost[N+1]; fill_n(lost, N+1, false); rep2(i, 1, N+1){ if(edge[i].size() == 0){ dep[i] = 0; lost[i] = true; que.push(i); } } int count[N+1]; //iに負ける人が何回出たか rep(i,N+1) count[i]=0; while(!que.empty()){ int i = que.front(); que.pop(); if(i == 1) break; int j = a[i]; int n = edge[j].size(); bool update = true; count[j]++; if(count<n) //まだn人出ていなかったら更新しない update=false; if(!update) continue; lost[j] = true; int d[n]; rep(k, n) d[k] = dep[edge[j][k]]; sort(d, d+n, greater<int>()); dep[j] = 0; rep(k, n){ dep[j] = max(dep[j], d[k]+k+1); } que.push(j); } cout << dep[1] << endl; }
a.cc: In function 'int main()': a.cc:43:17: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] 43 | if(count<n) //まだn人出ていなかったら更新しない | ~~~~~^~
s984733056
p03822
C++
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for(long long i=0;i<(long long)(n);i++) #define REP(i,k,n) for(long long i=k;i<(long long)(n);i++) #define all(a) a.begin(),a.end() #define eb emplace_back #define pb push_back #define lb(v,k) (lower_bound(all(v),k)-v.begin()) #define ub(v,k) (upper_bound(all(v),k)-v.begin()) typedef long long ll; typedef multiset<ll> S; typedef pair<ll,ll> P; typedef tuple<ll,ll,ll> PP; typedef priority_queue<ll> PQ; typedef priority_queue<ll,vector<ll>,greater<ll>> SPQ; using vi=vector<ll>; using vvi=vector<vector<ll>>; const ll inf=1001001001001001; const int INF=1001001001; const int mod=1000000007; bool chmin(auto &a,auto b){if(a>b){a=b;return true;}return false;} bool chmax(auto &a,auto b){if(a<b){a=b;return true;}return false;} int n; vi depth; vvi v; dfs(int i){ vi k;int a=0; for(int x:v[i]){ if(depth[x]=inf)depth[x]=dfs(x); k.pb(depth[x]); } sort(all(k)); rep(i,k.size())chmax(a,k[i]+i+1); return a; } int main(){ cin>>n; v=vvi(n); REP(i,1,n){ int a;cin>>a;a--; v[a].pb(i); } depth=vi(n); rep(i,n)depth[i]=inf; cout<<depth[0]<<endl; }
a.cc:21:12: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts' 21 | bool chmin(auto &a,auto b){if(a>b){a=b;return true;}return false;} | ^~~~ a.cc:21:20: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts' 21 | bool chmin(auto &a,auto b){if(a>b){a=b;return true;}return false;} | ^~~~ a.cc:22:12: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts' 22 | bool chmax(auto &a,auto b){if(a<b){a=b;return true;}return false;} | ^~~~ a.cc:22:20: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts' 22 | bool chmax(auto &a,auto b){if(a<b){a=b;return true;}return false;} | ^~~~ a.cc:26:1: error: ISO C++ forbids declaration of 'dfs' with no type [-fpermissive] 26 | dfs(int i){ | ^~~
s769400617
p03822
C++
#include <iostream> #include <cstdlib> #include <cmath> #include <vector> #include <map> #include <set> #include <algorithm> #include <queue> #include <stack> #include <functional> using namespace std; typedef long long ll; typedef vector<ll> vl; typedef vector<vl> vvl; typedef pair<ll,ll> P; typedef vector<P> vpl; #define rep(i,n) for(ll i=0; i<(n); i++) #define REP(i,a,b) for(ll i=(a); i<(b); i++) #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() const int inf = 1<<30; const ll linf = 1LL<<62; const int mod = 1e9+7; const int MAX = 510000; const int V = 100005; ll dy[8] = {1,0,-1,0,1,-1,1,-1}; ll dx[8] = {0,1,0,-1,1,-1,-1,1}; const double pi = acos(-1); template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;} template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;} template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;} #define INT_MAX 1e9+7 int main(){ ll n; cin >> n; vl a(n); vvl G(n); REP(i,1,n){ cin >> a[i]; a[i]--; G[a[i]].push_back(i); } vl d(n,inf); d[0] = 0; queue<ll> q; q.push(0); while(!q.empty()){ ll u = q.front(); q.pop(); for(auto v : G[u]){ d[v] = d[u] + 1; q.push(v); } } ll ans = 0; rep(i,n){ if(d[i]!=inf) ans = max(ans,d[i] + G[i].size()); } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:57:32: error: no matching function for call to 'max(ll&, long long unsigned int)' 57 | if(d[i]!=inf) ans = max(ans,d[i] + G[i].size()); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~ 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: template argument deduction/substitution failed: a.cc:57:32: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long long unsigned int') 57 | if(d[i]!=inf) ans = max(ans,d[i] + G[i].size()); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~ /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, 2 provided In file included from /usr/include/c++/14/algorithm:61, from a.cc:7: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:57:32: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 57 | if(d[i]!=inf) ans = max(ans,d[i] + G[i].size()); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~
s121183641
p03822
C++
#include <bits/stdc++.h> #define ll long long #define sz size #define pb push_back using namespace std; const ll MAXN = 1e5 + 100; vector <ll> g[MAXN]; bool used[MAXN]; ll n, len[MAXN]; void dfs(ll v) { used[v] = 1; len[v] = 1; for(auto to : g[v]) { if(!used[to]) { dfs(to); len[v] += len[to]; } } } int main() { cin >> n; ll k; for(int i = 2; i <= n; ++i) { cin >> k; g[i].pb(k); g[k].pb(i); } dfs(1); ll ans = 0; for(auto to : g[1]) { ans = max(ans, len[to]); } for(int i = 1; i <= n; ++i) { ans = max(ans, g[i].sz() * 1ll); } cout << ans; return 0; }
a.cc: In function 'int main()': a.cc:60:14: error: no matching function for call to 'max(long long int&, long long unsigned int)' 60 | ans = max(ans, g[i].sz() * 1ll); | ~~~^~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:60:14: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long long unsigned int') 60 | ans = max(ans, g[i].sz() * 1ll); | ~~~^~~~~~~~~~~~~~~~~~~~~~ /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, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:60:14: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 60 | ans = max(ans, g[i].sz() * 1ll); | ~~~^~~~~~~~~~~~~~~~~~~~~~
s996601994
p03822
C++
#include<bits/stdc++.h> #define INF 1e9 #define llINF 1e18 #define MOD 1000000007 #define pb push_back #define mp make_pair #define F first #define S second #define ll long long #define ull unsigned long long #define vi vector<ll> #define vvi vector<vi> #define DBG_N(hoge) cerr<<" "<<(hoge)<<endl; #define DBG cerr<<"!"<<endl; #define BITLE(n) (1LL<<((ll)n)) #define BITCNT(n) (__builtin_popcountll(n)) #define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1)) #define ALL(a) (a).begin(),(a).end() using namespace std; vvi E(222222); ll dp[222222]; ll dfs(ll now,ll par){ map<ll,ll>MP; for(auto a:E[now]){ if(a==par)continue; MP[dfs(a,now)]++; } if(MP.size()==0)return dp[now]=0; else{ ll num=-1; for(auto a:MP) num=(a.F>num)?a.F+a.S-1:num+cnt; return dp[now]=num+1; } } int main(){ cin.tie(0); ios::sync_with_stdio(false); ll n;cin>>n; for(int i=0;i<n-1;i++){ ll a;cin>>a; E[--a].pb(i+1); E[i+1].pb(a); } fill(dp,dp+222222,llINF); cout<<dfs(0,-1)<<endl; return 0; }
a.cc: In function 'long long int dfs(long long int, long long int)': a.cc:32:35: error: 'cnt' was not declared in this scope; did you mean 'int'? 32 | num=(a.F>num)?a.F+a.S-1:num+cnt; | ^~~ | int
s668697644
p03822
C++
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> a(n+1); set<int> s; set<int> btm; for(int i = 2; i <= n; i++) { btm.insert(i); } for(int i = 2; i <= n; i++) { cin >> a[i]; if(a[i] == 1) { s.insert(i); } btm.erase(a[i]); } vector<int> dp(n+1); for(int cand : s) { dp[cand] = 1; } function<int(int)> dfs = [&](int pos) { if(dp[pos] != 0) return dp[pos]; return dp[pos] = dfs(a[pos]) + 1; }; for(int i = 2; i <= n; i++) { dfs(i); } multiset<int> ms; for(int cand : btm) { ms.insert(dp[cand]); } int size = all.size(); int ans = 0; int count = 0; auto itr = ms.rbegin(); while(size) { ans = max(ans, *itr + count); count++; size--; itr++; } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:43:16: error: 'all' was not declared in this scope; did you mean 'std::filesystem::perms::all'? 43 | int size = all.size(); | ^~~ | std::filesystem::perms::all In file included from /usr/include/c++/14/filesystem:51, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:200, from a.cc:1: /usr/include/c++/14/bits/fs_fwd.h:158:7: note: 'std::filesystem::perms::all' declared here 158 | all = 0777, | ^~~
s678773824
p03822
C++
#include <algorithm> #include <assert.h> #include <bitset> #include <cfloat> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <limits.h> #include <list> #include <map> #include <math.h> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <string.h> #include <time.h> #include <unordered_map> #include <unordered_set> #include <vector> #define rep(i,n) for(int i=0;i<n;i++) #define REP(i,n) for(int i=1;i<=n;i++) #define int long long #define ll long long #define eps LDBL_EPSILON #define mod (ll)1000000007 #define INF LLONG_MAX/10 #define P pair<int,int> #define prique priority_queue using namespace std; int n, a; vector<int> vec[100010]; int depth[100010]; void dfs(int node, int d) { depth[node] = d; for (int i : vec[node]) { dfs(i, d + 1); } } signed main() { cin >> n; for (int i = 2; i <= n; i++) { cin >> a; vec[a].push_back(i); } dfs(1, 0); int ans = 0; REP(i, n) { ans = max(ans, depth[i] + vec[i].size()); } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:52:26: error: no matching function for call to 'max(long long int&, long long unsigned int)' 52 | ans = max(ans, depth[i] + vec[i].size()); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, 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: template argument deduction/substitution failed: a.cc:52:26: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long long unsigned int') 52 | ans = max(ans, depth[i] + vec[i].size()); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /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, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:52:26: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 52 | ans = max(ans, depth[i] + vec[i].size()); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
s691952984
p03822
C++
#include <bits/stdc++.h> using namespace std; #define lli long long int #define REP(i,s,n) for(int i=s;i<n;i++) #define DEBUG 0 #define mp(a,b) make_pair(a,b) vector<lli> v[100010]; lli index1[100010]; int main(){ lli n; cin>>n; for(lli i=2;i<=n;i++){ lli tmp; cin>>tmp; v[tmp].push_back(i); } queue<lli> q; queue<lli> size; q.push(1); size.push(0); lli lastAns = 0; while(q.size()){ lli top = q.front(); lli topS = size.front(); q.pop(); size.pop(); lastAns = topS; lli nowIndex = index1[top]; if(nowIndex<v[top].size()){ q.push(top); q.push(v[top].at(nowIndex)); size.push(topS+1); size.push(topS+1); index[top]++; } } cout<<lastAns<<endl; return 0; }
a.cc: In function 'int main()': a.cc:43:30: error: invalid types '<unresolved overloaded function type>[long long int]' for array subscript 43 | index[top]++; | ^
s023716272
p03822
C++
#include <bits/stdc++.h> using namespace std; #define lli long long int #define REP(i,s,n) for(int i=s;i<n;i++) #define DEBUG 0 #define mp(a,b) make_pair(a,b) vector<lli> v[100010]; lli index[100010]; int main(){ lli n; cin>>n; for(lli i=2;i<=n;i++){ lli tmp; cin>>tmp; v[tmp].push_back(i); } queue<lli> q; queue<lli> size; q.push(1); size.push(0); lli lastAns = 0; while(q.size()){ lli top = q.front(); lli topS = size.front(); q.pop(); size.pop(); lastAns = topS; lli nowIndex = index[top]; if(nowIndex<v[top].size()){ q.push(top); q.push(v[top].at(nowIndex)); size.push(topS+1); size.push(topS+1); index[top]++; } } cout<<lastAns<<endl; return 0; }
a.cc:11:17: error: 'long long int index [100010]' redeclared as different kind of entity 11 | lli index[100010]; | ^ In file included from /usr/include/string.h:462, from /usr/include/c++/14/cstring:43, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:121, from a.cc:1: /usr/include/strings.h:50:20: note: previous declaration 'const char* index(const char*, int)' 50 | extern const char *index (const char *__s, int __c) | ^~~~~ a.cc: In function 'int main()': a.cc:37:37: error: invalid types '<unresolved overloaded function type>[long long int]' for array subscript 37 | lli nowIndex = index[top]; | ^ a.cc:43:30: error: invalid types '<unresolved overloaded function type>[long long int]' for array subscript 43 | index[top]++; | ^
s731821134
p03822
C++
#include <iostream> #include <string> #include <utility> #include <stack> #include <vector> #include <queue> #include <algorithm> #include <map> #include <climits> #include <set> #include <cmath> #include <numeric> using namespace std; vector <int> edges[100000]; vector <int> reverse_edges[100000]; int in_degree[100000]; vector <int> tp_ord; bool used[100000]; int dp[100000]; void dfs(int cur){ used[cur] = true; for(int i = 0; i < edges[cur].size(); i++){ int next = edges[cur][i]; if(!used[next]){ dfs(next); } } tp_ord.push_back(cur); } int main(){ int N; cin >> N; for(int i = 0; i < N - 1; i++){ int a; cin >> a; edges[i + 1].push_back(a - 1); reverse_edges[a - 1].push_back(i + 1); in_degree[a - 1] ++; } for(int i = 0; i < N; i++){ if(in_degree[i] == 0){ dfs(i); } } reverse(tp_ord.begin(), tp_ord.end()); for(int i = 0; i < N; i++){ int cur = tp_ord[i]; int max_depth = 0; int min_depth = INT_MAX; for(int j = 0; j < reverse_edges[cur].size(); j++){ max_depth = max(max_depth, 1 + dp[reverse_edges[cur][j]]); min_depth = min(min_depth, 1 + dp[reverse_edges[cur][j]]); } dp[cur] = min(max_depth, min_depth + reverse_edges[cur].size() - 1); //cout << cur << " " << dp[cur] << endl; } cout << dp[0] << endl; return 0; }
a.cc: In function 'int main()': a.cc:58:22: error: no matching function for call to 'min(int&, std::vector<int>::size_type)' 58 | dp[cur] = min(max_depth, min_depth + reverse_edges[cur].size() - 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:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:58:22: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'std::vector<int>::size_type' {aka 'long unsigned int'}) 58 | dp[cur] = min(max_depth, min_depth + reverse_edges[cur].size() - 1); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61, from a.cc:7: /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:58:22: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 58 | dp[cur] = min(max_depth, min_depth + reverse_edges[cur].size() - 1); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
s577423308
p03822
C++
#if 1 #include <iostream> #include <cmath> #include <string> #include <vector> #include <climits> #include <algorithm> #include <unordered_set> #include <unordered_map> #include <functional> #include <set> #include <numeric> #include <cassert> using namespace std; #define int long long #define uint unsigned long long constexpr int MOD = 1000000007; constexpr int INF = 1145141919810; #define LOADVEC(type,name,N) std::vector<type>name(N); \ for (int nnn = 0; nnn < N; ++nnn) { \ cin >> name[nnn]; \ } #define LOADVEC2(type,name0,name1,N) std::vector<type>name0(N),name1(N); \ for (int nnn = 0; nnn < N; ++nnn) { \ cin >> name0[nnn];cin >> name1[nnn]; \ } #define LOAD(type,name) type name; \ cin >> name; void proc(); signed main() { ios::sync_with_stdio(false); proc(); return 0; } /* -------------------------------------------------------- -------------------------------------------------------- --------------- template ---------------------- -------------------------------------------------------- -------------------------------------------------------- */ void proc() { LOAD(int, N); LOADVEC(int, a, N - 1); std::vector<unordered_set<int>>childs(N); std::vector<unordered_set<int>>childs2; std::vector<int> depth(N, -1); std::vector<int>stack; for (int i = 0; i < N - 1; ++i) { childs[a[i] - 1].insert(1 + i); } childs2 = childs; // stack.reserve(N + 1); stack.push_back(0); depth[0] = -2; while (!stack.empty()) { int v = stack.back(); bool pushed = false; for (auto child : childs2[v]) { int child = *childs2[v].begin(); if (depth[child] == -1) { depth[child] = -2; stack.push_back(child); childs2[v].erase(child); pushed = true; break; } } if (!pushed) { std::vector<int>childsDepth; childsDepth.reserve(childs[v].size()); for (auto &child : childs[v]) { childsDepth.push_back(depth[child]); } std::sort(childsDepth.begin(), childsDepth.end(), std::greater<int>()); // int maxDepth = 0; for (int i = 0; i < childsDepth.size(); ++i) { int oneDepth = childsDepth[i] + i + 1; if (maxDepth < oneDepth)maxDepth = oneDepth; } depth[v] = maxDepth; stack.pop_back(); } } cout << depth[0]; } #endif
a.cc: In function 'void proc()': a.cc:70:29: error: redeclaration of 'long long int child' 70 | int child = *childs2[v].begin(); | ^~~~~ a.cc:69:27: note: 'long long int child' previously declared here 69 | for (auto child : childs2[v]) { | ^~~~~
s212105678
p03822
C++
#include <iostream> #include <cassert> #include <climits> #include <bitset> #include <stack> #include <queue> #include <iomanip> #include <limits> #include <string> #include <cmath> #include <set> #include <map> #include <math.h> #include <algorithm> #include <vector> #include <string.h> using namespace std; typedef long long ll; typedef pair<ll,ll> P; long long int INF = 1e18; double Pi = 3.1415926535897932384626; long long int mod = 1000000007; vector<ll> G[500005]; vector<P> tree[500010]; priority_queue <ll> pql; priority_queue <P> pqp; //big priority queue priority_queue <ll,vector<ll>,greater<ll> > pqls; priority_queue <P,vector<P>,greater<P> > pqps; //small priority queue //top pop int dx[8]={1,0,-1,0,1,1,-1,-1}; int dy[8]={0,1,0,-1,1,-1,-1,1}; char dir[] = "RULD"; //↓,→,↑,← #define p(x) cout<<x<<endl; #define el cout<<endl; #define pe(x) cout<<x<<" "; #define ps(x) cout<<fixed<<setprecision(25)<<x<<endl; #define pu(x) cout<<x; #define re(i,a,b) for(i=a;i<=b;i++); #define pb push_back #define lb lower_bound #define ub upper_bound #define deba(x) cout<< #x << " = " << x <<endl ll rui(ll abc,ll bed){ //abcのbed乗を計算する if(bed==0){return 1;} else{ ll ced = rui(abc,bed/2); ced *= ced; ced %= mod; if(bed%2==1){ced*=abc; ced%=mod;} return ced; } } ll i,j,k,ii,jj; ll n,m,num; ll a,b,c,e,f,g,h; ll y[800005],z[900005]; ll in[800005]; ll vnum = 0,sum,ans; bool dame; bool check[500005]; ll dfs(ll a){ if(num <= 2000){ ll x[2205]; }else if(num <= 5000){ ll x[5500]; }else{ ll x[8000]; } if(G[a].size() == 0){ return 0; }else{ ll num = G[a].size(); for(int i=0;i<num;i++){ x[i] = dfs(G[a][i]); } sort(x,x+num); ll a = 0; for(i = 0;i<num;i++){ a = max(a,x[i] + num - i); } return a; } } int main(){ cin>>n; for(i=0;i<n-1;i++){ cin >> a; //i+2番目はaに負けた G[a].pb(i+2); } p(dfs(1)); //p(ans); return 0; }
a.cc: In function 'll dfs(ll)': a.cc:89:25: error: 'x' was not declared in this scope 89 | x[i] = dfs(G[a][i]); | ^ a.cc:91:22: error: 'x' was not declared in this scope 91 | sort(x,x+num); | ^
s998506556
p03822
C++
#include <iostream> #include <cassert> #include <climits> #include <bitset> #include <stack> #include <queue> #include <iomanip> #include <limits> #include <string> #include <cmath> #include <set> #include <map> #include <math.h> #include <algorithm> #include <vector> #include <string.h> using namespace std; typedef long long ll; typedef pair<ll,ll> P; long long int INF = 1e18; double Pi = 3.1415926535897932384626; long long int mod = 1000000007; vector<ll> G[500005]; vector<P> tree[500010]; priority_queue <ll> pql; priority_queue <P> pqp; //big priority queue priority_queue <ll,vector<ll>,greater<ll> > pqls; priority_queue <P,vector<P>,greater<P> > pqps; //small priority queue //top pop int dx[8]={1,0,-1,0,1,1,-1,-1}; int dy[8]={0,1,0,-1,1,-1,-1,1}; char dir[] = "RULD"; //↓,→,↑,← #define p(x) cout<<x<<endl; #define el cout<<endl; #define pe(x) cout<<x<<" "; #define ps(x) cout<<fixed<<setprecision(25)<<x<<endl; #define pu(x) cout<<x; #define re(i,a,b) for(i=a;i<=b;i++); #define pb push_back #define lb lower_bound #define ub upper_bound #define deba(x) cout<< #x << " = " << x <<endl ll rui(ll abc,ll bed){ //abcのbed乗を計算する if(bed==0){return 1;} else{ ll ced = rui(abc,bed/2); ced *= ced; ced %= mod; if(bed%2==1){ced*=abc; ced%=mod;} return ced; } } ll i,j,k,ii,jj; ll n,m,num; ll a,b,c,e,f,g,h; ll y[800005],z[900005]; ll in[800005]; ll vnum = 0,sum,ans; bool dame; bool check[500005]; ll dfs(ll a){ if(G[a].size() == 0){ return 0; }else{ ll num = G[a].size(); if(num <= 2000){ ll x[2205]; }else if(num <= 5000){ ll x[5500]; }else{ ll x[8000]; } for(int i=0;i<num;i++){ x[i] = dfs(G[a][i]); } sort(x,x+num); ll a = 0; for(i = 0;i<num;i++){ a = max(a,x[i] + num - i); } return a; } } int main(){ cin>>n; for(i=0;i<n-1;i++){ cin >> a; //i+2番目はaに負けた G[a].pb(i+2); } p(dfs(1)); //p(ans); return 0; }
a.cc: In function 'll dfs(ll)': a.cc:89:25: error: 'x' was not declared in this scope 89 | x[i] = dfs(G[a][i]); | ^ a.cc:91:22: error: 'x' was not declared in this scope 91 | sort(x,x+num); | ^
s104701297
p03822
C++
#include "bits/stdc++.h" #define ll long long #define rep2(i,a,b) for(int i=a;i<=b;++i) #define rep(i,n) for(int i=0;i<n;i++) #define pii pair<int,int> #define tii tuple<int,int,int> #define pq priority_queue<int> #define pqg priority_queue<int,vector<int>,greater<int>> #define pb push_back ll int MOD=998244353; #define INF 2*1e9 #define N 310000 using namespace std; string alphabet("abcdefghijklmnopqrstuvwxyz"); int n; vector<int> v[N]; int depth(int a){ if(!v[a].size()) return 0; vector<int> w; rep(i,v[a].size()){ w.pb(depth(v[a][i])); } sort(w.begin(),w.end()); int ans=0; rep(i,w.size()){ ans=max(ans,w[i]+(int)w.size()-i); temp--; } return ans; } main(){ cin>>n; rep2(i,2,n){ int a; cin>>a; v[a].push_back(i); } cout<<depth(1); return 0; }
a.cc: In function 'int depth(int)': a.cc:29:9: error: 'temp' was not declared in this scope; did you mean 'tm'? 29 | temp--; | ^~~~ | tm a.cc: At global scope: a.cc:33:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 33 | main(){ | ^~~~
s849714063
p03822
C++
#include "bits/stdc++.h" #define ll long long #define rep2(i,a,b) for(int i=a;i<=b;++i) #define rep(i,n) for(int i=0;i<n;i++) #define pii pair<int,int> #define tii tuple<int,int,int> #define pq priority_queue<int> #define pqg priority_queue<int,vector<int>,greater<int>> #define pb push_back ll int MOD=998244353; #define INF 2*1e9 #define N 310000 using namespace std; string alphabet("abcdefghijklmnopqrstuvwxyz"); int n; vector<int> v[N]; int depth(int a){ if(!v[a].size()) return 0; vector<int> w; rep(i,v[a].size()){ w.pb(depth(v[a][i])); } sort(w.begin(),w.end()); int ans=0; rep(i,w.size()){ ans=max(ans,w[i]+w.size()-i); temp--; } return ans; } main(){ cin>>n; rep2(i,2,n){ int a; cin>>a; v[a].push_back(i); } cout<<depth(1); return 0; }
a.cc: In function 'int depth(int)': a.cc:28:16: error: no matching function for call to 'max(int&, std::vector<int>::size_type)' 28 | ans=max(ans,w[i]+w.size()-i); | ~~~^~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:28:16: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'std::vector<int>::size_type' {aka 'long unsigned int'}) 28 | ans=max(ans,w[i]+w.size()-i); | ~~~^~~~~~~~~~~~~~~~~~~~~ /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, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:28:16: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 28 | ans=max(ans,w[i]+w.size()-i); | ~~~^~~~~~~~~~~~~~~~~~~~~ a.cc:29:9: error: 'temp' was not declared in this scope; did you mean 'tm'? 29 | temp--; | ^~~~ | tm a.cc: At global scope: a.cc:33:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 33 | main(){ | ^~~~
s947020455
p03822
C++
#include "bits/stdc++.h" #define ll long long #define rep2(i,a,b) for(int i=a;i<=b;++i) #define rep(i,n) for(int i=0;i<n;i++) #define pii pair<int,int> #define tii tuple<int,int,int> #define pq priority_queue<int> #define pqg priority_queue<int,vector<int>,greater<int>> #define pb push_back ll int MOD=998244353; #define INF 2*1e9 #define N 310000 using namespace std; string alphabet("abcdefghijklmnopqrstuvwxyz"); int n; vector<int> v[N]; int depth(int a){ if(!v[a].size()) return 0; vector<int> w; rep(i,v[a].size()){ w.pb(depth(v[a][i])); } sort(w.begin(),w.end()); int ans=0; rep(i,w.size()){ ans=max(ans,w[i]+w.size-i); temp--; } return ans; } main(){ cin>>n; rep2(i,2,n){ int a; cin>>a; v[a].push_back(i); } cout<<depth(1); return 0; }
a.cc: In function 'int depth(int)': a.cc:28:28: error: invalid use of member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = int; _Alloc = std::allocator<int>; size_type = long unsigned int]' (did you forget the '()' ?) 28 | ans=max(ans,w[i]+w.size-i); | ~~^~~~ | () a.cc:29:9: error: 'temp' was not declared in this scope; did you mean 'tm'? 29 | temp--; | ^~~~ | tm a.cc: At global scope: a.cc:33:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 33 | main(){ | ^~~~
s329893718
p03822
C++
#include <bits/stdc++.h> using namespace std; const int N = 100010; int _w; int n, a[N], in[N], d[N]; int q[N], begin, end; vector<int> v[N]; bool cmp( int i, int j ) { return d[i] < d[j]; } int main() { ios::sync_with_stdio(false); cin >> n; for( int i = 2; i <= n; ++i ) { cin >> a[i]; ++in[a[i]]; v[a[i]].push_back(i); } for( int i = 1; i <= n; ++i ) if( !in[i] ) q[end++] = i; while( begin != end ) { int u = q[begin++]; sort(v[u].begin(), v[u].end(), cmp); for( int i = 0; i < (int)v[u].size(); ++i ) d[u] = max( d[u], d[v[u][i]] ) + 1; --in[a[u]]; if( in[a[u]] == 0 ) q[end++] = a[u]; } cout << d[1] << endl; return 0; }
a.cc: In function 'int main()': a.cc:25:27: error: reference to 'end' is ambiguous 25 | q[end++] = i; | ^~~ In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166, from a.cc:1: /usr/include/c++/14/valarray:1265:5: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)' 1265 | end(const valarray<_Tp>& __va) noexcept | ^~~ /usr/include/c++/14/valarray:1249:5: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)' 1249 | end(valarray<_Tp>& __va) noexcept | ^~~ 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: /usr/include/c++/14/bits/range_access.h:106:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])' 106 | end(_Tp (&__arr)[_Nm]) noexcept | ^~~ /usr/include/c++/14/bits/range_access.h:85:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)' 85 | end(const _Container& __cont) -> decltype(__cont.end()) | ^~~ /usr/include/c++/14/bits/range_access.h:74:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)' 74 | end(_Container& __cont) -> decltype(__cont.end()) | ^~~ In file included from /usr/include/c++/14/bits/algorithmfwd.h:39, from /usr/include/c++/14/bits/stl_algo.h:59, from /usr/include/c++/14/algorithm:61, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51: /usr/include/c++/14/initializer_list:99:5: note: 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)' 99 | end(initializer_list<_Tp> __ils) noexcept | ^~~ a.cc:8:18: note: 'int end' 8 | int q[N], begin, end; | ^~~ a.cc:26:16: error: reference to 'begin' is ambiguous 26 | while( begin != end ) { | ^~~~~ /usr/include/c++/14/valarray:1238:5: note: candidates are: 'template<class _Tp> const _Tp* std::begin(const valarray<_Tp>&)' 1238 | begin(const valarray<_Tp>& __va) noexcept | ^~~~~ /usr/include/c++/14/valarray:1227:5: note: 'template<class _Tp> _Tp* std::begin(valarray<_Tp>&)' 1227 | begin(valarray<_Tp>& __va) noexcept | ^~~~~ /usr/include/c++/14/bits/range_access.h:95:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::begin(_Tp (&)[_Nm])' 95 | begin(_Tp (&__arr)[_Nm]) noexcept | ^~~~~ /usr/include/c++/14/bits/range_access.h:63:5: note: 'template<class _Container> constexpr decltype (__cont.begin()) std::begin(const _Container&)' 63 | begin(const _Container& __cont) -> decltype(__cont.begin()) | ^~~~~ /usr/include/c++/14/bits/range_access.h:52:5: note: 'template<class _Container> constexpr decltype (__cont.begin()) std::begin(_Container&)' 52 | begin(_Container& __cont) -> decltype(__cont.begin()) | ^~~~~ /usr/include/c++/14/initializer_list:88:5: note: 'template<class _Tp> constexpr const _Tp* std::begin(initializer_list<_Tp>)' 88 | begin(initializer_list<_Tp> __ils) noexcept | ^~~~~ a.cc:8:11: note: 'int begin' 8 | int q[N], begin, end; | ^~~~~ a.cc:26:25: error: reference to 'end' is ambiguous 26 | while( begin != end ) { | ^~~ /usr/include/c++/14/valarray:1265:5: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)' 1265 | end(const valarray<_Tp>& __va) noexcept | ^~~ /usr/include/c++/14/valarray:1249:5: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)' 1249 | end(valarray<_Tp>& __va) noexcept | ^~~ /usr/include/c++/14/bits/range_access.h:106:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])' 106 | end(_Tp (&__arr)[_Nm]) noexcept | ^~~ /usr/include/c++/14/bits/range_access.h:85:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)' 85 | end(const _Container& __cont) -> decltype(__cont.end()) | ^~~ /usr/include/c++/14/bits/range_access.h:74:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)' 74 | end(_Container& __cont) -> decltype(__cont.end()) | ^~~ /usr/include/c++/14/initializer_list:99:5: note: 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)' 99 | end(initializer_list<_Tp> __ils) noexcept | ^~~ a.cc:8:18: note: 'int end' 8 | int q[N], begin, end; | ^~~ a.cc:27:27: error: reference to 'begin' is ambiguous 27 | int u = q[begin++]; | ^~~~~ /usr/include/c++/14/valarray:1238:5: note: candidates are: 'template<class _Tp> const _Tp* std::begin(const valarray<_Tp>&)' 1238 | begin(const valarray<_Tp>& __va) noexcept | ^~~~~ /usr/include/c++/14/valarray:1227:5: note: 'template<class _Tp> _Tp* std::begin(valarray<_Tp>&)' 1227 | begin(valarray<_Tp>& __va) noexcept | ^~~~~ /usr/include/c++/14/bits/range_access.h:95:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::begin(_Tp (&)[_Nm])' 95 | begin(_Tp (&__arr)[_Nm]) noexcept | ^~~~~ /usr/include/c++/14/bits/range_access.h:63:5: note: 'template<class _Container> constexpr decltype (__cont.begin()) std::begin(const _Container&)' 63 | begin(const _Container& __cont) -> decltype(__cont.begin()) | ^~~~~ /usr/include/c++/14/bits/range_access.h:52:5: note: 'template<class _Container> constexpr decltype (__cont.begin()) std::begin(_Container&)' 52 | begin(_Container& __cont) -> decltype(__cont.begin()) | ^~~~~ /usr/include/c++/14/initializer_list:88:5: note: 'template<class _Tp> constexpr const _Tp* std::begin(initializer_list<_Tp>)' 88 | begin(initializer_list<_Tp> __ils) noexcept | ^~~~~ a.cc:8:11: note: 'int begin' 8 | int q[N], begin, end; | ^~~~~ a.cc:33:27: error: reference to 'end' is ambiguous 33 | q[end++] = a[u]; | ^~~ /usr/include/c++/14/valarray:1265:5: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)' 1265 | end(const valarray<_Tp>& __va) noexcept | ^~~ /usr/include/c++/14/valarray:1249:5: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)' 1249 | end(valarray<_Tp>& __va) noexcept | ^~~ /usr/include/c++/14/bits/range_access.h:106:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])' 106 | end(_Tp (&__arr)[_Nm]) noexcept | ^~~ /usr/include/c++/14/bits/range_access.h:85:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)' 85 | end(const _Container& __cont) -> decltype(__cont.end()) | ^~~ /usr/include/c++/14/bits/range_access.h:74:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)' 74 | end(_Container& __cont) -> decltype(__cont.end()) | ^~~ /usr/include/c++/14/initializer_list:99:5: note: 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)' 99 | end(initializer_list<_Tp> __ils) noexcept | ^~~ a.cc:8:18: note: 'int end' 8 | int q[N], begin, end; | ^~~
s268353887
p03822
C++
#include<bits/stdc++.h> const int MX=100005; using namespace std; int n,f[MX],x[MX]; vector<int>G[MX]; void dfs(int k){ int c=0; for(auto i:G[k])dfs(i),x[++c]=f[i]; if(c){sort(x+1,x+c+1);for(int i=1;i<=c;i++)f[k]=max(f[k],x[c-i+1]+i);} } int main(){ cin>>n; for(int i=2,u;i<=n;i++)cin>>u,G[u].pb(i); dfs(1); cout<<f[1]<<endl; return 0; }
a.cc: In function 'int main()': a.cc:15:44: error: 'class std::vector<int>' has no member named 'pb' 15 | for(int i=2,u;i<=n;i++)cin>>u,G[u].pb(i); | ^~
s462348733
p03822
C++
#include<iostream> #include<vector> #include<algorithm> #include<cstring> #include<cstdio> #include<cmath> #include<cstdlib> #include<ctime> #include<queue> #include<set> #include<map> #include<stack> using namespace std; typedef long long LL; const int N=2e5; int gi() { int w=0;bool q=1;char c=getchar(); while ((c<'0'||c>'9') && c!='-') c=getchar(); if (c=='-') q=0,c=getchar(); while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar(); return q? w:-w; } int head[N],next[N]; int st[N],f[N]; inline void dfs(int k) { int i,len=0; for (i=head[k];i;i=next[i]) dfs(i); for (i=head[k];i;i=next[i]) st[++len]=f[i]; sort(st+1,st+1+len); for (i=1;i<=len;i++) f[k]=max(f[k],st[i]+1+len-i); } int main() { int n=gi(),i,k; for (i=2;i<=n;i++) next[i]=head[k=gi()],head[k]=i; dfs(1); cout<<f[1]<<endl; return 0; }
a.cc: In function 'void dfs(int)': a.cc:27:28: error: reference to 'next' is ambiguous 27 | for (i=head[k];i;i=next[i]) | ^~~~ In file included from /usr/include/c++/14/string:47, 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_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:23:13: note: 'int next [200000]' 23 | int head[N],next[N]; | ^~~~ a.cc:29:28: error: reference to 'next' is ambiguous 29 | for (i=head[k];i;i=next[i]) st[++len]=f[i]; | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:23:13: note: 'int next [200000]' 23 | int head[N],next[N]; | ^~~~ a.cc: In function 'int main()': a.cc:37:28: error: reference to 'next' is ambiguous 37 | for (i=2;i<=n;i++) next[i]=head[k=gi()],head[k]=i; | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:23:13: note: 'int next [200000]' 23 | int head[N],next[N]; | ^~~~
s059753318
p03822
C++
#include <bits/stdc++.h> using namespace std; int N; int ans; vector <int> G[100001]; int sum = 0; int dfs(int v,int p) { for(int i = 0; i < G[v].size(); i++) { int u = G[v][i]; if(u != p) { sum = dfs(u,v); //cout <<v<<" "<< sum <<endl; } } return sum + 1; } int main() { cin >> N; for(int i = 1; i < N; i++) { int a; cin >> a; a--; G[i].push_back(a); G[a].push_back(i); } for(int i = 0; i < G[0].size(); i++) { sum = 0; ans = max(ans,dfs(G[0][i],0)); //cout <<"G[0][i] = "<<dfs(G[0][i],0) <<endl; } cout << ans << endl; } #include <bits/stdc++.h> using namespace std; int N; int ans; vector <int> G[100001]; int sum = 0; int dfs(int v,int p) { for(int i = 0; i < G[v].size(); i++) { int u = G[v][i]; if(u != p) { sum = dfs(u,v); //cout <<v<<" "<< sum <<endl; } } return sum + 1; } int main() { cin >> N; for(int i = 1; i < N; i++) { int a; cin >> a; a--; G[i].push_back(a); G[a].push_back(i); } for(int i = 0; i < G[0].size(); i++) { sum = 0; ans = max(ans,dfs(G[0][i],0)); //cout <<"G[0][i] = "<<dfs(G[0][i],0) <<endl; } cout << ans << endl; }
a.cc:48:5: error: redefinition of 'int N' 48 | int N; | ^ a.cc:4:5: note: 'int N' previously declared here 4 | int N; | ^ a.cc:49:5: error: redefinition of 'int ans' 49 | int ans; | ^~~ a.cc:5:5: note: 'int ans' previously declared here 5 | int ans; | ^~~ a.cc:50:14: error: redefinition of 'std::vector<int> G [100001]' 50 | vector <int> G[100001]; | ^ a.cc:6:14: note: 'std::vector<int> G [100001]' previously declared here 6 | vector <int> G[100001]; | ^ a.cc:51:5: error: redefinition of 'int sum' 51 | int sum = 0; | ^~~ a.cc:7:5: note: 'int sum' previously defined here 7 | int sum = 0; | ^~~ a.cc:52:5: error: redefinition of 'int dfs(int, int)' 52 | int dfs(int v,int p) { | ^~~ a.cc:8:5: note: 'int dfs(int, int)' previously defined here 8 | int dfs(int v,int p) { | ^~~ a.cc:68:5: error: redefinition of 'int main()' 68 | int main() { | ^~~~ a.cc:24:5: note: 'int main()' previously defined here 24 | int main() { | ^~~~
s334516555
p03822
C++
#include <iostream> #include <vector> using namespace std; typedef long long lli; lli n; vector<vector<lli> > g; lli ans = 0; lli dfs(lli x){ lli ret = 0; vector<lli> d; for(lli i = 0;i < g[x].size();i++){ d.push_back(dfs(g[x][i])); } sort(d.rbegin(),d.rend()); for(lli i = 0;i < d.size();i++){ ret = max(ret,d[i]+i+1); } return ret; } int main(){ cin >> n; g = vector<vector<lli> > (n+1); for(lli i = 2;i <= n;i++){ lli a; cin >> a; g[a].push_back(i); } cout << dfs(1) << endl; return 0; }
a.cc: In function 'lli dfs(lli)': a.cc:14:5: error: 'sort' was not declared in this scope; did you mean 'short'? 14 | sort(d.rbegin(),d.rend()); | ^~~~ | short
s380104285
p03822
C++
5 1 1 2 4 7 1 2 1 3 1 4 4 4 4 1
a.cc:1:1: error: expected unqualified-id before numeric constant 1 | 5 | ^
s655180704
p03822
C++
#include<string> #include<iostream> #include<algorithm> #include<set> #include<math.h> #include<vector> #include<sstream> #include<queue> #include<functional> #include<bitset> #include<cstdio> #include<iomanip> #include <cstring> #include <climits> using namespace std; #define REP(i,n) for(int i=0;i < n; i++) #define RREP(i,n) for(int i=n-1;i >=0; i--) #define p(a) (a) * (a) #define p2(a,b) p((a) - (b)) #define MAX 101 #define MAX_V 15 int n, i, j, k; int f[100005], son[100005], Next[100005]; int id[100005]; void dfs(int x) { if (!son[x])return; int i, j, k = 0; for (i = son[x]; i; i = Next[i])dfs(i); for (i = son[x]; i; i = Next[i])id[++k] = i; sort(id + 1, id + k + 1, cmp); for (i = 1; i <= k; ++i) { j = f[id[i]] + i; if (j>f[x])f[x] = j; } } int main() { cin >> n; for (int i = 2; i <= n; i++) { cin >> k; Next[i] = son[k]; son[k] = i; } dfs(1); cout << f[i] << endl; return 0; }
a.cc: In function 'void dfs(int)': a.cc:30:34: error: 'cmp' was not declared in this scope; did you mean 'bcmp'? 30 | sort(id + 1, id + k + 1, cmp); | ^~~ | bcmp
s337978560
p03822
Java
public class Main { static int n; static int[] a; static int[] dp; static Node[] node; public static void main(String[] args) throws IOException { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); n=Integer.parseInt(br.readLine()); a=new int[n-1]; dp=new int[n+1]; node=new Node[n+1]; for(int i=0;i<n+1;i++){ node[i]=new Node(); } Arrays.fill(dp,-1); for(int i=0;i<n-1;i++){ a[i]=Integer.parseInt(br.readLine()); node[a[i]].next_list.add(i+2); }System.out.println(dfs(1)); } static int dfs(int target){ //System.out.println("target="+target); if(dp[target]!=-1){ return dp[target]; } int count=0; int ret=0; int[] temp=new int[node[target].next_list.size()]; for(int i=0;i<temp.length;i++){ temp[i]=dfs(node[target].next_list.get(i)); } Arrays.sort(temp); dp[target]=(temp.length==0) ? 0:temp[temp.length-1]+1; return dp[target]; } } class Node{ ArrayList<Integer> next_list=new ArrayList<>(); }
Main.java:7: error: cannot find symbol public static void main(String[] args) throws IOException { ^ symbol: class IOException location: class Main Main.java:38: error: cannot find symbol ArrayList<Integer> next_list=new ArrayList<>(); ^ symbol: class ArrayList location: class Node Main.java:8: error: cannot find symbol BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); ^ symbol: class BufferedReader location: class Main Main.java:8: error: cannot find symbol BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); ^ symbol: class BufferedReader location: class Main Main.java:8: error: cannot find symbol BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); ^ symbol: class InputStreamReader location: class Main Main.java:14: error: cannot find symbol Arrays.fill(dp,-1); ^ symbol: variable Arrays location: class Main Main.java:30: error: cannot find symbol Arrays.sort(temp); ^ symbol: variable Arrays location: class Main Main.java:38: error: cannot find symbol ArrayList<Integer> next_list=new ArrayList<>(); ^ symbol: class ArrayList location: class Node 8 errors
s460049139
p03822
Java
public class Main { static int n; static int[] a; static int[] dp; static Node[] node; public static void main(String[] args) throws IOException { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); n=Integer.parseInt(br.readLine()); a=new int[n-1]; dp=new int[n+1]; node=new Node[n+1]; for(int i=0;i<n+1;i++){ node[i]=new Node(); } Arrays.fill(dp,-1); for(int i=0;i<n-1;i++){ a[i]=Integer.parseInt(br.readLine()); node[a[i]].next_list.add(i+2); }System.out.println(dfs(1)); } static int dfs(int target){ //System.out.println("target="+target); if(dp[target]!=-1){ return dp[target]; } int count=0; int ret=0; int[] temp=new int[node[target].next_list.size()]; for(int i=0;i<temp.length;i++){ temp[i]=dfs(node[target].next_list.get(i)); } Arrays.parallelSort(temp); dp[target]=(temp.length==0) ? 0:temp[temp.length-1]+1; return dp[target]; } } class Node{ ArrayList<Integer> next_list=new ArrayList<>(); }
Main.java:7: error: cannot find symbol public static void main(String[] args) throws IOException { ^ symbol: class IOException location: class Main Main.java:38: error: cannot find symbol ArrayList<Integer> next_list=new ArrayList<>(); ^ symbol: class ArrayList location: class Node Main.java:8: error: cannot find symbol BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); ^ symbol: class BufferedReader location: class Main Main.java:8: error: cannot find symbol BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); ^ symbol: class BufferedReader location: class Main Main.java:8: error: cannot find symbol BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); ^ symbol: class InputStreamReader location: class Main Main.java:14: error: cannot find symbol Arrays.fill(dp,-1); ^ symbol: variable Arrays location: class Main Main.java:30: error: cannot find symbol Arrays.parallelSort(temp); ^ symbol: variable Arrays location: class Main Main.java:38: error: cannot find symbol ArrayList<Integer> next_list=new ArrayList<>(); ^ symbol: class ArrayList location: class Node 8 errors
s929516340
p03822
C++
#include<iostream> #include<cmath> #include<stdio.h> #include<vector> #include<string> using namespace std; vector<int> AA[100000]; int tree(int a){ int ans,i; vector<int> tmp; for(i=0;i<AA[a].size();i++){ tmp.push_back(tree(AA[a][i]-1)); } sort(tmp.begin(),tmp.end()); ans=0; for(i=0;i<tmp.size();i++){ ans=max(ans,tmp[i])+1; } return ans; } int main(void){ int i,j,N,a,ans; cin >> N; for(i=2;i<=N;i++){ cin >> a; AA[a-1].push_back(i); } cout << tree(0) << endl;; return 0; }
a.cc: In function 'int tree(int)': a.cc:16:5: error: 'sort' was not declared in this scope; did you mean 'sqrt'? 16 | sort(tmp.begin(),tmp.end()); | ^~~~ | sqrt
s449634870
p03822
C++
#include <iostream> #include <unordered_map> #include <vector> #include <stack> #include <set> int N; std::vector<int> A; int main() { std::cin >> N; for (int i = 0; i < N - 1; ++i) { int a; std::cin >> a; A.push_back(a - 1); } std::unordered_map<int, std::vector<int>> wins; for (int i = 0; i < N; ++i) wins[i] = {}; for (int i = 1; i < N; ++i) { wins[A[i - 1]].push_back(i) ; } //for (const auto &k : wins) { // std::cout << "KEY" << k.first << std::endl; // for (const auto &j : k.second) { // std::cout << j << " "; // } // std::cout << std::endl; //} std::stack<int> stack; std::set<int> expanded; std::vector<int> indices; stack.push(0); while (!stack.empty()) { const auto t = stack.top(); stack.pop(); if (expanded.find(t) != expanded.end()) { indices.push_back(t); continue; } expanded.insert(t); stack.push(t); for (const auto target : wins[t]) { stack.push(target); } } std::vector<int> depth_table; for (int i = 0; i < N; ++i) { depth_table.push_back(0); } std::vector<int> tmp; for (int i = 0; i < N; ++i) { tmp.push_back(0); } for (const int i : indices) { if (wins[i].size() == 0) { depth_table[i] = 0; continue; } int c = 0; for (const int j : wins[i]) { tmp[c++] = -depth_table[j]; } std::sort(tmp.begin(), tmp.begin() + c); depth_table[i] = -1; for (int j = 0; j < c; ++j) { if (-tmp[j] + j + 1 > depth_table[i]) { depth_table[i] = -tmp[j] + j + 1; } } } std::cout << depth_table[0] << std::endl; // def solve(i): // if len(wins[i]) == 0: // return 0 // ans = max(n + 1 + d for n, d in enumerate(sorted((solve(j) for j in wins[i]), reverse=True))) // return ans // // print(solve(0)) return 0; }
a.cc: In function 'int main()': a.cc:67:10: error: 'sort' is not a member of 'std'; did you mean 'qsort'? 67 | std::sort(tmp.begin(), tmp.begin() + c); | ^~~~ | qsort
s777489197
p03822
C++
#include <bits/stdc++.h> using namespace std; vector< vector<int> > array; long long solve(int x) { if (array[x].size() == 0) { return 0LL; } else { long long ans = 0; for (int i = 0; i < array[x].size(); i++) { ans = max(ans, solve(array[x][i]) + 1, array[x].size()); } return ans; } } int main() { long long N; scanf("%lld", &N); vector<long long> a(N + 1); array.resize(N + 1); for (long long i = 2; i <= N; i++) { scanf("%lld", &a[i]); //winner a[i], loser i; array[a[i]].push_back(i); } long long ans = solve(1); printf("%lld\n", ans); }
a.cc: In function 'long long int solve(int)': a.cc:8:9: error: reference to 'array' is ambiguous 8 | if (array[x].size() == 0) { | ^~~~~ 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, from a.cc:1: /usr/include/c++/14/bits/stl_pair.h:99:12: note: candidates are: 'template<class _Tp, long unsigned int _Nm> struct std::array' 99 | struct array; | ^~~~~ a.cc:4:23: note: 'std::vector<std::vector<int> > array' 4 | vector< vector<int> > array; | ^~~~~ a.cc:12:29: error: reference to 'array' is ambiguous 12 | for (int i = 0; i < array[x].size(); i++) { | ^~~~~ /usr/include/c++/14/bits/stl_pair.h:99:12: note: candidates are: 'template<class _Tp, long unsigned int _Nm> struct std::array' 99 | struct array; | ^~~~~ a.cc:4:23: note: 'std::vector<std::vector<int> > array' 4 | vector< vector<int> > array; | ^~~~~ a.cc:13:34: error: reference to 'array' is ambiguous 13 | ans = max(ans, solve(array[x][i]) + 1, array[x].size()); | ^~~~~ /usr/include/c++/14/bits/stl_pair.h:99:12: note: candidates are: 'template<class _Tp, long unsigned int _Nm> struct std::array' 99 | struct array; | ^~~~~ a.cc:4:23: note: 'std::vector<std::vector<int> > array' 4 | vector< vector<int> > array; | ^~~~~ a.cc:13:52: error: reference to 'array' is ambiguous 13 | ans = max(ans, solve(array[x][i]) + 1, array[x].size()); | ^~~~~ /usr/include/c++/14/bits/stl_pair.h:99:12: note: candidates are: 'template<class _Tp, long unsigned int _Nm> struct std::array' 99 | struct array; | ^~~~~ a.cc:4:23: note: 'std::vector<std::vector<int> > array' 4 | vector< vector<int> > array; | ^~~~~ a.cc: In function 'int main()': a.cc:25:5: error: reference to 'array' is ambiguous 25 | array.resize(N + 1); | ^~~~~ /usr/include/c++/14/bits/stl_pair.h:99:12: note: candidates are: 'template<class _Tp, long unsigned int _Nm> struct std::array' 99 | struct array; | ^~~~~ a.cc:4:23: note: 'std::vector<std::vector<int> > array' 4 | vector< vector<int> > array; | ^~~~~ a.cc:28:9: error: reference to 'array' is ambiguous 28 | array[a[i]].push_back(i); | ^~~~~ /usr/include/c++/14/bits/stl_pair.h:99:12: note: candidates are: 'template<class _Tp, long unsigned int _Nm> struct std::array' 99 | struct array; | ^~~~~ a.cc:4:23: note: 'std::vector<std::vector<int> > array' 4 | vector< vector<int> > array; | ^~~~~ a.cc: In function 'long long int solve(int)': a.cc:17:1: warning: control reaches end of non-void function [-Wreturn-type] 17 | } | ^
s238557551
p03822
C++
#include<bits/stdc++.h> using namespace std; #define int long long const int MAX_N = 100000; int N, A[MAX_N]; vector<int> e[MAX_N]; int Solve(int n) { vector<int> depths; for (int i = 0; i < e[n].size(); i++) { depths.push_back(Solve(e[n][i])); } sort(depths.begin(), depths.end()); int res = 0; for (int i = 0; i < e[n].size(); i++) { res = max(res, depths[i] + e[n].size() - i); } return res; } signed main() { A[0] = -1; cin >> N; for (int i = 1; i < N; i++) { cin >> A[i]; A[i]--; e[A[i]].push_back(i); } printf("%lld\n", Solve(0)); return 0; }
a.cc: In function 'long long int Solve(long long int)': a.cc:21:26: error: no matching function for call to 'max(long long int&, long long unsigned int)' 21 | res = max(res, depths[i] + e[n].size() - i); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:21:26: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long long unsigned int') 21 | res = max(res, depths[i] + e[n].size() - i); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /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, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:21:26: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 21 | res = max(res, depths[i] + e[n].size() - i); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
s417782511
p03822
C++
#include <iostream> #include <string> #include <vector> #include <map> #include <cmath> #include <algorithm> #include <cstdlib> #include <fstream> #include <set> #include <queue> using namespace std; vector<vector<int>> graph; int ans = 0; dfs(int root, int depth) { if (depth > ans) ans = depth; for (int i = 0; i < (int) graph[root].size(); ++i) { dfs(graph[root][i], depth + 1); } } vector<int> countOfWins; int findMaxWinsCount(int root) { if (countOfWins[root] == 0) return 0; vector<int> tmp((int) graph[root].size()); for (int i = 0; i < (int) graph[root].size(); ++i) { tmp[i] = findMaxWinsCount(graph[root][i]) + 1; } sort(tmp.begin(), tmp.end()); for (int i = 1; i < (int) tmp.size(); ++i) { if (tmp[i] <= tmp[i - 1]) tmp[i] = tmp[i] + 1; } return tmp[(int) tmp.size() - 1]; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; graph.resize(n); countOfWins.resize(n, 0); for (int i = 0; i < n - 1; ++i) { int tmp; cin >> tmp; --tmp; graph[tmp].push_back(i + 1); ++countOfWins[tmp]; } cout << findMaxWinsCount(0) << endl; /* for (int i = 0; i < n; ++i) { cout << i + 1 << ": " << endl; for (int j = 0; j < (int) graph[i].size(); ++j) { cout << graph[i][j] + 1 << " "; } cout << endl; cout << endl; }*/ return 0; }
a.cc:18:1: error: ISO C++ forbids declaration of 'dfs' with no type [-fpermissive] 18 | dfs(int root, int depth) { | ^~~ a.cc: In function 'int dfs(int, int)': a.cc:24:1: warning: no return statement in function returning non-void [-Wreturn-type] 24 | } | ^
s214802051
p03822
C++
#include <bits/stdc++.h> #define rep(i, a, n) for(int i = a; i < n; i++) #define repb(i, a, b) for(int i = a; i >= b; i--) #define all(a) a.begin(), a.end() #define o(a) cout << a << endl #define int long long using namespace std; typedef pair<int, int> P; vector<int> G[100010]; int dp[100010]; int INF = 1e9; int n; int dfs(int now){ if(dp[now] != -1) return dp[now]; if(G[now].size() == 0) return dp[now] = 0; vector<int> d; rep(i, 0, G[now].size()){ int tmp = dfs(G[now][i]); d.push_back(tmp); } sort(all(d)); reverse(all(d)); MAX = -1; rep(i, 0, d.size()){ MAX = d[i] + i + 1; } return dp[now] = MAX; } signed main(){ cin >> n; vector<int> a(n); memset(dp, -1, sizeof(dp)); rep(i, 1, n){ cin >> a[i]; a[i]--; G[a[i]]. push_back(i); } cout << dfs(0) << endl; }
a.cc: In function 'long long int dfs(long long int)': a.cc:25:5: error: 'MAX' was not declared in this scope 25 | MAX = -1; | ^~~
s382156570
p03822
Java
import java.util.*; public class Main{ public static void main(String[] args){ int i,j; int tmp=0; int ans=0; Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int[] a=new int[n-1];//2~n->0~n-2 List<Integer> loser=new ArrayList<Integer>(); for(i=0;i<n-1;i++){ a[i]=sc.nextInt(); if(a[i]==1)loser.add(i); } for(i=0;i<loser.size();i++){ tmp=0; for(j=0;j<n-1;j++){ if(a[j]=loser.get(i))tmp++; } ans=Math.max(tmp,ans); } System.out.println(ans); } }
Main.java:18: error: incompatible types: int cannot be converted to boolean if(a[j]=loser.get(i))tmp++; ^ 1 error
s758565699
p03822
C++
#include <bits/stdc++.h> using namespace std; const int maxn = 100005; int n; int a[maxn]; int main() { cin >> n; int ma = 0; for(int i = 0; i < n - 1; i++) { int x; scanf("%d", &x); a[x]++; ma = max(ma, a[x]); } cout << max(ma, (int)log2(n) + 1) << endl; return 0; } #include <bits/stdc++.h> using namespace std; const int maxn = 100005; int n; int a[maxn]; int main() { cin >> n; int ma = 0; for(int i = 0; i < n - 1; i++) { int x; scanf("%d", &x); a[x]++; ma = max(ma, a[x]); } cout << max(ma, (int)log2(n) + 1) << endl; return 0; }
a.cc:25:11: error: redefinition of 'const int maxn' 25 | const int maxn = 100005; | ^~~~ a.cc:5:11: note: 'const int maxn' previously defined here 5 | const int maxn = 100005; | ^~~~ a.cc:27:5: error: redefinition of 'int n' 27 | int n; | ^ a.cc:7:5: note: 'int n' previously declared here 7 | int n; | ^ a.cc:28:5: error: redefinition of 'int a [100005]' 28 | int a[maxn]; | ^ a.cc:8:5: note: 'int a [100005]' previously declared here 8 | int a[maxn]; | ^ a.cc:29:5: error: redefinition of 'int main()' 29 | int main() { | ^~~~ a.cc:9:5: note: 'int main()' previously defined here 9 | int main() { | ^~~~
s054000174
p03822
C++
#include <bits/stdc++.h> #define rep(i, a, n) for(int i = a; i < n; i++) #define repb(i, a, b) for(int i = a; i >= b; i--) #define all(a) a.begin(), a.end() #define o(a) cout << a << endl #define int long long using namespace std; typedef pair<int, int> P; vector<int> G[100010]; int d[100010]; int INF = 1e9; int n; void dfs(int now, int dist){ d[now] = dist; rep(i, 0, G[now].size()){ dfs(G[now][i], dist + 1); } } signed main(){ cin >> n; vector<int> a(n); queue<int> q; rep(i, 1, n){ cin >> a[i]; a[i]--; G[a[i]]. push_back(i); } dfs(0, 0); int MAX = 0; rep(i, 0, n){ MAX = max(MAX, d[i] + G[i].size()); } cout << MAX << endl; }
a.cc: In function 'int main()': a.cc:34:18: error: no matching function for call to 'max(long long int&, long long unsigned int)' 34 | MAX = max(MAX, d[i] + G[i].size()); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:34:18: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long long unsigned int') 34 | MAX = max(MAX, d[i] + G[i].size()); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~ /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, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:34:18: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 34 | MAX = max(MAX, d[i] + G[i].size()); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~
s557198010
p03822
C++
#include "bits/stdc++.h" using namespace std; #define int long long #define PB push_back #define MP make_pair #define ALL(V) V.begin(), V.end() typedef pair<int, int> pii; typedef pair<string, int> psi; typedef pair<int, pii> pipii; typedef pair<pii, pii> pipi; constexpr int INF = 1LL << 60; constexpr int MOD = 1000000007; constexpr int MAX_N = 100005; constexpr int dx[] = { 0, 1, 0, -1 }; constexpr int dy[] = { 1, 0, -1, 0 }; int n; vector<int> G[MAX_N]; int Solve(int i, int d) { int mx = d, mi = INF; for (int j = 0; j < G[i].size(); ++j) { int tmp = Solve(G[i][j], d + 1 + j); mx = max(mx, tmp); mi = min(mi, tmp); } return min(mx, mi + G[i].size()); } signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin >> n; for (int i = 2; i <= n; ++i) { int a; cin >> a; G[a].PB(i); } cout << Solve(1, 0) << endl; }
a.cc: In function 'long long int Solve(long long int, long long int)': a.cc:31:15: error: no matching function for call to 'min(long long int&, long long unsigned int)' 31 | return min(mx, mi + G[i].size()); | ~~~^~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:31:15: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long long unsigned int') 31 | return min(mx, mi + G[i].size()); | ~~~^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:31:15: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 31 | return min(mx, mi + G[i].size()); | ~~~^~~~~~~~~~~~~~~~~~~~~~
s867909983
p03822
C++
/* -------------------------------- */ /* Name: MD. Khairul Basar */ /* Institute: HSTU */ /* Dept: CSE */ /* Email: khairul.basar93@gmail.com */ /* -------------------------------- */ #include <bits/stdc++.h> /* all header files */ #define fs first #define sc second #define sp printf(" ") #define nl printf("\n") #define pb(a) push_back(a) #define setzero(a) memset(a,0,sizeof(a)) #define setneg(a) memset(a,-1,sizeof(a)) #define setinf(a) memset(a,126,sizeof(a)) #define tc1(x) printf("Case %d: ",x) #define tc2(x) printf("Case #%d: ",x) #define tc3(x) printf("Case %d:\n",x) #define tc4(x) printf("Case #%d:\n",x) #define iin(x) scanf("%d",&x) #define din(x) scanf("%lf",&x) #define lin(x) scanf("%lld",&x) #define clin(x) scanf("%I64d",&x) #define pr1(x) cout<<x<<"\n" #define pr2(x,y) cout<<x<<" "<<y<<"\n" #define pr3(x,y,z) cout<<x<<" "<<y<<" "<<z<<"\n" #define pr4(w,x,y,z) cout<<w<<" "<<x<<" "<<y<<" "<<z<<"\n" #define fast ios::sync_with_stdio(0) #define read freopen("input.txt","r",stdin) #define write freopen("output.txt","w",stdout) #define prflag1(flag) printf("%s\n",(flag)?"YES":"NO") #define prflag2(flag) printf("%s\n",(flag)?"Yes":"No") #define prflag3(flag) printf("%s\n",(flag)?"yes":"no") /* macro definitions */ using namespace std; typedef long long LL; typedef unsigned long long ULL; typedef pair<int, int>pii; typedef pair<LL, LL>pll; typedef vector<int>vi; typedef vector<LL>vll; typedef vector<pii>vpii; typedef vector<pll>vpll; /* type definitions */ LL MOD_EXPO(LL b, LL p, LL m) { if(p==0) return 1; LL ret=MOD_EXPO(b,p/2,m)%m; ret=(ret*ret)%m; return ((p&1) ? (ret*b)%m : ret%m); } LL POWER(LL N, LL K) { LL i,ans=1; for(i=1; i<=K; i++) ans*=N; return ans; } int SET(int N, int pos) { return (N | (1<<pos)); } int RESET(int N, int pos) { return (N & !(1<<pos)); } bool CHECK(int N, int pos) { return (N & (1<<pos)); } /* necessary functions */ int dx4[]= {1,-1,0,0}; int dy4[]= {0,0,1,-1}; int dx6[]= {0,0,1,-1,0,0}; int dy6[]= {1,-1,0,0,0,0}; int dz6[]= {0,0,0,0,1,-1}; int dx8[]= {1,-1,0,0,-1,1,-1,1}; int dy8[]= {0,0,1,-1,1,1,-1,-1}; int dkx8[]= {-1,1,-1,1,-2,-2,2,2}; int dky8[]= {2,2,-2,-2,1,-1,1,-1}; /* direction arrays */ int tc=1; const double eps=1e-9; const double pi=acos(-1.0); const long long int mx=1e5; const long long int mod=1e9+7; /* global declarations */ vi next[mx+5]; int n; int maxi; int dfs(int x, int level) { int ans,i; ans=1; for(i=0; i<next[x].size(); i++) { ans+=dfs(next[x][i],level+1); } //pr2(x,ans); return ans; } int main() { int i,a; while(cin>>n) { for(i=2; i<=n; i++) { iin(a); next[a].pb(i); } maxi=0; for(i=0;i<next[1].size();i++) { maxi=max(maxi,dfs(next[1][i],0)); } pr1(maxi); } return 0; }
a.cc: In function 'int dfs(int, int)': a.cc:108:16: error: reference to 'next' is ambiguous 108 | for(i=0; i<next[x].size(); i++) | ^~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:66, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:8: /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:100:4: note: 'vi next [100005]' 100 | vi next[mx+5]; | ^~~~ a.cc:110:18: error: reference to 'next' is ambiguous 110 | ans+=dfs(next[x][i],level+1); | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:100:4: note: 'vi next [100005]' 100 | vi next[mx+5]; | ^~~~ a.cc: In function 'int main()': a.cc:124:13: error: reference to 'next' is ambiguous 124 | next[a].pb(i); | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:100:4: note: 'vi next [100005]' 100 | vi next[mx+5]; | ^~~~ a.cc:127:19: error: reference to 'next' is ambiguous 127 | for(i=0;i<next[1].size();i++) | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:100:4: note: 'vi next [100005]' 100 | vi next[mx+5]; | ^~~~ a.cc:129:31: error: reference to 'next' is ambiguous 129 | maxi=max(maxi,dfs(next[1][i],0)); | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:100:4: note: 'vi next [100005]' 100 | vi next[mx+5]; | ^~~~
s224464678
p03822
C++
#include<iostream> 2.#include<cctype> 3.#include<vector> 4.#include<ctype.h> 5.#include<algorithm> 6.#include<queue> 7.#include<string> 8.#include<math.h> 9.#include<iomanip> 10.using namespace std; 11.long long n, m; vector<long long> a; 12.int main() { 13. cin >> n; 14. for (size_t i = 0; i < n + 1; i++) 15. { 16. a.push_back(0); 17. } 18. for (size_t i = 2; i < n+1; i++) 19. { 20. cin >> m; 21. a[m]++; 22. a[i]++; 23. a[m] = max(a[m], a[i]); 24. a[i] = max(a[m], a[i]); 25. 26. } 27. sort(a.begin(), a.end()); 28. cout << *(a.end()-1)<<endl; 29. return 0;
a.cc:2:3: error: stray '#' in program 2 | 2.#include<cctype> | ^ a.cc:3:3: error: stray '#' in program 3 | 3.#include<vector> | ^ a.cc:4:3: error: stray '#' in program 4 | 4.#include<ctype.h> | ^ a.cc:5:3: error: stray '#' in program 5 | 5.#include<algorithm> | ^ a.cc:6:3: error: stray '#' in program 6 | 6.#include<queue> | ^ a.cc:7:3: error: stray '#' in program 7 | 7.#include<string> | ^ a.cc:8:3: error: stray '#' in program 8 | 8.#include<math.h> | ^ a.cc:9:3: error: stray '#' in program 9 | 9.#include<iomanip> | ^ a.cc:2:1: error: expected unqualified-id before numeric constant 2 | 2.#include<cctype> | ^~ a.cc:11:1: error: expected unqualified-id before numeric constant 11 | 11.long long n, m; vector<long long> a; | ^~~~~~~ a.cc:11:20: error: 'vector' does not name a type 11 | 11.long long n, m; vector<long long> a; | ^~~~~~ a.cc:12:1: error: expected unqualified-id before numeric constant 12 | 12.int main() { | ^~~~~~
s341719423
p03822
C++
#include<iostream> #include<cctype> #include<vector> #include<ctype.h> #include<algorithm> #include<queue> #include<string> #include<math.h> #include<iomanip> using namespace std; long long n, m; vector<long long> a; int main() { cin >> n; for (size_t i = 0; i < n + 1; i++) { a.push_back(0); } for (size_t i = 2; i < n+1; i++) { cin >> m; a[m]++; a[i]++; a[m] = max(a[m], a[i]); a[i] = max(a[m], a[i]); } sort(a.begin(), a.end()); cout << *(a.end()-1)<<endl; return 0;
a.cc: In function 'int main()': a.cc:29:18: error: expected '}' at end of input 29 | return 0; | ^ a.cc:12:12: note: to match this '{' 12 | int main() { | ^
s078604891
p03822
C++
#include <iostream> #include <vector> #include <string> #include <algorithm> #include <cmath> #include <map> #include <queue> long long dfs(long long depth, long long p, std::vector<long long> v) { long long max_depth = 0; for (int i = 0; i < v.size(); i++) { if (v[i] == p) { max_depth = std::max(max_depth, dfs(depth + 1, i + 2, v)); } } max_depth = std::max(max_depth, std::count(v.begin(), v.end(), p) + depth); return max_depth; } int main() { long long n; std::cin >> n; std::vector<long long> v(n - 1); for (int i = 0; i < n - 1; i++) { std::cin >> v[i]; } long long max = 0; for (int i = 0; i < n; i++) { max = std::max(max, std::count(v.begin(), v.end(), i + 1)); } max = std::max(max, dfs(0, 1, v)); std::cout << max << std::endl; return 0; }
a.cc: In function 'int main()': a.cc:32:23: error: no matching function for call to 'max(long long int&, std::__iterator_traits<__gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >, void>::difference_type)' 32 | max = std::max(max, std::count(v.begin(), v.end(), i + 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: template argument deduction/substitution failed: a.cc:32:23: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'std::__iterator_traits<__gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >, void>::difference_type' {aka 'long int'}) 32 | max = std::max(max, std::count(v.begin(), v.end(), i + 1)); | ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /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, 2 provided In file included from /usr/include/c++/14/algorithm:61, from a.cc:4: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:32:23: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 32 | max = std::max(max, std::count(v.begin(), v.end(), i + 1)); | ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
s343114616
p03822
C++
#include <iostream> #include <vector> #include <algorithm> using namespace std; typedef long long ll; const int maxn = 111111; ll n, dp[maxn], a[maxn]; vector<int> G[maxn]; vector<ll> V; ll dfs(int x) { if(dp[x]) return dp[x]; dp[x] = 1; for(int i = 0; i < G[x].size(); i++) { int to = G[x][i]; dfs(to); } for(int i = 0; i < G[x].size(); i++) V.push_back(dp[G[x][i]]); sort(V.begin(), V.end()); for(int i = 0; i < V.size(); i++) dp[x] = max(dp[x], V[i]+V.size()-i); V.clear(); return dp[x]; } int main() { cin>>n; for(int i = 2; i <= n; i++) cin>>a[i]; for(int i = 2; i <= n; i++) G[a[i]].push_back(i); dfs(1); cout<<dp[1]-1<<endl; }
a.cc: In function 'll dfs(int)': a.cc:23:20: error: no matching function for call to 'max(ll&, long long unsigned int)' 23 | dp[x] = max(dp[x], V[i]+V.size()-i); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h: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: template argument deduction/substitution failed: a.cc:23:20: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long long unsigned int') 23 | dp[x] = max(dp[x], V[i]+V.size()-i); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~ /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, 2 provided In file included from /usr/include/c++/14/algorithm:61, from a.cc:3: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:23:20: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 23 | dp[x] = max(dp[x], V[i]+V.size()-i); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~
s234411688
p03822
C++
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using u32 = uint32_t; using vi = vector<int>; using vvi = vector<vi>; using vb = vector<bool>; using vvb = vector<vb>; using vl = vector<ll>; using vvl = vector<vl>; using vd = vector<double>; using vvd = vector<vd>; #define MAXC(c, x) (c = max(c, x)) #define MINC(c, x) (c = min(c, x)) #define REP(i,n) for(auto i = 0 * (n), i##_len = (n); i < i##_len; ++i) #define ALL(c) (c).begin(), (c).end() #define FOR(i,s,n) for(ll i=s, i##_len=(ll)(n); i<i##_len; ++i) #define TEN(x) ((ll)1e##x) const ll mod = TEN(9) + 7; int main() { #ifdef INPUT_FROM_FILE ifstream cin("sample.in"); ofstream cout("sample.out"); #endif cin.tie(0); ios_base::sync_with_stdio(false); cout << fixed << setprecision(50); ll n; cin >> n; vvl path(n); REP(i, n - 1) { ll a; cin >> a; path[a - 1].push_back(i + 1); } function<ll(ll)> dfs = [&](ll cur) { vl a; for (auto&& x : path[cur]) { a.push_back(dfs(x)); } sort(ALL(a)); reverse(ALL(a)); ll ans = 0; REP(i, a.size()) { ans = max(ans, a[i] + i + 1); } return ans; }; cout << dfs(0) << endl; return 0; }
a.cc: In lambda function: a.cc:44:34: error: no matching function for call to 'max(ll&, long long unsigned int)' 44 | ans = max(ans, a[i] + i + 1); | ~~~^~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:44:34: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long long unsigned int') 44 | ans = max(ans, a[i] + i + 1); | ~~~^~~~~~~~~~~~~~~~~~~ /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, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:44:34: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 44 | ans = max(ans, a[i] + i + 1); | ~~~^~~~~~~~~~~~~~~~~~~
s796496843
p03823
C++
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; using ld = long double; template <typename T> int sz(T &x) { return (int)(x.size()); } int power(int x, int y, int mod) { if (y == 0) { return 1; } int z = power(x, y >> 1, mod); z = z * 1ll * z % mod; if (y & 1) { z = z * 1ll * x % mod; } return z; } const int mod = 998244353; const int inf = 1'000'000'007; void solve() { int n; ll a, b; cin >> n >> a >> b; if (a > b) { swap(a, b); } vector<ll> s(n + 1); vector<int> dp(n + 1); vector<int> pref(n + 1); vector<int> bad(n + 1, 0); for (int i = 1; i <= n; ++i) { cin >> s[i]; } bad[0] = 0; s[0] = s[1] - b - 1; for (int i = 1; i <= n; ++i) { if (i + 2 <= n && s[i + 2] - s[i] < a) { cout << "0\n"; return 0; } if (s[i] - s[i - 1] < a) { bad[i] = i; } else { bad[i] = bad[i - 1]; } } dp[0] = 1; pref[0] = 1; for (int i = 1; i <= n; ++i) { int pos = lower_bound(s.begin(), s.end(), s[i] - b + 1) - s.begin(); --pos; int z = bad[i - 1] - 1; if (z > pos) { dp[i] = 0; } else { dp[i] = pref[pos] - (z <= 0 ? 0 : pref[z - 1]); if (dp[i] < 0) { dp[i] += inf; } } pref[i] = (pref[i - 1] + dp[i]) % inf; } int ans = 0; for (int i = bad[n] - 1; i <= n; ++i) { if (i > 0 && i < n && s[i + 1] - s[i - 1] < a) { continue; } (ans += dp[i]) %= inf; } cout << ans << "\n"; } int main() { #ifndef LOCAL58 // don't forget to remove if interactive ios_base :: sync_with_stdio(false); cin.tie(nullptr); #endif int t; t = 1; while (t--) { solve(); } return 0; }
a.cc: In function 'void solve()': a.cc:52:14: error: return-statement with a value, in function returning 'void' [-fpermissive] 52 | return 0; | ^
s739861286
p03823
C++
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; using ld = long double; template <typename T> int sz(T &x) { return (int)(x.size()); } int power(int x, int y, int mod) { if (y == 0) { return 1; } int z = power(x, y >> 1, mod); z = z * 1ll * z % mod; if (y & 1) { z = z * 1ll * x % mod; } return z; } const int mod = 998244353; const int inf = 1'000'000'007; void solve() { int n, a, b; cin >> n >> a >> b; if (a > b) { swap(a, b); } vector<int> s(n + 1); vector<int> dp(n + 1); vector<int> pref(n + 1); vector<int> bad(n + 1, 0); for (int i = 1; i <= n; ++i) { cin >> s[i]; } bad[0] = 0; s[0] = -inf; for (int i = 1; i <= n; ++i) { if (s[i] - s[i - 1] < a) { bad[i] = i; } else { bad[i] = bad[i - 1]; } } dp[0] = 1; pref[0] = 1; for (int i = 1; i <= n; ++i) { int pos = lower_bound(s.begin(), s.end(), s[i] - b + 1) - s.begin(); --pos; int z = bad[i - 1] - 1; if (z > pos) { dp[i] = 0; } else { dp[i] = pref[pos] - (z <= 0 ? 0 : pref[z - 1]); if (dp[i] < 0) { dp[i] += inf; } } pref[i] = (pref[i - 1] + dp[i]) % inf; } for (int i = 1; i + 2 <= n; ++i) { if (s[i + 2] - s[i] < a) { cout << "0\n"; return 0; } } int ans = 0; for (int i = bad[n] - 1; i <= n; ++i) { (ans += dp[i]) %= inf; } cout << ans << "\n"; } int main() { #ifndef LOCAL58 // don't forget to remove if interactive ios_base :: sync_with_stdio(false); cin.tie(nullptr); #endif int t; t = 1; while (t--) { solve(); } return 0; }
a.cc: In function 'void solve()': a.cc:78:14: error: return-statement with a value, in function returning 'void' [-fpermissive] 78 | return 0; | ^
s648818812
p03823
C++
#include<bits/stdc++.h> #define int long long #define ll long long #define ull unsigned long long using namespace std; const int maxn=100005; const int mod=1e9+7; int n,dp[maxn][2],nxt[2][maxn]; ll A,B,a[maxn],w[maxn]; template<class Type>Type read(){ Type res=0,f_f=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-') f_f=-1;ch=getchar();} while(ch>='0'&&ch<='9') res=(res<<3)+(res<<1)-'0'+ch,ch=getchar(); return res*f_f; } #define iread() (read<int>()) #define lread() (read<long long>()) #define ulread() (read<unsigned long long>()) namespace RMQ{ int lg[maxn]; ll f[maxn][20]; inline void prelog(){ lg[1]=0; for (int i=2;i<=n;i++){ lg[i]=lg[i-1]; lg[i]+=((1<<lg[i]+1)<=i)?1:0; } } inline void init(){ prelog(); for (int i=2;i<=n;i++) f[i][0]=w[i]; for (int i=2;(1<<i)<=n;i++){ for (int j=2;j+(1<<i)-1<=n;j++){ f[j][i]=min(f[j][i-1],f[j+(1<<i-1)][i-1]); } } } inline ll query(int x,int y){ int w=lg[y-x+1]; return min(f[x][w],f[y-(1<<w)+1][w]); } } inline void get_modu(int &x){ while(x>=mod) x-=mod; } inline void solve_a(int x){ int L=x+2,R=nxt[0][x]-1; if(L<=R&&RMQ::query(L,R)<B) return; dp[R][1]+=dp[x][0],get_modu(dp[R][1]); } inline void solve_b(int x){ int L=x+2,R=nxt[1][x]-1; if(L<=R&&RMQ::query(L,R)<A) return; dp[R][0]+=dp[x][1],get_modu(dp[R][0]); } int main(){ n=iread(),A=lread(),B=lread(); int tota=1,totb=1; for (int i=1;i<=n;i++){ a[i]=lread(); if(i^1){ w[i]=a[i]-a[i-1]; while(tota<i&&a[i]-a[tota]>=A) nxt[0][tota++]=i; while(totb<i&&a[i]-a[totb]>=B) nxt[1][totb++]=i; } } while(tota<=n) nxt[0][tota++]=n+1; while(totb<=n) nxt[1][totb++]=n+1; RMQ::init(); dp[1][0]=dp[1][1]=1; for (int i=1;i<n;i++){ if(dp[i][0]){ if(nxt[0][i]==i+1){ dp[i+1][0]+=dp[i][0],get_modu(dp[i+1][0]); dp[i+1][1]+=dp[i][0],get_modu(dp[i+1][1]); } else solve_a(i); } if(dp[i][1]){ if(nxt[1][i]==i+1){ dp[i+1][0]+=dp[i][1],get_modu(dp[i+1][0]); dp[i+1][1]+=dp[i][1],get_modu(dp[i+1][1]); } else solve_b(i); } } printf("%lld\n",(dp[n][0]+dp[n][1])%mod); return 0; }
cc1plus: error: '::main' must return 'int'
s853058657
p03823
C++
#include <bits/stdc++.h> #define f first #define s second using namespace std; using ll = long long; using ii = pair<int, int>; constexpr ll MOD = 1e9+7; template<typename T> class fenwick_tree { private: vector<T> FT, vector<pair<int, T>> S; public: fenwick_tree(int N) { FT.assign(N + 5, 0); } void update(int x, T val) { if (++x) S.emplace_back(x, val), for (; x < FT.size(); x += x & -x) (FT[x] += val + MOD) %= MOD; } T query(int x) { T ret = 0; if (++x) for (; x; x -= x & -x) (ret += FT[x] + MOD) %= MOD; return ret; } T query(int x, int y) { return query(y) - query(x - 1); } void clear() { for (auto & p : S) update(p.f, -p.s); S.clear(); } }; ll S[100001]; int main() { ios_base::sync_with_stdio(0), cin.tie(0); ll N, A, B; cin >> N >> A >> B; for (int i = 0; i < N; ++i) cin >> S[i]; fenwick_tree<ll> X(N), Y(N); X.update(0, 1), Y.update(0, 1); for (int i = 1, j = -1, k = -1; i < N; ++i) { while (j < N && S[i] - S[j + 1] >= B) ++j; ll y = X.query(0, j + 1); while (k < N && S[i] - S[k + 1] >= A) ++k; ll x = Y.query(0, k + 1); if (S[i] - S[i - 1] < A) X.clear(); if (S[i] - S[i - 1] < B) Y.clear(); if (y) Y.update(i, y); if (x) X.update(i, x); } cout << (X.query(0, N) + Y.query(0, N)) % MOD; }
a.cc:10:45: error: invalid declarator before 'S' 10 | private: vector<T> FT, vector<pair<int, T>> S; | ^ a.cc: In member function 'void fenwick_tree<T>::update(int, T)': a.cc:13:46: error: 'S' was not declared in this scope 13 | void update(int x, T val) { if (++x) S.emplace_back(x, val), for (; x < FT.size(); x += x & -x) (FT[x] += val + MOD) %= MOD; } | ^ a.cc:13:70: error: expected primary-expression before 'for' 13 | void update(int x, T val) { if (++x) S.emplace_back(x, val), for (; x < FT.size(); x += x & -x) (FT[x] += val + MOD) %= MOD; } | ^~~ a.cc:13:103: error: expected ';' before ')' token 13 | void update(int x, T val) { if (++x) S.emplace_back(x, val), for (; x < FT.size(); x += x & -x) (FT[x] += val + MOD) %= MOD; } | ^ a.cc: In member function 'void fenwick_tree<T>::clear()': a.cc:16:40: error: 'S' was not declared in this scope 16 | void clear() { for (auto & p : S) update(p.f, -p.s); S.clear(); } | ^ a.cc:16:62: error: 'S' was not declared in this scope 16 | void clear() { for (auto & p : S) update(p.f, -p.s); S.clear(); } | ^
s404227036
p03823
C++
.
a.cc:1:1: error: expected unqualified-id before '.' token 1 | . | ^
s451239864
p03823
C++
#include<iostream> #include<string> #include<algorithm> #include<vector> #include<queue> #include<map> #include<math.h> #include<iomanip> #include<set> #include<numeric> #include<cstring> #include<cstdio> #include<functional> #include<bitset> #include<limits.h> #include<cassert> #include<iterator> #include<complex> #include<stack> #include<unordered_map> #include<unordered_set> #include<time.h> #include<random> #include<array> using namespace std; using ll = long long; using ull = unsigned long long; #define rep(i, a, b) for(int i = a; i < b; i++) #define rrep(i, a, b) for(int i = b - 1; i >= a; i--) #define ALL(a) a.begin(), a.end() using pii = pair<int,int>; using piii = pair<pii,int>; using pll = pair<long long, long long>; using plll = pair<pll, long long>; // #pragma GCC optimize("Ofast") #define pcnt __builtin_popcount #define buli(x) __builtin_popcountll(x) #define pb push_back #define mp make_pair #define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ); #define isSquare(x) (sqrt(x)*sqrt(x) == x) template<class T>inline bool chmax(T &a, const T &b) {if(a<b){a = b; return 1;} return 0; }; template<class T>inline bool chmin(T &a, const T &b) {if(a>b){a = b; return 1;} return 0; }; inline void in(void){return;} template <typename First, typename... Rest> void in(First& first, Rest&... rest){cin >> first;in(rest...);return;} inline void out(void){cout << "\n";return;} template <typename First, typename... Rest> void out(First first, Rest... rest){cout << first << " ";out(rest...);return;} const double EPS = 1e-9; const int mod = 1e9 + 7; // const int mod = 998244353; const int INF = 1e9; const long long INFLL = 1e18; void iosetup() { cin.tie(nullptr);ios::sync_with_stdio(false); cout << fixed << setprecision(10); cerr << fixed << setprecision(10); } template< typename T1, typename T2 > ostream &operator<<(ostream &os, const pair< T1, T2 >& p) { os << p.first << " " << p.second; return os; } template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; } template< typename T > ostream &operator<<(ostream &os, const vector< T > &v) { for(int i = 0; i < (int) v.size(); i++) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } template< typename T > istream &operator>>(istream &is, vector< T > &v) { for(T &in : v) is >> in; return is; } template<class T> vector<T> make_vec(size_t a) {return vector<T>(a); } template<class T, class... Ts> auto make_vec(size_t a, Ts... ts){ return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...)); } template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S, T>& t){return pair<S,T>(s.first+t.first, s.second+t.second);} template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S, T>& t){return pair<S,T>(s.first-t.first, s.second-t.second);} template<class S, class T> pair<S,T> operator*(const pair<S,T> &s, const S& t){return pair<S,T>(s.first*t, s.second*t);} template <typename T> void Exit(T first){cout << first << endl;exit(0); }; template< int mod > struct ModInt { unsigned x; ModInt() : x(0) {} ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {} ModInt &operator+=(const ModInt &p) {if((x += p.x) >= mod) x -= mod;return *this;} ModInt &operator-=(const ModInt &p) {if((x += mod - p.x) >= mod) x -= mod;return *this;} ModInt &operator*=(const ModInt &p) {x = (int) (1LL * x * p.x % mod);return *this;} ModInt &operator/=(const ModInt &p) {*this *= p.inverse();return *this;} ModInt operator-() const { return ModInt(-x); } ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; } ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; } ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; } ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; } bool operator==(const ModInt &p) const { return x == p.x; } bool operator!=(const ModInt &p) const { return x != p.x; } ModInt inverse() const {int a = x, b = mod, u = 1, v = 0, t; while(b > 0) { t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); }return ModInt(u);} ModInt pow(int64_t n) const {ModInt ret(1), mul(x); while(n > 0) {if(n & 1) ret *= mul;mul *= mul;n >>= 1;}return ret;} friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x;} friend istream &operator>>(istream &is, ModInt &a) { int64_t t; is >> t; a = ModInt< mod >(t); return (is); } static int get_mod() { return mod; } }; using modint = ModInt< mod >; const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, 1, 0, -1}; const pii dxy[4] = {pii(1,0), pii(0, 1), pii(-1, 0), pii(0, -1)}; bool range(int a, int b, int x){if(a <= x and x < b)return true;else return false;} bool range(int a, int b, int c, int d, pii p){if(a <= p.first and p.first < b and c <= p.second and p.second < d) return true;else return false;} // https://atcoder.jp/contests/agc009/submissions/8119547 // https://ei1333.github.io/algorithm/segment-tree.html template< typename Monoid > struct SegmentTree { using F = function< Monoid(Monoid, Monoid) >; int sz; vector< Monoid > seg; const F f; const Monoid M1; SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1) { sz = 1; while(sz < n) sz <<= 1; seg.assign(2 * sz, M1); } void set(int k, const Monoid &x) { seg[k + sz] = x; } void build() { for(int k = sz - 1; k > 0; k--) { seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]); } } void update(int k, const Monoid &x) { k += sz; seg[k] = x; while(k >>= 1) { seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]); } } Monoid query(int a, int b) { Monoid L = M1, R = M1; for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) { if(a & 1) L = f(L, seg[a++]); if(b & 1) R = f(seg[--b], R); } return f(L, R); } Monoid operator[](const int &k) const { return seg[k + sz]; } }; // range min // SegmentTree< int > seg(N, [](int a, int b){ return min(a, b); }, INT_MAX); // range sum // SegmentTree< int > seg(N, [](int a, int b){ return a + b; }, 0); int main(){ iosetup(); int n; ll a, b;cin >> n >> a >> b; vector<ll> s(n);cin >> s; if(a < b) swap(a, b); s.insert(s.begin(), -INFLL); s.emplace_back(INFLL); n += 2; vector<int> prevb(n); prevb[0] = 0; // [j, i]の任意の要素の差がb以上な最小のj rep(i, 1, n) prevb[i] = (s[i] - s[i-1] >= b ? prevb[i-1] : i); SegmentTree< modint > seg(n, [](modint a, modint b){ return a + b; }, 0);  seg.update(0, 1); rep(i, 1, n){ int l = prevb[i-1]; int r = upper_bound(ALL(s), s[i] - a) - s.begin(); if(l-2 < 0 or s[l] - s[l-2] >= b) --l; seg.update(i, seg.query(l, r)); } cout << seg.query(n-1, n) << endl; return 0; }
a.cc:192:1: error: stray '\16' in program 192 | <U+000E> | ^~~~~~~~
s047551598
p03823
C++
#include <iostream> using namespace std; typedef long long ll; const ll INF = 1000000000000000009; const ll MOD = 1000000007; ll s[100005]; int ca[100005], cb[100005]; ll dpa[100005], dpb[100005]; int main() { ll n, a, b; cin >> n >> a >> b; s[0] = -INF; for(int i = 1; i <= n; i++) cin >> s[i]; for(int i = 1; i <= n; i++){ ca[i] = ca[i - 1]; cb[i] = cb[i - 1]; if(s[i] - s[i - 1] >= a) ca[i]++; if(s[i] - s[i - 1] >= b) cb[i]++; } dpa[0] = dpa[1] = dpb[0] = dpb[1] = 1; for(int i = 2; i <= n; i++){ if(ca[i] - ca[i - 1]) dpa[i] = (dpa[i - 1] + dpb[i - 1]) % MOD; else{ int j = upper_bound(s, s + n + 1, s[i] - a) - s; if(cb[i - 1] - cb[j] == (i - 1) - j) dpa[i] = dpb[j]; } if(cb[i] - cb[i - 1]) dpb[i] = (dpa[i - 1] + dpb[i - 1]) % MOD; else{ int j = upper_bound(s, s + n + 1, s[i] - b) - s; if(ca[i - 1] - ca[j] == (i - 1) - j) dpb[i] = dpa[j]; } } cout << (dpa[n] + dpb[n]) % MOD << endl; }
a.cc: In function 'int main()': a.cc:28:21: error: 'upper_bound' was not declared in this scope 28 | int j = upper_bound(s, s + n + 1, s[i] - a) - s; | ^~~~~~~~~~~ a.cc:33:21: error: 'upper_bound' was not declared in this scope 33 | int j = upper_bound(s, s + n + 1, s[i] - b) - s; | ^~~~~~~~~~~
s669058141
p03823
C++
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<ll> vi; typedef pair<ll,ll> pi; typedef vector<pi> vpi; typedef long double ld; #define pb emplace_back #define mp make_pair #define lb lower_bound #define ub upper_bound #define ALL(x) x.begin(), x.end() #define SZ(x) (ll)x.size() #define f first #define s second #define MAXN 200100 ll N,A,B; vi V,breaks; ll a; ll fw[MAXN]; void update(ll x, ll y, ll v){ ++y; for (;y;y-=y&(-y)){fw[y]+=v;fw[y]%=MOD;} for (;x;x-=x&(-x)){fw[x]=(fw[x]+MOD-v)%MOD; } ll query(ll x){ ++x; ll res=0; for (;x<=MAXN;x+=x&(-x)){res += fw[x];res %= MOD;} return res; } ll main(){ cin>>N>>A>>B; if (A > B)swap(A,B); // A is small V.pb(0); for (ll i=1;i<=N;++i){cin>>a;V.pb(a);} V.pb(1e18); for (ll i=1;i<N;++i){ if (V[i+1] - V[i] < A)breaks.pb(i); } ll lastbreak = -1; if (SZ(breaks))lastbreak = breaks.back(); breaks.pb(N); // for (auto i : breaks)cout<<i<<' '; update(0,0,1); for (ll i=0;i<=N;++i){ ll t = query(i); // cout<<i<<' '<<t<<'\n'; // Last update ll last_update = *ub(ALL(breaks), i)+1; ll first_update = lb(ALL(V), V[i] + B)-V.begin(); // cout<<V[i]+B<<'\n'; if (i==0)first_update=1; // cout<<"Update "<<first_update<<' '<<last_update<<'\n'; if (first_update <= last_update)update(first_update,last_update,t); } ll ans = 0; for (ll i=0;i<=N;++i){ // Whether or not there are any issues after the thing if (i < lastbreak)continue; if (i > 0 && V[i+1] - V[i-1] < A)continue; ans += query(i); ans %= MOD; } cout<<ans; }
a.cc: In function 'void update(ll, ll, ll)': a.cc:24:44: error: 'MOD' was not declared in this scope 24 | for (;y;y-=y&(-y)){fw[y]+=v;fw[y]%=MOD;} | ^~~ a.cc:25:41: error: 'MOD' was not declared in this scope 25 | for (;x;x-=x&(-x)){fw[x]=(fw[x]+MOD-v)%MOD; | ^~~ a.cc:28:15: error: a function-definition is not allowed here before '{' token 28 | ll query(ll x){ | ^ a.cc:35:8: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse] 35 | ll main(){ | ^~ a.cc:35:8: note: remove parentheses to default-initialize a variable 35 | ll main(){ | ^~ | -- a.cc:35:8: note: or replace parentheses with braces to value-initialize a variable a.cc:35:10: error: a function-definition is not allowed here before '{' token 35 | ll main(){ | ^ a.cc:69:2: error: expected '}' at end of input 69 | } | ^ a.cc:22:30: note: to match this '{' 22 | void update(ll x, ll y, ll v){ | ^
s931587057
p03823
C++
#include <bits/stdc++.h> using namespace std; #define INF_LL (int64)1e18 #define INF (int32)1e9 #define REP(i, n) for(int64 i = 0;i < (n);i++) #define FOR(i, a, b) for(int64 i = (a);i < (b);i++) #define all(x) x.begin(),x.end() #define fs first #define sc second using int32 = int_fast32_t; using uint32 = uint_fast32_t; using int64 = int_fast64_t; using uint64 = uint_fast64_t; using PII = pair<int32, int32>; using PLL = pair<int64, int64>; const double eps = 1e-10; template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;} template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;} template<typename T> vector<T> make_v(size_t a){return vector<T>(a);} template<typename T,typename... Ts> auto make_v(size_t a,Ts... ts){ return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); } template<typename T,typename U,typename... V> typename enable_if<is_same<T, U>::value!=0>::type fill_v(U &u,const V... v){u=U(v...);} template<typename T,typename U,typename... V> typename enable_if<is_same<T, U>::value==0>::type fill_v(U &u,const V... v){ for(auto &e:u) fill_v<T>(e,v...); } template<::std::uint_fast64_t mod> class ModInt{ private: using value_type = ::std::uint_fast64_t; value_type n; public: ModInt() : n(0) {} ModInt(value_type n_) : n(n_ % mod) {} ModInt(const ModInt& m) : n(m.n) {} template<typename T> explicit operator T() const { return static_cast<T>(n); } value_type get() const { return n; } friend ::std::ostream& operator<<(::std::ostream &os, const ModInt<mod> &a) { return os << a.n; } friend ::std::istream& operator>>(::std::istream &is, ModInt<mod> &a) { value_type x; is >> x; a = ModInt<mod>(x); return is; } bool operator==(const ModInt& m) const { return n == m.n; } bool operator!=(const ModInt& m) const { return n != m.n; } ModInt& operator*=(const ModInt& m){ n = n * m.n % mod; return *this; } ModInt pow(value_type b) const{ ModInt ans = 1, m = ModInt(*this); while(b){ if(b & 1) ans *= m; m *= m; b >>= 1; } return ans; } ModInt inv() const { return (*this).pow(mod-2); } ModInt& operator+=(const ModInt& m){ n += m.n; n = (n < mod ? n : n - mod); return *this; } ModInt& operator-=(const ModInt& m){ n += mod - m.n; n = (n < mod ? n : n - mod); return *this; } ModInt& operator/=(const ModInt& m){ *this *= m.inv(); return *this; } ModInt operator+(const ModInt& m) const { return ModInt(*this) += m; } ModInt operator-(const ModInt& m) const { return ModInt(*this) -= m; } ModInt operator*(const ModInt& m) const { return ModInt(*this) *= m; } ModInt operator/(const ModInt& m) const { return ModInt(*this) /= m; } ModInt& operator++(){ n += 1; return *this; } ModInt& operator--(){ n -= 1; return *this; } ModInt operator++(int){ ModInt old(n); n += 1; return old; } ModInt operator--(int){ ModInt old(n); n -= 1; return old; } ModInt operator-() const { return ModInt(mod-n); } }; template<::std::size_t size, ::std::uint_fast64_t mod=1000000007> class Factorial{ private: using value_type = ModInt<mod>; ::std::vector<value_type> fact, inv; public: Factorial() : fact(size+1, 1), inv(size+1, 1){ for(::std::size_t i = 1; i <= size; ++i){ fact[i] = fact[i-1] * value_type(i); inv[i] = fact[i].inv(); } } value_type comb(::std::int64_t a, ::std::int64_t b){ assert(a >= b); assert(b >= 0); return fact[a]*inv[b]*inv[a-b]; } value_type& operator[](::std::size_t k){ return fact[k]; } }; class UnionFind{ private: ::std::vector<int32_t> par; size_t n; public: UnionFind(){} UnionFind(size_t n):n(n){ par.resize(n, -1); } uint32_t find(uint32_t x){ return par[x] < 0 ? x : par[x] = find(par[x]); } size_t size(uint32_t x){ return -par[find(x)]; } bool unite(uint32_t x, uint32_t y){ x = find(x); y = find(y); if(x == y) return false; if(size(x) < size(y)) std::swap(x, y); par[x] += par[y]; par[y] = x; return true; } bool same(uint32_t x, uint32_t y){ return find(x) == find(y); } }; template<class ValueMonoid, class OperatorMonoid, class Modifier, template<class...> class Container=::std::vector> class LazySegTree{ public: using value_structure = ValueMonoid; using value_type = typename value_structure::value_type; using operator_structure = OperatorMonoid; using operator_type = typename operator_structure::value_type; using modifier = Modifier; using const_reference = const value_type &; using container_value_type = Container<value_type>; using container_operator_type = Container<operator_type>; using size_type = typename container_value_type::size_type; private: container_value_type tree; container_operator_type lazy; size_type size_, height; static size_type getsize(const size_type x){ size_type ret = 1; while(ret < x) ret <<= 1; return ret; } static size_type getheight(const size_type x){ size_type ret = 0; while((static_cast<size_type>(1) << ret) < x){ ret++; } return ret; } inline static value_type calc(const value_type a, const value_type b){ return value_structure::operation(a, b); } inline static void apply(operator_type &data, const operator_type a){ data = operator_structure::operation(data, a); } inline static value_type reflect(const value_type v, const operator_type o){ return modifier::operation(v, o); } void push(const size_type index){ tree[index] = reflect(tree[index], lazy[index]); apply(lazy[index << 1], lazy[index]); apply(lazy[index << 1 | 1], lazy[index]); lazy[index] = operator_structure::identity(); } void calc_node(const size_type index){ if(tree.size() <= (index << 1 | 1)) return; assert(0 < index); tree[index] = calc(reflect(tree[index << 1], lazy[index << 1]), reflect(tree[index << 1 | 1], lazy[index << 1 | 1])); } void build(size_type index){ while(index >>= 1){ calc_node(index); } } void propagate(const size_type index){ for(size_type shift = height; shift ; --shift){ push(index >> shift); } } void rebuild(){ for(size_type i = size_-1;i > 0;--i){ calc_node(i); } } public: LazySegTree() : size_(0), height(0), tree(), lazy(){} LazySegTree(const size_type size) : size_(size), height(getheight(size)), tree(size << 1, value_structure::initializer()), lazy(size << 1, operator_structure::identity()){ rebuild(); } template<class InputIterator> LazySegTree(InputIterator first, InputIterator last) : size_(::std::distance(first, last)){ height = getheight(size_); tree = container_value_type(size_, value_structure::identity()); lazy = container_operator_type(size_ << 1, operator_structure::identity()); tree.insert(tree.end(), first, last); rebuild(); } size_type size() const { return size_; } const_reference operator[](const size_type k){ assert(k < size_); propagate(k+size_); tree[k+size_] = reflect(tree[k+size_], lazy[k+size_]); lazy[k+size_] = operator_structure::identity(); return tree[k+size_]; } value_type query(size_type l, size_type r){ assert(l <= r); assert(0 <= l && l < size_); assert(0 <= r && r <= size_); value_type retl = value_structure::identity(), retr = value_structure::identity(); l += size_; r += size_; propagate(l); propagate(r-1); build(l); build(r-1); for(; l < r ; l >>= 1, r >>= 1){ if(l&1){ retl = calc(retl, reflect(tree[l], lazy[l])); l++; } if(r&1){ r--; retr = calc(reflect(tree[r], lazy[r]), retr); } } return calc(retl, retr); } void update(size_type l, size_type r, const operator_type& data){ assert(l <= r); assert(0 <= l && l < size_); assert(0 <= r && r <= size_); l += size_; r += size_; propagate(l); propagate(r - 1); for(size_type l_ = l, r_ = r; l_ < r_ ; l_ >>= 1, r_ >>= 1){ if(l_ & 1) apply(lazy[l_++], data); if(r_ & 1) apply(lazy[--r_], data); } build(l); build(r - 1); } template<class F> void update(size_type index, const F& f){ assert(0 <= index && index < size()); index += size_; propagate(index); tree[index] = f(::std::move(tree[index])); lazy[index] = operator_structure::identity(); build(index); } /* template<class F> size_type search(const F& f) const { // [0, result) is True and [0, result-1) is not. if(f(value_structure::identity())) return 0; if(!f(tree[1])) return size_+1; value_type acc = value_structure::identity(); size_type i = 1; while(i < } */ }; constexpr int64 mod = 1e9+7; using Mint = ModInt<mod>; class v_monoid { public: using value_type = Mint; static value_type identity() { return 0; } static value_type initializer() { return 0; } static value_type operation(const value_type& a, const value_type& b) { return a + b; } }; class o_monoid { public: using value_type = Mint; static value_type identity() { return 0; } static value_type operation(const value_type& a, const value_type& b) { return a + b; } }; class modifier { public: static Mint operation(const Mint& a, const Mint& b) { return a + b; } }; template<typename T> T sum(const vector<T>& v, int64 l, int64 r) { // sum[l, r) if (r <= 0) return 0; if (l <= 0) return v[r-1]; return v[r-1]-v[l-1]; } Mint sum(const vector<Mint>& v, int l, int r) { if (l > r) return 0; if (l <= 0) return v[r-1]; return v[r-1] - v[l-1]; } int main(void) { int64 N, A[2]; cin >> N >> A[0] >> A[1]; vector <int64> S(N + 1); S[0] = numeric_limits<int64_t>::min()/2; bool Aok = 0, Bok = 0; REP(i, N) { cin >> S[i + 1]; if (S[i+1] - S[i] >= A[0]) Aok = 1; if (S[i+1] - S[i] >= B[0]) Bok = 1; } if (!Aok || !Bok) { cout << 0 << endl; return 0; } S.push_back(numeric_limits<int64_t>::max()/2); vector<Mint> dpA(N+2, 0), dpB(N+2, 0); dpA[0] = 1; dpB[0] = 1; int64 la = 0, ra = 0, lb = 0, rb = 0; FOR(i, 1, N+1) { while (ra < i && S[i+1] - S[ra] >= A[0]) ra++; while (rb < i && S[i+1] - S[rb] >= A[1]) rb++; dpA[i] += sum(dpB, lb, ra); dpB[i] += sum(dpA, la, rb); if (S[i+1] - S[i] < A[0]) la = i; if (S[i+1] - S[i] < A[1]) lb = i; dpA[i] += dpA[i-1]; dpB[i] += dpB[i-1]; } cout << sum(dpA, N, N+1) + sum(dpB, N, N+1) << endl; }
a.cc: In function 'int main()': a.cc:381:26: error: 'B' was not declared in this scope 381 | if (S[i+1] - S[i] >= B[0]) Bok = 1; | ^