submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s980224091
p03786
C++
#include<bits/stdc++.h> using namespace std; #define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++) #define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++) #define MOD 1000000007 #define int long long #define ALL(a) (a).begin(),(a).end() #define vi vector<int> #define vii vector<vi> #define pii pair<int,int> #define priq priority_queue<int> #define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key))) #define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key))) #define tii tuple<int,int,int> signed main(){ int N; cin>>N; vi A(N); rep(i,0,N) cin>>A[i]; sort(ALL(A)); vi sum(N); sum[0]=A[0]; rep(i,1,N){ sum[i]=sum[i-1]+A[i]; } rep(i,0,N){ int K=sum[i]; int memo=i; while(1){ if(A[N-1]<=K*2){ ans=N-i; goto XYZ; } int Z=disup(A,K*2); if(Z==memo+1) break; memo=Z-1; K=sum[Z-1]; } } XYZ: cout<<ans<<endl; }
a.cc: In function 'int main()': a.cc:30:9: error: 'ans' was not declared in this scope; did you mean 'abs'? 30 | ans=N-i; | ^~~ | abs a.cc:41:9: error: 'ans' was not declared in this scope; did you mean 'abs'? 41 | cout<<ans<<endl; | ^~~ | abs
s063414468
p03786
C++
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { int N; cin >> N ; long long int a[100010],b[100010]; for (int i = 0; i < N; ++i) cin >> a[i]; sort(a,a+N); b[0] = a[0]; int ans = 0 res = N; for(int i=1;i<N;i++){ if(2*b[i-1] < a[i]){ res -= ans; ans = 0; } else{ b[i] += a[i]; ans++; } cout << res << endl; }
a.cc: In function 'int main()': a.cc:19:15: error: expected ',' or ';' before 'res' 19 | int ans = 0 res = N; | ^~~ a.cc:24:7: error: 'res' was not declared in this scope 24 | res -= ans; | ^~~ a.cc:33:12: error: 'res' was not declared in this scope 33 | cout << res << endl; | ^~~ a.cc:35:4: error: expected '}' at end of input 35 | } | ^ a.cc:7:12: note: to match this '{' 7 | int main() { | ^
s792158402
p03786
C++
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { int N; cin >> N ; long long int a[100010],b(N+1,0); for (int i = 0; i < N; ++i) cin >> a[i]; sort(a,a+N); b[0] = a[0]; int ans = 0 res = N; for(int i=1;i<N;i++){ if(2*b[i-1] < a[i]){ res -= ans; ans = 0; } else{ b[i] += a[i]; ans++; } cout << res << endl; }
a.cc: In function 'int main()': a.cc:10:35: error: expression list treated as compound expression in initializer [-fpermissive] 10 | long long int a[100010],b(N+1,0); | ^ a.cc:18:6: error: invalid types 'long long int[int]' for array subscript 18 | b[0] = a[0]; | ^ a.cc:20:15: error: expected ',' or ';' before 'res' 20 | int ans = 0 res = N; | ^~~ a.cc:24:11: error: invalid types 'long long int[int]' for array subscript 24 | if(2*b[i-1] < a[i]){ | ^ a.cc:25:7: error: 'res' was not declared in this scope 25 | res -= ans; | ^~~ a.cc:30:8: error: invalid types 'long long int[int]' for array subscript 30 | b[i] += a[i]; | ^ a.cc:34:12: error: 'res' was not declared in this scope 34 | cout << res << endl; | ^~~ a.cc:36:4: error: expected '}' at end of input 36 | } | ^ a.cc:7:12: note: to match this '{' 7 | int main() { | ^
s955616637
p03786
C++
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { int N; cin >> N ; vector<long long> a(N),b(N+1,0); for (int i = 0; i < N; ++i) cin >> a[i]; sort(a,a+N); b[0] = a[0]; int ans = 0 res = N; for(int i=1;i<N;i++){ if(2*b[i-1] < a[i]){ res -= ans; ans = 0; } else{ b[i] += a[i]; ans++; } cout << res << endl; }
a.cc: In function 'int main()': a.cc:16:17: error: no match for 'operator+' (operand types are 'std::vector<long long int>' and 'int') 16 | sort(a,a+N); | ~^~ | | | | | int | std::vector<long long int> In file included from /usr/include/c++/14/string:48, 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.h:627:5: note: candidate: 'template<class _Iterator> constexpr std::reverse_iterator<_Iterator> std::operator+(typename reverse_iterator<_Iterator>::difference_type, const reverse_iterator<_Iterator>&)' 627 | operator+(typename reverse_iterator<_Iterator>::difference_type __n, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:627:5: note: template argument deduction/substitution failed: a.cc:16:18: note: mismatched types 'const std::reverse_iterator<_Iterator>' and 'int' 16 | sort(a,a+N); | ^ /usr/include/c++/14/bits/stl_iterator.h:1798:5: note: candidate: 'template<class _Iterator> constexpr std::move_iterator<_IteratorL> std::operator+(typename move_iterator<_IteratorL>::difference_type, const move_iterator<_IteratorL>&)' 1798 | operator+(typename move_iterator<_Iterator>::difference_type __n, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1798:5: note: template argument deduction/substitution failed: a.cc:16:18: note: mismatched types 'const std::move_iterator<_IteratorL>' and 'int' 16 | sort(a,a+N); | ^ In file included from /usr/include/c++/14/string:54: /usr/include/c++/14/bits/basic_string.h:3598:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3598 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3598:5: note: template argument deduction/substitution failed: a.cc:16:18: note: 'std::vector<long long int>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 16 | sort(a,a+N); | ^ /usr/include/c++/14/bits/basic_string.h:3616:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3616 | operator+(const _CharT* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3616:5: note: template argument deduction/substitution failed: a.cc:16:18: note: mismatched types 'const _CharT*' and 'std::vector<long long int>' 16 | sort(a,a+N); | ^ /usr/include/c++/14/bits/basic_string.h:3635:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(_CharT, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3635 | operator+(_CharT __lhs, const basic_string<_CharT,_Traits,_Alloc>& __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3635:5: note: template argument deduction/substitution failed: a.cc:16:18: note: mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'int' 16 | sort(a,a+N); | ^ /usr/include/c++/14/bits/basic_string.h:3652:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)' 3652 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3652:5: note: template argument deduction/substitution failed: a.cc:16:18: note: 'std::vector<long long int>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 16 | sort(a,a+N); | ^ /usr/include/c++/14/bits/basic_string.h:3670:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, _CharT)' 3670 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, _CharT __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3670:5: note: template argument deduction/substitution failed: a.cc:16:18: note: 'std::vector<long long int>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 16 | sort(a,a+N); | ^ /usr/include/c++/14/bits/basic_string.h:3682:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3682 | operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3682:5: note: template argument deduction/substitution failed: a.cc:16:18: note: 'std::vector<long long int>' is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 16 | sort(a,a+N); | ^ /usr/include/c++/14/bits/basic_string.h:3689:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)' 3689 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3689:5: note: template argument deduction/substitution failed: a.cc:16:18: note: 'std::vector<long long int>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 16 | sort(a,a+N); | ^ /usr/include/c++/14/bits/basic_string.h:3696:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)' 3696 | operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3696:5: note: template argument deduction/substitution failed: a.cc:16:18: note: 'std::vector<long long int>' is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 16 | sort(a,a+N); | ^ /usr/include/c++/14/bits/basic_string.h:3719:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const _CharT*, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)' 3719 | operator+(const _CharT* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3719:5: note: template argument deduction/substitution failed: a.cc:16:18: note: mismatched types 'const _CharT*' and 'std::vector<long long int>' 16 | sort(a,a+N); | ^ /usr/include/c++/14/bits/basic_string.h:3726:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(_CharT, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)' 3726 | operator+(_CharT __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3726:5: note: template argument deduction/substitution failed: a.cc:16:18: note: mismatched types 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'int' 16 | sort(a,a+N); | ^ /usr/include/c++/14/bits/basic_string.h:3733:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, const _CharT*)' 3733 | operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3733:5: note: template argument deduction/substitution failed: a.cc:16:18: note: 'std::vector<long long int>' is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 16 | sort(a,a+N); | ^ /usr/include/c++/14/bits/basic_string.h:3740:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, _CharT)' 3740 | operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3740:5: note: template argument deduction/substitution failed: a.cc:16:18: note: 'std::vector<long long int>' is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 16 | sort(a,a+N); | ^ a.cc:19:15: error: expected ',' or ';' before 'res' 19 | int ans = 0 res = N; | ^~~ a.cc:24:7: error: 'res' was not declared in this scope 24 | res -= ans; | ^~~ a.cc:33:12: error: 'res' was not declared in this scope 33 | cout << res << endl; | ^~~ a.cc:35:4: error: expected '}' at end of input 35 | } | ^ a.cc:7:12: note: to match this '{' 7 | int main() { | ^
s565748745
p03786
C++
#include<bits/stdc++.h> using namespace std; int main(){ using ll = intfast64_t; int n; cin >> n; vector<ll> a(n); for(auto&& x:a)cin >> x; sort(a.begin(), a.end()); vector<ll> b(a); for(int i=0;i<n-1;i++) b[i+1] += b[i]; int f = 0; for(int i=0;i<n-1;i++){ cerr << i << " " << b[i] << " " << a[i+1] << endl; if(2 * b[i] < a[i+1])f = i + 1; } cout << n-f << endl; }
a.cc: In function 'int main()': a.cc:6:14: error: 'intfast64_t' does not name a type; did you mean 'int_fast64_t'? 6 | using ll = intfast64_t; | ^~~~~~~~~~~ | int_fast64_t a.cc:9:10: error: 'll' was not declared in this scope 9 | vector<ll> a(n); | ^~ a.cc:9:12: error: template argument 1 is invalid 9 | vector<ll> a(n); | ^ a.cc:9:12: error: template argument 2 is invalid a.cc:10:16: error: 'begin' was not declared in this scope 10 | for(auto&& x:a)cin >> x; | ^ a.cc:10:16: note: suggested alternatives: 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:1238:5: note: 'std::begin' 1238 | begin(const valarray<_Tp>& __va) noexcept | ^~~~~ In file included from /usr/include/c++/14/filesystem:53, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:200: /usr/include/c++/14/bits/fs_dir.h:608:3: note: 'std::filesystem::__cxx11::begin' 608 | begin(recursive_directory_iterator __iter) noexcept | ^~~~~ a.cc:10:16: error: 'end' was not declared in this scope 10 | for(auto&& x:a)cin >> x; | ^ a.cc:10:16: note: suggested alternatives: /usr/include/c++/14/valarray:1265:5: note: 'std::end' 1265 | end(const valarray<_Tp>& __va) noexcept | ^~~ /usr/include/c++/14/bits/fs_dir.h:613:3: note: 'std::filesystem::__cxx11::end' 613 | end(recursive_directory_iterator) noexcept | ^~~ a.cc:11:10: error: request for member 'begin' in 'a', which is of non-class type 'int' 11 | sort(a.begin(), a.end()); | ^~~~~ a.cc:11:21: error: request for member 'end' in 'a', which is of non-class type 'int' 11 | sort(a.begin(), a.end()); | ^~~ a.cc:12:12: error: template argument 2 is invalid 12 | vector<ll> b(a); | ^ a.cc:14:6: error: invalid types 'int[int]' for array subscript 14 | b[i+1] += b[i]; | ^ a.cc:14:16: error: invalid types 'int[int]' for array subscript 14 | b[i+1] += b[i]; | ^ a.cc:17:26: error: invalid types 'int[int]' for array subscript 17 | cerr << i << " " << b[i] << " " << a[i+1] << endl; | ^ a.cc:17:41: error: invalid types 'int[int]' for array subscript 17 | cerr << i << " " << b[i] << " " << a[i+1] << endl; | ^ a.cc:18:13: error: invalid types 'int[int]' for array subscript 18 | if(2 * b[i] < a[i+1])f = i + 1; | ^ a.cc:18:20: error: invalid types 'int[int]' for array subscript 18 | if(2 * b[i] < a[i+1])f = i + 1; | ^
s291430026
p03786
Java
import java.util.*; public class Main { public static void main(String[] args) throws Exception { // Your code here! Scanner sc = new Scanner(System.in); int n = sc.nextInt(); long[] array = new long[n]; int max = 0; for (int i = 0; i < n; i++) { array[i] = sc.nextInt(); max = Math.max(max, array[i]); } Arrays.sort(array); int count = 0; for (int i = 0; i < n; i++) { if (array[i] * 2 >= max) { count++; } } int index = 99999999; for (int i = 0; i < n - count; i++) { if (array[i] * 2 < array[i + 1]) { } else { index = i; } array[i + 1] += array[i]; } System.out.println(Math.max(n - index, count)); } }
Main.java:12: error: incompatible types: possible lossy conversion from long to int max = Math.max(max, array[i]); ^ 1 error
s865735306
p03786
C++
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++) #define ALL(v) (v).begin(), (v).end() #define PUTS(x) cout << (x) << endl; vector<Int> IntsIn(int n) { auto v = vector<Int>(0); for (int i = 0; i < n; i++) { Int a; cin >> a; v.push_back(a); } return v; } using Int = long long; int main() { Int n; cin >> n; auto v = IntsIn(n); sort(ALL(v)); Int ans = 0; Int s = 0; rep(i, n) { auto &a = v[i]; if (i == 0) { s = a; } else { if (2 * s >= a) { ans++; } else { ans = 0; } s += a; } } PUTS(ans + 1); }
a.cc:6:8: error: 'Int' was not declared in this scope; did you mean 'int'? 6 | vector<Int> IntsIn(int n) { | ^~~ | int a.cc:6:11: error: template argument 1 is invalid 6 | vector<Int> IntsIn(int n) { | ^ a.cc:6:11: error: template argument 2 is invalid a.cc: In function 'int IntsIn(int)': a.cc:7:21: error: 'Int' was not declared in this scope; did you mean 'int'? 7 | auto v = vector<Int>(0); | ^~~ | int a.cc:7:24: error: template argument 1 is invalid 7 | auto v = vector<Int>(0); | ^ a.cc:7:24: error: template argument 2 is invalid a.cc:9:12: error: expected ';' before 'a' 9 | Int a; | ^~ | ; a.cc:10:16: error: 'a' was not declared in this scope 10 | cin >> a; | ^ a.cc: In function 'int main()': a.cc:4:20: error: request for member 'begin' in 'v', which is of non-class type 'int' 4 | #define ALL(v) (v).begin(), (v).end() | ^~~~~ a.cc:20:10: note: in expansion of macro 'ALL' 20 | sort(ALL(v)); | ^~~ a.cc:4:33: error: request for member 'end' in 'v', which is of non-class type 'int' 4 | #define ALL(v) (v).begin(), (v).end() | ^~~ a.cc:20:10: note: in expansion of macro 'ALL' 20 | sort(ALL(v)); | ^~~ a.cc:24:20: error: invalid types 'int[int]' for array subscript 24 | auto &a = v[i]; | ^
s830624400
p03786
C++
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++) #define ALL(v) (v).begin(), (v).end() #define PUTS(x) cout << (x) << endl; using Int = long long; int main() { Int n; cin >> n; auto v = IntsIn(n); sort(ALL(v)); Int ans = 0; Int s = 0; rep(i, n) { auto &a = v[i]; if (i == 0) { s = a; } else { if (2 * s >= a) { ans++; } else { ans = 0; } s += a; } } PUTS(ans + 1); }
a.cc: In function 'int main()': a.cc:10:14: error: 'IntsIn' was not declared in this scope 10 | auto v = IntsIn(n); | ^~~~~~
s107838125
p03786
C++
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> a(n); for (int i=0;i<n;i++) cin >> a[i]; sort(a.begin(),a.end()); int ans=0; ll s=a[0]; for (int i=1;i<n;i++) { if (a[i]>2*s) ans=i; s+=a[i]; } cout << n-ans << endl; }
a.cc: In function 'int main()': a.cc:11:5: error: 'll' was not declared in this scope 11 | ll s=a[0]; | ^~ a.cc:13:20: error: 's' was not declared in this scope 13 | if (a[i]>2*s) ans=i; | ^ a.cc:14:9: error: 's' was not declared in this scope 14 | s+=a[i]; | ^
s746070171
p03786
C++
using ll=long long; using namespace std; int main() { ll N; ll g; vector<ll>A; vector<ll>B; cin >> N; for (ll i = 0; i < N; i++) { cin >> g; A.push_back(g); B.push_back(0); } sort(A.begin(),A.end()); ll count=0; for (ll j = 0; j <=N; j++) { B[N-1] += A[j]; } for (ll i=N-2; 0<=i; i--) { B[i] -= A[i+1]; if (B[i]*2 >= A[i+1] ) { count++; } else { break; } } cout << count; }
a.cc: In function 'int main()': a.cc:8:9: error: 'vector' was not declared in this scope 8 | vector<ll>A; | ^~~~~~ a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>' +++ |+#include <vector> 1 | using ll=long long; a.cc:8:18: error: expected primary-expression before '>' token 8 | vector<ll>A; | ^ a.cc:8:19: error: 'A' was not declared in this scope 8 | vector<ll>A; | ^ a.cc:9:18: error: expected primary-expression before '>' token 9 | vector<ll>B; | ^ a.cc:9:19: error: 'B' was not declared in this scope 9 | vector<ll>B; | ^ a.cc:10:9: error: 'cin' was not declared in this scope 10 | cin >> N; | ^~~ a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' +++ |+#include <iostream> 1 | using ll=long long; a.cc:16:9: error: 'sort' was not declared in this scope; did you mean 'short'? 16 | sort(A.begin(),A.end()); | ^~~~ | short a.cc:31:9: error: 'cout' was not declared in this scope 31 | cout << count; | ^~~~ a.cc:31:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
s871268084
p03786
C++
#include <bits/stdc++.h> #define sz(x) ((int)x.size()) #define int long long using namespace std; const int MAXN = 100 * 1000 + 23; int n, a[MAXN], ps[MAXN], ans; int main() { cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); partial_sum(a, a + n, ps + 1); for (int i = n - 1; i; i--) if (ps[i] * 2 < a[i]) ans = i; cout << n - ans; return 0; }
cc1plus: error: '::main' must return 'int'
s609982664
p03786
C++
#include <iostream> #include <utility> using namespace std; typedef long long ll; typedef pair<ll, int> P; int main() { int n; cin >> n; ll a[100002]; P p[100002]; for(int i = 0; i < n; i++){ cin >> a[i]; p[i] = P(a[i], i); } sort(p, p + n); int les = 0; for(int i = 0; i < n - 1; i++){ if(p[i].first * 2 < p[i + 1].first) les = i + 1; p[i + 1].first += p[i].first; } cout << n - les << endl; }
a.cc: In function 'int main()': a.cc:17:5: error: 'sort' was not declared in this scope; did you mean 'short'? 17 | sort(p, p + n); | ^~~~ | short
s867239280
p03786
C++
#include<bits/stdc++.h> using namespace std; #define int long long #define fo(a,b) for(int a=0;a<b;a++) #define Sort(a) sort(a.begin(),a.end()) #define rev(a) reverse(a.begin(),a.end()) #define fi first #define se second #define co(a) cout<<a<<endl #define sz size #define bgn begin() #define en end() #define pb(a) push_back(a) #define pop pop_back #define V vector #define P pair template<class T> void cou(vector<vector<T>> a){ int b=a.size(); int c=a[0].size(); fo(i,b){ fo(j,c){ cout<<a[i][j]; if(j==c-1) cout<<endl; else cout<<' '; } } } //template<> void cou(vector<vector<char>> a){ int b=a.size(); int c=a[0].size(); fo(i,b){ fo(j,c){ cout<<a[i][j]; if(j==c-1) cout<<endl; else cout<<' '; } } } int wari(int a,int b) { if(a%b==0) return a/b; else return a/b+1; } int keta(int a){ double b=a; b=log10(b); int c=b; return c+1; } int souwa(int a){ return a*(a+1)/2; } int lcm(int a,int b){ int d=a,e=b,f; if(a<b) swap(a,b); int c,m=1; while(m){ c=a%b; if(c==0){ f=b; m--; } else{ a=b; b=c; } } return d*e/f; } int gcm(int a,int b){ int d=a,e=b,f; if(a<b) swap(a,b); int c,m=1; while(m){ c=a%b; if(c==0){ f=b; m--; } else{ a=b; b=c; } } return f; } bool prime(int a){ if(a<2) return false; else if(a==2) return true; else if(a%2==0) return false; double b=sqrt(a); for(int i=3;i<=b;i+=2){ if(a%i==0){ return false; } } return true; } struct Union{ vector<int> par; Union(int n){ par= vector<int>(n, -1); } int find(int x){ if(par[x]<0) return x; else return par[x]=find(par[x]); } bool same(int a,int b){ return find(a)==find(b); } int Size(int a){ return -par[find(a)]; } void unite(int a,int b){ a=find(a); b=find(b); if(a==b) return; if(Size(b)>Size(a)) swap<int>(a,b); par[a]+=par[b]; par[b]=a; } }; int ketas(int a){ string b=to_string(a); int c=0; fo(i,keta(a)){ c+=b[i]-'0'; } return c; } signed main(){ int a,d,e=0,f=0; cin>>a; vector<int> b(a),c,d(a); fo(i,a) cin>>b[i]; d[0]=b[0]; Sort(b); for(int i=1;i<a;i++) d[i]=d[i-1]+b[i]; rev(d); fo(i,a){ if(d[i]>d[i-1]*3) f=i+1; } cout<<f<<endl; }
a.cc: In function 'int main()': a.cc:150:22: error: conflicting declaration 'std::vector<long long int> d' 150 | vector<int> b(a),c,d(a); | ^ a.cc:148:9: note: previous declaration as 'long long int d' 148 | int a,d,e=0,f=0; | ^ a.cc:153:4: error: invalid types 'long long int[int]' for array subscript 153 | d[0]=b[0]; | ^ a.cc:156:6: error: invalid types 'long long int[long long int]' for array subscript 156 | d[i]=d[i-1]+b[i]; | ^ a.cc:156:11: error: invalid types 'long long int[long long int]' for array subscript 156 | d[i]=d[i-1]+b[i]; | ^ a.cc:6:26: error: request for member 'begin' in 'd', which is of non-class type 'long long int' 6 | #define rev(a) reverse(a.begin(),a.end()) | ^~~~~ a.cc:157:3: note: in expansion of macro 'rev' 157 | rev(d); | ^~~ a.cc:6:36: error: request for member 'end' in 'd', which is of non-class type 'long long int' 6 | #define rev(a) reverse(a.begin(),a.end()) | ^~~ a.cc:157:3: note: in expansion of macro 'rev' 157 | rev(d); | ^~~ a.cc:159:9: error: invalid types 'long long int[long long int]' for array subscript 159 | if(d[i]>d[i-1]*3) | ^ a.cc:159:14: error: invalid types 'long long int[long long int]' for array subscript 159 | if(d[i]>d[i-1]*3) | ^
s443065031
p03786
C++
#include <iostream> #include <vector> int main() { int N; scanf("%d", &N); std::vector<long long> A(N); for(int i=0; i<N; i++) scanf(" %lld", &A[i]); std::sort(A.begin(), A.end()); std::vector<long long> sum(1, A[0]); for(int i=1; i<N; i++) sum.push_back(sum.back() + A[i]); for(int i=N-1; i>0; i--){ if(sum[i-1] * 2 < A[i]){ std::cout << N-i << std::endl; return 0; } } std::cout << N << std::endl; }
a.cc: In function 'int main()': a.cc:11:10: error: 'sort' is not a member of 'std'; did you mean 'qsort'? 11 | std::sort(A.begin(), A.end()); | ^~~~ | qsort
s601217829
p03786
C++
#include <iostream> #include <vector> #include <algorithm> using namespace std; typedef long long ll; int Judge(int tag, vector<ll> &d) { ll i, x = 0; for (i = 0; i <= tag; i++) x += d[i]; for (; i < d.size(); i++) { if ((x << 1) < d[i]) return false; x += d[i]; } return true; } int Search(vector<ll> &d, int l, int r) { if (l == r) return l; int tag = (l + r) >> 1; if (Judge(tag, d)) return Search(d, l, tag); else return Search(d, tag + 1, r); } int main(void) { int num, i; cin >> num; vector<ll> d(num); for (i = 0; i < num; i++) scanf_s("%lld", &d[i]); sort(d.begin(), d.end()); i = Search(d, 0, num - 1); cout << num - i << "\n"; return 0; }
a.cc: In function 'int main()': a.cc:35:17: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'? 35 | scanf_s("%lld", &d[i]); | ^~~~~~~ | scanf
s243366976
p03786
C++
#include <bits/stdc++.h> using namespace std; #define MAX 300001 lll A[MAX], B[MAX], C[1001][1001]; vll vA, vB; lll T,n,i,j,k,a,b,c,m,u,v,x,y,l,r,s,e,ans; string sA, sB, sC[MAX]; int main(){ cin >> n; for (i=0;i<n;i++){cin >> A[i];} sort(A, A + n); B[0] = A[0]; A[n] = 0; for (i=1;i<=n-1;i++) B[i] = A[i] + B[i - 1]; ans = 0; for (i=n;i>=1;i--){ if(A[i] / 2.0 <= B[i - 1]) ans++; else break; } cout << ans << endl; return 0; }
a.cc:8:1: error: 'lll' does not name a type 8 | lll A[MAX], B[MAX], C[1001][1001]; | ^~~ a.cc:9:1: error: 'vll' does not name a type 9 | vll vA, vB; | ^~~ a.cc:10:1: error: 'lll' does not name a type 10 | lll T,n,i,j,k,a,b,c,m,u,v,x,y,l,r,s,e,ans; | ^~~ a.cc: In function 'int main()': a.cc:16:12: error: 'n' was not declared in this scope; did you mean 'yn'? 16 | cin >> n; | ^ | yn a.cc:17:10: error: 'i' was not declared in this scope 17 | for (i=0;i<n;i++){cin >> A[i];} | ^ a.cc:17:30: error: 'A' was not declared in this scope; did you mean 'sA'? 17 | for (i=0;i<n;i++){cin >> A[i];} | ^ | sA a.cc:18:10: error: 'A' was not declared in this scope; did you mean 'sA'? 18 | sort(A, A + n); | ^ | sA a.cc:19:5: error: 'B' was not declared in this scope; did you mean 'sB'? 19 | B[0] = A[0]; A[n] = 0; | ^ | sB a.cc:20:9: error: 'i' was not declared in this scope 20 | for (i=1;i<=n-1;i++) B[i] = A[i] + B[i - 1]; | ^ a.cc:21:5: error: 'ans' was not declared in this scope; did you mean 'abs'? 21 | ans = 0; | ^~~ | abs a.cc:22:10: error: 'i' was not declared in this scope 22 | for (i=n;i>=1;i--){ | ^
s569577847
p03786
C++
#include <bits/stdc++.h> #define REP(i,n) for(int i=0;i<n;i++) #define REPP(i,n) for(int i=1;i<=n;i++) const double PI = acos(-1); const double EPS = 1e-15; long long INF=(long long)1E17; #define i_7 (long long)(1E9+7) long mod(long a){ long long c=a%i_7; if(c>=0)return c; return c+i_7; } using namespace std; bool prime(int n){ if(n==1){ return false; }else if(n==2){ return true; }else{ for(int i=2;i<=sqrt(n);i++){ if(n%i==0){ return false; } } return true; } } long long gcd(long long a, long long b){ if(a<b){ swap(a,b); } if(a%b==0){ return b; }else{ return gcd(b,a%b); } } long long lcm(long long x, long long y){ return (x/gcd(x,y))*y; } class UnionFind { public: //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。 vector<int> Parent; //クラスを作るときは、Parentの値を全て-1にする。 //以下のようにすると全てバラバラの頂点として解釈できる。 UnionFind(int N) { Parent = vector<int>(N, -1); } //Aがどのグループに属しているか調べる int root(int A) { if (Parent[A] < 0) return A; return Parent[A] = root(Parent[A]); } //自分のいるグループの頂点数を調べる int size(int A) { return -Parent[root(A)];//先祖をrootで取っておきたい。 } //AとBをくっ付ける bool connect(int A, int B) { //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける A = root(A); B = root(B); if (A == B) { //すでにくっついてるからくっ付けない return false; } //大きい方(A)に小さいほう(B)をくっ付けたい //大小が逆だったらAとBをひっくり返す。 if (size(A) < size(B)) swap(A, B); //Aのサイズを更新する Parent[A] += Parent[B]; //Bの親をAに変更する Parent[B] = A; return true; } }; bool func(int i,vector<long long> a){//i番目のモンスターが生き残れるかどうか。 int n=a.size(); vector<pair<long long,int>> b; REP() int main(){ int n; cin>>n; vector<long long> a(n); long long s[n]; REP(i,n){ cin>>a[i]; } sort(a.begin(),a.end()); REP(i,n){ if(i==0){ s[i]=a[i]; }else{ s[i]=s[i-1]+a[i]; } } int l=0,r=n;//二分探索でいける?? int lm,rm,mm; long long temp; while(r-l>1){ int m=(l+r)/2; lm = m+1; rm = n; temp = s[m]; mm = m; //m番目のモンスターが吸収できる最大のモンスターのインデックスを取得 while(true){ for(int i=m+1;i<n;i++){ if(a[i]<2*temp){ mm = i; } } temp = s[mm]; if(mm==m && m){ break; }else{ return 0; }
a.cc:92:7: error: macro "REP" requires 2 arguments, but only 1 given 92 | REP() | ^ a.cc:2:9: note: macro "REP" defined here 2 | #define REP(i,n) for(int i=0;i<n;i++) | ^~~ a.cc: In function 'bool func(int, std::vector<long long int>)': a.cc:92:3: error: 'REP' was not declared in this scope 92 | REP() | ^~~ a.cc:134:2: error: expected '}' at end of input 134 | } | ^ a.cc:89:37: note: to match this '{' 89 | bool func(int i,vector<long long> a){//i番目のモンスターが生き残れるかどうか。 | ^ a.cc:134:2: warning: no return statement in function returning non-void [-Wreturn-type] 134 | } | ^
s199056103
p03786
C++
#include <bits/stdc++.h> #define REP(i,n) for(int i=0;i<n;i++) #define REPP(i,n) for(int i=1;i<=n;i++) const double PI = acos(-1); const double EPS = 1e-15; long long INF=(long long)1E17; #define i_7 (long long)(1E9+7) long mod(long a){ long long c=a%i_7; if(c>=0)return c; return c+i_7; } using namespace std; bool prime(int n){ if(n==1){ return false; }else if(n==2){ return true; }else{ for(int i=2;i<=sqrt(n);i++){ if(n%i==0){ return false; } } return true; } } long long gcd(long long a, long long b){ if(a<b){ swap(a,b); } if(a%b==0){ return b; }else{ return gcd(b,a%b); } } long long lcm(long long x, long long y){ return (x/gcd(x,y))*y; } class UnionFind { public: //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。 vector<int> Parent; //クラスを作るときは、Parentの値を全て-1にする。 //以下のようにすると全てバラバラの頂点として解釈できる。 UnionFind(int N) { Parent = vector<int>(N, -1); } //Aがどのグループに属しているか調べる int root(int A) { if (Parent[A] < 0) return A; return Parent[A] = root(Parent[A]); } //自分のいるグループの頂点数を調べる int size(int A) { return -Parent[root(A)];//先祖をrootで取っておきたい。 } //AとBをくっ付ける bool connect(int A, int B) { //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける A = root(A); B = root(B); if (A == B) { //すでにくっついてるからくっ付けない return false; } //大きい方(A)に小さいほう(B)をくっ付けたい //大小が逆だったらAとBをひっくり返す。 if (size(A) < size(B)) swap(A, B); //Aのサイズを更新する Parent[A] += Parent[B]; //Bの親をAに変更する Parent[B] = A; return true; } }; bool func(int i,vector<long long> a){//i番目のモンスターが生き残れるかどうか。 int n=a.size(); vector<pair<long long,int>> b; REP() int main(){ int n; cin>>n; vector<long long> a(n); long long s[n]; REP(i,n){ cin>>a[i]; } sort(a.begin(),a.end()); REP(i,n){ if(i==0){ s[i]=a[i]; }else{ s[i]=s[i-1]+a[i]; } } int l=0,r=n;//二分探索でいける?? int lm,rm,mm; long long temp; while(r-l>1){ int m=(l+r)/2; lm = m+1; rm = n; temp = s[m]; //m番目のモンスターが吸収できる最大のモンスターのインデックスを取得 while(rm-lm>1){ mm = (lm+rm)/2; if(a[mm]<=2*temp){ lm = mm; }else{ rm = mm; } } temp = s[mm]; return 0; }
a.cc:92:7: error: macro "REP" requires 2 arguments, but only 1 given 92 | REP() | ^ a.cc:2:9: note: macro "REP" defined here 2 | #define REP(i,n) for(int i=0;i<n;i++) | ^~~ a.cc: In function 'bool func(int, std::vector<long long int>)': a.cc:92:3: error: 'REP' was not declared in this scope 92 | REP() | ^~~ a.cc:131:2: error: expected '}' at end of input 131 | } | ^ a.cc:89:37: note: to match this '{' 89 | bool func(int i,vector<long long> a){//i番目のモンスターが生き残れるかどうか。 | ^ a.cc:131:2: warning: no return statement in function returning non-void [-Wreturn-type] 131 | } | ^
s668075773
p03786
C++
#include <algorithm> #include <bitset> #include <cassert> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <stack> #include <vector> using namespace std; typedef long long ll; typedef pair<ll, ll> pii; typedef pair<int, pii> pipii; ll l[100005]; void solve() { int n; cin >> n; ll all = 0; for(int i = 0; i < n; i++) { cin >> l[i]; all += l[i]; } sort(l, l+n); int ret = 0; for(int i = n-1; i >= 0) { if(2*all >= l[i]) ret++; all -= l[i]; } cout << ret << endl; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); solve(); /* int t; cin >> t; for(int i = 1; i <= t; i++) { cout << "Case #" << i << ": "; solve(); } */ }
a.cc: In function 'void solve()': a.cc:31:26: error: expected ';' before ')' token 31 | for(int i = n-1; i >= 0) { | ^ | ;
s045072064
p03786
C++
#include<bits/stdc++.h> using namespace std; int main(){ int n;cin >>n; vector<int>a(n); for(auto&& w:a)cin>>w; sort(begin(a),end(a)); vector<int>s(n+1,0); for(int i=0;i<n;i++){ s[i+1]=s[i]+a[i];} int num=n-1; bool flg=false; for(int i=n-2;i>=0;i--){ if(a[i+1]>2*s[i+1]){ num=i; flg=true; break; } } if(!flg)cout<<n<<endl; else if(num<=n-2) cout<<n-1-num<<endl; } else cout<<1<<endl;
a.cc:23:9: error: expected unqualified-id before 'else' 23 | } else cout<<1<<endl; | ^~~~
s569824582
p03786
C++
#include<bits/stdc++.h> using namespace std; int main(){ int n;cin >>n; vector<int>a(n); for(auto&& w:a)cin>>w; sort(begin(a),end(a)); vector<int>s(n+1,0); for(int i=0;i<n;i++){ s[i+1]=s[i]+a[i];} int num=n-1; bool flg=false; for(int i=n-2;i>=0;i--){ if(a[i+1]>2*s[i+1]){ num=i; flg=true; break; } if(!flg)cout<<n<<endl; else cout<<n-num<<endl; }
a.cc: In function 'int main()': a.cc:22:2: error: expected '}' at end of input 22 | } | ^ a.cc:4:11: note: to match this '{' 4 | int main(){ | ^
s382029460
p03786
C++
#include <iostream> #include <algorithm> using namespace std; typedef long long ll; int main(){ ll n; cin >> n; ll a[n]; for(int i=0;i<n;i++) cin >> a[i]; sort(a,a+n); ll sum[n]; sum[0]=a[0]; for(int i=1;i<n;i++){ sum[i]=sum[i-1]+a[i]; } int x=0; for(int i=0;i<n-1;i++){ if(2*sum[i]<a[i+1]){ x=i; } } cout << n-x-1 << endl }
a.cc: In function 'int main()': a.cc:24:24: error: expected ';' before '}' token 24 | cout << n-x-1 << endl | ^ | ; 25 | } | ~
s057004892
p03786
C++
#include <bits/stdc++.h> using namespace std; int main() { int n,i,a[111111],sum[111111]; cin>>n; cin>>a[0]; sum[0]=a[0]; for(i=1;i<n;i++){ cin<<a[i]; sum[i]=sum[i-1]+a[i]; } sort(a,a+n); i=1; while(1){ if(sum[n-i-1]*2<a[n-i]){ cout<<i<<endl; return 0; } i++; if(i==n){ cout<<n<<endl; return 0; } } }
a.cc: In function 'int main()': a.cc:10:8: error: no match for 'operator<<' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and 'int') 10 | cin<<a[i]; | ~~~^~~~~~ | | | | | int | std::istream {aka std::basic_istream<char>} a.cc:10:8: note: candidate: 'operator<<(int, int)' (built-in) 10 | cin<<a[i]; | ~~~^~~~~~ a.cc:10:8: note: no known conversion for argument 1 from 'std::istream' {aka 'std::basic_istream<char>'} to 'int' In file included from /usr/include/c++/14/regex:68, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181, from a.cc:1: /usr/include/c++/14/bits/regex.h:1715:5: note: candidate: 'template<class _Ch_type, class _Ch_traits, class _Bi_iter> std::basic_ostream<_CharT, _Traits>& std::__cxx11::operator<<(std::basic_ostream<_CharT, _Traits>&, const sub_match<_Bi_iter>&)' 1715 | operator<<(basic_ostream<_Ch_type, _Ch_traits>& __os, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1715:5: note: template argument deduction/substitution failed: a.cc:10:13: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>' 10 | cin<<a[i]; | ^ In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:41: /usr/include/c++/14/cstddef:125:5: note: candidate: 'template<class _IntegerType> constexpr std::__byte_op_t<_IntegerType> std::operator<<(byte, _IntegerType)' 125 | operator<<(byte __b, _IntegerType __shift) noexcept | ^~~~~~~~ /usr/include/c++/14/cstddef:125:5: note: template argument deduction/substitution failed: a.cc:10:5: note: cannot convert 'std::cin' (type 'std::istream' {aka 'std::basic_istream<char>'}) to type 'std::byte' 10 | cin<<a[i]; | ^~~ In file included from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52: /usr/include/c++/14/string_view:763:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, basic_string_view<_CharT, _Traits>)' 763 | operator<<(basic_ostream<_CharT, _Traits>& __os, | ^~~~~~~~ /usr/include/c++/14/string_view:763:5: note: template argument deduction/substitution failed: a.cc:10:13: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>' 10 | cin<<a[i]; | ^ /usr/include/c++/14/bits/basic_string.h:4077:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 4077 | operator<<(basic_ostream<_CharT, _Traits>& __os, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:4077:5: note: template argument deduction/substitution failed: a.cc:10:13: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>' 10 | cin<<a[i]; | ^ /usr/include/c++/14/bitset:1687:5: note: candidate: 'template<class _CharT, class _Traits, long unsigned int _Nb> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const bitset<_Nb>&)' 1687 | operator<<(std::basic_ostream<_CharT, _Traits>& __os, | ^~~~~~~~ /usr/include/c++/14/bitset:1687:5: note: template argument deduction/substitution failed: a.cc:10:13: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>' 10 | cin<<a[i]; | ^ In file included from /usr/include/c++/14/bits/ios_base.h:46, from /usr/include/c++/14/streambuf:43, from /usr/include/c++/14/bits/streambuf_iterator.h:35, from /usr/include/c++/14/iterator:66, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:54: /usr/include/c++/14/system_error:339:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const error_code&)' 339 | operator<<(basic_ostream<_CharT, _Traits>& __os, const error_code& __e) | ^~~~~~~~ /usr/include/c++/14/system_error:339:5: note: template argument deduction/substitution failed: a.cc:10:13: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>' 10 | cin<<a[i]; | ^ In file included from /usr/include/c++/14/memory:80, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:56: /usr/include/c++/14/bits/shared_ptr.h:70:5: note: candidate: 'template<class _Ch, class _Tr, class _Tp, __gnu_cxx::_Lock_policy _Lp> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const __shared_ptr<_Tp, _Lp>&)' 70 | operator<<(std::basic_ostream<_Ch, _Tr>& __os, | ^~~~~~~~ /usr/include/c++/14/bits/shared_ptr.h:70:5: note: template argument deduction/substitution failed: a.cc:10:13: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>' 10 | cin<<a[i]; | ^ In file included from /usr/include/c++/14/istream:41, from /usr/include/c++/14/sstream:40, from /usr/include/c++/14/complex:45, from /usr/include/c++/14/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127: /usr/include/c++/14/ostream:563:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, _CharT)' 563 | operator<<(basic_ostream<_CharT, _Traits>& __out, _CharT __c) | ^~~~~~~~ /usr/include/c++/14/ostream:563:5: note: template argument deduction/substitution failed: a.cc:10:13: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>' 10 | cin<<a[i]; | ^ /usr/include/c++/14/ostream:573:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, char)' 573 | operator<<(basic_ostream<_CharT, _Traits>& __out, char __c) | ^~~~~~~~ /usr/include/c++/14/ostream:573:5: note: template argument deduction/substitution failed: a.cc:10:13: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>' 10 | cin<<a[i]; | ^ /usr/include/c++/14/ostream:579:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, char)' 579 | operator<<(basic_ostream<char, _Traits>& __out, char __c) | ^~~~~~~~ /usr/include/c++/14/ostream:579:5: note: template argument deduction/substitution failed: a.cc:10:13: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<char, _Traits>' 10 | cin<<a[i]; | ^ /usr/include/c++/14/ostream:590:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, signed char)' 590 | operator<<(basic_ostream<char, _Traits>& __out, signed char __c) | ^~~~~~~~ /usr/include/c++/14/ostream:590:5: note: template argument deduction/substitution failed: a.cc:10:13: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<char, _Traits>' 10 | cin<<a[i]; | ^ /usr/include/c++/14/ostream:595:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, unsigned char)' 595 | operator<<(basic_ostream<char, _Traits>& __out, unsigned char __c) | ^~~~~~~~ /usr/include/c++/14/ostream:595:5: note: template argument deduction/substitution failed: a.cc:10:13: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<char, _Traits>' 10 | cin<<a[i]; | ^ /usr/include/c++/14/ostream:654:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const _CharT*)' 654 | operator<<(basic_ostream<_CharT, _Traits>& __out, const _CharT* __s) | ^~~~~~~~ /usr/include/c++/14/ostream:654:5: note: template argument deduction/substitution failed: a.cc:10:13: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>' 10 | cin<<a[i]; | ^ In file included from /usr/include/c++/14/ostream:1022: /usr/include/c++/14/bits/ostream.tcc:307:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const char*)' 307 | operator<<(basic_ostream<_CharT, _Traits>& __out, const char* __s) | ^~~~~~~~ /usr/include/c++/14/bits/ostream.tcc:307:5: note: template argument deduction/substitution failed: a.cc:10:13: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>' 10 | cin<<a[i]; | ^ /usr/include/c++/14/ostream:671:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, const char*)' 671 | operator<<(basic_ostream<char, _Traits>& __out, const char* __s) | ^~~~~~~~ /usr/include/c++/14/ostream:671:5: note: template argument deduction/substitution failed: a.cc:10:13: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<char, _Traits>' 10 | cin<<a[i]; | ^ /usr/include/c++/14/ostream:684:5: note: candidate: 'templa
s204893338
p03786
C++
#include<bits/stdc++.h> using namespace std; #define int long long #define f(i,n) for(ll i=0;i<n;++i) #define pie 3.141592653589793238462643383279 #define mod 1e9+7 int x[100000],y[100000]; signed main(){ int n; cin>>n; f(i,n){ cin>>x[i]; } sort(x,x+n); f(i,n){ y[i]=x[i]; if(i) y[i]+=y[i-1]; } for(int i=n-2;i>=0;i--){ if(y[i]*2<x[i+1]){ cout<<n-i-1<<endl; return 0; } } cout<<n<<endl; }
a.cc: In function 'int main()': a.cc:4:20: error: 'll' was not declared in this scope 4 | #define f(i,n) for(ll i=0;i<n;++i) | ^~ a.cc:11:9: note: in expansion of macro 'f' 11 | f(i,n){ | ^ a.cc:11:11: error: 'i' was not declared in this scope 11 | f(i,n){ | ^ a.cc:4:27: note: in definition of macro 'f' 4 | #define f(i,n) for(ll i=0;i<n;++i) | ^ a.cc:4:20: error: 'll' was not declared in this scope 4 | #define f(i,n) for(ll i=0;i<n;++i) | ^~ a.cc:15:9: note: in expansion of macro 'f' 15 | f(i,n){ | ^ a.cc:15:11: error: 'i' was not declared in this scope 15 | f(i,n){ | ^ a.cc:4:27: note: in definition of macro 'f' 4 | #define f(i,n) for(ll i=0;i<n;++i) | ^
s367207645
p03786
Java
vimport java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.*; public class Main { public static void main(String[] args) { PrintWriter out = new PrintWriter(System.out); InputStreamScanner in = new InputStreamScanner(System.in); new Main().solve(in, out); out.flush(); } private void solve(InputStreamScanner in, PrintWriter out) { int n = in.nextInt(); int[] a = new int[n]; for (int i = 0; i < n; i++) { a[i] = in.nextInt(); } Arrays.sort(a); long total = a[0]; int bottom = 0; for (int i = 1; i < n; i++) { if (total * 2 < a[i]) { bottom = i; } total += a[i]; } out.println(n - bottom); } static class InputStreamScanner { private InputStream in; private byte[] buf = new byte[1024]; private int len = 0; private int off = 0; InputStreamScanner(InputStream in) { this.in = in; } String next() { StringBuilder sb = new StringBuilder(); for (int b = skip(); !isSpace(b);){ sb.appendCodePoint(b); b = read(); } return sb.toString(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } char nextChar() { return (char)skip(); } int skip() { for (int b; (b = read()) != -1;) { if (!isSpace(b)) { return b; } } return -1; } private boolean isSpace(int c) { return c < 33 || c > 126; } private int read() { if (len == -1) { throw new InputMismatchException("End of Input"); } if (off >= len){ off = 0; try { len = in.read(buf); } catch (IOException e) { throw new InputMismatchException(e.getMessage()); } if (len <= 0) { return -1; } } return buf[off++]; } } }
Main.java:1: error: class, interface, enum, or record expected vimport java.io.IOException; ^ Main.java:2: error: class, interface, enum, or record expected import java.io.InputStream; ^ Main.java:3: error: class, interface, enum, or record expected import java.io.PrintWriter; ^ Main.java:4: error: class, interface, enum, or record expected import java.util.*; ^ 4 errors
s119735629
p03786
C++
#include <iostream> #include <cstdio> #include <queue> #include <stdlib.h> #include <stack> #include <string.h> #include <set> #include <iomanip> #include <ctime> #include <map> #include <cmath> #include <algorithm> #include <sstream> #include <cstring> #define eps 1e-15 #define ull unsigned long long //priority_queue<int,vector<int>,greater<int> > q; //priority_queue<int,vector<int>,less<int> > q; //#define ls l, mid, rt << 1 //#define rs mid + 1, r, rt << 1 | 1 using namespace std; typedef long long ll; //typedef pair<int,int> P; const int inf = 0x3f3f3f3f; const int mod = 1e9+7; const long long mod1 = 1e16; //int gcd(int a, int b) {return a % b == 0 ? b : gcd(b, a % b);} //int Find(int x){return x == p[x] ? x : p[x] = Find(p[x]);} //#define lson 1<<rt //#define rson 1<<rt|1 const int maxn=1e5+7; #define pi 3.1415926535898 #define PI atan(1.0)*4 int dx[4]= {0,1,0,-1},dy[4]= {1,0,-1,0}; int dir[4][2]= {{1,0},{-1,0},{0,1},{0,-1}}; int dir1[8][2]= {{1,0},{-1,0},{0,1},{0,-1},{1,1},{-1,1},{1,-1},{-1,-1}}; //int d[]= {1,-1,4,-4}; //八数码问题 //---------------------------------------- bool check(int mid) { ll s=a[mid]; for(int j=0;j<n;j++) { if(j!=mid) { if(a[j]>s*2) a[j]+=s; else return 0; } } return 1; } int main() { cin>>n; for(int i=0; i<n; i++) cin>>a[i]; sort(a,a+n); int l=0,r=100000,mid; while(l<=r) { mid=(l+r)/2; if(check(mid)) { r=mid-1; } else l=mid+1; } cout<<l-1<<endl; return 0; }
a.cc: In function 'bool check(int)': a.cc:42:10: error: 'a' was not declared in this scope 42 | ll s=a[mid]; | ^ a.cc:43:19: error: 'n' was not declared in this scope 43 | for(int j=0;j<n;j++) | ^ a.cc: In function 'int main()': a.cc:58:10: error: 'n' was not declared in this scope; did you mean 'yn'? 58 | cin>>n; | ^ | yn a.cc:60:14: error: 'a' was not declared in this scope 60 | cin>>a[i]; | ^ a.cc:61:10: error: 'a' was not declared in this scope 61 | sort(a,a+n); | ^
s017673095
p03786
C++
#include <iostream> #include <cstdio> #include <queue> #include <stdlib.h> #include <stack> #include <string.h> #include <set> #include <iomanip> #include <ctime> #include <map> #include <cmath> #include <algorithm> #include <sstream> #include <cstring> #define eps 1e-15 #define ull unsigned long long //priority_queue<int,vector<int>,greater<int> > q; //priority_queue<int,vector<int>,less<int> > q; //#define ls l, mid, rt << 1 //#define rs mid + 1, r, rt << 1 | 1 using namespace std; typedef long long ll; //typedef pair<int,int> P; const int inf = 0x3f3f3f3f; const int mod = 1e9+7; const long long mod1 = 1e16; //int gcd(int a, int b) {return a % b == 0 ? b : gcd(b, a % b);} //int Find(int x){return x == p[x] ? x : p[x] = Find(p[x]);} //#define lson 1<<rt //#define rson 1<<rt|1 const int maxn=1e5+7; #define pi 3.1415926535898 #define PI atan(1.0)*4 int dx[4]= {0,1,0,-1},dy[4]= {1,0,-1,0}; int dir[4][2]= {{1,0},{-1,0},{0,1},{0,-1}}; int dir1[8][2]= {{1,0},{-1,0},{0,1},{0,-1},{1,1},{-1,1},{1,-1},{-1,-1}}; //int d[]= {1,-1,4,-4}; //八数码问题 //---------------------------------------- #include <iostream> #include <cstdio> #include <queue> #include <stdlib.h> #include <stack> #include <string.h> #include <set> #include <iomanip> #include <ctime> #include <map> #include <cmath> #include <algorithm> #include <sstream> #include <cstring> #define eps 1e-15 #define ull unsigned long long //priority_queue<int,vector<int>,greater<int> > q; //priority_queue<int,vector<int>,less<int> > q; //#define ls l, mid, rt << 1 //#define rs mid + 1, r, rt << 1 | 1 using namespace std; typedef long long ll; //typedef pair<int,int> P; const int inf = 0x3f3f3f3f; const int mod = 1e9+7; const long long mod1 = 1e16; //int gcd(int a, int b) {return a % b == 0 ? b : gcd(b, a % b);} //int Find(int x){return x == p[x] ? x : p[x] = Find(p[x]);} //#define lson 1<<rt //#define rson 1<<rt|1 const int maxn=1e5+7; #define pi 3.1415926535898 #define PI atan(1.0)*4 int dx[4]= {0,1,0,-1},dy[4]= {1,0,-1,0}; int dir[4][2]= {{1,0},{-1,0},{0,1},{0,-1}}; int dir1[8][2]= {{1,0},{-1,0},{0,1},{0,-1},{1,1},{-1,1},{1,-1},{-1,-1}}; //int d[]= {1,-1,4,-4}; //八数码问题 //---------------------------------------- int n,a[100001],ans; bool check(int mid) { ll s=a[mid]; for(int j=0;j<n;j++) { if(j!=mid) { if(a[j]>s*2) a[j]+=s; else return 0; } } return 1; } int main() { cin>>n; for(int i=0; i<n; i++) cin>>a[i]; sort(a,a+n); int l=0,r=100000,mid; while(l<=r) { mid=(l+r)/2; if(check(mid)) { r=mid-1; } else l=mid+1; } cout<<l-1<<endl; return 0; }
a.cc:63:11: error: redefinition of 'const int inf' 63 | const int inf = 0x3f3f3f3f; | ^~~ a.cc:24:11: note: 'const int inf' previously defined here 24 | const int inf = 0x3f3f3f3f; | ^~~ a.cc:64:11: error: redefinition of 'const int mod' 64 | const int mod = 1e9+7; | ^~~ a.cc:25:11: note: 'const int mod' previously defined here 25 | const int mod = 1e9+7; | ^~~ a.cc:65:17: error: redefinition of 'const long long int mod1' 65 | const long long mod1 = 1e16; | ^~~~ a.cc:26:17: note: 'const long long int mod1' previously defined here 26 | const long long mod1 = 1e16; | ^~~~ a.cc:70:11: error: redefinition of 'const int maxn' 70 | const int maxn=1e5+7; | ^~~~ a.cc:31:11: note: 'const int maxn' previously defined here 31 | const int maxn=1e5+7; | ^~~~ a.cc:73:5: error: redefinition of 'int dx [4]' 73 | int dx[4]= {0,1,0,-1},dy[4]= {1,0,-1,0}; | ^~ a.cc:34:5: note: 'int dx [4]' previously defined here 34 | int dx[4]= {0,1,0,-1},dy[4]= {1,0,-1,0}; | ^~ a.cc:73:23: error: redefinition of 'int dy [4]' 73 | int dx[4]= {0,1,0,-1},dy[4]= {1,0,-1,0}; | ^~ a.cc:34:23: note: 'int dy [4]' previously defined here 34 | int dx[4]= {0,1,0,-1},dy[4]= {1,0,-1,0}; | ^~ a.cc:74:5: error: redefinition of 'int dir [4][2]' 74 | int dir[4][2]= {{1,0},{-1,0},{0,1},{0,-1}}; | ^~~ a.cc:35:5: note: 'int dir [4][2]' previously defined here 35 | int dir[4][2]= {{1,0},{-1,0},{0,1},{0,-1}}; | ^~~ a.cc:75:5: error: redefinition of 'int dir1 [8][2]' 75 | int dir1[8][2]= {{1,0},{-1,0},{0,1},{0,-1},{1,1},{-1,1},{1,-1},{-1,-1}}; | ^~~~ a.cc:36:5: note: 'int dir1 [8][2]' previously defined here 36 | int dir1[8][2]= {{1,0},{-1,0},{0,1},{0,-1},{1,1},{-1,1},{1,-1},{-1,-1}}; | ^~~~
s067021893
p03786
C++
#include <iostream> #include <cstdio> #include <queue> #include <stdlib.h> #include <stack> #include <string.h> #include <set> #include <iomanip> #include <ctime> #include <map> #include <cmath> #include <algorithm> #include <sstream> #include <cstring> #define eps 1e-15 #define ull unsigned long long //priority_queue<int,vector<int>,greater<int> > q; //priority_queue<int,vector<int>,less<int> > q; //#define ls l, mid, rt << 1 //#define rs mid + 1, r, rt << 1 | 1 using namespace std; typedef long long ll; //typedef pair<int,int> P; const int inf = 0x3f3f3f3f; const int mod = 1e9+7; const long long mod1 = 1e16; //int gcd(int a, int b) {return a % b == 0 ? b : gcd(b, a % b);} //int Find(int x){return x == p[x] ? x : p[x] = Find(p[x]);} //#define lson 1<<rt //#define rson 1<<rt|1 const int maxn=1e5+7; #define pi 3.1415926535898 #define PI atan(1.0)*4 int dx[4]= {0,1,0,-1},dy[4]= {1,0,-1,0}; int dir[4][2]= {{1,0},{-1,0},{0,1},{0,-1}}; int dir1[8][2]= {{1,0},{-1,0},{0,1},{0,-1},{1,1},{-1,1},{1,-1},{-1,-1}}; //int d[]= {1,-1,4,-4}; //八数码问题 //---------------------------------------- #include <iostream> #include <cstdio> #include <queue> #include <stdlib.h> #include <stack> #include <string.h> #include <set> #include <iomanip> #include <ctime> #include <map> #include <cmath> #include <algorithm> #include <sstream> #include <cstring> #define eps 1e-15 #define ull unsigned long long //priority_queue<int,vector<int>,greater<int> > q; //priority_queue<int,vector<int>,less<int> > q; //#define ls l, mid, rt << 1 //#define rs mid + 1, r, rt << 1 | 1 using namespace std; typedef long long ll; //typedef pair<int,int> P; const int inf = 0x3f3f3f3f; const int mod = 1e9+7; const long long mod1 = 1e16; //int gcd(int a, int b) {return a % b == 0 ? b : gcd(b, a % b);} //int Find(int x){return x == p[x] ? x : p[x] = Find(p[x]);} //#define lson 1<<rt //#define rson 1<<rt|1 const int maxn=1e5+7; #define pi 3.1415926535898 #define PI atan(1.0)*4 int dx[4]= {0,1,0,-1},dy[4]= {1,0,-1,0}; int dir[4][2]= {{1,0},{-1,0},{0,1},{0,-1}}; int dir1[8][2]= {{1,0},{-1,0},{0,1},{0,-1},{1,1},{-1,1},{1,-1},{-1,-1}}; //int d[]= {1,-1,4,-4}; //八数码问题 //---------------------------------------- int n,a[100001],ans; bool check(int mid) { ll s=a[mid]; for(int j=0;j<n;j++) { if(j!=mid) { if(a[j]>s*2) a[j]+=s; else return 0; } } return 1; } int main() { cin>>n; for(int i=0; i<n; i++) cin>>a[i]; sort(a,a+n); int l=0,r=100000,mid; while(l<=r) { mid=(l+r)/2; if(check(mid)) { r=mid-1; } else l=mid+1; } cout<<l-1<<endl; return 0; }
a.cc:63:11: error: redefinition of 'const int inf' 63 | const int inf = 0x3f3f3f3f; | ^~~ a.cc:24:11: note: 'const int inf' previously defined here 24 | const int inf = 0x3f3f3f3f; | ^~~ a.cc:64:11: error: redefinition of 'const int mod' 64 | const int mod = 1e9+7; | ^~~ a.cc:25:11: note: 'const int mod' previously defined here 25 | const int mod = 1e9+7; | ^~~ a.cc:65:17: error: redefinition of 'const long long int mod1' 65 | const long long mod1 = 1e16; | ^~~~ a.cc:26:17: note: 'const long long int mod1' previously defined here 26 | const long long mod1 = 1e16; | ^~~~ a.cc:70:11: error: redefinition of 'const int maxn' 70 | const int maxn=1e5+7; | ^~~~ a.cc:31:11: note: 'const int maxn' previously defined here 31 | const int maxn=1e5+7; | ^~~~ a.cc:73:5: error: redefinition of 'int dx [4]' 73 | int dx[4]= {0,1,0,-1},dy[4]= {1,0,-1,0}; | ^~ a.cc:34:5: note: 'int dx [4]' previously defined here 34 | int dx[4]= {0,1,0,-1},dy[4]= {1,0,-1,0}; | ^~ a.cc:73:23: error: redefinition of 'int dy [4]' 73 | int dx[4]= {0,1,0,-1},dy[4]= {1,0,-1,0}; | ^~ a.cc:34:23: note: 'int dy [4]' previously defined here 34 | int dx[4]= {0,1,0,-1},dy[4]= {1,0,-1,0}; | ^~ a.cc:74:5: error: redefinition of 'int dir [4][2]' 74 | int dir[4][2]= {{1,0},{-1,0},{0,1},{0,-1}}; | ^~~ a.cc:35:5: note: 'int dir [4][2]' previously defined here 35 | int dir[4][2]= {{1,0},{-1,0},{0,1},{0,-1}}; | ^~~ a.cc:75:5: error: redefinition of 'int dir1 [8][2]' 75 | int dir1[8][2]= {{1,0},{-1,0},{0,1},{0,-1},{1,1},{-1,1},{1,-1},{-1,-1}}; | ^~~~ a.cc:36:5: note: 'int dir1 [8][2]' previously defined here 36 | int dir1[8][2]= {{1,0},{-1,0},{0,1},{0,-1},{1,1},{-1,1},{1,-1},{-1,-1}}; | ^~~~
s170813174
p03786
C++
#include<bits/stdc++.h> using namespace std; #define ll long long int main(){ ll n,j=0; cin>>n vector<ll> a(n); for(int i=0;i<n;i++) cin>>a[i]; sort(a.begin(),a.end()); for(int i=1;i<n;i++){ if(a[i-1]*2<a[i]){ j=i; } a[i]+=a[i-1]; } cout<<n-j; }
a.cc: In function 'int main()': a.cc:6:9: error: expected ';' before 'vector' 6 | cin>>n | ^ | ; 7 | vector<ll> a(n); | ~~~~~~ a.cc:8:29: error: 'a' was not declared in this scope 8 | for(int i=0;i<n;i++) cin>>a[i]; | ^ a.cc:9:8: error: 'a' was not declared in this scope 9 | sort(a.begin(),a.end()); | ^
s206116993
p03786
C++
N = int(input()) a = input().split() for i in range(0,N): a[i] = int(a[i]) a.sort() t = 0 flag = 1 i = 0 while flag: if a[i]*2 > a[i+1]: t = i flag = 0 else: i += 1 print(N-t)
a.cc:1:1: error: 'N' does not name a type 1 | N = int(input()) | ^
s885988536
p03786
C++
#include <iostream> #include <fstream> #include <cmath> #include <cstdlib> #include <ctime> #include <algorithm> #include <numeric> #include <functional> #include <string> #include <vector> #include <bitset> #include <map> #include <set> #include <stack> #include <queue> #include <deque> using namespace std; using ll = long long; using ull = unsigned long long; using ld = long double; #define REP(i,n) for(int i = 0; i < int(n); i++) #define REREP(i,n) for(int i = int(n - 1); i >= 0; i--) #define FOR(i, m, n) for(int i = int(m);i < int(n);i++) #define REFOR(i, m, n) for(int i = int(n - 1);i >= int(m);i--) #define ALL(obj) (obj).begin(),(obj).end() #define VI vector<int> #define VVI vector<vector<int>> #define VVVI vector<vector<vector<int>>> #define VD vector<double> #define VVD vector<vector<double>> #define VVVD vector<vector<vector<double>>> #define VL vector<ll> #define VVL vector<vector<ll>> #define VVVL vector<vector<vector<ll>>> #define VB vector<bool> #define VVB vector<vector<bool>> #define VVVB vector<vector<vector<bool>>> #define VS vector<string> #define VVS vector<vector<string>> #define VVVS vector<vector<vector<string>>> #define PII pair<int,int> #define PDD pair<double,double> #define PLL pair<ll,ll> #define VPII vector<pair<int,int>> #define VVPII vector<vector<pair<int,int>>> #define VVVPII vector<vector<vector<pair<int,int>>>> #define VPLL vector<pair<ll,ll>> #define VVPLL vector<vector<pair<ll,ll>>> #define VVVPLL vector<vector<vector<pair<ll,ll>>>> #define SUMI(obj) accumulate((obj).begin(), (obj).end(), 0) #define SUMD(obj) accumulate((obj).begin(), (obj).end(), 0.) #define SUML(obj) accumulate((obj).begin(), (obj).end(), 0LL) #define SORT(obj) sort((obj).begin(), (obj).end()) // 1,2,3,4,5... #define RESORT(obj) sort((obj).begin(), (obj).end(), greater<int>()) // 5,4,3,2,1... #define UB(obj,n) upper_bound((obj).begin(), (obj).end(), n) //itr > n #define LB(obj,n) lower_bound((obj).begin(), (obj).end(), n) //itr>= n const ll HMOD = (ll)1e9 + 7; const ll LMOD = 998244353; const ll HINF = (ll)1e18; const ll LINF = (ll)1e9; const long double PI = 3.1415926535897932384626433; const long double EPS = 1e-10; //integer class Integer { public: ll gcd(ll a, ll b) { if (a == 0 || b == 0) return 0; if (a < b) swap(a, b); while (b != 0) { a = a%b; swap(a, b); } return a; } ll lcm(ll a, ll b) { if (a == 0 || b == 0) return 0; return a / gcd(a, b)*b; } set<ll> divisor(ll N) { set<ll> st; for (ll i = 1; i*i <= N; i++) { if (N%i == 0) { st.insert(i); st.insert(N / i); } } return st; } //a vector that has prime factors of N (this includes only elements, which has no number of each prime factor) vector<ll> prime_factorization(ll N) { vector<ll> v; ll M = N; for (ll i = 2; i*i <= N; i++) { if (M%i == 0) v.push_back(i); while (M%i == 0) M /= i; } if (M != 1) v.push_back(M); return v; } int bitcount(ll N, int K) { int cnt = 0; for (int i = 0; i < K; i++) if (N & (1 << i)) cnt++; return cnt; } ll digitsum(ll N, int K) { ll sum = 0; for (; N > 0; N /= K) sum += N%K; return sum; } }; //geometry class Geometry { public: double dist(double x1, double y1, double x2, double y2) { return sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2)); } bool intersection_judgment(double ax, double ay, double bx, double by, double cx, double cy, double dx, double dy) { double ta = (cx - dx) * (ay - cy) + (cy - dy) * (cx - ax); double tb = (cx - dx) * (by - cy) + (cy - dy) * (cx - bx); double tc = (ax - bx) * (cy - ay) + (ay - by) * (ax - cx); double td = (ax - bx) * (dy - ay) + (ay - by) * (ax - dx); return tc * td < 0 && ta * tb < 0; } }; //eratosthenes class Eratosthenes { public: vector<bool> primary(int N) { vector<bool> primary(N + 1, true); primary[0] = false; if (N == 0) return primary; primary[1] = false; for (int i = 1; i*i <= N; i++) if (primary[i]) for (int j = 2 * i; j <= N; j += i) primary[j] = false; return primary; } }; //combination mod class Combination_Mod { public: VL factorial; //N! table void set(ll N, ll quotient) { factorial.resize(N + 1, 1); for (ll i = 1; i <= N; i++) { factorial[i] *= factorial[i - 1] * i; factorial[i] %= quotient; } return; } //repeat square method y = x^n mod quotient ll rsm(ll x, ll n, ll quotient) { ll y = 1; while (n > 0) { if (n & 1) { y *= x; y %= quotient; } x *= x; x %= quotient; n >>= 1; } return y; } //modulus of nCk - combination mod ll nCk(ll n, ll k, ll quotient) { if (n < k || n <= 0 || k <= 0) return 0; ll nCk = (factorial[n] % quotient); nCk *= rsm(factorial[k], quotient - 2, quotient); nCk %= quotient; nCk *= rsm(factorial[n - k], quotient - 2, quotient); return (nCk % quotient); } }; //combination class Combination { public: VVL nCk; VVD nCkP; void set(int N) { nCk.resize(N + 1); REP(i, N + 1) nCk[i].resize(N + 1, 0); nCk[0][0] = 1; for (int n = 1; n <= N; n++) { for (int k = 0; k <= n; k++) { if (k == 0) nCk[n][k] = nCk[n - 1][k]; else nCk[n][k] = nCk[n - 1][k - 1] + nCk[n - 1][k]; } } } void setP(int N) { nCkP.resize(N + 1); REP(i, N + 1) nCkP[i].resize(N + 1, 0.); nCkP[0][0] = 1; for (int n = 1; n <= N; n++) { for (int k = 0; k <= n; k++) { if (k == 0) nCkP[n][k] = nCkP[n - 1][k] / 2.; else nCkP[n][k] = (nCkP[n - 1][k - 1] + nCkP[n - 1][k]) / 2.; } } } }; //union-find class Union_Find { public: VI node; void set(int n) { node.resize(n); REP(i, n) node[i] = i; } int root(int n) { if (node[n] == n) return n; else return node[n] = root(node[n]); } void unite(int n, int m) { if (n > m) swap(n, m); n = root(n); m = root(m); if (n == m) return; else node[m] = n; } }; //dijkstra class Dijkstra { public: vector<vector<pair<int,ll>>> edge; VL dist; void set(int N, ll inf) { edge.resize(N); dist.resize(N); REP(i, N) dist[i] = inf; } void make_edge(int from, int to, ll cost) { edge[from].push_back({ to,cost }); } void dijkstra(int start) { priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> pq; dist[start] = 0; pq.push({ 0,start }); while (!pq.empty()) { int from = pq.top().second; pq.pop(); REP(i, edge[from].size()) { int to = edge[from][i].first; if (dist[to] > dist[from] + edge[from][i].second) { dist[to] = dist[from] + edge[from][i].second; pq.push({ dist[from] + edge[from][i].second,to }); } } } } }; //bellman ford class Bellman_Ford { public: struct edge { int from, to, cost; }; int N; VI node; vector<edge> graph; void set(int node_, int inf) { N = node_; node.resize(node_); } void make_edge(int from, int to, int cost) { graph.push_back({ from,to,cost }); } void bellman_ford(int start, int inf) { REP(i, N) node[i] = inf; node[start] = 0; REP(i, N - 1) REP(j, graph.size()) if (node[graph[j].to] > node[graph[j].from] + graph[j].cost) node[graph[j].to] = node[graph[j].from] + graph[j].cost; } }; //ford fulkerson class Ford_Fulkerson { public: struct edge { int to, cap, rev; }; int node, start, goal; vector<vector<edge>> graph; vector<bool> visit; void set(int node_, int start_, int goal_) { node = node_; start = start_; goal = goal_; graph.resize(node); visit.resize(node); } void make_edge(int from, int to, int cap) { graph[from].push_back({ to,cap,(int)graph[to].size() }); graph[to].push_back({ from,0,(int)graph[from].size() - 1 }); } int dfs(int from, int flow) { if (from == goal) return flow; visit[from] = false; REP(i, graph[from].size()) { if (visit[graph[from][i].to] && (graph[from][i].cap > 0)) { int dflow = dfs(graph[from][i].to, min(flow, graph[from][i].cap)); if (dflow > 0) { graph[from][i].cap -= dflow; graph[graph[from][i].to][graph[from][i].rev].cap += dflow; return dflow; } } } return 0; } int maxflow(void) { int maxflow = 0; while (1) { REP(i, graph.size()) visit[i] = true; int flow = dfs(start, 1); if (flow == 0) return maxflow; maxflow += flow; } } }; //longest increasing subsequence class Longest_Increasing_Subsequence { public: int N; VI dp, ar; void set(int N_) { N = N_; dp.resize(N, LINF); ar.resize(N);// ar has to be set value. } int make(void) { REP(i, N) *lower_bound(ALL(dp), ar[i]) = ar[i]; return distance(dp.begin(), lower_bound(ALL(dp), LINF)); } }; //least common ancestor class Least_Common_Ancestor { public: int node; int MAXLOG2; VVI edge; VI depth; VVI parent; void set(int node_, int MAXLOG2_) { node = node_; MAXLOG2 = MAXLOG2_; edge.resize(node); depth.resize(node); parent.resize(node); REP(i, node) parent[i].resize(MAXLOG2); } void dfs(int root, int root_from) { depth[root] = 0; parent[root][0] = root_from; stack<pair<int, int>> st; st.push({ root,root_from }); while (!st.empty()) { int from = st.top().first; int from_from = st.top().second; st.pop(); REP(i, edge[from].size()) { int to = edge[from][i]; if (to != from_from) { depth[to] = depth[from] + 1; parent[to][0] = from; st.push({ to,from }); } } } return; } //make table void initialize(int N) { REP(k, MAXLOG2 - 1) { REP(i, N) { if (parent[i][k] < 0) parent[i][k + 1] = -1; else parent[i][k + 1] = parent[parent[i][k]][k]; } } return; } //get least common ancestor int get(int a, int b) { if (depth[a] > depth[b]) swap(a, b); REP(k, MAXLOG2 - 1) if (((depth[b] - depth[a]) >> k) & 1) b = parent[b][k]; if (a == b) return a; REREP(k, MAXLOG2) { if (parent[a][k] != parent[b][k]) { a = parent[a][k]; b = parent[b][k]; } } return parent[a][0]; } }; //directed acyclic graph class Directed_Acyclic_Graph { public: int N; Dijkstra dijkstra; struct edge { int dest, cost; bool need; }; vector<vector<edge>> output; VI input; VI topological_order; void set(int N_, int inf) { N = N_; dijkstra.set(N, inf); output.resize(N); input.resize(N, 0); } void make_edge(int from, int to, int cost) { dijkstra.make_edge(from, to, cost); output[from].push_back({ to, cost, true }); } void make_dag(int start) { dijkstra.dijkstra(start); REP(i, N) { REP(j, output[i].size()) { int from = i; edge &e = output[i][j]; if (dijkstra.dist[e.dest] - dijkstra.dist[from] != e.cost) e.need = false; } } } bool topological_sort(int start) { REP(i, N) REP(j, output[i].size()) if (output[i][j].need) input[output[i][j].dest]++; stack<int> st; st.push(start); while (!st.empty()) { int from = st.top(); st.pop(); topological_order.push_back(from); REP(i, output[from].size()) { edge &e = output[from][i]; if (e.need) { input[e.dest]--; if (input[e.dest] == 0) st.push(e.dest); } } } bool valid = true; REP(i, N) if (input[i] > 0) valid = false; return valid; } }; //binary indexed tree class Binary_Indexed_Tree { public: int N; ll ini; vector<ll> bit; void set(int N_, ll ini_) { N = N_; ini = ini_; bit.resize(N + 1); for (int i = 0; i <= N; i++) bit[i] = ini; } //sum void add(int i, ll w) { for (int j = i; j <= N; j += j & -j) bit[j] += w; } ll sum(int i) { ll ret = ini; for (int j = i; j >= 1; j -= j & -j) ret += bit[j]; return ret; } //max void inc(int i, ll w) { for (int j = i; j <= N; j += j & -j) bit[j] = (bit[j]>w) ? bit[j] : w; } ll max(int i) { ll ret = ini; for (int j = i; j >= 1; j -= j & -j) ret = (ret>bit[j]) ? ret : bit[j]; return ret; } //min void dec(int i, ll w) { for (int j = i; j <= N; j += j & -j) bit[j] = (bit[j]<w) ? bit[j] : w; } ll min(int i) { ll ret = ini; for (int j = i; j >= 1; j -= j & -j) ret = (ret<bit[j]) ? ret : bit[j]; return ret; } }; void YN(bool flag) { cout << ((flag) ? "YES" : "NO") << endl; } void Yn(bool flag) { cout << ((flag) ? "Yes" : "No") << endl; } void yn(bool flag) { cout << ((flag) ? "yes" : "no") << endl; } int main() { int N; cin >> N; auto comp = [](const pair<ll, int> a, const pair<ll, int> b) { return (a.first != b.first) ? a.first > b.first:a.second > b.second; }; priority_queue < pair<ll, int>, vector<pair<ll, int>>, function<bool(pair<ll, int>, pair<ll, int>)> > pq([](pair<ll, int> &a, pair<ll, int>&b) { return ((a.first != b.first)?(a.first > b.first):(a.second < b.second)); }); REP(i,N){ int A; cin >> A; pq.push({A,1}); } while(1){ pair<ll, int> f = pq.top(); pq.pop(); if (!pq.empty()) { pair<ll, int> s = pq.top(); pq.pop(); if (s.first <= 2 * f.first) pq.push({ f.first + s.first,f.second + s.second }); else pq.push({ f.first + s.first,s.second }); } else { cout << f.second << endl; return 0; } } return 0; }
a.cc: In function 'int main()': a.cc:574:228: error: no matching function for call to 'std::priority_queue<std::pair<long long int, int>, std::vector<std::pair<long long int, int> >, std::function<bool(std::pair<long long int, int>, std::pair<long long int, int>)> >::priority_queue(main()::<lambda(std::pair<long long int, int>&, std::pair<long long int, int>&)>)' 574 | priority_queue < pair<ll, int>, vector<pair<ll, int>>, function<bool(pair<ll, int>, pair<ll, int>)> > pq([](pair<ll, int> &a, pair<ll, int>&b) { return ((a.first != b.first)?(a.first > b.first):(a.second < b.second)); }); | ^ In file included from /usr/include/c++/14/queue:66, from a.cc:15: /usr/include/c++/14/bits/stl_queue.h:691:9: note: candidate: 'template<class _InputIterator, class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(_InputIterator, _InputIterator, const _Compare&, _Sequence&&, const _Alloc&) [with _Alloc = _InputIterator; _Requires = _Alloc; _Tp = std::pair<long long int, int>; _Sequence = std::vector<std::pair<long long int, int> >; _Compare = std::function<bool(std::pair<long long int, int>, std::pair<long long int, int>)>]' 691 | priority_queue(_InputIterator __first, _InputIterator __last, | ^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:691:9: note: candidate expects 5 arguments, 1 provided /usr/include/c++/14/bits/stl_queue.h:679:9: note: candidate: 'template<class _InputIterator, class _Alloc, class, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(_InputIterator, _InputIterator, const _Compare&, const _Sequence&, const _Alloc&) [with _Alloc = _InputIterator; <template-parameter-2-3> = _Alloc; _Requires = <template-parameter-1-3>; _Tp = std::pair<long long int, int>; _Sequence = std::vector<std::pair<long long int, int> >; _Compare = std::function<bool(std::pair<long long int, int>, std::pair<long long int, int>)>]' 679 | priority_queue(_InputIterator __first, _InputIterator __last, | ^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:679:9: note: candidate expects 5 arguments, 1 provided /usr/include/c++/14/bits/stl_queue.h:671:9: note: candidate: 'template<class _InputIterator, class _Alloc, class, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(_InputIterator, _InputIterator, const _Compare&, const _Alloc&) [with _Alloc = _InputIterator; <template-parameter-2-3> = _Alloc; _Requires = <template-parameter-1-3>; _Tp = std::pair<long long int, int>; _Sequence = std::vector<std::pair<long long int, int> >; _Compare = std::function<bool(std::pair<long long int, int>, std::pair<long long int, int>)>]' 671 | priority_queue(_InputIterator __first, _InputIterator __last, | ^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:671:9: note: candidate expects 4 arguments, 1 provided /usr/include/c++/14/bits/stl_queue.h:663:9: note: candidate: 'template<class _InputIterator, class _Alloc, class, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(_InputIterator, _InputIterator, const _Alloc&) [with _Alloc = _InputIterator; <template-parameter-2-3> = _Alloc; _Requires = <template-parameter-1-3>; _Tp = std::pair<long long int, int>; _Sequence = std::vector<std::pair<long long int, int> >; _Compare = std::function<bool(std::pair<long long int, int>, std::pair<long long int, int>)>]' 663 | priority_queue(_InputIterator __first, _InputIterator __last, | ^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:663:9: note: candidate expects 3 arguments, 1 provided /usr/include/c++/14/bits/stl_queue.h:649:9: note: candidate: 'template<class _InputIterator, class> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(_InputIterator, _InputIterator, const _Compare&, _Sequence&&) [with <template-parameter-2-2> = _InputIterator; _Tp = std::pair<long long int, int>; _Sequence = std::vector<std::pair<long long int, int> >; _Compare = std::function<bool(std::pair<long long int, int>, std::pair<long long int, int>)>]' 649 | priority_queue(_InputIterator __first, _InputIterator __last, | ^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:649:9: note: candidate expects 4 arguments, 1 provided /usr/include/c++/14/bits/stl_queue.h:638:9: note: candidate: 'template<class _InputIterator, class> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(_InputIterator, _InputIterator, const _Compare&, const _Sequence&) [with <template-parameter-2-2> = _InputIterator; _Tp = std::pair<long long int, int>; _Sequence = std::vector<std::pair<long long int, int> >; _Compare = std::function<bool(std::pair<long long int, int>, std::pair<long long int, int>)>]' 638 | priority_queue(_InputIterator __first, _InputIterator __last, | ^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:638:9: note: candidate expects 4 arguments, 1 provided /usr/include/c++/14/bits/stl_queue.h:629:9: note: candidate: 'template<class _InputIterator, class> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(_InputIterator, _InputIterator, const _Compare&) [with <template-parameter-2-2> = _InputIterator; _Tp = std::pair<long long int, int>; _Sequence = std::vector<std::pair<long long int, int> >; _Compare = std::function<bool(std::pair<long long int, int>, std::pair<long long int, int>)>]' 629 | priority_queue(_InputIterator __first, _InputIterator __last, | ^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:629:9: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/bits/stl_queue.h:594:9: note: candidate: 'template<class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(std::priority_queue<_Tp, _Sequence, _Compare>&&, const _Alloc&) [with _Requires = _Alloc; _Tp = std::pair<long long int, int>; _Sequence = std::vector<std::pair<long long int, int> >; _Compare = std::function<bool(std::pair<long long int, int>, std::pair<long long int, int>)>]' 594 | priority_queue(priority_queue&& __q, const _Alloc& __a) | ^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:594:9: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/bits/stl_queue.h:590:9: note: candidate: 'template<class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const std::priority_queue<_Tp, _Sequence, _Compare>&, const _Alloc&) [with _Requires = _Alloc; _Tp = std::pair<long long int, int>; _Sequence = std::vector<std::pair<long long int, int> >; _Compare = std::function<bool(std::pair<long long int, int>, std::pair<long long int, int>)>]' 590 | priority_queue(const priority_queue& __q, const _Alloc& __a) | ^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:590:9: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/bits/stl_queue.h:585:9: note: candidate: 'template<class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const _Compare&, _Sequence&&, const _Alloc&) [with _Requires = _Alloc; _Tp = std::pair<long long int, int>; _Sequence = std::vector<std::pair<long long int, int> >; _Compare = std::function<bool(std::pair<long long int, int>, std::pair<long long int, int>)>]' 585 | priority_queue(const _Compare& __x, _Sequence&& __c, const _Alloc& __a) | ^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:585:9: note: candidate expects 3 arguments, 1 provided /usr/include/c++/14/bits/stl_queue.h:579:9: note: candidate: 'template<class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const _Compare&, const _Sequence&, const _Alloc&) [with _Requires = _Alloc; _Tp = std::pair<long long int, int>; _Sequence = std::vector<std::pair<long long int, int> >; _Compare = std::function<bool(std::pair<long long int, int>, std::pair<long long int, int>)>]' 579 | priority_queue(const _Compare& __x, const _Sequence& __c, | ^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:579:9: note: candidate expects 3 arguments, 1 provided /usr/include/c++/14/bits/stl_queue.h:573:9: note: candidate: 'template<class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const _Compare&, const _Alloc&) [with _Requires = _Alloc; _Tp = std::pair<long long int, int>; _Sequence = std::vector<std::pair<long long int, int> >; _Compare = std::function<bool(std::pair<long long int, int>, std::pair<long long int, int>)>]' 573 | priority_queue(const _Compare& __x, const _Alloc& __a) | ^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:573:9: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/bits/stl_queue.h:569:9: note: candidate: 'template<class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const _Alloc&) [with _Requires = _Alloc; _Tp = std::pair<long long int, int>; _Sequence = std::vector<std::pair<long long int, int> >; _Compare = std::function<bool(std::pair<long long int, int>, std::pair<long long int, int>)>]' 569 | priority_queue(const _Alloc& __a) | ^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:569:9: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_queue.h: In substitution of 'template<class _Tp, class _Sequence, class _Compare> template<class _Alloc> using std::priority_queue<_Tp, _Sequence, _Compare>::_Uses = typename std::enable_if<std::uses_allocator<_Sequence, _Alloc>::value>::type [with _Alloc = main()::<lambda(std::pair<long long int, int>&, std::pair<long long int, int>&)>; _Tp = std::pair<long long int, int>; _Sequence = std::vector<std::pair<long long int, int> >; _Compare = std::function<bool(std::pair<long long int, int>, std::pair<long long int, int>)>]': /usr/include/c++/14/bits/stl_queue.h:567:33: required from here
s947328726
p03786
C++
#include <iostream> using namespace std; int main(){ int n; cin >> n; long long a[100000]; for(int i = 0; i < n; i++){ cin >> a[i]; } sort(a,a+n); long long sum = 0; int cnt = 0; for(int i = 0; i < n; i++){ sum += a[i]; if(i==n-1){ cnt++; continue; } if(sum*2 >= a[i+1]){ cnt++; }else{ cnt = 0; } } cout << cnt << endl; }
a.cc: In function 'int main()': a.cc:12:5: error: 'sort' was not declared in this scope; did you mean 'short'? 12 | sort(a,a+n); | ^~~~ | short
s033535672
p03786
C++
#include <bits/stdc++.h> #define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++) #define rrep(i,a,b) for(long long int i=(a);i<(b);i++) #define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--) #define all(v) (v).begin(), (v).end() #define pb(q) push_back(q) #define Abs(a,b) max(a,b)-min(a,b) #define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;} #define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;} #define Cout(x) cout<<(x)<<endl #define POSSIBLE(condition) if(condition){cout << "POSSIBLE" << endl;}else{cout << "IMPOSSIBLE" << endl;} #define Possible(condition) if(condition){cout << "Possible" << endl;}else{cout << "Impossible" << endl;} #define possible(condition) if(condition){cout << "possible" << endl;}else{cout << "impossible" << endl;} #define Size(n) (n).size() typedef long long ll; using namespace std; const int INF = 1e9,MOD = 1e9 + 7,ohara=1e6; const ll LINF = 1e18; /*--------------------------------------------------------------- long long int kaizyo(long long int hh){ cmp=1; while(hh>1){ cmp=(cmp*hh)%MOD; hh--; } return cmp; } long long int ruizyo(long long int aa, long long int bb){ if(aa==0){ return 1; } else if(aa%2==0){ long long int tt=ruizyo(aa/2,bb); return (tt*tt)%MOD; } else{ return (ruizyo(aa-1,bb)*bb)%MOD; } }フェルマ-のア --------------------------------------------------------------- while(x!=0){ sum+=x%10; / x/=10; } 各桁の和 --------------------------------------------------------------- pair<int,int> p[100000]; cin >> tmp; p[i]=make_pair(tmp,i); cout << p[i].second+1 << endl;//ペアの右側つまりiを出力 --------------------------------------------------------------- bool f[100001];//1000000以下の素数を調べよう! rrep(i,2,100001){ f[i]=false; } rrep(i,2,100001){ if(!f[i]){ for(int j=i+i;j<=100000;j+=i){ f[j]=true; } } } for(int i=3;i<=100000;i+=2){ if(!f[i]){ c[i]++; } } --------------------------------------------------------------- long long gcd(long long aaa,long long bbb){ if(bbb==0){ return aaa; } return gcd(bbb,aaa%bbb); } long long lcm(long long aaa,long long bbb){ long long g = gcd(aaa,bbb); return aaa/g * bbb; }左から最大公約数と最小公倍数 --------------------------------------------------------------- long long int prime_cnt[10000]; for(int i=2;i*i<=n;i++){ while(n%i==0){ n/=i; prime_cnt[i]+=1; } if(n>1){ prime_cnt[n]+=1; break; } }ある数nを素因数分解しましょう --------------------------------------------------------------- debug: cout<<"i: "<<i<<" j: "<<j<<" cnt: "<<cnt<<"\n"; ---------------------------------------------------------------*/ long long int n,cnt=0,ans=0,a[ohara],b,c,d,cmp,cmpp,m,h,w,x,y,sum[ohara],pos; int dy[]={1,0,-1,0}; int dx[]={0,1,0,-1}; string alph("abcdefghijklmnopqrstuvwxyz"),s; bool fl=true; struct edge{int to,cost;}; //-------------------------↓↓↓↓↓↓------------------------ int main(void){ cin.tie(0); ios::sync_with_stdio(false); cin>>n; rep(i,n)cin>>a[i]; sort(a,a+n); rep(i,n){ sum[i]=a[i]; } rep(i,n-1){ sum[i+1]+=sum[i]; } reverse(a,a+n); rep(i,n){ // cnt+=a[i]; if((sum[i-1]*2>=a[i]){ ans++; } } Cout(ans+1); return 0; }
a.cc: In function 'int main()': a.cc:140:33: error: expected ')' before '{' token 140 | if((sum[i-1]*2>=a[i]){ | ~ ^ | ) a.cc:143:8: error: expected primary-expression before '}' token 143 | } | ^
s348584685
p03786
C
#include<stdio.h> #include<algorithm> using namespace std; int main() { int i,n,a[100005],temp=1; long long sum; scanf("%d",&n); for(i=0;i<n;i++) scanf("%d",&a[i]); sort(a,a+n); sum=(long long)a[0]; for(i=1;i<n;i++) { if(sum*2<=(long long)a[i]) { temp=1; sum+=(long long)a[i]; } else { temp++; sum+=(long long)a[i]; } } printf("%d\n",temp); }
main.c:2:9: fatal error: algorithm: No such file or directory 2 | #include<algorithm> | ^~~~~~~~~~~ compilation terminated.
s250058038
p03786
C
#include<stdio.h> #include<algorithm> using namespace std; int main() { int a[100003]; int i,j,n,k,sum,m,flag; while(scanf("%d",&n)!=EOF) { for(i=0;i<n;i++) { scanf("%d",&a[i]); } sum=0; sort(a,a+n); k=0; for(i=0;i<n-1;i++) { k+=a[i]; m=k; for(j=i+1;j<n;j++) { flag=1; if(a[j]>(2*m)) { flag=0; break; } m+=a[j]; } if(flag==1) sum++; } printf("%d\n",sum+1); } return 0; }
main.c:2:9: fatal error: algorithm: No such file or directory 2 | #include<algorithm> | ^~~~~~~~~~~ compilation terminated.
s705076400
p03786
C++
#include<stdio.h> #include<math.h> #include<algorithm> #include<queue> #include<deque> #include<string> #include<string.h> #include<vector> #include<set> #include<map> #include<stdlib.h> using namespace std; const long long mod=1000000007; const long long inf=mod*mod; const long long d2=500000004; int b[110000]; int main(){ int a; scanf("%d",&a); for(int i=0;i<a;i++)scanf("%d",b+i); std::sort(b,b+a); long long now=0; for(int i=0;i<a;i++)now+=b[i]; int ret=0; for(int i=a-1;i>=0;i--){ if(b[i+1]>now*2)break; ret++; now-=b[i]; } printf("%d\n",ret); } #include<stdio.h> #include<math.h> #include<algorithm> #include<queue> #include<deque> #include<string> #include<string.h> #include<vector> #include<set> #include<map> #include<stdlib.h> using namespace std; const long long mod=1000000007; const long long inf=mod*mod; const long long d2=500000004; int b[110000]; int main(){ int a; scanf("%d",&a); for(int i=0;i<a;i++)scanf("%d",b+i); std::sort(b,b+a); long long now=0; for(int i=0;i<a;i++)now+=b[i]; int ret=0; for(int i=a-1;i>=0;i--){ if(b[i+1]>now*2)break; ret++; now-=b[i]; } printf("%d\n",ret); }
a.cc:44:17: error: redefinition of 'const long long int mod' 44 | const long long mod=1000000007; | ^~~ a.cc:13:17: note: 'const long long int mod' previously defined here 13 | const long long mod=1000000007; | ^~~ a.cc:45:17: error: redefinition of 'const long long int inf' 45 | const long long inf=mod*mod; | ^~~ a.cc:14:17: note: 'const long long int inf' previously defined here 14 | const long long inf=mod*mod; | ^~~ a.cc:46:17: error: redefinition of 'const long long int d2' 46 | const long long d2=500000004; | ^~ a.cc:15:17: note: 'const long long int d2' previously defined here 15 | const long long d2=500000004; | ^~ a.cc:47:5: error: redefinition of 'int b [110000]' 47 | int b[110000]; | ^ a.cc:16:5: note: 'int b [110000]' previously declared here 16 | int b[110000]; | ^ a.cc:48:5: error: redefinition of 'int main()' 48 | int main(){ | ^~~~ a.cc:17:5: note: 'int main()' previously defined here 17 | int main(){ | ^~~~
s262361173
p03786
C++
#include <bits/stdc++.h> using namespace std; #define int long long typedef long long ll; typedef unsigned long long ull; typedef unsigned __int128 HASH; typedef pair<int,int> pii; typedef pair<ll, ll> pll; typedef pair<ull, ull> pullull; typedef pair<ll,int> plli; typedef pair<double, int> pdbi; typedef pair<int,pii> pipii; typedef pair<ll,pll> plpll; typedef vector<int> vi; typedef vector<ll> vll; typedef vector<vi> vvi; typedef vector<vvi> vvvi; typedef vector<pii> vpii; typedef vector<vector<int>> mat; #define rep(i,n) for (int i=0;i<(n);i++) #define rep2(i,a,b) for (int i=(a);i<(b);i++) #define rrep(i,n) for (int i=(n);i>0;i--) #define rrep2(i,a,b) for (int i=(a);i>b;i--) #define pb push_back #define fi first #define se second #define all(a) (a).begin(),(a).end() #define rall(a) (a).rbegin(),(a).rend() const ll hmod1 = 999999937; const ll hmod2 = 1000000000 + 9; const int INF = 1<<30; const ll mod = 1000000000 + 7; const int dx4[4] = {1, 0, -1, 0}; const int dy4[4] = {0, 1, 0, -1}; const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1}; const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1}; const double pi = 3.141592653589793; #define addm(X, Y) (X) = ((X) + ((Y) % mod) + mod) % mod int n; int a[100000 + 5]; int sum[100000 + 5]; signed main(){ cin.tie(0); ios::sync_with_stdio(false); cin >> n; rep(i, n) { cin >> a[i]; } sort(a, a + n); rep(i, n) { sum[i] = a[i] + sum[max(0, i - 1)]; //cout << sum[i] << endl; } int ans = 1; rrep2(i, n - 2, -1) { if (2 * sum[i] < a[i + 1]) break; ans++; } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:57:32: error: no matching function for call to 'max(int, long long int)' 57 | sum[i] = a[i] + sum[max(0, 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:57:32: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 57 | sum[i] = a[i] + sum[max(0, 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:57:32: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 57 | sum[i] = a[i] + sum[max(0, i - 1)]; | ~~~^~~~~~~~~~
s286014439
p03786
C++
#include <bits/stdc++.h> using namespace std; #define x first #define y second #define dbg(x) cout << #x << '=' << x << '\n'; #define ll long long #define pi pair<int,int> #define pl pair<long long,long long> #define lg length() #define pb push_back ifstream in("file.in"); ofstream out("file.out"); #define MAXN 100005 #define INF 1000000005 #define LINF 1000000000000000005 long long n,a[100005]; bool good(int x){ long long s=0; for(int i=1;i<=min(x,n);i++) s+=a[i]; for(int i=x+1;i<=n;i++){ if(2*s>=a[i]) s+=a[i]; else return 0; } return 1; } int32_t main(){ ios_base :: sync_with_stdio(0); cin >> n; for(int i=1;i<=n;i++) cin >> a[i]; sort(a+1,a+n+1); int p=0; for(int i=(1<<17);i;i/=2){ if(good(p+i)) continue; else p+=i; } if(good(p+1)) p++; cout << n-p+1; }
a.cc: In function 'bool good(int)': a.cc:21:23: error: no matching function for call to 'min(int&, long long int&)' 21 | for(int i=1;i<=min(x,n);i++) s+=a[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: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:21:23: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 21 | for(int i=1;i<=min(x,n);i++) s+=a[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: /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:21:23: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 21 | for(int i=1;i<=min(x,n);i++) s+=a[i]; | ~~~^~~~~
s546844677
p03786
C++
// 簡易競プロテンプレ #include <bits/stdc++.h> #define ll long long using namespace std; ll n; ll a[114514], s[114514]; bool ok(int m){ if (m<0) return false; if (m>=n) return true; ll w = s[m+1]; for(int i=m+1;i<n;i++){ if (w * 2 < a[i]) return false; w += a[i]; } return true; } int main(void){ cin >> n; for(int i=0;i<n;i++) cin >> a[i]; sort(&a[0], &a[n]); for(int i=0;i<n;i++) s[i+1] = s[i] + a[i]; int mini = 0, maxi = n; while(1){ int med = (mini + maxi + rand()%2)/2; if (ok(med-1)) {maxi = med-1;} else if (!ok(med)) {mini = med+1;} else break; } cout << med << endl; return 0; }
a.cc: In function 'int main()': a.cc:30:10: error: 'med' was not declared in this scope 30 | cout << med << endl; | ^~~
s071387575
p03786
C++
// 簡易競プロテンプレ #include <bits/stdc++.h> #define ll long long using namespace std; ll n; ll a[114514], s[114514]; bool ok(int m){ if (m<0) return false; if (m>=n) return true; ll w = s[m+1]; for(int i=m+1;i<n;i++){ if (w * 2 < a[i]) return false; w += a[i]; } return true; } int main(void){ cin >> n; for(int i=0;i<n;i++) cin >> a[i]; sort(a.begin(), a.end()); for(int i=0;i<n;i++) s[i+1] = s[i] + a[i]; int mini = 0, maxi = n; while(1){ int med = (mini + maxi + rand()%2)/2; if (ok(med-1)) {maxi = med-1;} else if (!ok(med)) {mini = med+1;} else break; } cout << med << endl; return 0; }
a.cc: In function 'int main()': a.cc:20:9: error: request for member 'begin' in 'a', which is of non-class type 'long long int [114514]' 20 | sort(a.begin(), a.end()); | ^~~~~ a.cc:20:20: error: request for member 'end' in 'a', which is of non-class type 'long long int [114514]' 20 | sort(a.begin(), a.end()); | ^~~ a.cc:30:10: error: 'med' was not declared in this scope 30 | cout << med << endl; | ^~~
s040152601
p03786
Java
package spring; import java.util.*; public class ColorfulCreatures { public static void main(String[] args) { // TODO Auto-generated method stub Scanner s=new Scanner(System.in); int N=s.nextInt(); double A[]=new double[N]; double B=0;; int i=0; int count=1; for(i=0;i<N;i++){ A[i]=s.nextInt(); } Arrays.sort(A); B=A[0]; for(i=0;i<N-1;i++){ if(A[i+1]/B<=2){ count++; B+=A[i+1]; }else{ count=1; B+=A[i+1]; } } System.out.print(count); } }
Main.java:5: error: class ColorfulCreatures is public, should be declared in a file named ColorfulCreatures.java public class ColorfulCreatures { ^ 1 error
s289361716
p03786
Java
import java.util.Scanner; public class main { public static void main(String[] args) { // TODO Auto-generated method stub Scanner s=new Scanner(System.in); int N=s.nextInt(); double A[]=new double[N]; double B[]=new double[N]; int i=0,j=0; int color=0; int count=0; for(i=0;i<N;i++){ A[i]=s.nextInt(); B[i]=A[i]; } for(i=N;i>=2;i--){ for(j=0;j<i-1;j++){ if(A[j]>A[j+1]){ B[j+1]=A[j]; B[j]=A[j+1]; A[j]=B[j]; A[j+1]=B[j+1]; } } } for(i=0;i<N;i++){ count=0; for(j=0;j<N;j++){ if(B[j]/B[i]<=2.0&&i!=j){ B[i]+=B[j]; count++; } } B[i]=A[i]; if(count==N-1){ color++; } } System.out.print(color); } }
Main.java:3: error: class main is public, should be declared in a file named main.java public class main { ^ 1 error
s971055163
p03786
Java
import java.util.Scanner; public class ColorfulCreatures { public static void main(String[] args) { // TODO Auto-generated method stub Scanner s=new Scanner(System.in); int N=s.nextInt(); double A[]=new double[N]; double B[]=new double[N]; int i=0,j=0; int color=0; int count=0; for(i=0;i<N;i++){ A[i]=s.nextInt(); B[i]=A[i]; } for(i=N;i>=2;i--){ for(j=0;j<i-1;j++){ if(A[j]>A[j+1]){ B[j+1]=A[j]; B[j]=A[j+1]; A[j]=B[j]; A[j+1]=B[j+1]; } } } for(i=0;i<N;i++){ count=0; for(j=0;j<N;j++){ if(B[j]/B[i]<=2.0&&i!=j){ B[i]+=B[j]; count++; } } B[i]=A[i]; if(count==N-1){ color++; } } System.out.print(color); } }
Main.java:3: error: class ColorfulCreatures is public, should be declared in a file named ColorfulCreatures.java public class ColorfulCreatures { ^ 1 error
s659994796
p03786
Java
package spring; import java.util.Scanner; public class ColorfulCreatures { public static void main(String[] args) { // TODO Auto-generated method stub Scanner s=new Scanner(System.in); int N=s.nextInt(); double A[]=new double[N]; double B[]=new double[N]; int i=0,j=0; int color=0; int count=0; for(i=0;i<N;i++){ A[i]=s.nextInt(); B[i]=A[i]; } for(i=N;i>=2;i--){ for(j=0;j<i-1;j++){ if(A[j]>A[j+1]){ B[j+1]=A[j]; B[j]=A[j+1]; A[j]=B[j]; A[j+1]=B[j+1]; } } } for(i=0;i<N;i++){ count=0; for(j=0;j<N;j++){ if(B[j]/B[i]<=2.0&&i!=j){ B[i]+=B[j]; count++; } } B[i]=A[i]; if(count==N-1){ color++; } } System.out.print(color); } }
Main.java:5: error: class ColorfulCreatures is public, should be declared in a file named ColorfulCreatures.java public class ColorfulCreatures { ^ 1 error
s941535304
p03786
Java
package spring; import java.util.Scanner; public class ColorfulCreatures { public static void main(String[] args) { // TODO Auto-generated method stub Scanner s=new Scanner(System.in); int N=s.nextInt(); double A[]=new double[N]; double B[]=new double[N]; int i=0,j=0; int color=0; int count=0; for(i=0;i<N;i++){ A[i]=s.nextInt(); B[i]=A[i]; } for(i=N;i>=2;i--){ for(j=0;j<i-1;j++){ if(A[j]>A[j+1]){ B[j+1]=A[j]; B[j]=A[j+1]; A[j]=B[j]; A[j+1]=B[j+1]; } } } for(i=0;i<N;i++){ count=0; for(j=0;j<N;j++){ if(B[j]/B[i]<=2.0&&i!=j){ B[i]+=B[j]; count++; } } B[i]=A[i]; if(count==N-1){ color++; } } System.out.print(color); } }
Main.java:5: error: class ColorfulCreatures is public, should be declared in a file named ColorfulCreatures.java public class ColorfulCreatures { ^ 1 error
s107040072
p03786
Java
import java.util.Scanner; public class Main { public static void main(String[] args) { // TODO 自動生成されたメソッド・スタブ Scanner scan = new Scanner(System.in); int n = scan.nextInt(); int a[] = new int[n]; int b[] = new int[n]; int total = 0; for(int i=0;i<n;i++){ a[i]=scan.nextInt(); b[i]=a[i]; total +=a[i]; } int size; int ans = 0; for(int i=0;i<n;i++){ size = a[i]; for(int j=0;j<n;j++){ if(size*2 >= a[j] && a[j] != 0 && j != i){ size += a[j]; a[j] = 0; j = 0; } if(size == total){ ans++; break; } } for(int k=0;k<n;k++){ a[k]=b[k]; } } System.out.println(ans); }
Main.java:47: error: reached end of file while parsing } ^ 1 error
s786899412
p03786
Java
import java.util.Arrays; import java.util.Scanner; public class creatures { public static void main(String[] args) { // TODO Auto-generated method stub Scanner s = new Scanner(System.in); int n = s.nextInt(); int[] arr = new int[n]; for (int i = 0; i < n; i++) { arr[i] = s.nextInt(); } Arrays.sort(arr); int count = 1; long curr = arr[0]; for (int j = 1; j < n; j++) { if ( 2 * curr >=arr[j] ) { count++; } else { count = 1; } curr += arr[j]; } System.out.println(count); } }
Main.java:5: error: class creatures is public, should be declared in a file named creatures.java public class creatures { ^ 1 error
s283010701
p03786
C++
//#include "stdafx.h" #include <iostream> #include <vector> #include <algorithm> using namespace std; #define int long long #define REP(N,i) for(int i = 0;i < N; i++) #define RREP(N, i) for(int i = N - 1; 0 <= i;i--) #define DUMPI(i) cout << i << endl; #define DUMPII(i,j) cout << i << "," << j << endl; int N; int A[101010]; bool Ab[101010] = { false }; signed main() { cin >> N; REP(N, i) cin >> A[i]; sort(A, A + N); int size, color, monsCnt; RREP(N, i) { memset(Ab, false, N); color = i; monsCnt = N - 1; size = A[i]; Ab[i] = true; RREP(N, j) { //DUMPII(A[i], A[j]); if (!Ab[j] && i != j && A[j] <= size * 2) { size += A[j]; Ab[j] = true; monsCnt--; } } if (monsCnt != 0) { cout << N - i << endl; return 0; } } cout << N << endl; return 0; }
a.cc: In function 'int main()': a.cc:25:17: error: 'memset' was not declared in this scope 25 | memset(Ab, false, N); | ^~~~~~ a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 4 | #include <algorithm> +++ |+#include <cstring> 5 |
s064338261
p03786
C++
typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> P; int N; int A[100000]; int cnt; void solve() { cin >> N; rep(i, N) { cin >> A[i]; } sort(A, A+N); cnt = N; int i; ll sum = 0; bool flag; for(i = 0; i < N - 1; i++) { sum += A[i]; if(sum * 2 < A[i + 1]) { flag = true; break; } } if(i == N - 1 && flag == false) { cnt = N; } else { cnt = N - (i + 1); } cout << cnt << endl; } int main() { solve(); return 0; }
a.cc:3:9: error: 'pair' does not name a type 3 | typedef pair<int, int> P; | ^~~~ a.cc: In function 'void solve()': a.cc:10:3: error: 'cin' was not declared in this scope 10 | cin >> N; | ^~~ a.cc:11:7: error: 'i' was not declared in this scope 11 | rep(i, N) { | ^ a.cc:11:3: error: 'rep' was not declared in this scope 11 | rep(i, N) { | ^~~ a.cc:14:3: error: 'sort' was not declared in this scope; did you mean 'short'? 14 | sort(A, A+N); | ^~~~ | short a.cc:31:3: error: 'cout' was not declared in this scope 31 | cout << cnt << endl; | ^~~~ a.cc:31:18: error: 'endl' was not declared in this scope 31 | cout << cnt << endl; | ^~~~
s575282906
p03786
C++
#include<ctime> #include<iostream> #include<algorithm> #include<cstdio> #include<cstdlib> #include<cmath> #include<cstring> #include<cassert> #include<string> #include<sstream> #include<fstream> #include<deque> #include<queue> #include<vector> #include<map> #include<list> #include<stack> #include<set> #include<bitset> #include<iomanip> #include<utility> #include<functional> #include<cctype> #include<cerrno> #include<cfloat> #include<ciso646> #include<climits> #include<clocale> #include<complex> #include<csetjmp> #include<csignal> #include<cstdarg> #include<cstddef> #include<cwchar> #include<cwctype> #include<exception> #include<locale> #include<numeric> #include<new> #include<stdexcept> #include<limits> using namespace std; #define ll long long #define INF 1e9 #define rep(i,n) for(int (i)=0;(i)<n;i++) #define REP(i,n) for(int (i)=1;(i)<=n;i++) #define mk(a,b) make_pair(a,b) #define fi first #define se second #define pii pair<int,int> const int maxn=100005; int n,ans; int a[maxn]; int main() { scanf("%d",&n); rep(i,n)scanf("%d",&a[i]); sort(a,a+n); ll cur=0; rep(i,n-1) { cur+=a[i]; if((ll)a[i+1]>cur*2)ans++,cur=0; } printf("%d",n-ans); return 0; }
a.cc: In function 'int main()': a.cc:66:20: error: '\U0000ff08ll\U0000ff09a' was not declared in this scope 66 | if((ll)a[i+1]>cur*2)ans++,cur=0; | ^~~~~~~
s929342347
p03786
C++
3 3 1 4
a.cc:1:1: error: expected unqualified-id before numeric constant 1 | 3 | ^
s211809532
p03786
C++
#include <iostream> #include <vector> #include <algorithm> using namespace std; typedef long long ll; int main() { ll N, m = -1; vector<int> A; cin >> N; for (int i=0; i<N; i++) { int tmp; cin >> tmp; m = max(m, tmp); A.push_back(tmp); } sort(A.begin(), A.end()); ll ans = N, now = 0; while (2 * A[now] < m) { ll can = A[now]; for (int comp=now+1; comp<N; comp++) { if (A[comp] <= 2 * can) { can += A[comp]; } else { ans -= (comp - now); A[comp] += can; now = comp; break; } if (comp == N-1) { now = N-1; break; } } } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:15:12: error: no matching function for call to 'max(ll&, int&)' 15 | m = max(m, tmp); | ~~~^~~~~~~~ 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:15:12: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 15 | m = max(m, tmp); | ~~~^~~~~~~~ /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:15:12: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 15 | m = max(m, tmp); | ~~~^~~~~~~~
s129157018
p03786
C++
#include <bits/stdc++.h> using namespace std; const int maxn = 100005; struct creature { int color, size; }; int n; creature a[maxn]; int ok[maxn]; int sum[maxn]; int cmp(creature x, creature y) { return x.size < y.size; } void work() { memset(ok, 0, sizeof ok); memset(sum, 0, sizeof sum); sort(a+1, a+n+1, cmp); for(int i=1; i<=n; i++) sum = sum[i-1] + a[i].size; ok[a[n].color] = 1; for(int i=n-1; i>=1; i--) { if(ok[a[i+1].color] && sum[i]*2 >= a[i+1].size) ok[a[i].color] = 1; else return; } } int main() { cin >> n; for(int i=1; i<=n; i++) { cin >> a[i].size; a[i].color = i; } work(); int cnt = 0; for(int i=1; i<=n; i++) if(ok[i]) cnt++; cout << cnt << endl; return 0; }
a.cc: In function 'void work()': a.cc:23:37: error: incompatible types in assignment of 'int' to 'int [100005]' 23 | for(int i=1; i<=n; i++) sum = sum[i-1] + a[i].size; | ~~~~^~~~~~~~~~~~~~~~~~~~~~
s930533915
p03786
C
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <math.h> #include <stdlib.h> #define MOD 1000000007 void input_array(int how_data,int *data); int get_random(int min, int max); int factorial(int n); int qsort_09(const int *sys1 , const int *sys2); int qsort_90(const int *sys1 , const int *sys2); int main(void){ int how_data; scanf("%d",&how_data); int size_data[how_data]; input_array(how_data,size_data); //1匹ずつに対して生き残れるか判定 //食べられる魚を食べて食べられなくなったら× 自分だけで〇 //ソートしたほうがいいやつ //累積和で計算量減らす qsort(size_data,how_data,sizeof(int),(int (*)(const void *,const void *))qsort_09); int loop1,loop2; int ans=1;//最後の一匹(最大)は絶対残れる long int ruisekiwa=0; for(loop1=0;loop1<how_data-1;loop1++){ int now_size=size_data[loop1]+ruisekiwa;//自分より小さい=間違いなく食える loop2=loop1+1; //自分の次 while(1){ if(loop2==how_data-1){ ans++; //printf("OK:%d size:%d\n",loop1,size_data[loop1]); break; }else if(now_size*2>=size_data[loop2]){ now_size+=size_data[loop2]; loop2++; }else{ break; } } ruisekiwa+=size_data[loop1]; } printf("%d\n",ans); return 0; }
/usr/bin/ld: /tmp/cccg1AH7.o: in function `main': main.c:(.text+0x82): undefined reference to `input_array' /usr/bin/ld: main.c:(.text+0x93): undefined reference to `qsort_09' collect2: error: ld returned 1 exit status
s018649308
p03786
C++
#include <iostream> #include <string> #include <vector> #include <map> #include <cstdio> #include <utility> using namespace std; int main() { int n; cin >> n; vector<long long> a(n); for(int i = 0; i < n; i++) { cin >> a[i]; } sort(a.begin(), a.end()); //累積わ vector<long long > b(n); b[0] = a[0]; for(int i = 1; i < n; i++) { b[i] = a[i] + b[i-1]; //cout << "i: " << i <<" " << b[i] << endl; } int cnt =0; for(int i = n-2; i >= 0; i--) { if(b[i] * 2>= a[i+1]) { cnt++; }else { //cout << b[i] <<" " << a[i+1] << endl; break; } } cout << cnt + 1 << endl; return 0; }
a.cc: In function 'int main()': a.cc:18:3: error: 'sort' was not declared in this scope; did you mean 'short'? 18 | sort(a.begin(), a.end()); | ^~~~ | short
s797764951
p03786
C++
#include <iostream> #include <vector> using namespace std; typedef long long lli; lli n; vector<lli> a; lli sum = 0; int main(int argc, char const *argv[]) { cin >> n; a = vector<lli> (n); for(lli i = 0;i < n;i++) cin >> a[i]; sort(a.begin(),a.end()); lli j; for(lli i = 0;i < n;i++){ if(sum * 2 < a[i]) j = i; sum += a[i]; } cout << n-j << endl; return 0; }
a.cc: In function 'int main(int, const char**)': a.cc:12:5: error: 'sort' was not declared in this scope; did you mean 'short'? 12 | sort(a.begin(),a.end()); | ^~~~ | short
s016787538
p03787
C++
#include <bits/stdc++.h> #include "../lib/data_structure/union_find.hpp" using namespace std; #define SZ(x) (int)(x.size()) #define REP(i, n) for(int i=0;i<(n);++i) #define FOR(i, a, b) for(int i=(a);i<(b);++i) #define RREP(i, n) for(int i=(int)(n);i>=0;--i) #define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i) #define ALL(a) (a).begin(),(a).end() #define DUMP(x) cerr<<#x<<" = "<<(x)<<endl #define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl; using ll = long long; using vi = vector<int>; using vvi = vector<vi>; using vll = vector<ll>; using vvll = vector<vll>; using P = pair<int, int>; const double eps = 1e-8; const ll MOD = 1000000007; const int INF = INT_MAX / 2; const ll LINF = LLONG_MAX / 2; template <typename T1, typename T2> bool chmax(T1 &a, const T2 &b) { if(a < b) {a = b; return true;} return false; } template <typename T1, typename T2> bool chmin(T1 &a, const T2 &b) { if(a > b) {a = b; return true;} return false; } template<typename T1, typename T2> ostream& operator<<(ostream &os, const pair<T1, T2> p) { os << p.first << ":" << p.second; return os; } template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { REP(i, SZ(v)) { if(i) os << " "; os << v[i]; } return os; } vi col; map<int, bool> notnibu; void sch(int now, int prev, int nowcol, const vvi &g, UnionFind &uf) { col[now] = nowcol; for(auto &nxt: g[now]) { if(nxt == prev) continue; if(col[nxt] == nowcol) { notnibu[uf.root(now)] = true; return; } else if(col[nxt] == -1) { sch(nxt, now, !nowcol, g, uf); if (notnibu[uf.root(now)]) return; } } } int main() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(10); ll n, m; cin >> n >> m; vvi g(n); UnionFind uf(n); REP(i, m) { int a, b; cin >> a >> b; a--; b--; g[a].push_back(b); g[b].push_back(a); uf.unite(a, b); } col.resize(n, -1); int id = 0; REP(i, n) { if(col[i] != -1) continue; sch(i, -1, 0, g, uf); id++; } ll a = 0, b = 0, c = 0; map<int, bool> one; REP(i, n) { if(uf.size(i) == 1) { one[uf.root(i)] = true; c++; } } vector<bool> sel(n); REP(i, n) { int e = uf.root(i); if(e == -1) continue; if(one[e] || sel[e]) continue; else if(notnibu[e]) b++; else a++; sel[e] = true; } cout << (a + b) * (a + b) + a * a + n * n - (n - c) * (n - c) << endl; }
a.cc:2:10: fatal error: ../lib/data_structure/union_find.hpp: No such file or directory 2 | #include "../lib/data_structure/union_find.hpp" | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ compilation terminated.
s792227953
p03787
C++
#include <bits/stdc++.h> #include "../lib/data_structure/union_find.hpp" using namespace std; #define SZ(x) (int)(x.size()) #define REP(i, n) for(int i=0;i<(n);++i) #define FOR(i, a, b) for(int i=(a);i<(b);++i) #define RREP(i, n) for(int i=(int)(n);i>=0;--i) #define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i) #define ALL(a) (a).begin(),(a).end() #define DUMP(x) cerr<<#x<<" = "<<(x)<<endl #define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl; using ll = long long; using vi = vector<int>; using vvi = vector<vi>; using vll = vector<ll>; using vvll = vector<vll>; using P = pair<int, int>; const double eps = 1e-8; const ll MOD = 1000000007; const int INF = INT_MAX / 2; const ll LINF = LLONG_MAX / 2; template <typename T1, typename T2> bool chmax(T1 &a, const T2 &b) { if(a < b) {a = b; return true;} return false; } template <typename T1, typename T2> bool chmin(T1 &a, const T2 &b) { if(a > b) {a = b; return true;} return false; } template<typename T1, typename T2> ostream& operator<<(ostream &os, const pair<T1, T2> p) { os << p.first << ":" << p.second; return os; } template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { REP(i, SZ(v)) { if(i) os << " "; os << v[i]; } return os; } vi col; vi vid; map<int, bool> notnibu; void sch(int now, int prev, int nowcol, int id, const vvi &g) { col[now] = nowcol; vid[now] = id; for(auto &nxt: g[now]) { if(nxt == prev) continue; if(col[nxt] == nowcol) { notnibu[id] = true; return; } else if(col[nxt] == -1) { sch(nxt, now, !nowcol, id, g); if (notnibu[id]) return; } } } int main() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(10); ll n, m; cin >> n >> m; vvi g(n); UnionFind uf(n); REP(i, m) { int a, b; cin >> a >> b; a--; b--; g[a].push_back(b); g[b].push_back(a); uf.unite(a, b); } col.resize(n, -1); vid.resize(n, -1); int id = 0; REP(i, n) { if(col[i] != -1) continue; sch(i, -1, 0, id, g); id++; } ll a = 0, b = 0, c = 0; map<int, bool> one; REP(i, n) { if(uf.size(i) == 1) { one[vid[i]] = true; c++; } } vector<bool> sel(n); for(auto &e: vid) { if(one[e] || sel[e]) continue; else if(notnibu[e]) b++; else a++; sel[e] = true; } cout << (a + b) * (a + b) + a * a + n * n - (n - c) * (n - c) << endl; }
a.cc:2:10: fatal error: ../lib/data_structure/union_find.hpp: No such file or directory 2 | #include "../lib/data_structure/union_find.hpp" | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ compilation terminated.
s077209011
p03787
C++
// warm heart, wagging tail,and a smile just for you! // ███████████ // ███╬╬╬╬╬╬╬╬╬╬███ // ███╬╬╬╬╬████╬╬╬╬╬╬███ // ███████████ ██╬╬╬╬╬████╬╬████╬╬╬╬╬██ // █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██ // ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██ // ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██ // ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████ // ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██ // ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███ // ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██ // ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████ // █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████ // ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██ // ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██ // ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███ // ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████ // ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████ // ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██ // ██████████████ ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████ // ███████ █████ ███████████████████ // #include "bits/stdc++.h" using namespace std; #define INF (1<<30) #define LINF (1LL<<60) #define fs first #define sc second #define int long long #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i) #define REP(i,n) FOR(i,0,(n)) #define RREP(i,n) RFOR(i,0,(n)) #define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr) #define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr) #define range(i,a,b) ((a)<=(i) && (i)<(b)) #define debug(x) cout << #x << " = " << (x) << endl #define SP << " " << 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;} #define MSB(x) (63-__builtin_clzll(x)) #define pcnt(x) (__builtin_popcountll(x)) #define parity(i,j) (i&(1LL<<j)) typedef pair<int,int> P; typedef tuple<int,int,int> T; typedef vector<int> vec; typedef vector<vector<int>> mat; const int N = 1e5+10; vector<int> edge[N],color(N,0); bool isBip(int no){ if(!color[no]) color[no] = 1; bool flag = true; for(auto to:edge[no]){ if(color[no]==color[to]) flag = false; else if(!color[to]){ color[to] = -color[no]; if(!isBip(to)) flag = false; } } return flag; } signed main(){ ios::sync_with_stdio(false); cin.tie(0); int n,m; cin >> n >> m; REP(_,m){ int x,y; cin >> x >> y; x--; y--; edge[x].emplace_back(y); edge[y].emplace_back(x); } int x = 0, y = 0, z = 0; REP(i,n){ if(color[i]) continue; if(!edge[i].size()) z++; else{ if(isBip(i)) x++; else y++; } } REP(i,n) assert(used[i]==1); cout << 2*n*z-z*z + 2*y*(x+y) - y*y + 2*x*x << endl; return 0; }
In file included from /usr/include/c++/14/cassert:44, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:106, from a.cc:24: a.cc: In function 'int main()': a.cc:90:19: error: 'used' was not declared in this scope 90 | REP(i,n) assert(used[i]==1); | ^~~~
s498418895
p03787
C++
#include<iostream> #include<algorithm> #include<vector> #include<queue> using namespace std; typedef long long ll; #define int ll vector<ll> node[100005]; ll groups[100005]={0},group_num[100005]={0},col[100005]={0}; bool used[100005]={0}; bool dfs(ll pos,ll k,ll cl){ used[pos]=true; groups[pos]=k; col[pos]=cl; ll nc=cl%2; nc++; bool res=true; for(int i=0;i<node[pos].size();i++){ ll to=node[pos][i]; if(!used[to]){ used[to]=true; groups[to]=k; col[to]=nc; dfs(to,k,nc); } if(col[to]!=nc){ res=false; } } return res; } signed main(){ ll n,m; cin>>n>>m; for(int i=0;i<m;i++){ ll s,t; cin>>s>>t; node[s].push_back(t); node[t].push_back(s); } for(int i=1;i<=n;i++) used[i]=false; ll cnct_num=0,a=0,b=0,c=0; for(int i=1;i<=n;i++){ if(!used[i]){ used[i]=true; group[i]=cnct_num; if(node[i].size()==0) { c++; cnct_num++; continue; } bool f=dfs(i,cnct_num,1); if(f) { b++; // cout<<"B"<<i<<endl; } else{ a++; // cout<<"A"<<i<<endl; } cnct_num++; } } cout<<a*a+2*a*b+2*b*b+c*(n*2-c)<<endl; }
a.cc: In function 'int main()': a.cc:46:7: error: 'group' was not declared in this scope; did you mean 'groups'? 46 | group[i]=cnct_num; | ^~~~~ | groups
s066881471
p03787
C++
#include <bits/stdc++.h> using namespace std; using ll = long long; using Pi = pair<int, int>; using Pl = pair<ll, ll>; using vint = vector<int>; using vll = vector<ll>; template<typename T> using uset = unordered_set<T>; template<typename T1, typename T2> using umap = unordered_map<T1, T2>; constexpr int INF = (1 << 30) - 1; constexpr ll LLINF = 1LL << 60; constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1}; constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}; constexpr char el = '\n'; constexpr int mod = 1000000007; template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); } template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); } 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; } int N, M; vector<vint> G(100005); bool flag[100005] = {}; int color[100005]; int dfs(int v, int c = 0) { int ret = 1; if (color[v] != -1 && c != color[v]) return (0); color[v] = c; if (flag[v]) return (1); flag[v] = true; //cout << v << endl; for (auto &u : G[v]) ret &= dfs(u, 1 - c); return (ret); } int main() { cin >> N >> M; fill_n(color, 100005, -1); for (int i = 0; i < M; i++) { int u, v; cin >> u >> v; --u, --v; G[u].push_back(v); G[v].push_back(u); } int colorable = 0; int cnt = 0; for (int i = 0; i < N; i++) { if (!flag[i]) { if (G[i].size > 0) colorable += dfs(i); cnt++; } } ll ans = cnt * cnt; ans += (ll)colorable * (colorable - 1); cout << ans << endl; return (0); }
a.cc: In function 'int main()': a.cc:53:38: 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 '()' ?) 53 | if (G[i].size > 0) colorable += dfs(i); | ()
s323620464
p03787
C++
#include<bits/stdc++.h> using namespace std; typedef pair<int, int> P; typedef long long ll; ll N, M, color[100001], A, B, C; vector<int> G[100001]; bool dfs(int now, int c){ color[now] = c; for(int i=0; i<G[now].size(); i++){ if(color[G[now][i]] != -1){ if(color[G[now][i]] == c) return false; continue; }else{ if(!dfs(G[now][i], 1-c)) return false; } } return true; } void dfs2(int now){ color[now] = 2; for(not i=0; i<G[now].size(); i++){ if(color[G[now][i]] == 2) dfs2(G[now][i]); } return; } int main(){ cin >> N >> M; for(int i=0; i<M; i++){ int u, v; cin >> u >> v; u--; v--; G[u].push_back(v); G[v].push_back(u); } for(int i=0; i<N; i++) color[i] = -1; for(int i=0; i<N; i++){ if(!G[i].size()) A++; else{ if(color[i] != -1) continue; if(dfs(i, 0)) B++; else{C++; dfs2(i); } } } ll ans = 2*B*B + A*A + 2*A*(N-A) + 2*B*C + C*C; cout << ans << endl; return 0; }
a.cc: In function 'void dfs2(int)': a.cc:24:11: error: 'i' was not declared in this scope 24 | for(not i=0; i<G[now].size(); i++){ | ^
s188845094
p03787
C++
#include<bits/stdc++.h> using namespace std; typedef pair<int, int> P; typedef long long ll; ll N, M, color[100001], A, B, C; vector<int> G[100001]; bool dfs(int now, int c){ color[now] = c; for(int i=0; i<G[now].size(); i++){ if(color[G[now][i]] != -1){ if(color[G[now][i]] == c) return false; continue; }else{ if(!dfs(G[now][i], 1-c)) return false; } } return true; } void dfs2(int now){ color[now] = 1; for(not i=0; i<G[now].size(); i++){ if(color[G[now][i]] == -1) dfs2(G[now][i]); } return; } int main(){ cin >> N >> M; for(int i=0; i<M; i++){ int u, v; cin >> u >> v; u--; v--; G[u].push_back(v); G[v].push_back(u); } for(int i=0; i<N; i++) color[i] = -1; for(int i=0; i<N; i++){ if(!G[i].size()) A++; else{ if(color[i] != -1) continue; if(dfs(i, 0)) B++; else{C++; dfs2(i); } } } ll ans = 2*B*B + A*A + 2*A*(N-A) + 2*B*C + C*C; cout << ans << endl; return 0; }
a.cc: In function 'void dfs2(int)': a.cc:24:11: error: 'i' was not declared in this scope 24 | for(not i=0; i<G[now].size(); i++){ | ^
s933627242
p03787
C++
#include<bits/stdc++.h> using namespace std; typedef pair<int, int> P; typedef long long ll; int N, M, color[100001], cnt, cnt1, cnt2, used[100001]; vector<int> G[100001]; bool dfs(int now, int c){ color[now] = c; if(c == 1) cnt1++; else cnt2++; for(int i=0; i<G[now].size(); i++){ if(color[G[now][i]] != -1){ if(color[G[now][i]] == c) return false; }else{ if(!dfs(G[now][i], 1-c)) return false; } } return true; } void dfs2(int now){ used[now] = 1; cnt++; for(int i=0; i<G[now].size(); i++){ if(used[G[now][i]] == 0){ dfs(G[now][i]); } } return; } int main(){ cin >> N >> M; // 二部グラフの連結成分それぞれについて、(1の個数と0の個数) 二部グラフでない連結成分のそれぞれの要素数 vector<P> nibu, not; for(int i=0; i<N; i++){ int u, v; cin >> u >> v; u--; v--; G[u].push_back(v); G[v].push_back(u); } for(int i=0; i<N; i++) color[i] = -1; for(int i=0; i<N; i++){ cnt = 0, cnt1 = 0; cnt2 = 0; if(color[i] != -1) continue; if(dfs(i, 0)) nibu.push_back(P(cnt1, cnt2)); else{ dfs2(i); not.push_back(cnt); } } return 0; }
a.cc: In function 'void dfs2(int)': a.cc:28:28: error: too few arguments to function 'bool dfs(int, int)' 28 | dfs(G[now][i]); | ~~~^~~~~~~~~~~ a.cc:9:6: note: declared here 9 | bool dfs(int now, int c){ | ^~~ a.cc: In function 'int main()': a.cc:37:25: error: expected unqualified-id before 'not' token 37 | vector<P> nibu, not; | ^~~ a.cc:51:28: error: expected primary-expression before '.' token 51 | not.push_back(cnt); | ^
s565468991
p03787
C++
//#include<bits/stdc++.h> #include<iostream> #include <vector> #include <algorithm> #include <cmath> #include <set> #include <queue> #include <deque> #include <map> #include <stack> #include<bitset> #include<list> #include<cassert> #include<numeric> using namespace std; const long long N = 1000 * 100 + 5; long long c[N], n, cnt = 0, is, bi, nbi; vector < long long > graph[N]; bool mark[N], b; void dfs(long long v) { mark[v] = 1; for (auto u : graph[v]) { if (c[u] == c[v]) { b = 0; } if (!mark[u]) { c[u] = 1 - c[v]; dfs(u); } } return; } void dfs2() { memset(c , -1 , sizeof c); for(long long i = 0; i < n; i++) { if(!mark[i]) { cnt++; b = 1; c[i] = 1; if(graph[i].size()) { dfs(i); if(b) { bi++; } else { nbi++; } } else { is++; } } } return; } int main() { long long m; cin >> n >> m; for (long long i = 0; i < m; i++) { long long u, v; cin >> u >> v; graph[u - 1].push_back(v - 1); graph[v - 1].push_back(u - 1); } dfs2(); cout << (bi + nbi) * (bi + nbi) + bi * bi + 2 * n * is - is * is << endl; }
a.cc: In function 'void dfs2()': a.cc:41:9: error: 'memset' was not declared in this scope 41 | memset(c , -1 , sizeof c); | ^~~~~~ a.cc:15:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 14 | #include<numeric> +++ |+#include <cstring> 15 |
s757136007
p03787
C++
#include<bits/stdc++.h> //ios::sync_with_stdio(false);cin.tie(0); using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<int,int> pii; typedef pair<pii,int> ppii; typedef pair<int,pii> pipi; typedef pair<ll,ll> pll; typedef pair<pll,ll> ppll; typedef pair<ll,pll> plpl; typedef tuple<ll,ll,ll> tl; ll mod=1000000007; ll mod2=998244353; ll mod3=1000003; ll mod4=998244853; ll inf=1000000000000000000; double pi=2*acos(0); #define rep(i,m,n) for(ll i=m;i<n;i++) #define rrep(i,n,m) for(ll i=n;i>=m;i--) int dh[4]={1,-1,0,0}; int dw[4]={0,0,1,-1}; int ddh[8]={-1,-1,-1,0,0,1,1,1}; int ddw[8]={-1,0,1,-1,1,-1,0,1}; ll lmax(ll a,ll b){ if(a<b)return b; else return a; } ll lmin(ll a,ll b){ if(a<b)return a; else return b; } ll gcd(ll a,ll b){ if(a<b)swap(a,b); if(b==0)return a; if(a%b==0)return b; return gcd(b,a%b); } ll Pow(ll n,ll k){ ll ret=1; ll now=n; while(k>0){ if(k&1)ret*=now; now*=now; k/=2; } return ret; } int main(){ int n,m;cin>>n>>m; vector<int> v[n+1]; int a[m],b[m]; map<pii,int> mp; rep(i,0,m){ cin>>a[i]>>b[i]; v[a[i]].push_back(b[i]); v[b[i]].push_back(a[i]); mp[{a[i],b[i]}]=i; mp[{b[i],a[i]}]=i; } bool used[n+1],usedm[m]; fill(used,used+n+1,false); fill(usedm,usedm+m,false); ll num[3]; fill(num,num+3,0); int col[n+1]; fill(col,col+n+1,-1); rep(i,1,n+1){ if(used[i])continue; queue<int> q;q.push(i); used[i]=true; col[now]=0; int c=0; int cnt=0; while(q.size()>0){ int now=q.front();q.pop(); cnt++; rep(j,0,v[now].size()){ int ne=v[now][j]; int nec=col[now]^1; if(col[ne]>=0){ if(col[ne]!=nec){ c=1; } } else{ col[ne]=nec; q.push(ne); used[ne]=true; } } } if(cnt==0)num[0]++; else if(c==1)num[1]++; else num[2]++; } ll ans=2*num[2]*num[2]; ans+=num[1]*num[1]+2*num[1]*num[2]; ans+=2*n*num[0]-num[0]*num[0]; cout<<ans<<endl; }
a.cc: In function 'int main()': a.cc:72:9: error: 'now' was not declared in this scope; did you mean 'pow'? 72 | col[now]=0; | ^~~ | pow
s810678508
p03787
C++
/*Program from Luvwgyx*/ #include<cstdio> #include<cstring> #include<algorithm> using namespace std; const int maxn=1e5+10; const int maxm=2e5+10; struct node{int to,nxt;}e[maxm<<1]; int tot,p,c,d,flag,head[maxn],deg[maxn],vis[maxn],col[maxn]; int read(){ int x=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} return x*f; } void print(ll x){ if(x<0)putchar('-'),x=-x; if(x>9)print(x/10); putchar(x%10+'0'); } void write(ll x){print(x);puts("");} void add(int u,int v){e[++tot].to=v;e[tot].nxt=head[u];head[u]=tot;deg[u]++;} void insert(int u,int v){add(u,v);add(v,u);} void dfs(int x){ for(int i=head[x],v=e[i].to;i;i=e[i].nxt,v=e[i].to){ if(!vis[v])col[v]=col[x]^1,vis[v]=1,dfs(v); else if(col[v]^col[x]^1)c-=flag,d+=flag,flag=0; } } int main(){ int n=read(),m=read(); for(int i=1;i<=m;i++)insert(read(),read()); for(int i=1;i<=n;i++){ if(!deg[i])p++; else if(!vis[i])flag=1,c++,vis[i]=1,dfs(i); }write(p*n+p*(n-p)+d*d+c*2*(d+c)); return 0; }
a.cc:16:6: error: variable or field 'print' declared void 16 | void print(ll x){ | ^~~~~ a.cc:16:12: error: 'll' was not declared in this scope 16 | void print(ll x){ | ^~ a.cc:21:6: error: variable or field 'write' declared void 21 | void write(ll x){print(x);puts("");} | ^~~~~ a.cc:21:12: error: 'll' was not declared in this scope 21 | void write(ll x){print(x);puts("");} | ^~ a.cc: In function 'int main()': a.cc:36:6: error: 'write' was not declared in this scope; did you mean 'fwrite'? 36 | }write(p*n+p*(n-p)+d*d+c*2*(d+c)); | ^~~~~ | fwrite
s121072927
p03787
C++
#include<cstdio> #include<algorithm> using namespace std; typedef long long ll; ll dsu[100005],vis[100005],m,x,y,z,u,v,n,i,sum=0,tmp=0; vector<ll> s[100005]; void dfs(int p,int f) { ll i,v; sum++; vis[p]=1; for(i=0;i<s[p].size();i++) { v=s[p][i]; if(vis[v]&&v!=f)tmp=1; if(vis[v])continue; dfs(v,p); } } int main() { scanf("%d%d",&n,&m); for(i=1;i<=n;i++)dsu[i]=i; for(i=1;i<=m;i++) { scanf("%d%d",&u,&v); s[u].push_back(v); s[v].push_back(u); } for(i=1;i<=n;i++) { if(vis[i])continue; sum=tmp=0; dfs(i,0); if(sum==1)x++; else { if(tmp==0)y++; else z++; } } printf("%lld\n",2LL*n*x-x*x+2LL*y*y+z*z+2LL*z*y); return 0; }
a.cc:6:1: error: 'vector' does not name a type 6 | vector<ll> s[100005]; | ^~~~~~ a.cc: In function 'void dfs(int, int)': a.cc:12:19: error: 's' was not declared in this scope 12 | for(i=0;i<s[p].size();i++) | ^ a.cc: In function 'int main()': a.cc:27:17: error: 's' was not declared in this scope 27 | s[u].push_back(v); | ^
s079184082
p03787
C++
#include<bits/stdc++.h> #define ll long long #define ull unsigned ll #define uint unsigned #define db long double #define pii pair<int,int> #define pll pair<ll,ll> #define IT iterator #define PB push_back #define MK make_pair #define LB lower_bound #define UB upper_bound #define EB emplace_back #define fi first #define se second #define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++) #define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--) #define UPD(x,y) (((x)+=(y))>=mo?x-=mo:233) #define CLR(a,v) memset(a,v,sizeof(a)); #define CPY(a,b) memcpy(a,b,sizeof(a)); #define LS3 k*2,l,mid #define RS3 k*2+1,mid+1,r #define LS5 k*2,l,mid,x,y #define RS5 k*2+1,mid+1,r,x,y #define GET pushdown(k);int mid=(l+r)/2 #define INF ((1ll<<60)-233) #define sqr(x) ((x)*(x)) #define debug puts("wzpkking") using namespace std; const int N=100005; int n,m,I,P,Q,co[N]; vector<int> e[N]; bool check(int x,int fa,int c){ co[x]=c; bool ans=1; for (auto i:e[x]){ if (i==fa) continue; if (!co[i]) ans&=check(i,x,-c); else ans&=(c!=co[i]); } return ans; } int main(){ scanf("%d%d",&n,&m); For(i,1,m){ int x,y; scanf("%d%d",&x,&y); e[x].PB(y); e[y].PB(x); } For(i,1,n){ if (co[i]) continue; if (e[i].size()==0) I++; else if (check(i,0,-)) Q++; else P++; } printf("%lld\n",1ll*I*I+2ll*I*(n-I)+1ll*P*P+2LL*P*Q+2ll*Q*Q); }
a.cc: In function 'int main()': a.cc:57:37: error: expected primary-expression before ')' token 57 | else if (check(i,0,-)) Q++; | ^
s329047923
p03787
C++
dtjhyjykdtjhyjykdtjhyjykdtjhyjykdtjhyjykdtjhyjykdtjhyjykdtjhyjykdtjhyjykdtjhyjykdtjhyjyk
a.cc:1:1: error: 'dtjhyjykdtjhyjykdtjhyjykdtjhyjykdtjhyjykdtjhyjykdtjhyjykdtjhyjykdtjhyjykdtjhyjykdtjhyjyk' does not name a type 1 | dtjhyjykdtjhyjykdtjhyjykdtjhyjykdtjhyjykdtjhyjykdtjhyjykdtjhyjykdtjhyjykdtjhyjykdtjhyjyk | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
s450850282
p03787
C++
#include <cstdio> #include <cstring> #include <algorithm> #define repu(i,x,y) for (int i=x; i<=y; ++i) using namespace std; typedef long long LL; int n,m,cnt0,cnt1,cnt2,c[100100]; struct edge { int v; edge *nxt; } pool[400100],*tp=pool,*fst[100100]; int getint() { char ch; while (!isdigit(ch=getchar())); int x=ch-'0'; for (; isdigit(ch=getchar()); x=x*10+ch-'0'); return x; } bool dfs(int x,int w) { if (c[x]!=-1) return c[x]!=w; c[x]=w; for (edge *i=fst[x]; i; i=i->nxt) if (dfs(i->v,w^1)) return 1; return 0; } int main() { for (scanf("%d%d",&n,&m); m--;) { int u=getint(),v=getint(); *tp=(edge){v,fst[u]},fst[u]=tp++; *tp=(edge){u,fst[v]},fst[v]=tp++; } memset(c,255,sizeof(c)); repu(i,1,n) if (c[i]==-1) if (!fst[i]) ++cnt0; else dfs(i,0)?++cnt2:++cnt1; LL ans=LL(cnt0)*n*2-LL(cnt0)*cnt0; ans+=LL(cnt1)*cnt1*2; ans+=LL(cnt1*2+cnt2)*cnt2; printf("%lld\n",ans); return 0; }
a.cc: In function 'int getint()': a.cc:18:13: error: 'isdigit' was not declared in this scope 18 | while (!isdigit(ch=getchar())); | ^~~~~~~ a.cc:20:12: error: 'isdigit' was not declared in this scope 20 | for (; isdigit(ch=getchar()); x=x*10+ch-'0'); | ^~~~~~~
s991251664
p03787
C++
#include<bits/stdc++.h> #define MAXN 1000000+10 using namespace std; int n,m,I,P,Q; int tot,head[MAXN],to[MAXN],nxt[MAXN],linker[MAXN]; bool f,vis[MAXN]; void add(int x,int y){ cnt++; to[cnt]=y; nxt[cnt]=head[x]; head[x]=cnt; } void dfs(int x,int fa){ vis[x]=true; linker[x]=linker[fa]^1; for(int i=head[x];i;i=nxt[i]){ int y=to[i]; if(y!=fa){ if(vis[y]) if(linker[x]==linker[y])f=true; else dfs(y,x); } } } int main(){ scanf("%d%d",&n,&m); int x,y; for(int i=0;i<m;i++){ cin>>x>>y; add(x,y); add(y,x); } for(int i=1;i<=n;i++) if(!vis[i]){ if(!head[i]){ I++; vis[i]=true; continue; } f=false; dfs(i,0); if(f)P++; else Q++; } long long ans=2LL*I*n-1LL*I*I+1LL*P*P+2LL*P*Q+2LL*Q*Q; printf("%lld\n",ans); return 0; }
a.cc: In function 'void add(int, int)': a.cc:8:9: error: 'cnt' was not declared in this scope; did you mean 'int'? 8 | cnt++; | ^~~ | int
s730822776
p03787
C++
#include<cmath> #include<math.h> #include<ctype.h> #include<algorithm> #include<bitset> #include<cassert> #include<cctype> #include<cerrno> #include<cfloat> #include<ciso646> #include<climits> #include<clocale> #include<complex> #include<csetjmp> #include<csignal> #include<cstdarg> #include<cstddef> #include<cstdio> #include<cstdlib> #include<cstring> #include<ctime> #include<cwchar> #include<cwctype> #include<deque> #include<exception> #include<fstream> #include<functional> #include<iomanip> #include<ios> #include<iosfwd> #include<iostream> #include<istream> #include<iterator> #include<limits> #include<list> #include<locale> #include<map> #include<memory> #include<new> #include<numeric> #include<ostream> #include<queue> #include<set> #include<sstream> #include<stack> #include<stdexcept> #include<streambuf> #include<string> #include<typeinfo> #include<utility> #include<valarray> #include<vector> #include<string.h> #include<stdlib.h> #include<stdio.h> using namespace std; int n,m,I,P,Q; int cnt,head[100010],to[400010],next[400010],linker[100010]; bool f,vis[100010]; void add(int x,int y) { cnt++; to[cnt]=y; next[cnt]=head[x]; head[x]=cnt; } void dfs(int x,int fa) { vis[x]=true; linker[x]=linker[fa]^1; for (int i=head[x];i;i=next[i]) { int y=to[i]; if (y!=fa) { if (vis[y]) { if (linker[x]==linker[y]) { f=true; } continue; } else { dfs(y,x); } } } } int main() { scanf("%d%d",&n,&m); int x,y; for (int i=0;i<m;i++) { scanf("%d%d",&x,&y); add(x,y); add(y,x); } for (int i=1;i<=n;i++) { if (!vis[i]) { if (head[i]) { I++; vis[i]=true; continue; } f=false; dfs(i,0); if (f) { P++; } else { Q++; } } } long long ans=2LL*I*n-1LL*I*I+1LL*P*P+2LL*P*Q+2LL*Q*Q; printf("%lld\n",ans); return 0; }
a.cc: In function 'void add(int, int)': a.cc:64:9: error: reference to 'next' is ambiguous 64 | next[cnt]=head[x]; | ^~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:66, from /usr/include/c++/14/bits/specfun.h:43, from /usr/include/c++/14/cmath:3906, 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:58:33: note: 'int next [400010]' 58 | int cnt,head[100010],to[400010],next[400010],linker[100010]; | ^~~~ a.cc: In function 'void dfs(int, int)': a.cc:71:32: error: reference to 'next' is ambiguous 71 | for (int i=head[x];i;i=next[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:58:33: note: 'int next [400010]' 58 | int cnt,head[100010],to[400010],next[400010],linker[100010]; | ^~~~
s306594510
p03787
C++
#include<cmath> #include<math.h> #include<ctype.h> #include<algorithm> #include<bitset> #include<cassert> #include<cctype> #include<cerrno> #include<cfloat> #include<ciso646> #include<climits> #include<clocale> #include<complex> #include<csetjmp> #include<csignal> #include<cstdarg> #include<cstddef> #include<cstdio> #include<cstdlib> #include<cstring> #include<ctime> #include<cwchar> #include<cwctype> #include<deque> #include<exception> #include<fstream> #include<functional> #include<iomanip> #include<ios> #include<iosfwd> #include<iostream> #include<istream> #include<iterator> #include<limits> #include<list> #include<locale> #include<map> #include<memory> #include<new> #include<numeric> #include<ostream> #include<queue> #include<set> #include<sstream> #include<stack> #include<stdexcept> #include<streambuf> #include<string> #include<typeinfo> #include<utility> #include<valarray> #include<vector> #include<string.h> #include<stdlib.h> #include<stdio.h> using namespace std; int n,m,I,P,Q; int cnt,head[100010],to[400010],next[400010],linker[100010]; bool f,vis[100010]; void add(int x,int y) { cnt++; to[cnt]=y; next[cnt]=head[x]; head[x]=cnt; } void dfs(int x,int fa) { vis[x]=true; linker[x]=linker[fa]^1; for (int i=head[x];i;i=next[i]) { int y=to[i]; if (y!=fa) { if (vis[y]) { if (linker[x]==linker[y]) { f=true; } continue; } else { dfs(y,x); } } } } int main() { scanf("%d%d",&n,&m); int x,y; for (int i=0;i<m;i++) { scanf("%d%d",&x,&y); add(x,y); add(y,x); } for (int i=1;i<=n;i++) { if (!vis[i]) { if (head[i]) { I++; vis[i]=true; continue; } f=false; dfs(i,0); if (f) { P++; } else { Q++; } } } long long ans=2LL*I*n-1LL*I*I+1LL*P*P+2LL*P*Q+2LL*Q*Q; printf("%lld\n",ans); return 0; }
a.cc: In function 'void add(int, int)': a.cc:64:9: error: reference to 'next' is ambiguous 64 | next[cnt]=head[x]; | ^~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:66, from /usr/include/c++/14/bits/specfun.h:43, from /usr/include/c++/14/cmath:3906, 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:58:33: note: 'int next [400010]' 58 | int cnt,head[100010],to[400010],next[400010],linker[100010]; | ^~~~ a.cc: In function 'void dfs(int, int)': a.cc:71:32: error: reference to 'next' is ambiguous 71 | for (int i=head[x];i;i=next[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:58:33: note: 'int next [400010]' 58 | int cnt,head[100010],to[400010],next[400010],linker[100010]; | ^~~~
s189918063
p03787
C++
#include <cstdio> #include <iostream> #include <vector> #include <queue> #include <set> #include <algorithm> using namespace std; const int maxn = 100000 + 5; typedef long long int64; int n, m; vector<int> adj[maxn]; int visited[maxn]; int color[maxn]; int64 solve() { fill(visited, visited+n+1, 0); int64 sp = 0; int64 p2 = 0; int64 pc = 0; for (int i = 1; i <= n; ++i) if (visited[i] == 0) { visited[i] = 1; color[i] = 0; queue<int> q; q.push(i); int mixed = 0; int cnt = 0; while (!q.empty()) { int curr = q.front(); q.pop(); ++cnt; for (auto& next: adj[curr]) { if (visited[next]) mixed |= color[curr] == color[next]; else color[next] = color[curr] ^ 1, visited[next] = 1, q.push(next); } } if (cnt == 1) ++sp; else if (mixed) ++pc; else ++p2; } int64 ans = 0; ans += sp * n * 2 - sp - sp * (sp - 1); ans += 2 * p2 + pc; ans += 2 * p2 * (p2 - 1); ans += pc * (pc - 1); ans += 2 * p2 * pc; // cout << sp << " " << p2 << " " << pc << endl; return ans; } int64 bf() { int64 ans = 0; set<pair<int, int>> st; for (int i = 1; i <= n; ++i) for (int j = 1; j <= n; ++j) if (st.count({i, j}) == 0) { pair<int, int> now{i, j}; queue<pair<int, int>> q; q.push(now); st.insert(now); ++ans; while (!q.empty()) { auto curr = q.front(); q.pop(); for (auto& a: adj[curr.first]) for (auto& b: adj[curr.second]) if (st.count({a, b}) == 0) { st.insert({a,b}); q.push({a,b}); } } } return ans; } int main() { while (scanf("%d%d", &n, &m) == 2) { for (int i = 0; i < m; ++i) { int u, v; scanf("%d%d", &u, &v); adj[u].push_back(v); adj[v].push_back(u); } cout << solve() << endl; // cerr << bf() << endl;#include <cstdio> #include <iostream> #include <vector> #include <queue> #include <set> #include <algorithm> using namespace std; const int maxn = 100000 + 5; typedef long long int64; int n, m; vector<int> adj[maxn]; int visited[maxn]; int color[maxn]; int64 solve() { fill(visited, visited+n+1, 0); int64 sp = 0; int64 p2 = 0; int64 pc = 0; for (int i = 1; i <= n; ++i) if (visited[i] == 0) { visited[i] = 1; color[i] = 0; queue<int> q; q.push(i); int mixed = 0; int cnt = 0; while (!q.empty()) { int curr = q.front(); q.pop(); ++cnt; for (auto& next: adj[curr]) { if (visited[next]) mixed |= color[curr] == color[next]; else color[next] = color[curr] ^ 1, visited[next] = 1, q.push(next); } } if (cnt == 1) ++sp; else if (mixed) ++pc; else ++p2; } int64 ans = 0; ans += sp * n * 2 - sp - sp * (sp - 1); ans += 2 * p2 + pc; ans += 2 * p2 * (p2 - 1); ans += pc * (pc - 1); ans += 2 * p2 * pc; // cout << sp << " " << p2 << " " << pc << endl; return ans; } int64 bf() { int64 ans = 0; set<pair<int, int>> st; for (int i = 1; i <= n; ++i) for (int j = 1; j <= n; ++j) if (st.count({i, j}) == 0) { pair<int, int> now{i, j}; queue<pair<int, int>> q; q.push(now); st.insert(now); ++ans; while (!q.empty()) { auto curr = q.front(); q.pop(); for (auto& a: adj[curr.first]) for (auto& b: adj[curr.second]) if (st.count({a, b}) == 0) { st.insert({a,b}); q.push({a,b}); } } } return ans; } int main() { while (scanf("%d%d", &n, &m) == 2) { for (int i = 0; i < m; ++i) { int u, v; scanf("%d%d", &u, &v); adj[u].push_back(v); adj[v].push_back(u); } cout << solve() << endl; cerr << bf() << endl; for (int i = 1; i <= n; ++i) adj[i].clear(); } return 0; } for (int i = 1; i <= n; ++i) adj[i].clear(); } return 0; }
a.cc: In function 'int main()': a.cc:102:12: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse] 102 | int64 solve() | ^~ a.cc:102:12: note: remove parentheses to default-initialize a variable 102 | int64 solve() | ^~ | -- a.cc:102:12: note: or replace parentheses with braces to value-initialize a variable a.cc:103:1: error: a function-definition is not allowed here before '{' token 103 | { | ^ a.cc:140:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse] 140 | int64 bf() | ^~ a.cc:140:9: note: remove parentheses to default-initialize a variable 140 | int64 bf() | ^~ | -- a.cc:140:9: note: or replace parentheses with braces to value-initialize a variable a.cc:141:1: error: a function-definition is not allowed here before '{' token 141 | { | ^ a.cc:164:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse] 164 | int main() | ^~ a.cc:164:9: note: remove parentheses to default-initialize a variable 164 | int main() | ^~ | -- a.cc:164:9: note: or replace parentheses with braces to value-initialize a variable a.cc:165:1: error: a function-definition is not allowed here before '{' token 165 | { | ^
s385042760
p03787
C
int n, m, a[200009], b[200009], e[400009], c[100009], s[100009], cnt, col[100009]; bool dfs(int pos) { bool ret = true; cnt++; for (int i = c[pos]; i < c[pos + 1]; i++) { if (col[e[i]] == col[pos]) ret = false; if (col[e[i]] == 0) { col[e[i]] = 3 - col[pos]; if (!dfs(e[i])) ret = false; } } return ret; } void reader(int *x) { for (char c = getchar_unlocked(); 48 <= c && c <= 57; c = getchar()) *x = *x * 10 + c - 48; } int main() { reader(&n); reader(&m); for (int i = 0; i < m; i++) { reader(&a[i]); reader(&b[i]); c[--a[i]]++; c[--b[i]]++; } for (int i = 0; i < n; i++) s[i + 1] = s[i] + c[i]; c[0] = 0; for (int i = 0; i < n; i++) c[i + 1] = s[i + 1]; for (int i = 0; i < m; i++) e[s[a[i]]++] = b[i], e[s[b[i]]++] = a[i]; int c0 = 0, c1 = 0, c2 = 0; for (int i = 0; i < n; i++) { if (col[i] == 0) { col[i] = 1; cnt = 0; bool res = dfs(i); if (cnt == 1) c0++; else if (!res) c1++; else c2++; } } printf("%lld\n", 1LL * (c1 + c2) * (c1 + c2) + 1LL * c2 * c2 + 1LL * n * n - 1LL * (n - c0) * (n - c0)); return 0; }
main.c:2:1: error: unknown type name 'bool' 2 | bool dfs(int pos) { | ^~~~ main.c:1:1: note: 'bool' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>' +++ |+#include <stdbool.h> 1 | int n, m, a[200009], b[200009], e[400009], c[100009], s[100009], cnt, col[100009]; main.c: In function 'dfs': main.c:3:9: error: unknown type name 'bool' 3 | bool ret = true; cnt++; | ^~~~ main.c:3:9: note: 'bool' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>' main.c:3:20: error: 'true' undeclared (first use in this function) 3 | bool ret = true; cnt++; | ^~~~ main.c:3:20: note: 'true' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>' main.c:3:20: note: each undeclared identifier is reported only once for each function it appears in main.c:5:50: error: 'false' undeclared (first use in this function) 5 | if (col[e[i]] == col[pos]) ret = false; | ^~~~~ main.c:5:50: note: 'false' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>' main.c: In function 'reader': main.c:14:23: error: implicit declaration of function 'getchar_unlocked' [-Wimplicit-function-declaration] 14 | for (char c = getchar_unlocked(); 48 <= c && c <= 57; c = getchar()) *x = *x * 10 + c - 48; | ^~~~~~~~~~~~~~~~ main.c:14:67: error: implicit declaration of function 'getchar' [-Wimplicit-function-declaration] 14 | for (char c = getchar_unlocked(); 48 <= c && c <= 57; c = getchar()) *x = *x * 10 + c - 48; | ^~~~~~~ main.c:1:1: note: 'getchar' is defined in header '<stdio.h>'; this is probably fixable by adding '#include <stdio.h>' +++ |+#include <stdio.h> 1 | int n, m, a[200009], b[200009], e[400009], c[100009], s[100009], cnt, col[100009]; main.c: In function 'main': main.c:29:25: error: unknown type name 'bool' 29 | bool res = dfs(i); | ^~~~ main.c:29:25: note: 'bool' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>' main.c:35:9: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration] 35 | printf("%lld\n", 1LL * (c1 + c2) * (c1 + c2) + 1LL * c2 * c2 + 1LL * n * n - 1LL * (n - c0) * (n - c0)); | ^~~~~~ main.c:35:9: note: include '<stdio.h>' or provide a declaration of 'printf' main.c:35:9: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch] main.c:35:9: note: include '<stdio.h>' or provide a declaration of 'printf'
s879897723
p03787
C
#include <stdio.h> int dfs(int, int); int N, M; int edge[100010][100010]; int used[100010]; int main(void) { int i, tmp[2], single = 0, bipartite = 0, other = 0, ans = 0; scanf("%d%d", &N, &M); for (i = 0; i < M; i++) { scanf("%d%d", &tmp[0], &tmp[1]); edge[tmp[0]][tmp[1]] = 1; edge[tmp[1]][tmp[0]] = 1; } for (i = 1; i <= N; i++) { if (used[i] != 0) continue; switch (dfs(i, 1)) { case 1 : bipartite++; break; case 0 : other++; break; case -1: single++; break; } } ans += single * (N - single) * 2 + single * single; ans += other * bipartite * 2 + other * other; ans += bipartite * bipartite * 2; printf("%d\n", ans); return 0; } // 二部グラフなら1、辺がなければ-1、それ以外は0を返す int dfs(int v, int sign) { int i, single_flag = 1, res = 1; used[v] = sign; for (i = 1; i <= N; i++) { if (edge[v][i] == 1) { if (used[i] == sign) res = 0; else if (used[i] == 0) res = dfs(i, -sign); single_flag = 0; } } if (single_flag) return -1; else return res; }
/tmp/ccFkCKXz.o: in function `main': main.c:(.text+0xfa): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccFkCKXz.o /tmp/ccFkCKXz.o: in function `dfs': main.c:(.text+0x1d2): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccFkCKXz.o main.c:(.text+0x224): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccFkCKXz.o main.c:(.text+0x249): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccFkCKXz.o collect2: error: ld returned 1 exit status
s368443108
p03787
C++
#include<bits/stdc++.h> #include<unordered_map> #include<unordered_set> #include<random> using namespace std; //snuke #define fi first #define se second #define rep(i,n) for(int i = 0; i < (n); ++i) #define rrep(i,n) for(int i = 1; i <= (n); ++i) #define drep(i,n) for(int i = (n)-1; i >= 0; --i) #define gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next) #define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++) #define rng(a) a.begin(),a.end() #define maxs(x,y) x = max(x,y) #define mins(x,y) x = min(x,y) #define pb push_back #define sz(x) (int)(x).size() #define pcnt __builtin_popcount #define uni(x) x.erase(unique(rng(x)),x.end()) #define df(x) int x = in() #define dame { puts("-1"); return 0;} #define show(x) cout<<#x<<" = "<<x<<endl; #define PQ(T) priority_queue<T,vector<T>,greater<T> > #define bn(x) ((1<<x)-1) #define newline puts("") using namespace std; typedef long long int ll; typedef pair<int, int> P; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<ll> vl; typedef vector<P> vp; inline int in() { int x; scanf("%d", &x); return x; } inline void priv(vi a) { rep(i, sz(a)) printf("%d%c", a[i], i == sz(a) - 1 ? '\n' : ' '); } template<typename T>istream& operator>>(istream&i, const vector<T>&v) { rep(j, sz(v))i >> v[j]; return i; } template<typename T>string join(const vector<T>&v) { stringstream s; rep(i, sz(v))s << ' ' << v[i]; return s.str().substr(1); } template<typename T>ostream& operator<<(ostream&o, const vector<T>&v) { if (sz(v))o << join(v); return o; } template<typename T1, typename T2>istream& operator>>(istream&i, const pair<T1, T2>&v) { return i >> v.fi >> v.se; } template<typename T1, typename T2>ostream& operator<<(ostream&o, const pair<T1, T2>&v) { return o << v.fi << "," << v.se; } const int MX = 100005, INF = 1001001001; const ll LINF = 1e18; const double eps = 1e-10; vvi to; vi used; class solver{ public: int dfs(int v, int c) { if (used[v] != -1) { return used[v] == c; } used[v] = c; if (sz(to[v]) == 0) return 2; int res = 1; for (int u : to[v]) { if (!dfs(u, c ^ 1)) res = 0; } return res; } vl g(3); long long int main(int n,int m,vector<pair<int,int> > lis) { to = vvi(n); rep(i, m) { int a, b; a = lis[i].first; b = lis[i].second; to[a].pb(b); to[b].pb(a); } used = vi(n, -1); rep(i, n) { if (used[i] != -1) continue; g[dfs(i, 0)]++; } // cout<<g<<endl; ll ans = 0; ans += g[0] * g[0]; ans += g[0] * g[1] * 2; ans += g[1] * g[1] * 2; // cout<<g<<endl; ans += g[2] * n * 2; ans -= g[2] * g[2]; return ans; } }; solver snuke; #define MAX 200002 int n; int m; vector<int> v[MAX]; long long int nf; long long int bi; long long int ot; bool flag[MAX]; bool vis[MAX]; inline bool dfs(int b){ vis[b] = true; for (int i = 0; i < v[b].size(); i++){ int go = v[b][i]; if (vis[go]){ if (flag[go] == flag[b])return false; } else{ flag[go] = (flag[b] ^ true); if (dfs(go) == false)return false; } } return true; } vector<pair<int, int> > road; int main(){ cin >> n >> m; for (int i = 0; i < m; i++){ int a, b; scanf("%d%d", &a, &b); a--; b--; v[a].push_back(b); v[b].push_back(a); road.push_back(make_pair(a, b)); } for (int i = 0; i < n; i++){ if (vis[i])continue; if (v[i].size() == 0){ nf++; continue; } if (dfs(i)){ bi++; } else{ ot++; } } long long int ans = 0; ans += (long long int)(nf)*(long long int)(nf)+(long long int)(nf)*(long long int)(n-nf)*2LL; ans += bi*bi * 2LL; ans += bi*ot * 2LL; ans += ot*ot; if (nf != snuke.g[2])return 1; printf("%lld\n", ans); return 0; }
a.cc:81:14: error: expected identifier before numeric constant 81 | vl g(3); | ^ a.cc:81:14: error: expected ',' or '...' before numeric constant a.cc: In member function 'long long int solver::main(int, int, std::vector<std::pair<int, int> >)': a.cc:95:26: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 95 | g[dfs(i, 0)]++; | ^ a.cc:99:25: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 99 | ans += g[0] * g[0]; | ^ a.cc:99:32: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 99 | ans += g[0] * g[0]; | ^ a.cc:100:25: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 100 | ans += g[0] * g[1] * 2; | ^ a.cc:100:32: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 100 | ans += g[0] * g[1] * 2; | ^ a.cc:101:25: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 101 | ans += g[1] * g[1] * 2; | ^ a.cc:101:32: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 101 | ans += g[1] * g[1] * 2; | ^ a.cc:103:25: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 103 | ans += g[2] * n * 2; | ^ a.cc:104:25: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 104 | ans -= g[2] * g[2]; | ^ a.cc:104:32: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 104 | ans -= g[2] * g[2]; | ^ a.cc: In function 'int main()': a.cc:171:26: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 171 | if (nf != snuke.g[2])return 1; | ^
s074017179
p03787
C++
#include <bits/stdc++.h> using namespace std; namespace { #define all(x) begin(x), end(x) #define rall(x) rbegin(x), rend(x) #define len(x) (int)((x).size()) #define X first #define Y second #define FOR(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) #ifndef ONLINE_JUDGE #include "debug.h" #else #define DEBUG(...) #define DEBUG_2D(...) #endif // ONLINE_JUDGE typedef long long int ll; typedef long double ld; typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<ll> vll; template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>; ll expmod(ll a,ll b,ll mod) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;} template<typename T> T sqr(const T& x) { return x*x; } ll flog(const ll x) { return 63 - __builtin_clzll(x); } template<typename T> void sort(T& t) { sort(all(t)); } template<typename T> void undupe(vector<T>& v) { sort(v); v.erase(unique(all(v)), v.end()); } struct _IOS { _IOS() { ios::sync_with_stdio(0); cin.tie(0); } } _IOS; } const ll MOD = 1e9 + 9; const ll INF = 1e15; const double EPS = 1e-8; int N, M; vvi adj; vi vis; vi col; vi deg; ll comp = 0, good = 0, bad = 0, wt = 0, bk = 0; bool ok = true; void dfs(int u, int c) { vis[u] = 1; col[u] = c; if (c) wt++; else bk++; for (int v : adj[u]) { if (col[v] == c) ok = false; if (!vis[v]) dfs(v, c^1); } } int main() { cin >> N >> M; adj.resize(N); deg.resize(N); FOR(i,0,M) { int u, v; cin >> u >> v; u--, v--; adj[u].push_back(v); adj[v].push_back(u); deg[u]++, deg[v]++; } ll A = 0; FOR(i,0,N) { if (deg[i] == 0) { A++; } } vis.assign(N, 0); col.assign(N, -1); FOR(u,0,N) if (!vis[u] && !(deg[u] == 0)) { comp++; ok = true; wt = 0, bk = 0; dfs(u, 0); if (ok) good++; else bad++; } ll ans = (bad*(bad + 2*good)) + (2*good*good) + (2*N*A - A*A); cout << ans << "\n"; }
a.cc:14:10: fatal error: debug.h: No such file or directory 14 | #include "debug.h" | ^~~~~~~~~ compilation terminated.
s994203048
p03787
C
#include <cstdio> #include <list> std::list<int> G[100000]; int mark[100000]; std::list<int> cs; int iso; int dfs(int i, int c, int b){ for(int j : G[i]){ if(mark[j]&&mark[j]!=-c) b = 0; if(!mark[j]){ mark[j]=-c; b &= dfs(j, -c, b); } } return b; } int dfs0(int i, int c, int b){ iso=1; for(int j : G[i]){ if(mark[j]&&mark[j]!=-c) b = 0; if(!mark[j]){ mark[j]=-c; b &= dfs(j, -c, b); iso=0; } } return b; } long long int c(int n){ int ans=0; int ans2=0; int ans0=0; while(1){ int i, j; for(i=0;i<n;i++){ if(!mark[i]) break; } if(i==n){ ans-=ans2; return (long long) ans*ans+(long long) ans2*ans2 + (ans0 ? (long long)(2*n-iso)*iso : 0); } mark[i] = 1; ans++; j=dfs0(i, 1, 1); ans2+=j&~iso; ans0+=iso; } } int main(){ int i, n, m; std::scanf("%d%d", &n, &m); for(i=0;i<m;i++){ int a, b; std::scanf("%d%d", &a,&b); G[a-1].push_back(b-1); G[b-1].push_back(a-1); } printf("%lld\n", c(n)); return 0; }
main.c:1:10: fatal error: cstdio: No such file or directory 1 | #include <cstdio> | ^~~~~~~~ compilation terminated.
s342852126
p03787
C++
#include <bits/stdc++.h> using namespace std; #ifdef DEBUG #define debug(...) printf(__VA_ARGS__) #else #define debug(...) (void)0 #endif #define MP make_pair #define PB push_back #define LL long long #define pii pair<int,int> #define F first #define S second #define ALL(x) (x).begin(),(x).end() #define SZ(x) ((int)(x).size()) //const int inf = 0x7fffffff; //beware overflow //const LL INF = 0x7fffffffffffffff; //beware overflow #define mem(x, y) memset(x, (y), sizeof(x) ); #define IOS ios_base::sync_with_stdio(0); cin.tie(0) template<typename A, typename B> ostream& operator <<(ostream &s, const pair<A,B> &p) { return s<<"("<<p.first<<","<<p.second<<")"; } template<typename T> ostream& operator <<(ostream &s, const vector<T> &c) { s << "[ "; for (auto it : c) s << it << " "; s << "]"; return s; } template<typename T> ostream& operator << (ostream &o, const set<T> &st) { o << "{"; for (auto it=st.begin(); it!=st.end(); it++) o << (it==st.begin() ? "" : ", ") << *it; return o << "}"; } template<typename T1, typename T2> ostream& operator << (ostream &o, const map<T1, T2> &mp) { o << "{"; for (auto it=mp.begin(); it!=mp.end(); it++) { o << (it==mp.begin()?"":", ") << it->fi << ":" << it->se; } o << "}"; return o; } inline LL getint(){ LL _x=0,_tmp=1; char _tc=getchar(); while( (_tc<'0'||_tc>'9')&&_tc!='-' ) _tc=getchar(); if( _tc == '-' ) _tc=getchar() , _tmp = -1; while(_tc>='0'&&_tc<='9') _x*=10,_x+=(_tc-'0'),_tc=getchar(); return _x*_tmp; } #define maxn 100005 vector<int> G[maxn]; bool vis[maxn]; int sz; bool dfs(int u, int p=-1) { assert( !vis[u]); sz++; vis[u] = true; bool cycle=false; for(int v : G[u]) if(v!=p) { if( vis[v] ) cycle=true; else cycle |= dfs(v, u); } return cycle; } int main() { int n=getint(), m=getint(); for(int i=0;i<m;i++) { int x, y; scanf("%d %d", &x, &y); x--, y--; G[x].PB(y), G[y].PB(x); } vector<int> v; vector<bool> cy; for(int i=0;i<n;i++)if(!vis[i]) { sz=0; cy.PB( dfs(i) ); v.PB(sz); } LL cyc=0, nocyc=0, cnt1=0; for(int i=0;i<SZ(cy);i++) { if( v[i]==1 ) cnt1++; else { if(cy[i])cyc++; else nocyc++; } } assert( cnt+cnt1==SZ(v)); LL cnt=cyc+nocyc; LL cc = n-cnt1; LL ans = cyc+2*nocyc+2*( nocyc*(nocyc-1) + cnt*(cnt-1)/2 - nocyc*(nocyc-1)/2 ) + cnt1*cnt1+2*cc*cnt1; cout << ans << endl; }
In file included from /usr/include/c++/14/cassert:44, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:106, from a.cc:1: a.cc: In function 'int main()': a.cc:92:13: error: 'cnt' was not declared in this scope; did you mean 'cnt1'? 92 | assert( cnt+cnt1==SZ(v)); | ^~~
s095900397
p03787
C++
#include <iostream> #include <iomanip> #include <stdio.h> #include <set> #include <vector> #include <map> #include <cmath> #include <algorithm> #include <memory.h> #include <string> #include <sstream> #include <cstdlib> #include <ctime> #include <cassert> using namespace std; typedef long long LL; typedef pair<int,int> PII; #define MP make_pair #define PB push_back #define FF first #define SS second #define FORN(i, n) for (int i = 0; i < (int)(n); i++) #define FOR1(i, n) for (int i = 1; i <= (int)(n); i++) #define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--) #define DEBUG(X) { cout << #X << " = " << (X) << endl; } #define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; } #define MOD 1000000007 #define INF 2000000000 int GLL(LL& x) { return scanf("%lld", &x); } int GI(int& x) { return scanf("%d", &x); } const int MAXN = 100005; int color[MAXN]; int n, m, cs; bool bip; vector< vector<int> > adj; void dfs(int u) { for (auto& v : adj[u]) { if (color[v] != 0) { if (color[u] == color[v]) bip = false; } else { color[v] = 3 - color[u]; cs++; dfs(v); } } } int main() { memset(color, 0, sizeof color); GI(n); GI(m); adj.resize(n+1); FOR1(i, m) { int u, v; GI(u); GI(v); adj[u].PB(v); adj[v].PB(u); } LL odd = 0, noOdd = 0, single = 0; FOR1(i, n) { if (color[i] == 0) { color[i] = 1; cs = 1; bip = true; dfs(i); // DEBUG(i); DEBUG(bip); if (cs == 1) { single++; } else if (bip) { noOdd++; } else { odd++; } } } //DEBUG(single); //DEBUG(noOdd); //DEBUG(odd); cout << 2 * single * (n - single) + single * single + 2 * odd * noOdd + odd * odd + 2 * noOdd * noOdd << endl; return 0; } bee
a.cc:108:1: error: 'bee' does not name a type 108 | bee | ^~~
s651529836
p03788
C++
#pragma GCC optimize("Ofast") #pragma GCC optimize("no-stack-protector") #pragma GCC optimize("unroll-loops") #pragma GCC optimize("unswitch-loops") #pragma GCC optimize("fast-math") #pragma GCC optimize("section-anchors") #pragma GCC optimize("profile-reorder-functions") #pragma GCC optimize("profile-values") #pragma GCC optimize("tracer") #pragma GCC optimize("vpt") #pragma GCC optimize("rename-registers") #pragma GCC optimize("move-loop-invariants") #pragma GCC optimize("function-sections") #pragma GCC optimize("data-sections") #pragma GCC optimize("branch-target-load-optimize") #pragma GCC optimize("branch-target-load-optimize2") #pragma GCC optimize("btr-bb-exclusive") #pragma GCC target("sse2") #pragma GCC target("sse3") #pragma GCC target("ssse3") #pragma GCC target("sse4.1") #pragma GCC target("sse4.2") #pragma GCC target("avx") #pragma GCC target("avx2") #pragma GCC target("popcnt") #pragma GCC target("abm") #pragma GCC target("mmx") #pragma GCC target("tune=native") #include<bits/stdc++.h> using namespace std; #define ii pair <int, int> #define app push_back #define all(a) a.begin(), a.end() #define bp __builtin_popcountll #define ll long long #define mp make_pair #define f first #define s second #define Time (double)clock()/CLOCKS_PER_SEC const int N = 2e5 + 7; bitset <N> a, inv; int n, k; void print() { for (int i = 0; i < n; ++i) { if (a[i]) cout << 'A'; else cout << 'B'; } cout << endl; } signed main() { #ifdef HOME freopen("input.txt", "r", stdin); #else #define endl '\n' ios_base::sync_with_stdio(0); cin.tie(0); #endif cin >> n >> k; string s; cin >> s; for (int i = 0; i < n; ++i) a[i] = s[i] == 'A'; if (n == 1) { a[0] = a[0] ^ (k & 1); print(); exit(0); } while (!a[n - 1] && k) { --k; if (a[0]) { a[0] = a[0] ^ 1; } else { for (int i = 0; i + 1 < n; ++i) { if (a[i] == a[i + 1]) { a[i] = a[i] ^ 1; } } a[n - 1] = 1; } } if (k == 0) { print(); exit(0); } for (int i = 0; i < n - 1; ++i) inv[i] = 1; for (int i = 0; i < 2 * n && k; ++i) { --k; if (a[0]) { a[0] = a[0] ^ 1; } else { a ^= (a ^ (a >> 1) ^ inv) & inv; } } if (a[0] || (a[0] == a[1])) { a[0] = a[0] ^ (k & 1); } print(); }
a.cc:6:39: error: section anchors must be disabled when toplevel reorder is disabled 6 | #pragma GCC optimize("section-anchors") | ^ a.cc:8:38: warning: bad option '-fprofile-values' to pragma 'optimize' [-Wpragmas] 8 | #pragma GCC optimize("profile-values") | ^ a.cc:13:41: warning: bad option '-ffunction-sections' to pragma 'optimize' [-Wpragmas] 13 | #pragma GCC optimize("function-sections") | ^ a.cc:14:37: warning: bad option '-fdata-sections' to pragma 'optimize' [-Wpragmas] 14 | #pragma GCC optimize("data-sections") | ^ a.cc:15:51: warning: bad option '-fbranch-target-load-optimize' to pragma 'optimize' [-Wpragmas] 15 | #pragma GCC optimize("branch-target-load-optimize") | ^ a.cc:16:52: warning: bad option '-fbranch-target-load-optimize2' to pragma 'optimize' [-Wpragmas] 16 | #pragma GCC optimize("branch-target-load-optimize2") | ^ a.cc:17:40: warning: bad option '-fbtr-bb-exclusive' to pragma 'optimize' [-Wpragmas] 17 | #pragma GCC optimize("btr-bb-exclusive") | ^ In file included from /usr/include/c++/14/cassert:43, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:33, from a.cc:29: /usr/include/x86_64-linux-gnu/c++/14/bits/c++config.h:321:29: error: section anchors must be disabled when toplevel reorder is disabled 321 | inline void __terminate() _GLIBCXX_USE_NOEXCEPT | ^~~~~~~~~~~~~~~~~~~~~ /usr/include/x86_64-linux-gnu/c++/14/bits/c++config.h: In function 'void std::__terminate()': /usr/include/x86_64-linux-gnu/c++/14/bits/c++config.h:323:82: error: section anchors must be disabled when toplevel reorder is disabled 323 | void terminate() _GLIBCXX_USE_NOEXCEPT __attribute__ ((__noreturn__,__cold__)); | ^ /usr/include/x86_64-linux-gnu/c++/14/bits/c++config.h:323:82: error: section anchors must be disabled when toplevel reorder is disabled /usr/include/x86_64-linux-gnu/c++/14/bits/c++config.h: At global scope: /usr/include/x86_64-linux-gnu/c++/14/bits/c++config.h:543:29: error: section anchors must be disabled when toplevel reorder is disabled 543 | __is_constant_evaluated() _GLIBCXX_NOEXCEPT | ^~~~~~~~~~~~~~~~~ /usr/include/x86_64-linux-gnu/c++/14/bits/c++config.h:582:3: error: section anchors must be disabled when toplevel reorder is disabled 582 | _GLIBCXX_NOEXCEPT; | ^~~~~~~~~~~~~~~~~ /usr/include/x86_64-linux-gnu/c++/14/bits/c++config.h:582:3: error: section anchors must be disabled when toplevel reorder is disabled /usr/include/x86_64-linux-gnu/c++/14/bits/c++config.h:608:25: error: section anchors must be disabled when toplevel reorder is disabled 608 | __glibcxx_assert_fail() | ^ In file included from /usr/include/features.h:523, from /usr/include/x86_64-linux-gnu/c++/14/bits/os_defines.h:39, from /usr/include/x86_64-linux-gnu/c++/14/bits/c++config.h:683: /usr/include/assert.h:71:45: error: section anchors must be disabled when toplevel reorder is disabled 71 | __THROW __attribute__ ((__noreturn__)) __COLD; | ^~~~~~ /usr/include/assert.h:71:45: error: section anchors must be disabled when toplevel reorder is disabled /usr/include/assert.h:76:45: error: section anchors must be disabled when toplevel reorder is disabled 76 | __THROW __attribute__ ((__noreturn__)) __COLD; | ^~~~~~ /usr/include/assert.h:76:45: error: section anchors must be disabled when toplevel reorder is disabled /usr/include/assert.h:82:45: error: section anchors must be disabled when toplevel reorder is disabled 82 | __THROW __attribute__ ((__noreturn__)) __COLD; | ^~~~~~ /usr/include/assert.h:82:45: error: section anchors must be disabled when toplevel reorder is disabled In file included from /usr/include/c++/14/cctype:42, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:35: /usr/include/ctype.h:80:40: error: section anchors must be disabled when toplevel reorder is disabled 80 | __THROW __attribute__ ((__const__)); | ^ /usr/include/ctype.h:80:40: error: section anchors must be disabled when toplevel reorder is disabled /usr/include/ctype.h:82:40: error: section anchors must be disabled when toplevel reorder is disabled 82 | __THROW __attribute__ ((__const__)); | ^ /usr/include/ctype.h:82:40: error: section anchors must be disabled when toplevel reorder is disabled /usr/include/ctype.h:84:40: error: section anchors must be disabled when toplevel reorder is disabled 84 | __THROW __attribute__ ((__const__)); | ^ /usr/include/ctype.h:84:40: error: section anchors must be disabled when toplevel reorder is disabled /usr/include/ctype.h:108:1: error: section anchors must be disabled when toplevel reorder is disabled 108 | __exctype (isalnum); | ^~~~~~~~~ /usr/include/ctype.h:108:1: error: section anchors must be disabled when toplevel reorder is disabled /usr/include/ctype.h:109:1: error: section anchors must be disabled when toplevel reorder is disabled 109 | __exctype (isalpha); | ^~~~~~~~~ /usr/include/ctype.h:109:1: error: section anchors must be disabled when toplevel reorder is disabled /usr/include/ctype.h:110:1: error: section anchors must be disabled when toplevel reorder is disabled 110 | __exctype (iscntrl); | ^~~~~~~~~ /usr/include/ctype.h:110:1: error: section anchors must be disabled when toplevel reorder is disabled /usr/include/ctype.h:111:1: error: section anchors must be disabled when toplevel reorder is disabled 111 | __exctype (isdigit); | ^~~~~~~~~ /usr/include/ctype.h:111:1: error: section anchors must be disabled when toplevel reorder is disabled /usr/include/ctype.h:112:1: error: section anchors must be disabled when toplevel reorder is disabled 112 | __exctype (islower); | ^~~~~~~~~ /usr/include/ctype.h:112:1: error: section anchors must be disabled when toplevel reorder is disabled /usr/include/ctype.h:113:1: error: section anchors must be disabled when toplevel reorder is disabled 113 | __exctype (isgraph); | ^~~~~~~~~ /usr/include/ctype.h:113:1: error: section anchors must be disabled when toplevel reorder is disabled /usr/include/ctype.h:114:1: error: section anchors must be disabled when toplevel reorder is disabled 114 | __exctype (isprint); | ^~~~~~~~~ /usr/include/ctype.h:114:1: error: section anchors must be disabled when toplevel reorder is disabled /usr/include/ctype.h:115:1: error: section anchors must be disabled when toplevel reorder is disabled 115 | __exctype (ispunct); | ^~~~~~~~~ /usr/include/ctype.h:115:1: error: section anchors must be disabled when toplevel reorder is disabled /usr/include/ctype.h:116:1: error: section anchors must be disabled when toplevel reorder is disabled 116 | __exctype (isspace); | ^~~~~~~~~ /usr/include/ctype.h:116:1: error: section anchors must be disabled when toplevel reorder is disabled /usr/include/ctype.h:117:1: error: section anchors must be disabled when toplevel reorder is disabled 117 | __exctype (isupper); | ^~~~~~~~~ /usr/include/ctype.h:117:1: error: section anchors must be disabled when toplevel reorder is disabled /usr/include/ctype.h:118:1: error: section anchors must be disabled when toplevel reorder is disabled 118 | __exctype (isxdigit); | ^~~~~~~~~ /usr/include/ctype.h:118:1: error: section anchors must be disabled when toplevel reorder is disabled /usr/include/ctype.h:122:30: error: section anchors must be disabled when toplevel reorder is disabled 122 | extern int tolower (int __c) __THROW; | ^~~~~~~ /usr/include/ctype.h:122:30: error: section anchors must be disabled when toplevel reorder is disabled /usr/include/ctype.h:125:30: error: section anchors must be disabled when toplevel reorder is disabled 125 | extern int toupper (int __c) __THROW; | ^~~~~~~ /usr/include/ctype.h:125:30: error: section anchors must be disabled when toplevel reorder is disabled /usr/include/ctype.h:130:1: error: section anchors must be disabled when toplevel reorder is disabled 130 | __exctype (isblank); | ^~~~~~~~~ /usr/include/ctype.h:130:1: error: section anchors must be disabled when toplevel reorder is disabled /usr/include/ctype.h:135:42: error: section anchors must be disabled when toplevel reorder is disabled 135 | extern int isctype (int __c, int __mask) __THROW; | ^~~~~~~ /usr/include/ctype.h:135:42: error: section anchors must be disabled when toplevel reorder is disabled /usr/include/ctype.h:142:30: error: section anchors must be disabled when toplevel reorder is disabled 142 | extern int isascii (int __c) __THROW; | ^~~~~~~ /usr/include/ctype.h:142:30: error: section anchors must be disabled when toplevel reorder is disabled /usr/include/ctype.h:146:30: error: section anchors must be disabled when toplevel reorder is disabled 146 | extern int toascii (int __c) __THROW; | ^~~~~~~ /usr/include/ctype.h:146:30: error: section anchors must be disabled when toplevel reorder is disabled /usr/include/ctype.h:150:1: error: section anchors must be disabled when toplevel reorder is disabled 150 | __exctype (_toupper); | ^~~~~~~~~ /usr/include/ctype.h:150:1: error: section anchors must be disabled when toplevel reorder is disabled /usr/include/ctype.h:151:1: error: section anchors must be disabled when toplevel reorder
s512768300
p03788
C++
#pragma GCC optimize("O2") #pragma GCC optimize("unroll-loops") #include<bits/stdc++.h> #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define pb push_back using namespace std; using ll = long long; //using arr = array; using pi = pair<int, int>; using vi = vector<int>; using vvi = vector<vi>; using vpi = vector<pi>; using ld = long double; const int maxn = 1<<18, mod = 1e9 + 7; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int n, k; string s; void go() {//naive int i = 0, v = 1; while(i>=0&&i<n) { if(s[i] == 'A') v=-v; s[i] = s[i] == 'A' ? 'B' : 'A'; i += v; } cout << (i<0?'L':'R') << " "; } string get(int n, int k, string s) { for(auto &i : s) i -= 'A'; int l = 0, a = 0; for(int i = 0; i < k; i++) { if(s[l] == a) s[l] = !a; else { l = ++l == n ? 0 : l; a ^= 1; s[l ? l-1 : n-1] = a; } } r++; string res = ""; while(true) { res += char('A' + (s[l++]^a)); if(l == r) break; if(l == n) l = 0; } return res; } int main() { cin.tie(0)->sync_with_stdio(0); cin >> n >> k >> s; cout << (get(n, k, s)); }
a.cc: In function 'std::string get(int, int, std::string)': a.cc:39:9: error: 'r' was not declared in this scope 39 | r++; | ^
s043600183
p03788
C++
#include<iostream> #include<algorithm> #include<vector> #include<string> #include<set> #include<queue> #include<stack> #include<bitset> #include<functional> #include<map> #include<iomanip> #include<limits> #include<unordered_set> #include<cmath> #include <numeric> #include <array> #include <complex> using namespace std; //long long p = 998244353; long long p = 1000000007; #define int long long #define ll long long #define vel vector<ll> #define vvel vector<vel> #define rep(i,n) for(int i=0;i<n;i++) #define sor(v) sort(v.begin(),v.end()) #define mmax(a,b) a=max(a,b) #define mmin(a,b) a=min(a,b) #define mkp make_pair #define pin pair<int,int> #define qin pair<pin,int> #define V vector #define Endl endl #define veb vector<bool> #define fcout cout << fixed << setprecision(15) #define rev(s) reverse(s.begin(),s.end()) #define lower(h,val) lower_bound(h.begin(),h.end(),val)-h.begin() #define upper(h,val) upper_bound(h.begin(),h.end(),val)-h.begin() vel kai; vel inv_kai; int rui(int a, int n, int mod) { if (n == 0) { return 1 % mod; } int x = rui(a, n / 2, mod); x *= x; x %= mod; if (n % 2 == 1) { x *= a; x %= mod; } return x; } int root(int x, vel& pa) { if (pa[x] == -1) { return x; } int ans = root(pa[x], pa); pa[x] = ans; return ans; } bool mar(int x, int y, vel& pa) { x = root(x, pa); y = root(y, pa); if (x != y) { pa[x] = y; } return (x != y); } int gcd(int x, int y) { if (x < y) { return gcd(y, x); } if (y == 0) { return x; } return gcd(y, x % y); } int lcm(ll x, ll y) { x = abs(x); y = abs(y); return x * y / gcd(x, y); } long long modinv(long long a, long long m) { long long b = m, u = 1, v = 0; while (b) { long long t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } u %= m; if (u < 0) u += m; return u; } void make_kai(int max_kai) { kai = vel(max_kai, 1); inv_kai = kai; rep(i, max_kai - 1) { kai[i + 1] = kai[i] * (i + 1); kai[i + 1] %= p; inv_kai[i + 1] = modinv(kai[i + 1], p); } } int com(int n, int r) { if ((n < 0) || (r < 0) || (r > n)) { return 0; } int ans = (kai[n] * inv_kai[r]) % p; return (ans * inv_kai[n - r]) % p; } vel uni(vel x) { if (x.size() == 0) { return x; } sor(x); int n = x.size(); vel ans(1, x[0]); for (int j = 1; j < n; j++) { if (x[j - 1] != x[j]) { ans.push_back(x[j]); } } x = ans; return x; } void pr(vel& v) { int n = v.size(); if (n != 0) { cout << v[0]; rep(i, n - 1) { cout << " " << v[i + 1]; } cout << endl; } } vel dijk(V<V<pin>>& way, int st, int inf) { int n = way.size(); vel dist(n, inf); dist[st] = 0; priority_queue<pin, vector<pin>, greater<pin>> pq; pq.push(mkp(0, st)); veb is_checked(n, false); while (!pq.empty()) { pin x = pq.top(); pq.pop(); int pot = x.second; if (!is_checked[pot]) { is_checked[pot] = true; for (auto y : way[pot]) { int nex_dist = x.first + y.second; int nex_pot = y.first; if (dist[nex_pot] > nex_dist) { dist[nex_pot] = nex_dist; pq.push(mkp(nex_dist, y.first)); } } } } return dist; } vel mul(vel& a, vel& b) { int n = a.size(); int m = b.size(); vel ans(n + m - 1, 0); rep(i, n) { rep(j, m) { ans[i + j] += a[i] * b[j]; ans[i + j] %= p; } } return ans; } vel rui_p(vel& a, int n) { if (n == 0) { return { 1 }; } vel qans = rui_p(a, n / 2); qans = mul(qans, qans); if (n % 2 == 1) { qans = mul(qans, a); } return qans; } bool is_prime(int n) { if (n == 0 || n == 1) { return false; } for (int i = 2; i * i <= n; i++) { if (n % i == 0) { return false; } } return true; } #define bs bitset<50> void per(int& ans) { ans %= p; if (ans < 0) { ans += p; } } int count_zero(V<bs>& a) { int n = a.size(); int now_st = 0; rep(i, 300) { int fir_ze = -1; for (int j = now_st; j < n; j++) { if (a[j][i]) { fir_ze = j; break; } } if (fir_ze >= 0) { rep(j, n) { if (j != fir_ze && a[j][i]) { a[j] = a[fir_ze] xor a[j]; } } swap(a[now_st], a[fir_ze]); now_st++; } } int ans = 0; rep(i, n) { bool fl = true; rep(j, 300) { if (a[i][j]) { fl = false; break; } } if (fl) { ans++; } } return ans; } #define upperbound(v,val) upper_bound(v.begin(),v.end(),val)-v.begin(); #define lowerbound(v,val) lower_bound(v.begin(),v.end(),val)-v.begin(); #define mat V<V<pin>> int inf = 10000; int linf = 10000; pin p_mul(pin a, pin b) { pin c = mkp(max(b.first, a.first + b.second), a.second + b.second); return c; } mat m_mul(mat& a, mat& b) { int n = a.size(); mat c(n, V<pin>(n, mkp(-inf, -inf))); int ze = 0; rep(i, n) { rep(j, n) { rep(k, n) { if (a[i][j].second > -linf && b[j][k].second > -linf) { pin x = p_mul(a[i][j], b[j][k]); mmax(c[i][k].first, x.first); mmax(c[i][k].second, x.second); mmax(c[i][k].first, ze); } } } } return c; } mat solve(mat& way, int k) { if (k == 1) { return way; } mat ans = solve(way, k / 2); ans = m_mul(ans, ans); if (k % 2 == 1) { ans = m_mul(ans, way); } return ans; }vvel disj_min(vel& v) { int n = v.size(); vvel ret(22, vel(n)); ret[0] = v; rep(i, 21) { rep(j, n) { int nex = j + (1 << i); if (nex < n) { ret[i + 1][j] = min(ret[i][j], ret[i][nex]); } else { ret[i + 1][j] = ret[i][j]; } } } return ret; } vvel disj_max(vel& v) { int n = v.size(); vvel ret(20, vel(n)); ret[0] = v; rep(i, 19) { rep(j, n) { int nex = j + (1 << i); if (nex < n) { ret[i + 1][j] = max(ret[i][j], ret[i][nex]); } else { ret[i + 1][j] = ret[i][j]; } } } return ret; } int find_min(vvel& dv, int l, int r) { int i = 19; while (l + (1 << i) > r) { i--; } return min(dv[i][l], dv[i][r - (1 << i)]); } int find_max(vvel& dv, int l, int r) { int i = 19; while (l + (1 << i) > r) { i--; } return max(dv[i][l], dv[i][r - (1 << i)]); } void pri(int x, int y, int z, int w) { cout << x << "," << 500 << "," << 60 << "," << 60 << ","; cout << y << "," << 500 << "," << 60 << "," << 60; rep(i, 5) { if (i != z) { cout << "," << 0; } else { cout << "," << w; } } cout << endl; } signed main() { int n, k; cin >> n >> k; string s; cin >> s; if (n == 1) { if ((k % 2 == 1) xor (s[0] == 'A')) { cout << 'A' << endl; } else { cout << 'B' << endl; } return 0; } deque<char> deq; rep(i, n) { deq.push_back(s[i]); } int loop = 0; bool trick = false; while (loop <= n + 10 && k > 0) { loop++; 'A'; char c = deq.front(); deq.pop_front(); if (c == 'A') { deq.push_front('B'); k--; continue; } if (k == 1) { deq.push_back('B'); trick = true; k = 0; break; } c = deq.front(); deq.pop_front(); if (c == 'A') { k++; } else if (k == 2) { deq.push_front('A'); deq.push_back('B'); trick = true; k = 0; break; } k -= 3; deq.push_back('B'); deq.push_back('A'); } if (k <= 0) { while (!deq.empty()) { char c = deq.front(); deq.pop_front(); if (trick xor (c == 'A')) { cout << 'A'; } else { cout << 'B'; } } cout << endl; } else { assert(true); assert(false); if (n % 2 == 0) { rep(i, n) { if (i % 2 == 0) { cout << 'B'; } else { cout << 'A'; } } } else { int x = k % 2; if (x % 2 == 0) { cout << 'A'; } else { cout << 'B'; } rep(i, n - 1) { if (i % 2 == 0) { cout << 'B'; } else { cout << 'A'; } } } cout << endl; } return 0; }
a.cc: In function 'int main()': a.cc:326:7: error: 'assert' was not declared in this scope 326 | assert(true); | ^~~~~~ a.cc:18:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>' 17 | #include <complex> +++ |+#include <cassert> 18 | using namespace std;
s060707129
p03788
C++
#include <bits/stdc++.h> using namespace std; #define int long long const int MAXN = 4 * 100 * 1000 + 1234; int n, k; string s; char rev(char c) { return (c == 'A')? 'B': 'A'; } string gen(int c) { string ss; if (c % 2 == 0) for (int i = 0; i <= n; i++) ss += s[i + c]; else for (int i = 0; i <= n; i++) ss += rev(s[i + c]); return ss; } string prv(string s) { if (s[0] == 'A') { s[0] = 'B'; return s; } return s; } void out(string s) { if (s == "") return ; for (int i = 0; i < n; i++) putchar(s[i]); exit(0); } int main() { cin >> n >> k; cin >> s; int ans[MAXN]; char ch[2] = {'B', 'A'}; for (int i = 0; i <= 2 * n + 100; i++) s += ch[i % 2]; ans[0] = (s[0] == ch[1]); for (int i = 1; i <= n + 10; i++) { ans[i] = ans[i - 1] + 1; // cerr << ans[i] << ' ' << s[i] << ' ' << ch[i & 1] << endl; ans[i] += s[i] == ch[i % 2 ^ 1]; } // for (int i = 0; i <= n; i++) // cerr << i << ' ' << ans[i] << endl; for (int i = 0; i <= n + 10; i++) { // cerr << i << ' ' << gen(i) << endl; if (k == ans[i]) out(prv(gen(i))); else if (k == ans[i] - 1) out(gen(i)); } // cerr << "yoho " << ans[n] << endl; k -= ans[n + 1]; k %= 2; if (k == 0 || n % 2 == 0) out(gen(n)); else out(prv(gen(n))); }
cc1plus: error: '::main' must return 'int'
s849118908
p03788
C++
// g++ -std=c++11 a.cpp #include<iostream> #include<vector> #include<string> #include<algorithm> #include<map> #include<set> #include<unordered_map> #include<utility> #include<cmath> #include<random> #include<cstring> #include<queue> #include<stack> #include<bitset> #include<cstdio> #include<sstream> #include<iomanip> #include<assert.h> #include<typeinfo> #define loop(i,a,b) for(int i=a;i<b;i++) #define rep(i,a) loop(i,0,a) #define FOR(i,a) for(auto i:a) #define pb push_back #define all(in) in.begin(),in.end() #define shosu(x) fixed<<setprecision(x) #define show1d(v) rep(_,v.size())cout<<" "<<v[_];cout<<endl; #define show2d(v) rep(_,v.size()){rep(__,v[_].size())cout<<" "<<v[_][__];cout<<endl;}cout<<endl; using namespace std; //kaewasuretyuui typedef long long ll; //#define int ll typedef ll Def; typedef pair<Def,Def> pii; typedef vector<Def> vi; typedef vector<vi> vvi; typedef vector<pii> vp; typedef vector<vp> vvp; typedef vector<string> vs; typedef vector<double> vd; typedef vector<vd> vvd; typedef pair<Def,pii> pip; typedef vector<pip>vip; // #define mt make_tuple // typedef tuple<int,int,int> tp; // typedef vector<tp> vt; template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;} template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;} //template<class C>constexpr int size(const C &c){return (int)c.size();} //template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;} const double PI=acos(-1); const double EPS=1e-9; Def inf = sizeof(Def) == sizeof(long long) ? 1e18+10 : 1e9+10; // int dx[]={0,1,0,-1,1,1,-1,-1}; // int dy[]={1,0,-1,0,1,-1,1,-1};//RDLU int dx[]={-1,-1,0,0,1,1}; int dy[]={-1,0,-1,1,0,1};//RDLU void solve(string s,int n,int m){ int t=0; while(m&&t<s.size()){ if('A'+t%2==s[t]){ m--; if(s[t]=='A')s[t]++; else s[t]--; if(!m)break; } t++;m--; } string out=s.substr(t); if(t%2)rep(i,out.size())if(out[i]=='A')out[i]++; else out[i]--; while(out.size()!=n)out+=(char)('A'+(n+1-out.size())%2); if(t==n&&m%2)out[0]='B'; cout<<out<<endl; } int main(){ int n,m; cin>>n; string s; cin>>s; solve(s,n,i); }
a.cc: In function 'int main()': a.cc:81:19: error: 'i' was not declared in this scope 81 | solve(s,n,i); | ^
s670496429
p03788
C++
#include<iostream> #include<cstdio> #include<string> #include<cstring> #include<vector> #include<algorithm> #include<queue> #include<stack> #define maxn 200050 #define maxint ~0U>>1 std::stack<int> sta; std::vector<int> comp[maxn]; int incomp[maxn],instack[maxn],dfn[maxn],low[maxn]; int index,cnum; int n,m,q,d[maxn],rice[maxn],noodle[maxn],v[maxn],s,p,ans,dis[maxn]; bool jud[maxn]; std::vector<int> g[maxn],nowg[maxn]; int nowrice[maxn],nownoodle[maxn],nows; void input(){ std::cin>>n>>m; int u,v; for(int i = 1;i <= m;i++){ scanf("%d%d",&u,&v); g[u].push_back(v); } } void tarjan(int u){ instack[u] = 2; dfn[u] = low[u] = ++index; sta.push(u); for(int i = 0;i < g[u].size();i++){ int j = g[u][i]; if(!dfn[j]){ tarjan(j); low[u] = std::min(low[u],low[j]); }else if(instack[j] == 2){ low[u] = std::min(low[u],dfn[j]); } } if(dfn[u] == low[u]){ ++cnum; while(!sta.empty()){ int t = sta.top(); sta.pop(); instack[t] = 1; incomp[t] = cnum; comp[cnum].push_back(t); if(t == u){ break; } } } } void work(){ for(int i = 1;i <= n;i++){ if(!dfn[i]) tarjan(i); } int u,v,newu,newv; for(int i = 1;i <= n;i++){ u = i; newu = incomp[u]; nowrice[newu] += 1; for(int j = 0;j < g[u].size();j++){ v = g[u][j]; newv = incomp[v]; if(newu == newv) continue; nowg[newu].push_back(newv); } } } void dfs(int x){ if(nowg[x].size() == 0){ dis[x] = nowrice[x]; return; } for(int i = 0;i < nowg[x].size();i++){ if(!dis[nowg[x][i]]) dfs(nowg[x][i]); dis[x] = std::max(dis[x],dis[nowg[x][i]] + nowrice[x]); } return; } void spfa(){ memset(dis,0,sizeof(dis)); for(int i = 1;i <= cnum;i++){ if(!dis[i]) dfs(i); } } int main(){ input(); work(); spfa(); int ansnow = 0; for(int i = 1;i <= cnum;i++){ ansnow = std::max(ansnow,dis[i]); } std::cout<<ansnow; return 0; }
a.cc:15:5: error: 'int index' redeclared as different kind of entity 15 | int index,cnum; | ^~~~~ In file included from /usr/include/string.h:462, from /usr/include/c++/14/cstring:43, from a.cc:4: /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 'void tarjan(int)': a.cc:30:25: error: no pre-increment operator for type 30 | dfn[u] = low[u] = ++index; | ^~~~~
s153644568
p03788
C++
#include<bits/stdc++.h> using namespace std; const int N=2e5+10; bitset<N> S0,T0; bitset<N-1> S1,T1; int n,k;char s[N]; template<unsigned N> void work(bitset<N> &S){ if (S[0]) S^=~(S^(S>>1)),S[N-1]=0;else S[0]=1; } int main() { scanf("%d%d%s",&n,&k,s); for (int i=N-2;i>=0;i-=2) T0[i]=S0[i]=1; for (int i=N-1;i>=0;i-=2) T1[i]=S1[i]=1; for (int i=0;i<n;i++) if (n&1) S1[i]=(s[i]=='B');else S0[i]=(s[i]=='B'); while (k--){ if (n&1){ work(S1); if (S1==T1){k%=2;if (k&1) work(S1);break;} } else{ work(S0); if (S0==T0){k%=2;if (k&1) work(S0);break;} } } for (int i=0;i<n;i++) putchar((n&1?S1[i]:S0[i])+'A'); puts(""); return 0; }
a.cc: In function 'int main()': a.cc:20:29: error: no matching function for call to 'work(std::bitset<200009>&)' 20 | work(S1); | ~~~~^~~~ a.cc:8:6: note: candidate: 'template<unsigned int N> void work(std::bitset<N>&)' 8 | void work(bitset<N> &S){ | ^~~~ a.cc:8:6: note: template argument deduction/substitution failed: a.cc:20:29: note: mismatched types 'unsigned int' and 'long unsigned int' 20 | work(S1); | ~~~~^~~~ a.cc:21:55: error: no matching function for call to 'work(std::bitset<200009>&)' 21 | if (S1==T1){k%=2;if (k&1) work(S1);break;} | ~~~~^~~~ a.cc:8:6: note: candidate: 'template<unsigned int N> void work(std::bitset<N>&)' 8 | void work(bitset<N> &S){ | ^~~~ a.cc:8:6: note: template argument deduction/substitution failed: a.cc:21:55: note: mismatched types 'unsigned int' and 'long unsigned int' 21 | if (S1==T1){k%=2;if (k&1) work(S1);break;} | ~~~~^~~~ a.cc:24:29: error: no matching function for call to 'work(std::bitset<200010>&)' 24 | work(S0); | ~~~~^~~~ a.cc:8:6: note: candidate: 'template<unsigned int N> void work(std::bitset<N>&)' 8 | void work(bitset<N> &S){ | ^~~~ a.cc:8:6: note: template argument deduction/substitution failed: a.cc:24:29: note: mismatched types 'unsigned int' and 'long unsigned int' 24 | work(S0); | ~~~~^~~~ a.cc:25:55: error: no matching function for call to 'work(std::bitset<200010>&)' 25 | if (S0==T0){k%=2;if (k&1) work(S0);break;} | ~~~~^~~~ a.cc:8:6: note: candidate: 'template<unsigned int N> void work(std::bitset<N>&)' 8 | void work(bitset<N> &S){ | ^~~~ a.cc:8:6: note: template argument deduction/substitution failed: a.cc:25:55: note: mismatched types 'unsigned int' and 'long unsigned int' 25 | if (S0==T0){k%=2;if (k&1) work(S0);break;} | ~~~~^~~~
s621829291
p03788
C++
#include<unordered_set> #include<unordered_map> using namespace std; #define MAX 200002 int n; int k; deque<int> d; char buf[MAX]; string ans; int main(){ cin >> n >> k; scanf("%s", buf); for (int i = 0; i < n; i++){ if (buf[i] - 'A' == 0){ d.push_back((i & 1) ^ 1); } else{ d.push_back((i & 1)); } } if (n == 1){ k %= 2; d.front() ^= k; return 1; } else{ int C = 0; while (k&&C <= 3 * n){ k--; C++; if (d.front() == 1){ d.front() = 0; continue; } d.pop_front(); d.push_back(((n - 1) & 1) ^ 1); } if (k == 0){ } else{ if (d.front() == 0&&d[1]==0){ //B } else{ k %= 2; if (k){ d.front() ^= 1; } } } } for (int i = 0; i < d.size(); i++){ int go = ((i % 2) == d[i]); ans.push_back('A' + go); } printf("%s\n", ans.c_str()); return 0; }
a.cc:10:1: error: 'deque' does not name a type 10 | deque<int> d; | ^~~~~ a.cc:14:1: error: 'string' does not name a type 14 | string ans; | ^~~~~~ a.cc: In function 'int main()': a.cc:18:9: error: 'cin' was not declared in this scope 18 | cin >> n >> k; | ^~~ a.cc:3:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 2 | #include<unordered_map> +++ |+#include <iostream> 3 | using namespace std; a.cc:19:9: error: 'scanf' was not declared in this scope 19 | scanf("%s", buf); | ^~~~~ a.cc:22:25: error: 'd' was not declared in this scope 22 | d.push_back((i & 1) ^ 1); | ^ a.cc:25:25: error: 'd' was not declared in this scope 25 | d.push_back((i & 1)); | ^ a.cc:30:17: error: 'd' was not declared in this scope 30 | d.front() ^= k; | ^ a.cc:38:29: error: 'd' was not declared in this scope 38 | if (d.front() == 1){ | ^ a.cc:42:25: error: 'd' was not declared in this scope 42 | d.pop_front(); | ^ a.cc:49:29: error: 'd' was not declared in this scope 49 | if (d.front() == 0&&d[1]==0){ //B | ^ a.cc:59:29: error: 'd' was not declared in this scope 59 | for (int i = 0; i < d.size(); i++){ | ^ a.cc:61:17: error: 'ans' was not declared in this scope 61 | ans.push_back('A' + go); | ^~~ a.cc:63:24: error: 'ans' was not declared in this scope 63 | printf("%s\n", ans.c_str()); | ^~~ a.cc:63:9: error: 'printf' was not declared in this scope 63 | printf("%s\n", ans.c_str()); | ^~~~~~ a.cc:3:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>' 2 | #include<unordered_map> +++ |+#include <cstdio> 3 | using namespace std;
s583537535
p03788
Java
// package atcoder.agc.agc011; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; public class D { public static void main(String[] args) { InputReader in = new InputReader(System.in); PrintWriter out = new PrintWriter(System.out); int n = in.nextInt(); int k = in.nextInt(); s = in.nextToken().toCharArray(); int[] arr = new int[3*n]; for (int i = 0; i < n ; i++) { arr[i] = s[i] == 'A' ? 0 : 1; } int head = 0; int flg = 0; int m = Math.min(k, 2*n); for (int i = 0; i < m ; i++) { if ((arr[head] ^ flg) == 0) { arr[head] ^= 1; } else { head++; flg ^= 1; arr[head+n-1] = flg; } } k -= m; k %= 2; for (int i = head; i < head+n ; i++) { s[i-head] = (arr[i] ^ flg) == 0 ? 'A' : 'B'; } if (k >= 1) { doit(0, 1); } out.println(String.valueOf(s)); out.flush(); } private static int doit(int i, int dir) { if (i < 0 || i >= s.length) { return dir; } if (s[i] == 'A') { s[i] = 'B'; return doit(i-dir, -dir); } else { s[i] = 'A'; return doit(i+dir, dir); } } static char[] s; static class InputReader { private InputStream stream; private byte[] buf = new byte[1024]; private int curChar; private int numChars; public InputReader(InputStream stream) { this.stream = stream; } private int[] nextInts(int n) { int[] ret = new int[n]; for (int i = 0; i < n; i++) { ret[i] = nextInt(); } return ret; } private int[][] nextIntTable(int n, int m) { int[][] ret = new int[n][m]; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { ret[i][j] = nextInt(); } } return ret; } private long[] nextLongs(int n) { long[] ret = new long[n]; for (int i = 0; i < n; i++) { ret[i] = nextLong(); } return ret; } private long[][] nextLongTable(int n, int m) { long[][] ret = new long[n][m]; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { ret[i][j] = nextLong(); } } return ret; } private double[] nextDoubles(int n) { double[] ret = new double[n]; for (int i = 0; i < n; i++) { ret[i] = nextDouble(); } return ret; } private int next() { if (numChars == -1) throw new InputMismatchException(); if (curChar >= numChars) { curChar = 0; try { numChars = stream.read(buf); } catch (IOException e) { throw new InputMismatchException(); } if (numChars <= 0) return -1; } return buf[curChar++]; } public char nextChar() { int c = next(); while (isSpaceChar(c)) c = next(); if ('a' <= c && c <= 'z') { return (char) c; } if ('A' <= c && c <= 'Z') { return (char) c; } throw new InputMismatchException(); } public String nextToken() { int c = next(); while (isSpaceChar(c)) c = next(); StringBuilder res = new StringBuilder(); do { res.append((char) c); c = next(); } while (!isSpaceChar(c)); return res.toString(); } public int nextInt() { int c = next(); while (isSpaceChar(c)) c = next(); int sgn = 1; if (c == '-') { sgn = -1; c = next(); } int res = 0; do { if (c < '0' || c > '9') throw new InputMismatchException(); res *= 10; res += c-'0'; c = next(); } while (!isSpaceChar(c)); return res*sgn; } public long nextLong() { int c = next(); while (isSpaceChar(c)) c = next(); long sgn = 1; if (c == '-') { sgn = -1; c = next(); } long res = 0; do { if (c < '0' || c > '9') throw new InputMismatchException(); res *= 10; res += c-'0'; c = next(); } while (!isSpaceChar(c)); return res*sgn; } public double nextDouble() { return Double.valueOf(nextToken()); } public boolean isSpaceChar(int c) { return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; } public interface SpaceCharFilter { public boolean isSpaceChar(int ch); } } static void debug(Object... o) { System.err.println(Arrays.deepToString(o)); } }
Main.java:9: error: class D is public, should be declared in a file named D.java public class D { ^ 1 error
s074736148
p03788
C++
#include <bits/stdc++.h> using namespace std; using ll=long long; #define int ll #define FOR(i,a,b) for(int i=int(a);i<int(b);i++) #define REP(i,b) FOR(i,0,b) #define MP make_pair #define PB push_back #define ALL(x) x.begin(),x.end() #define REACH cerr<<"reached line "<<__LINE__<<endl #define DBG(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl using pi=pair<int,int>; using vi=vector<int>; using ld=long double; template<class T,class U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os<<"("<<p.first<<","<<p.second<<")"; return os; } template<class T> ostream& operator <<(ostream& os,const vector<T>& v){ os<<"["; REP(i,(int)v.size()){ if(i)os<<","; os<<v[i]; } os<<"]"; return os; } int read(){ int i; scanf("%lld",&i); return i; } void printSpace(){ printf(" "); } void printEoln(){ printf("\n"); } void print(int x,int suc=1){ printf("%lld",x); if(suc==1) printEoln(); if(suc==2) printSpace(); } string readString(){ static char buf[3341919]; scanf("%s",buf); return string(buf); } char* readCharArray(){ static char buf[3341919]; static int bufUsed=0; char* ret=buf+bufUsed; scanf("%s",ret); bufUsed+=strlen(ret)+1; return ret; } template<class T,class U> void chmax(T& a,U b){ if(a<b) a=b; } template<class T,class U> void chmin(T& a,U b){ if(a>b) a=b; } template<class T> T Sq(const T& t){ return t*t; } const int inf=LLONG_MAX/3; signed main(){ int n=read(),k=read(); string s=readString(); int g=0,q; { REP(i,n){ bool w=(s[i]=='A^(i&1)); if(w){ if(k>=2){ g++; k-=2; if(k==0)q=0; }else{ k--; q=1; } }else{ k--; g++; if(k==0)q=0; } if(k==0) break; } if(k){ if(n^1){ g+=k/2; q=k&1; } else{ g+=k; q=0; } } } string t; REP(i,n) if(i+g<n) t+=((g&1)^(s[i+g]=='A'))?'A':'B'; else t+=((n-1-i)&1)?'B':'A'; if(q){ if(t[0]=='A') t[0]='B'; else{ REP(i,n-1) t[i]=t[i+1]=='A'?'B':'A'; t[n-1]='A'; } } cout<<t<<endl; }
a.cc:98:39: warning: missing terminating ' character 98 | bool w=(s[i]=='A^(i&1)); | ^ a.cc:98:39: error: missing terminating ' character 98 | bool w=(s[i]=='A^(i&1)); | ^~~~~~~~~~ a.cc: In function 'int main()': a.cc:99:25: error: expected primary-expression before 'if' 99 | if(w){ | ^~ a.cc:98:39: error: expected ')' before 'if' 98 | bool w=(s[i]=='A^(i&1)); | ~ ^ | ) 99 | if(w){ | ~~
s474278903
p03788
C++
#include <bits/stdc++.h> using namespace std; const int MAXN = 100 + 10; const int INF = (int)(1e9); char opp(char c) { return ((c == 'A') ? 'B' : 'A'); } void print_alter(char f, int t, int n) { for(int i = 0; i < t; ++i) cout << f; for(int i = t; i < n; ++i) { f = opp(f); cout << f; } cout << endl; } void solve(string &s, int k) { int n = s.length(); int sc = 0; bool B = false; while (k > 0) { if (sc >= n) break; char f = (B) ? 'B' : (((sc % 2) == 1) ? opp(s[sc]) : s[sc]); B = false; --k; if (f == 'B') ++sc; else { B = true; } } if (k == 0) { if (sc == n) print_alter((((n % 2) == 0) ? 'B' : 'A'), 1, n); else { char f = (B) ? 'B' : (((sc % 2) == 1) ? opp(s[sc]) : s[sc]); cout << f; for(int i = sc + 1; i < n; ++i) cout << (((sc % 2) == 1) ? opp(s[i]) : s[i]); if (sc > 0) { char c = ((sc % 2) == 1) ? 'A' : 'B'; print_alter(c, 1, sc); } else cout << endl; } } else { char f = ((n % 2) == 0) ? 'B' : 'A'; if (f == 'B') --k; if ((k % 2) == 0) { print_alter('A', 1, n); } else { print_alter('B', 2, n); } } } void run() { int n, k; cin >> n >> k; string s; cin >> s; solve(s, i); } int main() { //freopen("input.txt", "r", stdin); int ntests = 1; //cin >> ntests; for(int tc = 1; tc <= ntests; ++tc) { run(); } }
a.cc: In function 'void run()': a.cc:67:14: error: 'i' was not declared in this scope 67 | solve(s, i); | ^
s678215194
p03788
C++
#include<algorithm> #include<cmath> #include<iomanip> #include<iostream> #include<map> #include<numeric> #include<queue> #include<set> #include<sstream> #include<vector> using namespace std; using uint = unsigned int; using ll = long long; const int M = 1e9 + 7; const ll MLL = 1e18L + 9; #pragma unused(M) #pragma unused(MLL) #ifdef LOCAL #include"rprint.hpp" #else template <class... T> void printl(T&&...){ } template <class... T> void printc(T&&...){ } template <class... T> void prints(T&&...){ } template <class... T> void printd(T&&...){ } #endif int main(){ // chrono::steady_clock clk; auto start = clk.now(); int n, k; cin >> n >> k; string s; cin >> s; vector<int> ss(n); for(int i=0;i<n;i++){ ss[i] = s[i] == 'A'; } bool flip = false, fflip = false;; int idx = 0; for(int i=0;i<k;i++){ if(flip ^ ss[idx]){ ss[idx] = !ss[idx]; }else{ flip = !flip; idx++; if(idx == n){ idx = 0; } } // if(i % 1000000 == 0 && clk.now() - start > 1900ms){ // if(n % 2 && (k - i - 1) % 2){ // fflip = true; // } // break; // } } cout << (fflip ^ flip ^ ss[idx] ? 'A' : 'B'); for(int i=1;i<n;i++){ cout << (flip ^ ss[(idx + i) % n] ? 'A' : 'B'); } cout << '\n'; return 0; }
a.cc: In function 'int main()': a.cc:29:18: error: 'clk' was not declared in this scope 29 | auto start = clk.now(); | ^~~
s984703254
p03788
C++
#pragma comment(linker, "/STACK:1024000000,1024000000") #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #include <vector> #include <set> #include <map> #include <string> using namespace std; #define LL long long #define mp make_pair #define fr first #define sc second #define pb push_back #define lc (x<<1) #define rc ((x<<1)|1) const int N=200005; char s[N]; int a[N]; char cal(int x,int k){ x^=k%2;return x?'A':'B'; } int main(){ // freopen("in.txt","r",stdin);freopen("out.txt","w",stdout); int i,n,k; scanf("%d%d",&n,&k); scanf("%s",s+1); for (i=1;i<=n;i++) if (s[i]=='A') a[i]=1; else a[i]=0; int K=k,; for (i=1;i<=n;i++) {if (a[i]^((i-1)%2)) k-=2; else k--;if (k<=0) break;} if (i<n||i==n&&k==-1){ int tp,j; if (k==-1) {tp=1;printf("B");} else tp=0; for (j=i+1;j<=n;j++) if (a[j]^((i-tp)%2)) printf("A"); else printf("B"); tp+=n-i; for (j=tp+1;j<=n;j++) if (j%2==n%2) printf("A"); else printf("B"); puts("");return 0; } if (n%2==0){ for (i=1;i<=n;i++) if (i%2==1) printf("B"); else printf("A"); puts("");return 0; } if (k%2==0) {if (i%2==1) printf("B"); else printf("A");} else {if (i%2==0) printf("B"); else printf("A");} for (i=2;i<=n;i++) if (i%2==1) printf("B"); else printf("A"); puts(""); // system("pause"); return 0; }
a.cc: In function 'int main()': a.cc:31:13: error: expected unqualified-id before ';' token 31 | int K=k,; | ^
s697768407
p03788
C++
#include <bits/stdc++.h> using namespace std; typedef signed long long ll; #undef _P #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x<(to);x++) #define FORR(x,arr) for(auto& x:arr) #define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++) #define ALL(a) (a.begin()),(a.end()) #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,0xff,sizeof(a)) //------------------------------------------------------- int N,K; string S; string T; void solve() { int i,j,k,l,r,x,y; string s; cin>>N>>K>>S; int pos=0,rev=0,revn=0; while(K-->0) if(pos==N) break; if((S[pos]=='A') ^ rev ^ revn) { revn^=1; } else { pos++; revn = 0; rev ^=1; } } string R; if(pos==N) { while(R.size()<N) { if((N-R.size())%2==1) R+='A'; else R+='B'; } if(R[0]=='A' && K%2) R[0]='B'; } else { int first=1; while(pos<N) { if(rev ^ ((first==1)&&revn)) { R+='A'+'B'-S[pos]; } else { R+=S[pos]; } pos++; first=0; } while(R.size()<N) { if((N-R.size())%2==1) R+='A'; else R+='B'; } } cout<<R<<endl; /* T=S; FOR(i,100) { int x=0,side=0; while(x>=0 && x<N) { S[x]='A'+'B'-S[x]; if(side==0) { if(S[x]=='B') x--, side=1; else x++; } else { if(S[x]=='B') x++, side=0; else x--; } } if(T[0]=='A') T[0]='B'; else { T=T.substr(1); FORR(c,T) c='A'+'B'-c; T+='A'; } cout<<(i+1)<<"\t"<<S<<endl; } */ } int main(int argc,char** argv){ string s;int i; if(argc==1) ios::sync_with_stdio(false), cin.tie(0); FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin); solve(); return 0; }
a.cc:39:9: error: expected unqualified-id before 'if' 39 | if(pos==N) { | ^~ a.cc:46:9: error: expected unqualified-id before 'else' 46 | else { | ^~~~ a.cc:63:9: error: 'cout' does not name a type 63 | cout<<R<<endl; | ^~~~ a.cc:94:1: error: expected declaration before '}' token 94 | } | ^
s825716743
p03788
C++
#include<bits/stdc++.h> typedef long long ll; using namespace std; void mf(){ freopen("input.in","r",stdin); freopen("output.ou","w",stdout); } int a[100007]; int n, k; // map<string, int> mm; string convert(){ string s = ""; for(int i = 0; i<n;i++){ s+=char(a[i]+'A'); } return s; } inline bool check1(int res){ if(abs(res- n/2) > 1) return false; for(int i = 1; i < n;i++) if(a[i] == a[i-1]) return false; return true; } void solve(){ cin>>n>>k; string st; // srand(time(NULL)); // n = 100000; // for(int i = 0; i < n; i++) a[i] = rand()%2; cin>>st; int res = 0; for(int i = 0; i<n;i++) { a[i] = st[i]-'A'; res+=a[i]; } for(int j = 1; j<= k;j++){ int dir = 1, p = -1; while(true){ p+=dir; if(p<0 || p>=n) break; if(a[p]== 0) dir = -dir; res -= a[p]; a[p] = 1- a[p]; res += a[p]; } if(check1(res)){ if(a[0]==1){ for(int i = 0; i < n;i++) cout<<char( (1- i%2 ) + 'A'); }else{ if((k-j)%2==0){ for(int i= 0; i<n;i++) cout<<char((i%2)+'A'); }else{ cout<<'B'; for(int i = 1;i<n;i++) cout<<char((i%2)+'A'); } } return; } } for(int i = 0; i<n;i++)cout<<char(a[i]+'A'); } void test(){ // string x;cin>>x; srand(time(NULL)); // n = x.length(); n = 13; for(int i = 0; i < n; i++) a[i] = rand()%2; string st = convert(); cerr<<"START==\n"<<st<<"\n===\n"; mm[st] = 0; for(int i = 1; i <=25; i++){ int dir = 1, p = -1; while(true){ p+=dir; if(p<0 || p>=n) break; if(a[p]== 0) dir = -dir; a[p] = 1- a[p]; } st = convert(); // cerr<<"step "<<i<<endl<<st<<"\n==="<<endl; cerr<<st<<endl; // if(mm.find(st) != mm.end()){ // cerr<<st<<" "; // cerr<<i- mm[st]<<endl; // cerr<<mm[st]<<" "<<i<<endl; // mm[st] = i; // //break; // }else{ // mm[st] = i; // } } } int main(){ ios_base::sync_with_stdio(false); #ifdef tuanh mf(); #endif solve(); return 0; }
a.cc: In function 'void test()': a.cc:75:9: error: 'mm' was not declared in this scope; did you mean 'tm'? 75 | mm[st] = 0; | ^~ | tm
s414387608
p03788
C++
#include<iostream> #include<vector> #include<queue> #include<functional> #include<map> #include<set> #include<string> int main() { std::string str; int N, K; std::cin >> N >> K; std::cin >> str; struct func_t { bool f; bool operator()(char c) { if ((f&&c == 'A') || (!f&&c == 'B')) { f ^= true; return true; } return false; } }; int count{}; while (!std::all_of(str.rbegin(), str.rend(), func_t{ true })) { bool d = false; int c{}; while (c >= 0 && c < N) { if (!d) { if (str[c] == 'A') { str[c] = 'B'; --c; d = true; } else { str[c] = 'A'; ++c; } } else { if (str[c] = 'A') { str[c] = 'B'; ++c; d = false; } else { str[c] = 'A'; --c; } } } ++count; if (count == K) { std::cout << str << std::endl; return 0; } } if ((K - count) % 2 == 0) { std::cout << str << std::endl; } else if (N % 2 == 1) { std::cout << "B" << str.substr(1) << std::endl; } }
a.cc: In function 'int main()': a.cc:30:22: error: 'all_of' is not a member of 'std' 30 | while (!std::all_of(str.rbegin(), str.rend(), func_t{ true })) | ^~~~~~
s314476608
p03789
C++
#include<cstdio> const int MAX_N = 200000; int a[MAX_N + 1]; int p[MAX_N + 1]; bool fst[MAX_N + 1]; bool check(int x, int y, int n) { for(int i = 1; i <= y; i++) fst[i] = true; for(int i = 1; i <= x; i++) { if(a[i] < a[i - 1]) return false; fst[a[i]] = false; } for(int i = y + 1; i < n; i++) { if(p[i] > p[i + 1]) return false; } int lt = 0; for(int i = 1; i <= y; i++) { if(fst[i]) { if(lt > p[i]) return false; lt = p[i]; } } return true; } void solve(int n) { int an1 = -1, an2 = -1; for(int i = 1; i <= n; i++) { scanf("%d", &a[i]); p[a[i]] = i; } for(int x = 0; x <= n; x++) { for(int y = x; y <= n; y++) { if(check(x, y, n)) { if(an1 == -1) an1 = x; an2 = x; } } } printf("%d %d\n", an1, an2); } int main() { int T; while(~scanf("%d", &T) solve(T); return 0; }
a.cc: In function 'int main()': a.cc:43:24: error: expected ')' before 'solve' 43 | while(~scanf("%d", &T) solve(T); | ~ ^~~~~~ | )
s334179735
p03789
C++
#include <iostream> #include <string> #define llint long long using namespace std; int n; string s; int a[5000005]; llint adjust(llint p, llint x) { if(x == 0 || x < a[p]) return -1; x = (x-a[p])/10*10 + a[p]; if(n-p < 9){ llint sum = 0, mul = 1; for(int i = p; i < n; i++){ sum += mul * a[i]; mul *= 10; } x = min(x, sum); } return x; } bool sub(llint p, llint x) { //cout << "-" << x << endl; for(;x;x/=10){ a[p] -= x % 10; llint t = p; while(a[t] < 0){ a[t] += 10, a[t+1]--; t++; } p++; } return a[n-1] == 0; } bool check(llint x) { //cout << "! " << x << endl; for(int i = 0; i < n; i++) a[i] = s[i]-'0'; x *= 9; for(int i = 0; i < n; i++){ x = adjust(i, x); if(x == -1) return false; if(sub(i, x)) break; //cout << "="; for(int i = n-1; i >= 0; i--) cout << a[i]; cout << endl; } return true; } int main(void) { cin >> s; n = s.size(); reverse(s.begin(), s.end()); llint ub = n*2, lb = 0, mid; while(ub-lb>1){ mid = (ub+lb)/2; if(check(mid)) ub = mid; else lb = mid; } cout << ub << endl; return 0; }
a.cc: In function 'int main()': a.cc:59:3: error: 'reverse' was not declared in this scope 59 | reverse(s.begin(), s.end()); | ^~~~~~~