submission_id stringlengths 10 10 | problem_id stringlengths 6 6 | language stringclasses 3
values | code stringlengths 1 522k | compiler_output stringlengths 43 10.2k |
|---|---|---|---|---|
s041359046 | p03659 | C++ | include <iostream>
#include <vector>
#include <math.h>
using namespace std;
int main() {
int N;
cin >> N;
vector<int> data;
data.reserve(N);
int input;
int total = 0;
for (int n = 0; n < N; n++) {
cin >> input;
total += input;
data.push_back(input);
}
int x = data[0];
int y = total - x;
int min = abs(x - y);
for (int n = 1; n < (N - 1); n++) {
x += data[n];
y -= data[n];
if (abs(x - y) < min) {
min = abs(x - y);
}
}
cout << min << endl;
return 0;
} | a.cc:1:1: error: 'include' does not name a type
1 | include <iostream>
| ^~~~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:62,
from /usr/include/c++/14/vector:62,
from a.cc:2:
/usr/include/c++/14/ext/type_traits.h:164:35: error: 'constexpr const bool __gnu_cxx::__is_null_pointer' redeclared as different kind of entity
164 | __is_null_pointer(std::nullptr_t)
| ^
/usr/include/c++/14/ext/type_traits.h:159:5: note: previous declaration 'template<class _Type> constexpr bool __gnu_cxx::__is_null_pointer(_Type)'
159 | __is_null_pointer(_Type)
| ^~~~~~~~~~~~~~~~~
/usr/include/c++/14/ext/type_traits.h:164:26: error: 'nullptr_t' is not a member of 'std'
164 | __is_null_pointer(std::nullptr_t)
| ^~~~~~~~~
In file included from /usr/include/c++/14/bits/stl_pair.h:60,
from /usr/include/c++/14/bits/stl_algobase.h:64:
/usr/include/c++/14/type_traits:295:27: error: 'size_t' has not been declared
295 | template <typename _Tp, size_t = sizeof(_Tp)>
| ^~~~~~
/usr/include/c++/14/type_traits:666:33: error: 'nullptr_t' is not a member of 'std'
666 | struct is_null_pointer<std::nullptr_t>
| ^~~~~~~~~
/usr/include/c++/14/type_traits:666:42: error: template argument 1 is invalid
666 | struct is_null_pointer<std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:670:48: error: template argument 1 is invalid
670 | struct is_null_pointer<const std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:674:51: error: template argument 1 is invalid
674 | struct is_null_pointer<volatile std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:678:57: error: template argument 1 is invalid
678 | struct is_null_pointer<const volatile std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:984:26: error: 'size_t' has not been declared
984 | template<typename _Tp, size_t _Size>
| ^~~~~~
/usr/include/c++/14/type_traits:985:40: error: '_Size' was not declared in this scope
985 | struct __is_array_known_bounds<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:985:46: error: template argument 1 is invalid
985 | struct __is_array_known_bounds<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std'
1429 | : public integral_constant<std::size_t, alignof(_Tp)>
| ^~~~~~
/usr/include/c++/14/type_traits:1429:57: error: template argument 1 is invalid
1429 | : public integral_constant<std::size_t, alignof(_Tp)>
| ^
/usr/include/c++/14/type_traits:1429:57: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1438:37: error: 'size_t' is not a member of 'std'
1438 | : public integral_constant<std::size_t, 0> { };
| ^~~~~~
/usr/include/c++/14/type_traits:1438:46: error: template argument 1 is invalid
1438 | : public integral_constant<std::size_t, 0> { };
| ^
/usr/include/c++/14/type_traits:1438:46: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1440:26: error: 'std::size_t' has not been declared
1440 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:1441:21: error: '_Size' was not declared in this scope
1441 | struct rank<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:1441:27: error: template argument 1 is invalid
1441 | struct rank<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:1442:37: error: 'size_t' is not a member of 'std'
1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^~~~~~
/usr/include/c++/14/type_traits:1442:65: error: template argument 1 is invalid
1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^
/usr/include/c++/14/type_traits:1442:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1446:37: error: 'size_t' is not a member of 'std'
1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^~~~~~
/usr/include/c++/14/type_traits:1446:65: error: template argument 1 is invalid
1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^
/usr/include/c++/14/type_traits:1446:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1451:32: error: 'size_t' was not declared in this scope
1451 | : public integral_constant<size_t, 0> { };
| ^~~~~~
/usr/include/c++/14/type_traits:64:1: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
63 | #include <bits/version.h>
+++ |+#include <cstddef>
64 |
/usr/include/c++/14/type_traits:1451:41: error: template argument 1 is invalid
1451 | : public integral_constant<size_t, 0> { };
| ^
/usr/include/c++/14/type_traits:1451:41: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1453:26: error: 'size_t' has not been declared
1453 | template<typename _Tp, size_t _Size>
| ^~~~~~
/usr/include/c++/14/type_traits:1454:23: error: '_Size' was not declared in this scope
1454 | struct extent<_Tp[_Size], 0>
| ^~~~~
/usr/include/c++/14/type_traits:1454:32: error: template argument 1 is invalid
1454 | struct extent<_Tp[_Size], 0>
| ^
/usr/include/c++/14/type_traits:1455:32: error: 'size_t' was not declared in this scope
1455 | : public integral_constant<size_t, _Size> { };
| ^~~~~~
/usr/include/c++/14/type_traits:1455:32: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/c++/14/type_traits:1455:40: error: '_Size' was not declared in this scope
1455 | : public integral_constant<size_t, _Size> { };
| ^~~~~
/usr/include/c++/14/type_traits:1455:45: error: template argument 1 is invalid
1455 | : public integral_constant<size_t, _Size> { };
| ^
/usr/include/c++/14/type_traits:1455:45: error: template argument 2 is invalid
/usr/include/c++/14/type_traits:1457:42: error: 'size_t' has not been declared
1457 | template<typename _Tp, unsigned _Uint, size_t _Size>
| ^~~~~~
/usr/include/c++/14/type_traits:1458:23: error: '_Size' was not declared in this scope
1458 | struct extent<_Tp[_Size], _Uint>
| ^~~~~
/usr/include/c++/14/type_traits:1458:36: error: template argument 1 is invalid
1458 | struct extent<_Tp[_Size], _Uint>
| ^
/usr/include/c++/14/type_traits:1463:32: error: 'size_t' was not declared in this scope
1463 | : public integral_constant<size_t, 0> { };
| ^~~~~~
/usr/include/c++/14/type_traits:1463:32: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/c++/14/type_traits:1463:41: error: template argument 1 is invalid
1463 | : public integral_constant<size_t, 0> { };
| ^
/usr/include/c++/14/type_traits:1463:41: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1857:26: error: 'size_t' does not name a type
1857 | { static constexpr size_t __size = sizeof(_Tp); };
| ^~~~~~
/usr/include/c++/14/type_traits:1857:26: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/c++/14/type_traits:1859:14: error: 'size_t' has not been declared
1859 | template<size_t _Sz, typename _Tp, bool = (_Sz <= _Tp::__size)>
| ^~~~~~
/usr/include/c++/14/type_traits:1859:48: error: '_Sz' was not declared in this scope
1859 | template<size_t _Sz, typename _Tp, bool = (_Sz <= _Tp::__size)>
| ^~~
/usr/include/c++/14/type_traits:1860:14: error: no default argument for '_Tp'
1860 | struct __select;
| ^~~~~~~~
/usr/include/c++/14/type_traits:1862:14: error: 'size_t' has not been declared
1862 | template<size_t _Sz, typename _Uint, typename... _UInts>
| ^~~~~~
/usr/include/c++/14/type_traits:1863:23: error: '_Sz' was not declared in this scope
1863 | struct __select<_Sz, _List<_Uint, _UInts...>, true>
| ^~~
/usr/include/c++/14/type_traits:1863:57: error: template argument 1 is invalid
1863 | struct __select<_Sz, _List<_Uint, _UInts...>, true>
| ^
/usr/include/c++/14/type_traits:1866:14: error: 'size_t' has not been declared
1866 | template<size_t _Sz, typename _Uint, typename... _UInts>
| ^~~~~~
/usr/include/c++/14/type_traits:1867:23: error: '_Sz' was not declared in this scope
1867 | struct __select<_Sz, _List<_Uint, _UInts...>, false>
| ^~~
/usr/include/c++/14/type_traits:1867:58: error: template argument 1 is invalid
1867 | struct __select<_Sz, _List<_Uint, _UInts...>, false>
| |
s098800017 | p03659 | Java |
import java.util.Scanner;
class Main{
public static void main(String[] args){
Scanner scanner=new Scanner(System.in);
int n=scanner.nextInt();
int[] l=new int[n];
int[] snuke=new int[n];
for(int i=0;i<n;i++){
l[i]=scanner.nextInt();
}
int sum=0;
for(int i=0;i<n;i++){
sum+=l[i];
snuke[i]=sum;
}
int sub=0
int min=0;
sub=Math.abs((snuke[0]-(sum-snuke[0])));
min=sub;
for(int i=0;i<n-1;i++){
sub=Math.abs((snuke[i]-(sum-snuke[i])));
if(sub<min){
min=sub;
}
}
System.out.println(min);
}
} | Main.java:20: error: ';' expected
int sub=0
^
1 error
|
s641293331 | p03659 | C++ | #include <iostream>
#include <algorithm>
using namespace std;
int a[200002];
int f( int l, int r ) {
int sum = 0;
int i;
for ( i = l; i <= r; i++ ) {
sum += a[i];
}
return sum;
}
int main()
{
int n;
cin >> n;
int i;
for ( i = 1; i <= n; i++ ) {
cin >>a[i];
}
int sum1 = 0, sum2 = 0;
int sumT = f(1, n);
int Min = INT_MAX;
sum1 = a[1];
sum2 = sumT - sum1;
if ( abs(sum1 - sum2) < Min ) {
Min = abs(sum1 - sum2);
}
for ( i = 2; i < n; i++ ) {
sum1 += a[i];
sum2 = sumT - sum1;
if ( abs(sum1 - sum2) < Min ) {
Min = abs(sum1 - sum2);
}
}
cout << Min;
return 0;
}
| a.cc: In function 'int main()':
a.cc:30:15: error: 'INT_MAX' was not declared in this scope
30 | int Min = INT_MAX;
| ^~~~~~~
a.cc:3:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
2 | #include <algorithm>
+++ |+#include <climits>
3 | using namespace std;
|
s126879702 | p03659 | C++ | #include<iostream>
#include<cctype>
#include<vector>
#include <ctype.h>
#include<algorithm>
#include<queue>
#include<string>
#include <math.h>
#include <iomanip>
using namespace std;
long long n, s[200000], ans,a[200000],t=0;
int main() {
cin >> n;
for (size_t i = 0; i < n; i++)
{
cin >> s[i];
t += s[i];
a[i] = t;
}
ans = abs(abs(a[n - 1]) - abs(2 * a[0]));
for (size_t i = 0; i < n-1; i++)
{
ans=min(abs(abs(a[n - 1]) - abs(2 * a[i])), ans);
}
cout << ans << endl;
return 0; | a.cc: In function 'int main()':
a.cc:26:18: error: expected '}' at end of input
26 | return 0;
| ^
a.cc:12:12: note: to match this '{'
12 | int main() {
| ^
|
s212756424 | p03659 | C++ | #include <iostream>
using namespace std;
int min(int a, int b) {
if (a < b)return a;
else return b;
}
int avd(long long int a, long long int b) {
if (a < b)return b - a;
else return a - b;
}
int av(long long int a) {
if (a > 0)return a;
else return -a;
}
int main() {
int N;
int a[200010];
long long int all_sum, sunuke, dif, tmp;
all_sum = 0;
sunuke = 0;
dif = INT_MAX;
cin >> N;
for (int i = 1; i <= N; i++) {
cin >> a[i];
}
for (int i = 1; i <= N; i++) {
all_sum += a[i];
}
for (int i = 1; i < N; i++) {
sunuke += a[i];
if (dif > avd(sunuke, all_sum - sunuke)) {
dif = avd(sunuke, all_sum - sunuke);
}
}
cout << dif << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:30:15: error: 'INT_MAX' was not declared in this scope
30 | dif = INT_MAX;
| ^~~~~~~
a.cc:2:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
1 | #include <iostream>
+++ |+#include <climits>
2 | using namespace std;
|
s579172216 | p03659 | C++ | #include <iostream>
#include <climits>
long long int N;
long long int a[200001] = {};
long long int min = INT_MAX;
long long int b = 0;
long long int c = 0;
using namespace std;
int main() {
cin >> N;
for (int i = 1; i <= N; i++) {
cin >> a[i];
c += a[i];
}
for (int i = 1; i < N; i++) {
b += a[i];
c -= a[i];
if (min > abs(b - c))min = abs(b - c);
}
cout << min << endl;
} | a.cc: In function 'int main()':
a.cc:21:21: error: reference to 'min' is ambiguous
21 | if (min > abs(b - c))min = abs(b - c);
| ^~~
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:281:5: note: candidates are: '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:233:5: note: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
a.cc:6:15: note: 'long long int min'
6 | long long int min = INT_MAX;
| ^~~
a.cc:21:38: error: reference to 'min' is ambiguous
21 | if (min > abs(b - c))min = abs(b - c);
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidates are: '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:233:5: note: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
a.cc:6:15: note: 'long long int min'
6 | long long int min = INT_MAX;
| ^~~
a.cc:23:17: error: reference to 'min' is ambiguous
23 | cout << min << endl;
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidates are: '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:233:5: note: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
a.cc:6:15: note: 'long long int min'
6 | long long int min = INT_MAX;
| ^~~
|
s834651142 | p03659 | C++ | #include <iostream>
using namespace std;
int min(int a, int b) {
if (a < b)return a;
else return b;
}
int avd(long long int a, long long int b) {
if (a < b)return b - a;
else return a - b;
}
int av(long long int a) {
if (a > 0)return a;
else return -a;
}
int main() {
int N;
int a[200010];
long long int all_sum, sunuke, dif, tmp;
all_sum = 0;
sunuke = 0;
dif = INT_MAX;
cin >> N;
for (int i = 1; i <= N; i++) {
cin >> a[i];
}
for (int i = 1; i <= N; i++) {
all_sum += a[i];
}
for (int i = 1; i < N; i++) {
sunuke += a[i];
if (dif > avd(sunuke, all_sum - sunuke)) {
dif = avd(sunuke, all_sum - sunuke);
}
}
cout << dif << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:30:15: error: 'INT_MAX' was not declared in this scope
30 | dif = INT_MAX;
| ^~~~~~~
a.cc:2:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
1 | #include <iostream>
+++ |+#include <climits>
2 | using namespace std;
|
s751672508 | p03659 | C++ | #include<iostream>
#include<cctype>
#include<vector>
#include <ctype.h>
#include<algorithm>
#include<queue>
#include<string>
#include <math.h>
#include <iomanip>
using namespace std;
int n, s[200000], ans;
long long a[200000],t=0;
int main() {
cin >> n;
for (size_t i = 0; i < n; i++)
{
cin >> s[i];
t += s[i];
a[i] = t;
}
ans = abs(abs(a[n - 1]) - abs(2 * a[0]));
for (size_t i = 0; i < n-1; i++)
{
ans=min(abs(abs(a[n - 1]) - abs(2 * a[i])), ans);
}
cout << ans << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:24:24: error: no matching function for call to 'min(long long int, int&)'
24 | ans=min(abs(abs(a[n - 1]) - abs(2 * a[i])), ans);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed:
a.cc:24:24: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
24 | ans=min(abs(abs(a[n - 1]) - abs(2 * a[i])), ans);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
from a.cc:5:
/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:24:24: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
24 | ans=min(abs(abs(a[n - 1]) - abs(2 * a[i])), ans);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
s533301994 | p03659 | C++ | #include<stdio.h>
int abs(int a)
{
if(a>0) return a;
else return -a;
}
int main()
{
__int64 sum=0;
int n,i;
__int64 min;
__int64 sumz=0,sumy=0;
__int64 x[200001];
scanf("%d",&n);
for (i=1;i<=n;i++)
{
scanf("%I64d",&x[i]);
sum+=x[i];
}
sumy=sum;
for(i=1;i<n;i++)
{
sumz+=x[i];
sumy-=x[i];
if(i==1) min=abs(sumz-sumy);
else if(abs(sumz-sumy)<min) min=abs(sumz-sumy);
}
printf("%I64d",min);
} | a.cc: In function 'int main()':
a.cc:9:9: error: '__int64' was not declared in this scope; did you mean '__int64_t'?
9 | __int64 sum=0;
| ^~~~~~~
| __int64_t
a.cc:11:16: error: expected ';' before 'min'
11 | __int64 min;
| ^~~~
| ;
a.cc:12:16: error: expected ';' before 'sumz'
12 | __int64 sumz=0,sumy=0;
| ^~~~~
| ;
a.cc:13:16: error: expected ';' before 'x'
13 | __int64 x[200001];
| ^~
| ;
a.cc:17:32: error: 'x' was not declared in this scope
17 | scanf("%I64d",&x[i]);
| ^
a.cc:18:17: error: 'sum' was not declared in this scope
18 | sum+=x[i];
| ^~~
a.cc:20:9: error: 'sumy' was not declared in this scope
20 | sumy=sum;
| ^~~~
a.cc:20:14: error: 'sum' was not declared in this scope
20 | sumy=sum;
| ^~~
a.cc:23:17: error: 'sumz' was not declared in this scope
23 | sumz+=x[i];
| ^~~~
a.cc:23:23: error: 'x' was not declared in this scope
23 | sumz+=x[i];
| ^
a.cc:25:26: error: 'min' was not declared in this scope; did you mean 'main'?
25 | if(i==1) min=abs(sumz-sumy);
| ^~~
| main
a.cc:26:40: error: 'min' was not declared in this scope; did you mean 'main'?
26 | else if(abs(sumz-sumy)<min) min=abs(sumz-sumy);
| ^~~
| main
a.cc:28:24: error: 'min' was not declared in this scope; did you mean 'main'?
28 | printf("%I64d",min);
| ^~~
| main
|
s525949632 | p03659 | Java | import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Main {
private final static Scanner sc = new Scanner(System.in);
/**
* 本処理を実行します。
*/
public static void execute() {
int n = nextInt();
List<Integer> a = nextInts(n);
int size = a.size();
int result = Integer.MAX_VALUE;
if (size == 2) {
result = Math.abs(a.get(0) - a.get(1));
} else {
for (int i = 0; i < size - 1; i++) {
List<Integer> before = a.subList(0, i + 1);
List<Integer> after = a.subList(i + 1, size);
int beforeSum = before.parallelStream().mapToInt(bi -> bi).sum();
int afterSum = after.parallelStream().mapToInt(ai -> ai).sum();
int absSum = Math.abs(beforeSum - afterSum);
if (absSum < result) {
result = absSum;
}
}
}
out(result);
}
/**
* 次の標準入力をintで受け取ります。
* @return 標準入力値(int)
*/
public static int nextInt() {
return sc.nextInt();
}
/**
* 次の標準入力をStringで受け取ります。
* @return 標準入力値(String)
*/
public static String nextString() {
return sc.next();
}
/**
* 次の標準入力を指定回数分intで受け取ります。
* @param n 取得回数
* @return 取得した標準入力値の配列(int)
*/
public static List<Integer> nextInts(int n) {
List<Integer> list = new ArrayList<>();
for (int i = 0; i < n; i++) {
list.add(nextInt());
}
return list;
}
/**
* 標準出力にオブジェクトを出力します。
* @param o 出力対象
*/
public static void out(Object o) {
System.out.println(o);
}
public static void main(String[] args) {
execute();
} | Main.java:79: error: reached end of file while parsing
}
^
1 error
|
s537653638 | p03659 | C++ | #include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
ll n,i,j,k,s;
cin>>n;
s=0;
vector<int> a(n+1),b(n+1);
for(i=1;i<=n;i++){
cin>>j;
b[i]=j+b[i-1];
}
ll d=2e9+1;
for(i=1;i<=n-1;i++){
d=min(d,abs(b[n]-2*b[i]));
}
cout<<d;
} | a.cc: In function 'int main()':
a.cc:17:10: error: no matching function for call to 'min(long long int&, int)'
17 | d=min(d,abs(b[n]-2*b[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:17:10: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
17 | d=min(d,abs(b[n]-2*b[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:17:10: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
17 | d=min(d,abs(b[n]-2*b[i]));
| ~~~^~~~~~~~~~~~~~~~~~~~
|
s356041303 | p03659 | C++ | #include <iostream>
#include <vector>
#include <numeric>
#include <cmath>
using namespace std;
int main(){
int n,s,sum;
cin >> n;
vector<int>a(n),b(n - 1);
for(auto& v : a){
cin >> v;
}
s = sum = accumulate(a.begin(),a.end(),0);
for(int i = 0; i < n - 1; ++i){
sum -= a[i];
b[i] = sum;
}
int out=INT_MAX;
for(auto d : b){
if(abs(d - (s - d))<out){
out = abs(d - (s - d));
}
}
cout << out << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:21:17: error: 'INT_MAX' was not declared in this scope
21 | int out=INT_MAX;
| ^~~~~~~
a.cc:5:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
4 | #include <cmath>
+++ |+#include <climits>
5 | using namespace std;
|
s271653969 | p03659 | C++ | #include<iostream>
using namespace std;
long long abs(long long x){
if(x < 0){
return -x;
}
else{
return x;
}
}
int n;
long long a[200005], s[200005];
int main(void){
cin >> n;
for(int i = 0; i < n; i++){
cin >> a[i];
}
for(int i = 0; i < n; i++){
s[i + 1] = a[i] + s[i];
}
long long m = 2 * s[1] - s[n];
for(int i = 1; i < n; i++){
m = min(m, abs(2 * s[i] - s[n]));
}
cout << m << endl;
}
| a.cc: In function 'int main()':
a.cc:26:19: error: call of overloaded 'abs(long long int)' is ambiguous
26 | m = min(m, abs(2 * s[i] - s[n]));
| ~~~^~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/cstdlib:79,
from /usr/include/c++/14/ext/string_conversions.h:43,
from /usr/include/c++/14/bits/basic_string.h:4154,
from /usr/include/c++/14/string:54,
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/stdlib.h:980:12: note: candidate: 'int abs(int)'
980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
| ^~~
a.cc:4:11: note: candidate: 'long long int abs(long long int)'
4 | long long abs(long long x){
| ^~~
In file included from /usr/include/c++/14/cstdlib:81:
/usr/include/c++/14/bits/std_abs.h:137:3: note: candidate: 'constexpr __float128 std::abs(__float128)'
137 | abs(__float128 __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:85:3: note: candidate: 'constexpr __int128 std::abs(__int128)'
85 | abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; }
| ^~~
/usr/include/c++/14/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)'
79 | abs(long double __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)'
75 | abs(float __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)'
71 | abs(double __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)'
61 | abs(long long __x) { return __builtin_llabs (__x); }
| ^~~
/usr/include/c++/14/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)'
56 | abs(long __i) { return __builtin_labs(__i); }
| ^~~
|
s443626736 | p03659 | C++ | #include <bits/stdc++.h>
#define int long long
using namespace std;
int main()
{
int n,i,j,k,s;
cin>>n;
s=0;
vector<int> a(n+1),b(n+1);
for(i=1;i<=n;i++){
cin>>j;
b[i]=j+b[i-1];
}
int d=2e9+1;
for(i=1;i<=n-1;i++){
d=min(d,abs(b[n]-2*b[i]));
}
cout<<d;
} | cc1plus: error: '::main' must return 'int'
|
s901372296 | p03659 | C++ | #include <iostream>
#include <limits>
#include <algorithm>
using namespace std;
int a[200011];
int f( int l, int r ) {
int sum = 0;
int i;
for ( i = l; i <= r; i++ ) {
sum += a[i];
}
return sum;
}
int main()
{
int n;
cin >> n;
int i;
for ( i = 1; i <= n; i++ ) {
cin >>a[i];
}
int sum1 = 0, sum2 = 0;
int sumT = f(1, n);
int Min = INT_MAX;
for ( i = 1; i < n; i++ ) {
sum1 = f(1, i);
sum2 = sumT - sum1;
if ( abs(sum1 - sum2) < Min ) {
Min = abs(sum1 - sum2);
}
}
cout << Min;
return 0;
}
| a.cc: In function 'int main()':
a.cc:31:15: error: 'INT_MAX' was not declared in this scope
31 | int Min = INT_MAX;
| ^~~~~~~
a.cc:4:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
3 | #include <algorithm>
+++ |+#include <climits>
4 | using namespace std;
|
s014832343 | p03659 | C++ | #include<iostream>
using namespace std;
long long int abs(long long int x){
if(x < 0){
return -x;
}
else{
return x;
}
}
int n;
long long int a[200005], s[200005];
int main(void){
cin >> n;
for(int i = 0; i < n; i++){
cin >> a[i];
}
for(int i = 0; i < n; i++){
s[i + 1] = a[i] + s[i];
}
long long int m = 2 * s[1] - s[n];
for(int i = 1; i < n; i++){
m = min(m, abs(2 * s[i] - s[n]));
}
cout << m << endl;
}
| a.cc: In function 'int main()':
a.cc:26:19: error: call of overloaded 'abs(long long int)' is ambiguous
26 | m = min(m, abs(2 * s[i] - s[n]));
| ~~~^~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/cstdlib:79,
from /usr/include/c++/14/ext/string_conversions.h:43,
from /usr/include/c++/14/bits/basic_string.h:4154,
from /usr/include/c++/14/string:54,
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/stdlib.h:980:12: note: candidate: 'int abs(int)'
980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
| ^~~
a.cc:4:15: note: candidate: 'long long int abs(long long int)'
4 | long long int abs(long long int x){
| ^~~
In file included from /usr/include/c++/14/cstdlib:81:
/usr/include/c++/14/bits/std_abs.h:137:3: note: candidate: 'constexpr __float128 std::abs(__float128)'
137 | abs(__float128 __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:85:3: note: candidate: 'constexpr __int128 std::abs(__int128)'
85 | abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; }
| ^~~
/usr/include/c++/14/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)'
79 | abs(long double __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)'
75 | abs(float __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)'
71 | abs(double __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)'
61 | abs(long long __x) { return __builtin_llabs (__x); }
| ^~~
/usr/include/c++/14/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)'
56 | abs(long __i) { return __builtin_labs(__i); }
| ^~~
|
s967752404 | p03659 | C++ | #include <stdio.h>
#include <limits.h>
#include <stdlib.h>
int abs(int i){
if(i < 0)
return -1 * i;
return i;
}
int main(void){
int *c;
int n;
scanf("%d",&n);
c = malloc(sizeof(int) * n);
int sum = 0;
int i;
for(i = 0; i < n;i++){
scanf("%d",&c[i]);
sum += c[i];
}
int res = INT_MAX;
int sunuke = 0;
for(i = 0; i < n - 1;i++){
sunuke += c[i];
sum -= c[i];
if(abs(sunuke - sum) < res)
res = abs(sunuke - sum);
}
printf("%d\n",res);
free(c);
return 0;
}
| a.cc: In function 'int main()':
a.cc:17:13: error: invalid conversion from 'void*' to 'int*' [-fpermissive]
17 | c = malloc(sizeof(int) * n);
| ~~~~~~^~~~~~~~~~~~~~~~~
| |
| void*
|
s004580509 | p03659 | C++ | #include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
__int64 str[200005];
int main()
{
__int64 i,n,min;
cin>>n;
for (i=0;i<n;i++)
cin>>str[i];
sort(str,str+n);
min=str[1]-str[0];
for (i=2;i<n;i++)
if(str[2]-str[1]<min) min=str[2]-str[1];
cout<<min<<endl;
}
| a.cc:5:1: error: '__int64' does not name a type; did you mean '__int64_t'?
5 | __int64 str[200005];
| ^~~~~~~
| __int64_t
a.cc: In function 'int main()':
a.cc:8:9: error: '__int64' was not declared in this scope; did you mean '__int64_t'?
8 | __int64 i,n,min;
| ^~~~~~~
| __int64_t
a.cc:9:14: error: 'n' was not declared in this scope
9 | cin>>n;
| ^
a.cc:10:18: error: 'i' was not declared in this scope
10 | for (i=0;i<n;i++)
| ^
a.cc:11:22: error: 'str' was not declared in this scope; did you mean 'std'?
11 | cin>>str[i];
| ^~~
| std
a.cc:12:14: error: 'str' was not declared in this scope; did you mean 'std'?
12 | sort(str,str+n);
| ^~~
| std
a.cc:14:18: error: 'i' was not declared in this scope
14 | for (i=2;i<n;i++)
| ^
a.cc:16:13: error: no match for 'operator<<' (operand types are 'std::ostream' {aka 'std::basic_ostream<char>'} and '<unresolved overloaded function type>')
16 | cout<<min<<endl;
| ~~~~^~~~~
In file included from /usr/include/c++/14/iostream:41,
from a.cc:2:
/usr/include/c++/14/ostream:116:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ostream_type& (*)(__ostream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
116 | operator<<(__ostream_type& (*__pf)(__ostream_type&))
| ^~~~~~~~
/usr/include/c++/14/ostream:116:36: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::basic_ostream<char>::__ostream_type& (*)(std::basic_ostream<char>::__ostream_type&)' {aka 'std::basic_ostream<char>& (*)(std::basic_ostream<char>&)'}
116 | operator<<(__ostream_type& (*__pf)(__ostream_type&))
| ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/ostream:125:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>; __ios_type = std::basic_ios<char>]'
125 | operator<<(__ios_type& (*__pf)(__ios_type&))
| ^~~~~~~~
/usr/include/c++/14/ostream:125:32: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::basic_ostream<char>::__ios_type& (*)(std::basic_ostream<char>::__ios_type&)' {aka 'std::basic_ios<char>& (*)(std::basic_ios<char>&)'}
125 | operator<<(__ios_type& (*__pf)(__ios_type&))
| ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
/usr/include/c++/14/ostream:135:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::ios_base& (*)(std::ios_base&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
135 | operator<<(ios_base& (*__pf) (ios_base&))
| ^~~~~~~~
/usr/include/c++/14/ostream:135:30: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::ios_base& (*)(std::ios_base&)'
135 | operator<<(ios_base& (*__pf) (ios_base&))
| ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
/usr/include/c++/14/ostream:174:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
174 | operator<<(long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:174:23: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long int'
174 | operator<<(long __n)
| ~~~~~^~~
/usr/include/c++/14/ostream:178:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
178 | operator<<(unsigned long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:178:32: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long unsigned int'
178 | operator<<(unsigned long __n)
| ~~~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:182:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(bool) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
182 | operator<<(bool __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:182:23: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'bool'
182 | operator<<(bool __n)
| ~~~~~^~~
In file included from /usr/include/c++/14/ostream:1022:
/usr/include/c++/14/bits/ostream.tcc:96:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short int) [with _CharT = char; _Traits = std::char_traits<char>]'
96 | basic_ostream<_CharT, _Traits>::
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/ostream.tcc:97:22: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'short int'
97 | operator<<(short __n)
| ~~~~~~^~~
/usr/include/c++/14/ostream:189:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(short unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
189 | operator<<(unsigned short __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:189:33: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'short unsigned int'
189 | operator<<(unsigned short __n)
| ~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/ostream.tcc:110:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(int) [with _CharT = char; _Traits = std::char_traits<char>]'
110 | basic_ostream<_CharT, _Traits>::
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/ostream.tcc:111:20: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'int'
111 | operator<<(int __n)
| ~~~~^~~
/usr/include/c++/14/ostream:200:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
200 | operator<<(unsigned int __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:200:31: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'unsigned int'
200 | operator<<(unsigned int __n)
| ~~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:211:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
211 | operator<<(long long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:211:28: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long long int'
211 | operator<<(long long __n)
| ~~~~~~~~~~^~~
/usr/include/c++/14/ostream:215:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
215 | operator<<(unsigned long long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:215:37: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long long unsigned int'
215 | operator<<(unsigned long long __n)
| ~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:231:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
231 | operator<<(double __f)
| ^~~~~~~~
/usr/include/c++/14/ostream:231:25: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'double'
231 | operator<<(double __f)
| ~~~~~~~^~~
/usr/include/c++/14/ostream:235:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(float) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
235 | operator<<(float __f)
| ^~~~~~~~
/usr/include/c++/14/ostream:235:24: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'float'
235 | operator<<(float __f)
| ~~~~~~^~~
/usr/include/c++/14/ostream:243:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
243 | operator<<(long double __f)
| ^~~~~~~~
/usr/include/c++/14/ostream:243:30: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long double'
243 | operator<<(long double __f)
| ~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:301:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& st |
s690598384 | p03659 | C++ | #include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
__int64 str[200005];
int main()
{
__int64int i,n,min;
cin>>n;
for (i=0;i<n;i++)
cin>>str[i];
sort(str,str+n);
min=str[1]-str[0];
for (i=2;i<n;i++)
if(str[2]-str[1]<min) min=str[2]-str[1];
cout<<min<<endl;
}
| a.cc:5:1: error: '__int64' does not name a type; did you mean '__int64_t'?
5 | __int64 str[200005];
| ^~~~~~~
| __int64_t
a.cc: In function 'int main()':
a.cc:8:9: error: '__int64int' was not declared in this scope; did you mean '__int64_t'?
8 | __int64int i,n,min;
| ^~~~~~~~~~
| __int64_t
a.cc:9:14: error: 'n' was not declared in this scope
9 | cin>>n;
| ^
a.cc:10:18: error: 'i' was not declared in this scope
10 | for (i=0;i<n;i++)
| ^
a.cc:11:22: error: 'str' was not declared in this scope; did you mean 'std'?
11 | cin>>str[i];
| ^~~
| std
a.cc:12:14: error: 'str' was not declared in this scope; did you mean 'std'?
12 | sort(str,str+n);
| ^~~
| std
a.cc:14:18: error: 'i' was not declared in this scope
14 | for (i=2;i<n;i++)
| ^
a.cc:16:13: error: no match for 'operator<<' (operand types are 'std::ostream' {aka 'std::basic_ostream<char>'} and '<unresolved overloaded function type>')
16 | cout<<min<<endl;
| ~~~~^~~~~
In file included from /usr/include/c++/14/iostream:41,
from a.cc:2:
/usr/include/c++/14/ostream:116:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ostream_type& (*)(__ostream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
116 | operator<<(__ostream_type& (*__pf)(__ostream_type&))
| ^~~~~~~~
/usr/include/c++/14/ostream:116:36: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::basic_ostream<char>::__ostream_type& (*)(std::basic_ostream<char>::__ostream_type&)' {aka 'std::basic_ostream<char>& (*)(std::basic_ostream<char>&)'}
116 | operator<<(__ostream_type& (*__pf)(__ostream_type&))
| ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/ostream:125:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>; __ios_type = std::basic_ios<char>]'
125 | operator<<(__ios_type& (*__pf)(__ios_type&))
| ^~~~~~~~
/usr/include/c++/14/ostream:125:32: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::basic_ostream<char>::__ios_type& (*)(std::basic_ostream<char>::__ios_type&)' {aka 'std::basic_ios<char>& (*)(std::basic_ios<char>&)'}
125 | operator<<(__ios_type& (*__pf)(__ios_type&))
| ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
/usr/include/c++/14/ostream:135:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::ios_base& (*)(std::ios_base&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
135 | operator<<(ios_base& (*__pf) (ios_base&))
| ^~~~~~~~
/usr/include/c++/14/ostream:135:30: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::ios_base& (*)(std::ios_base&)'
135 | operator<<(ios_base& (*__pf) (ios_base&))
| ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
/usr/include/c++/14/ostream:174:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
174 | operator<<(long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:174:23: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long int'
174 | operator<<(long __n)
| ~~~~~^~~
/usr/include/c++/14/ostream:178:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
178 | operator<<(unsigned long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:178:32: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long unsigned int'
178 | operator<<(unsigned long __n)
| ~~~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:182:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(bool) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
182 | operator<<(bool __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:182:23: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'bool'
182 | operator<<(bool __n)
| ~~~~~^~~
In file included from /usr/include/c++/14/ostream:1022:
/usr/include/c++/14/bits/ostream.tcc:96:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short int) [with _CharT = char; _Traits = std::char_traits<char>]'
96 | basic_ostream<_CharT, _Traits>::
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/ostream.tcc:97:22: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'short int'
97 | operator<<(short __n)
| ~~~~~~^~~
/usr/include/c++/14/ostream:189:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(short unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
189 | operator<<(unsigned short __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:189:33: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'short unsigned int'
189 | operator<<(unsigned short __n)
| ~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/ostream.tcc:110:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(int) [with _CharT = char; _Traits = std::char_traits<char>]'
110 | basic_ostream<_CharT, _Traits>::
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/ostream.tcc:111:20: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'int'
111 | operator<<(int __n)
| ~~~~^~~
/usr/include/c++/14/ostream:200:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
200 | operator<<(unsigned int __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:200:31: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'unsigned int'
200 | operator<<(unsigned int __n)
| ~~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:211:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
211 | operator<<(long long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:211:28: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long long int'
211 | operator<<(long long __n)
| ~~~~~~~~~~^~~
/usr/include/c++/14/ostream:215:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
215 | operator<<(unsigned long long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:215:37: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long long unsigned int'
215 | operator<<(unsigned long long __n)
| ~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:231:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
231 | operator<<(double __f)
| ^~~~~~~~
/usr/include/c++/14/ostream:231:25: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'double'
231 | operator<<(double __f)
| ~~~~~~~^~~
/usr/include/c++/14/ostream:235:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(float) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
235 | operator<<(float __f)
| ^~~~~~~~
/usr/include/c++/14/ostream:235:24: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'float'
235 | operator<<(float __f)
| ~~~~~~^~~
/usr/include/c++/14/ostream:243:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
243 | operator<<(long double __f)
| ^~~~~~~~
/usr/include/c++/14/ostream:243:30: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long double'
243 | operator<<(long double __f)
| ~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:301:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream |
s753835070 | p03659 | C++ | #include <iostream>
#include <sstream>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;
const int MAXN = 1001000;
const int MOD = 1000000007;
const int INF = INT_MAX;
long long sum[MAXN];
int main()
{
long long n, a;
memset(sum, 0, sizeof(sum));
cin >> n;
for (int i = 1; i <= n; ++i)
{
cin >> a;
sum[i] = sum[i - 1] + a;
}
long long ans = INF;
for (int i = 1; i < n; ++i)
ans = min(ans, abs(sum[n] - sum[i] - sum[i]));
cout << ans << endl;
//system("pause");
return 0;
} | a.cc:19:17: error: 'INT_MAX' was not declared in this scope
19 | const int INF = INT_MAX;
| ^~~~~~~
a.cc:15:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
14 | #include <cstring>
+++ |+#include <climits>
15 |
|
s403569479 | p03659 | C++ | #include<iostream>
using namespace std;
long long int abs(long long int x){
if(x < 0){
return -x;
}
else{
return x;
}
}
int n;
long long int a[200005], s[200005];
int main(void){
cin >> n;
for(int i = 0; i < n; i++){
cin >> a[i];
}
for(int i = 0; i < n; i++){
s[i + 1] = a[i] + s[i];
}
long long int m = s[n];
for(int i = 1; i < n; i++){
m = min(m, abs(2 * s[i] - s[n]));
}
cout << m << endl;
}
| a.cc: In function 'int main()':
a.cc:26:19: error: call of overloaded 'abs(long long int)' is ambiguous
26 | m = min(m, abs(2 * s[i] - s[n]));
| ~~~^~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/cstdlib:79,
from /usr/include/c++/14/ext/string_conversions.h:43,
from /usr/include/c++/14/bits/basic_string.h:4154,
from /usr/include/c++/14/string:54,
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/stdlib.h:980:12: note: candidate: 'int abs(int)'
980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
| ^~~
a.cc:4:15: note: candidate: 'long long int abs(long long int)'
4 | long long int abs(long long int x){
| ^~~
In file included from /usr/include/c++/14/cstdlib:81:
/usr/include/c++/14/bits/std_abs.h:137:3: note: candidate: 'constexpr __float128 std::abs(__float128)'
137 | abs(__float128 __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:85:3: note: candidate: 'constexpr __int128 std::abs(__int128)'
85 | abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; }
| ^~~
/usr/include/c++/14/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)'
79 | abs(long double __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)'
75 | abs(float __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)'
71 | abs(double __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)'
61 | abs(long long __x) { return __builtin_llabs (__x); }
| ^~~
/usr/include/c++/14/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)'
56 | abs(long __i) { return __builtin_labs(__i); }
| ^~~
|
s710356971 | p03659 | C++ | #include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <cstdio>
#include <cmath>
#include <sstream>
#include <algorithm>
using namespace std;
int main() {
int N;
cin >> N;
vector<long long> card;
for (int i = 0; i < N; i++) {
long long t;
cin >> t;
if (i != 0) {
card.push_back(t + card[i - 1]);
}
else {
card.push_back(t);
}
}
long long total = card[N - 1];
int count = 0;
long long min = LLONG_MAX - 1;
for (int i = 0; i < N - 1; i++) {
long long x, y, z;
x = card[i];
y = total - card[i];
z = abs(x - y);
if (min > z) {
min = z;
}
}
cout << min << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:29:25: error: 'LLONG_MAX' was not declared in this scope
29 | long long min = LLONG_MAX - 1;
| ^~~~~~~~~
a.cc:9:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
8 | #include <algorithm>
+++ |+#include <climits>
9 |
|
s236412874 | p03659 | C++ | #include<iostream>
using namespace std;
int abs(int x){
if(x < 0){
return -x;
}
else{
return x;
}
}
int n;
long long int a[200005], s[200005];
int main(void){
cin >> n;
for(int i = 0; i < n; i++){
cin >> a[i];
}
for(int i = 0; i < n; i++){
s[i + 1] = a[i] + s[i];
}
int m = s[n];
for(int i = 1; i < n; i++){
m = min(m, abs(2 * s[i] - s[n]));
}
cout << m << endl;
}
| a.cc: In function 'int main()':
a.cc:26:12: error: no matching function for call to 'min(int&, long long int)'
26 | m = min(m, abs(2 * s[i] - s[n]));
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed:
a.cc:26:12: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
26 | m = min(m, abs(2 * s[i] - s[n]));
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/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
|
s282376081 | p03659 | C++ | //#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include<cmath>
#define lowbit(x) ((x)&(-x))
#define Max(a,b) (a>b?a:b)
#define Min(a,b) (a>b?b:a)
#define INF 0x3f3f3f3f
#define sz size()
#define pb push_back
#define ph push
#define mem(x, y) memset(x, y, sizeof(x));
#define mem0(x) mem(x,0)
#define mem1(x) mem(x,-1)
#define memINF(x) mem(x,INF)
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=a;i>(b);--i)
using namespace std;
typedef __int64 ll;
int const Max_N = 1e6+5;
ll a[Max_N];
ll sum[Max_N] = {0};
int main()
{
int N;
cin >> N;
rep(i,1,N+1)
{
cin >> a[i];
sum[i] += sum[i-1] + a[i];
}
ll ans = 1e18;
rep(i,1,N)
{
// cout << sum[i] << endl;
// cout << sum[N] - 2*sum[i] << endl;
ans = min(ans,abs(sum[N] - 2*sum[i]));
}
cout << ans << endl;
return 0;
}
//freopen("in.txt","r",stdin);
//std::ios::sync_with_stdio(false);
| a.cc:29:9: error: '__int64' does not name a type; did you mean '__int64_t'?
29 | typedef __int64 ll;
| ^~~~~~~
| __int64_t
a.cc:32:1: error: 'll' does not name a type; did you mean 'all'?
32 | ll a[Max_N];
| ^~
| all
a.cc:33:1: error: 'll' does not name a type; did you mean 'all'?
33 | ll sum[Max_N] = {0};
| ^~
| all
a.cc: In function 'int main()':
a.cc:40:24: error: 'a' was not declared in this scope
40 | cin >> a[i];
| ^
a.cc:41:17: error: 'sum' was not declared in this scope
41 | sum[i] += sum[i-1] + a[i];
| ^~~
a.cc:45:9: error: 'll' was not declared in this scope; did you mean 'all'?
45 | ll ans = 1e18;
| ^~
| all
a.cc:50:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
50 | ans = min(ans,abs(sum[N] - 2*sum[i]));
| ^~~
| abs
a.cc:50:35: error: 'sum' was not declared in this scope
50 | ans = min(ans,abs(sum[N] - 2*sum[i]));
| ^~~
a.cc:52:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
52 | cout << ans << endl;
| ^~~
| abs
|
s466525431 | p03659 | C++ | #include <iostream>
#include <vector>
#include <cmath>
using namespace std;
int main()
{
long N;
long ans = LONG_MAX;
cin >> N;
vector<int> A(N);
vector<long> subSum(N);
for (int i = 0; i < N; i++)
{
cin >> A[i];
if (i > 0)
subSum[i] = subSum[i - 1] + A[i];
else
subSum[i] = A[i];
}
long sum = subSum[N - 1];
for (int i = 0; i < N - 1; i++)
{
long num = abs(subSum[i] - (sum - subSum[i]));
if (ans > num)
ans = num;
}
cout << ans << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:10:20: error: 'LONG_MAX' was not declared in this scope
10 | long ans = LONG_MAX;
| ^~~~~~~~
a.cc:4:1: note: 'LONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
3 | #include <cmath>
+++ |+#include <climits>
4 |
|
s460721801 | p03660 | C++ | #include <bits/stdc++.h>
#dedine int long long
using namespace std;
/* エイリアス */
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define em emplace
/* 関数マクロ */
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n, m) for (ll i = n; i <= m; ++i)
#define rep3(i, n, m) for (ll i = n; i >= m; --i)
#define all(v) v.begin(), v.end()
#define si(v) int(v.size())
#define UNIQUE(v) sort(all(v)), v.erase(unique(all(v)),v.end())
/* 定数 */
const ll mod = 1e9 + 7;
const ll infll = (1LL << 62) - 1;
const ll inf = (1LL << 30) - 1;
/* その他 */
template<class S, class T> inline bool chmax(S &a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class S, class T> inline bool chmin(S &a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> using pq = priority_queue<T>;
template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;
int n;
vector<vi> edge(100001);
vi dijkstra(int start)
{
vi ret(n, inf);
ret[start] = 0;
pqg<pii> que;
que.em(0, start);
while (!que.empty()) {
pii p = que.top(); que.pop();
int d = p.fi, v = p.se;
if (ret[v] < d) continue;
for (auto to : edge[v]) {
if (ret[to] > d + 1) {
ret[to] = d + 1;
que.em(d + 1, to);
}
}
}
return ret;
}
signed main()
{
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cout << fixed << setprecision(15);
cin >> n;
rep(i, n-1) {
int a, b; cin >> a >> b;
edge[a-1].eb(b-1);
edge[b-1].eb(a-1);
}
auto black = dijkstra(0);
auto white = dijkstra(n-1);
int b = 0, w = 0;
rep(i, n) {
if (black[i] <= white[i]) ++b;
else ++w;
}
if (b > w) cout << "Fennec" << endl;
else cout << "Snuke" << endl;
}
| a.cc:2:2: error: invalid preprocessing directive #dedine; did you mean #define?
2 | #dedine int long long
| ^~~~~~
| define
|
s667506390 | p03660 | C++ | k | a.cc:1:1: error: 'k' does not name a type
1 | k
| ^
|
s656211563 | p03660 | C++ | #include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}
int main(){FIN
ll n;cin>>n;
vvll path(n);
REP(i,n-1) {
ll aa, bb;cin>>aa>>bb;
aa--; bb--;
path[aa].push_back(bb);
path[bb].push_back(aa);
}
vll vis(n,0);
queue<ll> que1, que2;
que1.push(0); que2.push(n-1);
ll c1=0, c2=0;
while(que1.size() && que2.size()){
REP(i,que1.size()){
ll p = que1.front();
que1.pop();
vis[p]=1;
c1++;
for(auto pp: path[p]){
if (vis[pp]==0) {que1.push(pp); vis[pp]=1;}
}
}
REP(i,que2.size()){
ll p = que2.front();
que2.pop();
vis[p]=1;
c2++;
for(auto pp: path[p]){
if (vis[pp]==0) {que2.push(pp); vis[pp]=1:}
}
}
}
if(c2>=c1) cout<<"Snuke"<<endl;
else cout<<"Fennec"<<endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:59:58: error: expected ';' before ':' token
59 | if (vis[pp]==0) {que2.push(pp); vis[pp]=1:}
| ^
| ;
|
s911602801 | p03660 | C++ | #include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
using Graph = vector<vector<int>>;
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
struct edge{ll to, cost;};
typedef pair<ll,ll> P;
struct graph{
ll V;
vector<vector<edge> > G;
vector<ll> d;
graph(ll n){
init(n);
}
void init(ll n){
V = n;
G.resize(V);
d.resize(V);
rep(i,V){
d[i] = INF;
}
}
void add_edge(ll s, ll t, ll cost){
edge e;
e.to = t, e.cost = cost;
G[s].push_back(e);
}
void dijkstra(ll s){
rep(i,V){
d[i] = INF;
}
d[s] = 0;
priority_queue<P,vector<P>, greater<P> > que;
que.push(P(0,s));
while(!que.empty()){
P p = que.top(); que.pop();
ll v = p.second;
if(d[v]<p.first) continue;
for(auto e : G[v]){
if(d[e.to]>d[v]+e.cost){
d[e.to] = d[v]+e.cost;
que.push(P(d[e.to],e.to));
}
}
}
}
};
class UnionFind
{
public:
int par[100005];
int depth[100005];
int nGroup[100005];
UnionFind(int n) {
init(n);
}
void init(int n) {
for(int i=0; i<n; i++) {
par[i] = i;
depth[i] = 0;
nGroup[i] = 1;
}
}
int root(int x) {
if(par[x] == x) {
return x;
} else {
return par[x] = root(par[x]);
}
}
bool same(int x, int y) {
return root(x) == root(y);
}
void unite(int x, int y) {
x = root(x);
y = root(y);
if(x == y) return;
if(depth[x] < depth[y]) {
par[x] = y;
nGroup[y] += nGroup[x];
nGroup[x] = 0;
} else {
par[y] = x;
nGroup[x] += nGroup[y];
nGroup[y] = 0;
if(depth[x] == depth[y])
depth[x]++;
}
}
};
const ll MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++){
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
// 二項係数計算
ll COM(ll n, ll k){
if (n < k) return 0;
if (n < 0 || k < 0) return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
ll n; cin>>n;
ll a[n]={},b[n]={};
Graph G(n);
rep(i,n-1){
cin>>a[i]>>b[i];
G[a[i]-1].pb(b[i]-1);
G[b[i]-1].pb(a[i]-1);
}
vector<int> dist1(n, -1); // 全頂点を「未訪問」に初期化
queue<int> que;
// 初期条件 (頂点 0 を初期ノードとする)
dist1[0] = 0;
que.push(0); // 0 を橙色頂点にする
// BFS 開始 (キューが空になるまで探索を行う)
while (!que.empty()) {
int v = que.front(); // キューから先頭頂点を取り出す
que.pop();
// v から辿れる頂点をすべて調べる
for (int nv : G[v]) {
if (dist1[nv] != -1) continue; // すでに発見済みの頂点は探索しない
// 新たな白色頂点 nv について距離情報を更新してキューに追加する
dist1[nv] = dist1[v] + 1;
que.push(nv);
}
}
vector<int> dist2(n, -1); // 全頂点を「未訪問」に初期化
queue<int> que;
// 初期条件 (頂点 0 を初期ノードとする)
dist[n-1] = 0;
que.push(n-1); // 0 を橙色頂点にする
// BFS 開始 (キューが空になるまで探索を行う)
while (!que.empty()) {
int v = que.front(); // キューから先頭頂点を取り出す
que.pop();
// v から辿れる頂点をすべて調べる
for (int nv : G[v]) {
if (dist2[nv] != -1) continue; // すでに発見済みの頂点は探索しない
// 新たな白色頂点 nv について距離情報を更新してキューに追加する
dist2[nv] = dist2[v] + 1;
que.push(nv);
}
}
ll ca = 0;
rep(i,n){
if(dist1[i]<=dist2[i]) ca++;}
if(ca>n-ca) cout << "Fennec" << endl;
else cout << "Snuke" << endl;
}
| a.cc: In function 'int main()':
a.cc:179:16: error: redeclaration of 'std::queue<int> que'
179 | queue<int> que;
| ^~~
a.cc:157:16: note: 'std::queue<int> que' previously declared here
157 | queue<int> que;
| ^~~
a.cc:182:5: error: 'dist' was not declared in this scope; did you mean 'dist2'?
182 | dist[n-1] = 0;
| ^~~~
| dist2
|
s102252453 | p03660 | C++ | #include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
using Graph = vector<vector<int>>;
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
struct edge{ll to, cost;};
typedef pair<ll,ll> P;
struct graph{
ll V;
vector<vector<edge> > G;
vector<ll> d;
graph(ll n){
init(n);
}
void init(ll n){
V = n;
G.resize(V);
d.resize(V);
rep(i,V){
d[i] = INF;
}
}
void add_edge(ll s, ll t, ll cost){
edge e;
e.to = t, e.cost = cost;
G[s].push_back(e);
}
void dijkstra(ll s){
rep(i,V){
d[i] = INF;
}
d[s] = 0;
priority_queue<P,vector<P>, greater<P> > que;
que.push(P(0,s));
while(!que.empty()){
P p = que.top(); que.pop();
ll v = p.second;
if(d[v]<p.first) continue;
for(auto e : G[v]){
if(d[e.to]>d[v]+e.cost){
d[e.to] = d[v]+e.cost;
que.push(P(d[e.to],e.to));
}
}
}
}
};
class UnionFind
{
public:
int par[100005];
int depth[100005];
int nGroup[100005];
UnionFind(int n) {
init(n);
}
void init(int n) {
for(int i=0; i<n; i++) {
par[i] = i;
depth[i] = 0;
nGroup[i] = 1;
}
}
int root(int x) {
if(par[x] == x) {
return x;
} else {
return par[x] = root(par[x]);
}
}
bool same(int x, int y) {
return root(x) == root(y);
}
void unite(int x, int y) {
x = root(x);
y = root(y);
if(x == y) return;
if(depth[x] < depth[y]) {
par[x] = y;
nGroup[y] += nGroup[x];
nGroup[x] = 0;
} else {
par[y] = x;
nGroup[x] += nGroup[y];
nGroup[y] = 0;
if(depth[x] == depth[y])
depth[x]++;
}
}
};
const ll MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++){
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
// 二項係数計算
ll COM(ll n, ll k){
if (n < k) return 0;
if (n < 0 || k < 0) return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
ll n; cin>>n;
ll a[n]={},b[n]={};
UnionFind.tree(n);
rep(i,n-1){
cin>>a[i]>>b[i];
tree.unite(a[i]-1,b[i]-1);}
| a.cc: In function 'int main()':
a.cc:150:10: error: expected unqualified-id before '.' token
150 | UnionFind.tree(n);
| ^
a.cc:153:1: error: 'tree' was not declared in this scope; did you mean 'free'?
153 | tree.unite(a[i]-1,b[i]-1);}
| ^~~~
| free
a.cc:153:28: error: expected '}' at end of input
153 | tree.unite(a[i]-1,b[i]-1);}
| ^
a.cc:147:12: note: to match this '{'
147 | int main() {
| ^
|
s649511515 | p03660 | C++ | #include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;
/*
BFSで距離を求める.
1からの距離 <= N からの距離 ならば黒
1からの距離 > N からの距離 ならば白
*/
using Graph = vector<vector<int>>;
int main(){
int N;
cin >> N;
Graph G(N);
REP(i,N-1){
int a, b;
cin >> a >>b;
--a; --b;
G[a].push_back(b);
G[b].push_back(a);
}
vector<int> distf(N, -1); //未訪問に初期化
queue<int> que;
//init
distf[0] = 0;
que.push(0);
//BFS
while(!que.empty()){
int v = que.front(); que.pop();
for( int nv : G[v]){
if( distf[nv] != -1) continue;
distf[nv] = distf[v] + 1;
que.push(nv);
}
}
//REP(i,N) cout << i << ": " << distf[i] << endl;
vector<int> dists(N, -1); //未訪問に初期化
queue<int> ques;
//init
dists[0] = 0;
ques.push(0);
//BFS
while(!ques.empty()){
int v = ques.front(); ques.pop();
for( int nv : G[v]){
if( dists[nv] != -1) continue;
dists[nv] = dists[v] + 1;
ques.push(nv);
}
}
REP(i,n){
if(distf[i] <= dists[i]) ++cntf;
else ++cnts;
}
if(cntf > cnts) cout << "Fennec" << endl;
else cout << "Sunuke" << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:77:10: error: 'n' was not declared in this scope
77 | REP(i,n){
| ^
a.cc:2:38: note: in definition of macro 'REP'
2 | #define REP(i,n) for (int i = 0; i <(n); ++i)
| ^
a.cc:78:33: error: 'cntf' was not declared in this scope
78 | if(distf[i] <= dists[i]) ++cntf;
| ^~~~
a.cc:79:13: error: 'cnts' was not declared in this scope
79 | else ++cnts;
| ^~~~
a.cc:82:7: error: 'cntf' was not declared in this scope
82 | if(cntf > cnts) cout << "Fennec" << endl;
| ^~~~
a.cc:82:14: error: 'cnts' was not declared in this scope
82 | if(cntf > cnts) cout << "Fennec" << endl;
| ^~~~
|
s104359892 | p03660 | C++ | #pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define endl "\n"
#define sz(x) ((ll)(x).size())
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define prt(x) cout << (x)
#define prtl(x) cout << (x) << endl
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define rrep(i,a,b) for(ll i=a; i>b; i--)
#define mp(a, b) make_pair(a, b)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define debug(v) cout << #v<< ": " << v <<endl;
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using vvc = vector<vector<char>>;
using ll = long long int;
using P = pair<long long int, long long int>;
using Map = map<long long int, long long int>;
ll INF = 1LL<<60;
ll M = 1000000007;
void cnt(ll a, ll p, ll &c, const vvll &e){
c++;
for(auto x: e[a]){
if(x == p){
continue;
}
cnt(x, a, c, e);
}
}
bool gl(ll a, ll p, ll g, const vvll &e, set<ll> &r){
if(a == g){
return true;
}
if(sz(e[a]) == 1){
return false;
}
bool b = false;
for(auto x: e[a]){
if(x == p){
continue;
}
if(gl(x, a, g, e, r)){
r.insert(x);
b = true;
}
}
return b;
}
ll cnt2(ll a, ll p, ll g, const vvll &e){
if(a == g){
return 0;
}
if(sz(e[a]) == 1&&p != INF){
return -INF;
}
ll v = -INF;
for(auto x: e[a]){
if(x == p){
continue;
}
chmax(v, cnt2(x, a, g, e));
}
return v+1;
}
int main(){
ll N; cin >> N;
vvll e(N, vll(0));
rep(i, 0, N-1){
ll a, b; cin >> a >> b;
a--; b--;
e[a].emplace_back(b);
e[b].emplace_back(a);
}
ll s = 0, f = 0;
ll n1;
set<ll> route;
gl(0, INF, N-1, e, route);
route.insert(0);
set<ll> rf;
for(auto x: e[0]){
if(gl(x, 0, N-1, e, rf)){
n1 = x;
}
}
ll n2;
for(auto x: e[N-1]){
if(gl(x, N-1, 0, e, rf)){
n2 = x;
}
}
//prt(n1); prt(" "); prtl(n2);
//prtl("1");
for(auto x: e[0]){
if(x == n1){
continue;
}
ll v = 0;
cnt(x, 0, v, e);
//prtl(v);
f += v;
}
for(auto x: e[N-1]){
if(x == n2){
continue;
}
ll w = 0;
cnt(x, N-1, w, e);
s += w;
}
ll c = cnt2(0, INF, N-1, e);
c--;
//prtl(s); prtl(f);
//prtl(c);
ll t = 0;
ll x = n1, y = n2; ll p1 = 0, p2 = N-1;
while(c > 0){
if(t%2 == 0){
ll z;
f++;
for(auto v: e[x]){
if(v == p1){
continue;
}
ll m = sz(route);
route.insert(v)
if(sz(route) == m){
z = v;
continue;
}else{
route.erase(v);
ll r = 0;
cnt(v, x, r, e);
f += r;
}
}
p1 = x;
x = z;
}else{
ll z;
s++;
for(auto v: e[y]){
if(v == p2){
continue;
}
ll m = sz(route);
route.insert(v)
if(sz(route) == m){
z = v;
continue;
}else{
route.erase(v);
ll r = 0;
cnt(v, y, r, e);
s += r;
}
}
p2 = y;
y = z;
}
c--;
t++;
}
//prtl(s); prtl(f);
if(s > f){
prtl("Snuke");
}else if(s == f){
prtl("Snuke");
}else{
prtl("Fennec");
}
}
| a.cc: In function 'int main()':
a.cc:137:32: error: expected ';' before 'if'
137 | route.insert(v)
| ^
| ;
138 | if(sz(route) == m){
| ~~
a.cc:141:18: error: 'else' without a previous 'if'
141 | }else{
| ^~~~
a.cc:158:32: error: expected ';' before 'if'
158 | route.insert(v)
| ^
| ;
159 | if(sz(route) == m){
| ~~
a.cc:162:18: error: 'else' without a previous 'if'
162 | }else{
| ^~~~
|
s134883512 | p03660 | C++ | use std::io::*;
const INF: usize = 1 << 30;
fn dfs(v: usize, p: usize, d: &mut Vec<usize>, g: &Vec<Vec<usize>>) {
for &nv in g[v].iter() {
if nv != p {
d[nv] = d[v] + 1;
dfs(nv, v, d, &g);
}
}
}
fn main() {
let mut s: String = String::new();
stdin().read_to_string(&mut s).ok();
let mut itr = s.trim().split_whitespace();
let n: usize = itr.next().unwrap().parse().unwrap();
let mut g = vec![Vec::new(); n];
for _ in 1..n {
let a = itr.next().unwrap().parse::<usize>().unwrap() - 1;
let b = itr.next().unwrap().parse::<usize>().unwrap() - 1;
g[a].push(b);
g[b].push(a);
}
// 0から / n - 1から
let mut d1 = vec![INF; n];
let mut d2 = vec![INF; n];
d1[0] = 0;
d2[n - 1] = 0;
dfs(0, 0, &mut d1, &g);
dfs(n - 1, n - 1, &mut d2, &g);
let mut w = 0;
let mut b = 0;
for i in 0..n {
if d1[i] <= d2[i] {
b += 1;
} else {
w += 1;
}
}
if b > w {
println!("Fennec");
} else {
println!("Snuke");
}
}
| a.cc:18:14: error: too many decimal points in number
18 | for _ in 1..n {
| ^~~~
a.cc:35:14: error: too many decimal points in number
35 | for i in 0..n {
| ^~~~
a.cc:1:1: error: 'use' does not name a type
1 | use std::io::*;
| ^~~
a.cc:2:10: error: found ':' in nested-name-specifier, expected '::'
2 | const INF: usize = 1 << 30;
| ^
| ::
a.cc:2:7: error: 'INF' does not name a type
2 | const INF: usize = 1 << 30;
| ^~~
a.cc:4:1: error: 'fn' does not name a type
4 | fn dfs(v: usize, p: usize, d: &mut Vec<usize>, g: &Vec<Vec<usize>>) {
| ^~
a.cc:12:1: error: 'fn' does not name a type
12 | fn main() {
| ^~
|
s551077838 | p03660 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vint;
typedef vector<double> vdbl;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<int> > vvint;
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;
typedef priority_queue<int, vector<int>, greater<int> > spqint; //小さい順に取り出し
typedef priority_queue<ll, vector<ll>, greater<ll> > spqll; //小さい順に取り出し
typedef priority_queue<int, vector<int>, less<int> > bpqint; //大きい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll> > bpqll; //大きい順に取り出し
#define REP(i, n) for (int(i) = 0; (i) < (int)(n); i++)
#define FOR(i, a, b) for (int(i) = a; (i) < (int)b; i++)
#define IREP(i, v) for (auto i = v.begin(); i != v.end(); i++)
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define PF push_front
#define TS to_string
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
const double PI = M_PI;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } //最小公倍数
void yes()
{
cout << "Fennec" << endl;
}
void no()
{
cout << "Snuke" << endl;
}
//-----------------------------------------
int V, E ;
vector<int> seen ;
queue<int> que ;
//-----------------------------------------
int main()
{
cin.tie(0);
ios::sync_with_stdio(false);
int n ;
cin >> n ;
V = n ;
vector<int> zero(V,0) ;
seen = zero ;
vvint g(n) ;
REP(i,n-1){
int a, b ;
cin >> a >> b ;
g[a-1].PB(b-1) ;
g[b-1].PB(a-1) ;
}
vector<int> set1 ;
vector<int> set2 ;
que.push(0) ;
seen[0] = 1 ;
while(!que.empty()){
int k = que.front() ;
set1.PB(k) ;
que.pop() ;
for(int i=0;i<g[k].size();i++){
if(seen[g[k][i]]==0 && g[k][i]!=n-1){
que.push(g[k][i]) ;
seen[g[k][i]] = 1 ;
}
}
}
seen = zero ;
que.push(n-1) ;
seen[n-1] = 1 ;
while(!que.empty()){
int k = que.front() ;
set2.PB(k) ;
que.pop() ;
for(int i=0;i<g[k].size();i++){
if(seen[g[k][i]]==0 && g[k][i]!=0){
que.push(g[k][i]) ;
seen[g[k][i]] = 1 ;
}
}
}
int fc = 0 ;
int sc = 0 ;
int cnt = 0 ;
REP(i,SZ(set1)){
if(BS(ALL(set2),set1[i])){
cnt++ ;
}
}
fc = SZ(set1) -cnt ;
sc = SZ(set2) -cnt ;
fc += cnt/2 + cnt%2 ;
sc += cnt/2 ;
if(fc=>sc){
yes() ;
}
else{
no() ;
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:133:11: error: expected primary-expression before '>' token
133 | if(fc=>sc){
| ^
|
s500766187 | p03660 | C++ | #include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int INF =1001001001;
void dfs(int x, int n, int count, vector<vector<int>> graph, vector<int> &dist, vector<bool> &visit){
visit[x] = true;
dist[x] = count;
// printf("dist:%d\n",dist[x]);
++count;
for(auto g :graph[x]){
if(visit[g]) continue;
dfs(g,n,count,graph,dist,visit);
}
}
int main()
{
int n;
cin >> n;
// 5-7-4-1-2
// L3-6
// 1-4-2-3
vector<vector<ll>> graph(n);
vector<int> distA(n);
vector<int> distB(n);
vector<bool> visit(n);
rep(i,n-1){
int a,b;
cin >> a >> b;
--a; --b;
graph[a].push_back(b);
graph[b].push_back(a);
}
//それぞれからの距離を求める
//フェネックA
dfs(0,n,0,graph, distA,visit);
//リセット
rep(i,n) visit[i] = false;
//スヌケ
dfs(n-1,n,0,graph, distB, visit);
int A = 0;
int B = 0;
rep(i,n){
if(distA[i] <= distB[i]) A++;
else B++;
}
// rep(i,n) printf("A:%d B:%d\n",distA[i], distB[i]);
if(A > B) cout << "Fennec" << endl;
else cout << "Snuke" << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:42:14: error: could not convert 'graph' from 'vector<vector<long long int>>' to 'vector<vector<int>>'
42 | dfs(0,n,0,graph, distA,visit);
| ^~~~~
| |
| vector<vector<long long int>>
a.cc:46:16: error: could not convert 'graph' from 'vector<vector<long long int>>' to 'vector<vector<int>>'
46 | dfs(n-1,n,0,graph, distB, visit);
| ^~~~~
| |
| vector<vector<long long int>>
|
s947813024 | p03660 | C++ | #include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int INF =1001001001;
const int MAX = 100000;
bool graph[MAX][MAX];
int distA[MAX];
int distB[MAX];
bool visit[MAX];
void dfs(int x, int n, int count, bool a){
if(visit[x]) return;
visit[x] = true;
if(a) distA[x] = count; else distB[x] = count;
++count;
rep(i,n){
if(graph[x][i] == false) continue;
if(visit[i]) continue;
dfs(i,n,count,a);
}
}
int main()
{
int n;
cin >> n;
// 5-7-4-1-2
// L3-6
// 1-4-2-3
rep(i,n-1){
int a,b;
cin >> a >> b;
--a; --b;
graph[a][b] = true;
graph[b][a] = true;
}
//それぞれからの距離を求める
//フェネックA
dfs(0,n,0,true);
//リセット
rep(i,n) visit[i] = false;
//スヌケ
dfs(n-1,n,0,false);
int A = 0;
int B = 0;
rep(i,n){
if(distA[i] <= distB[i]) A++;
else B++;
}
if(A > B) cout << "Fennec" << endl;
else cout << "Snuke" << endl;
return 0;
} | a.cc: In function 'void dfs(int, int, int, bool)':
a.cc:14:7: error: reference to 'visit' is ambiguous
14 | if(visit[x]) return;
| ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:80,
from a.cc:1:
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
1855 | visit(_Visitor&& __visitor, _Variants&&... __variants)
| ^~~~~
a.cc:11:6: note: 'bool visit [100000]'
11 | bool visit[MAX];
| ^~~~~
a.cc:15:4: error: reference to 'visit' is ambiguous
15 | visit[x] = true;
| ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
1855 | visit(_Visitor&& __visitor, _Variants&&... __variants)
| ^~~~~
a.cc:11:6: note: 'bool visit [100000]'
11 | bool visit[MAX];
| ^~~~~
a.cc:20:10: error: reference to 'visit' is ambiguous
20 | if(visit[i]) continue;
| ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
1855 | visit(_Visitor&& __visitor, _Variants&&... __variants)
| ^~~~~
a.cc:11:6: note: 'bool visit [100000]'
11 | bool visit[MAX];
| ^~~~~
a.cc: In function 'int main()':
a.cc:46:13: error: reference to 'visit' is ambiguous
46 | rep(i,n) visit[i] = false;
| ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
1855 | visit(_Visitor&& __visitor, _Variants&&... __variants)
| ^~~~~
a.cc:11:6: note: 'bool visit [100000]'
11 | bool visit[MAX];
| ^~~~~
|
s100720417 | p03660 | C++ | #include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int INF =1001001001;
const int MAX = 100000;
bool graph[MAX][MAX];
int distA[MAX];
int distB[MAX];
bool visit[MAX];
void dfs(int x, int n, int count, bool a){
if(visit[x]) return;
visit[x] = true;
if(a) distA[x] = count; else distB[x] = count;
++count;
rep(i,n){
if(graph[x][i] == false) continue;
if(visit[i]) continue;
dfs(i,n,count,a);
}
}
int main()
{
int n;
cin >> n;
// 5-7-4-1-2
// L3-6
// 1-4-2-3
rep(i,n-1){
int a,b;
cin >> a >> b;
--a; --b;
graph[a][b] = true;
graph[b][a] = true;
}
//それぞれからの距離を求める
//フェネックA
dfs(0,n,0,true);
//リセット
rep(i,n) visit[i] = false;
//スヌケ
dfs(n-1,n,0,false);
int A = 0;
int B = 0;
rep(i,n){
if(distA[i] <= distB[i]) A++;
else B++;
}
if(A > B) cout << "Fennec" << endl;
else cout << "Snuke" << endl;
} | a.cc: In function 'void dfs(int, int, int, bool)':
a.cc:14:7: error: reference to 'visit' is ambiguous
14 | if(visit[x]) return;
| ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:80,
from a.cc:1:
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
1855 | visit(_Visitor&& __visitor, _Variants&&... __variants)
| ^~~~~
a.cc:11:6: note: 'bool visit [100000]'
11 | bool visit[MAX];
| ^~~~~
a.cc:15:4: error: reference to 'visit' is ambiguous
15 | visit[x] = true;
| ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
1855 | visit(_Visitor&& __visitor, _Variants&&... __variants)
| ^~~~~
a.cc:11:6: note: 'bool visit [100000]'
11 | bool visit[MAX];
| ^~~~~
a.cc:20:10: error: reference to 'visit' is ambiguous
20 | if(visit[i]) continue;
| ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
1855 | visit(_Visitor&& __visitor, _Variants&&... __variants)
| ^~~~~
a.cc:11:6: note: 'bool visit [100000]'
11 | bool visit[MAX];
| ^~~~~
a.cc: In function 'int main()':
a.cc:46:13: error: reference to 'visit' is ambiguous
46 | rep(i,n) visit[i] = false;
| ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
1855 | visit(_Visitor&& __visitor, _Variants&&... __variants)
| ^~~~~
a.cc:11:6: note: 'bool visit [100000]'
11 | bool visit[MAX];
| ^~~~~
|
s362457176 | p03660 | C++ | #include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int INF =1001001001;
const int MAX = 100000;
bool graph[MAX][MAX];
int distA[MAX];
int distB[MAX];
bool visit[MAX];
void dfs(int x, int n, int count, bool a){
if(visit[x]) return;
visit[x] = true;
if(a) distA[x] = count; else distB[x] = count;
++count;
rep(i,n){
if(graph[x][i] == false) continue;
if(visit[i]) continue;
dfs(i,n,count,a);
}
}
int main()
{
int n;
cin >> n;
// 5-7-4-1-2
// L3-6
// 1-4-2-3
rep(i,n-1){
int a,b;
cin >> a >> b;
--a; --b;
graph[a][b] = true;
graph[b][a] = true;
}
//それぞれからの距離を求める
//フェネックA
dfs(0,n,0,true);
//リセット
rep(i,n) visit[i] = false;
//スヌケ
dfs(n-1,n,0,false);
int A = 0,
int B = 0;
rep(i,n){
if(distA[i] <= distB[i]) A++;
else B++;
}
if(A > B) cout << "Fennec" << endl;
else cout << "Snuke" << endl;
} | a.cc: In function 'void dfs(int, int, int, bool)':
a.cc:14:7: error: reference to 'visit' is ambiguous
14 | if(visit[x]) return;
| ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:80,
from a.cc:1:
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
1855 | visit(_Visitor&& __visitor, _Variants&&... __variants)
| ^~~~~
a.cc:11:6: note: 'bool visit [100000]'
11 | bool visit[MAX];
| ^~~~~
a.cc:15:4: error: reference to 'visit' is ambiguous
15 | visit[x] = true;
| ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
1855 | visit(_Visitor&& __visitor, _Variants&&... __variants)
| ^~~~~
a.cc:11:6: note: 'bool visit [100000]'
11 | bool visit[MAX];
| ^~~~~
a.cc:20:10: error: reference to 'visit' is ambiguous
20 | if(visit[i]) continue;
| ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
1855 | visit(_Visitor&& __visitor, _Variants&&... __variants)
| ^~~~~
a.cc:11:6: note: 'bool visit [100000]'
11 | bool visit[MAX];
| ^~~~~
a.cc: In function 'int main()':
a.cc:46:13: error: reference to 'visit' is ambiguous
46 | rep(i,n) visit[i] = false;
| ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
1855 | visit(_Visitor&& __visitor, _Variants&&... __variants)
| ^~~~~
a.cc:11:6: note: 'bool visit [100000]'
11 | bool visit[MAX];
| ^~~~~
a.cc:51:4: error: expected unqualified-id before 'int'
51 | int B = 0;
| ^~~
a.cc:55:12: error: 'B' was not declared in this scope
55 | else B++;
| ^
a.cc:58:11: error: 'B' was not declared in this scope
58 | if(A > B) cout << "Fennec" << endl;
| ^
|
s124247273 | p03660 | C++ | #include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int INF =1001001001;
const int MAX = 100000;
bool graph[MAX][MAX];
int distA[MAX];
int distB[MAX];
bool visit[MAX];
void dfs(int x, int n, int count, bool a){
if(visit[x]) return;
visit[x] = true;
if(a) distA[x] = count; else distB[x] = count;
++count;
rep(i,n){
if(graph[x][i] == false) continue;
if(visit[i]) continue;
dfs(i,n,count,a);
}
}
int main()
{
int n;
cin >> n;
// 5-7-4-1-2
// L3-6
// 1-4-2-3
rep(i,n-1){
int a,b;
cin >> a >> b;
--a; --b;
graph[a][b] = true;
graph[b][a] = true;
}
//それぞれからの距離を求める
//フェネックA
dfs(0,n,0,true);
//リセット
rep(i,n) visit[i] = false;
//スヌケ
dfs(n-1,n,0,false);
int a = 0,
int b = 0;
rep(i,n){
if(distA[i] <= distB[i]) a++;
else b++;
}
if(a > b) cout << "Fennec" << endl;
else cout << "Snuke" << endl;
} | a.cc: In function 'void dfs(int, int, int, bool)':
a.cc:14:7: error: reference to 'visit' is ambiguous
14 | if(visit[x]) return;
| ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:80,
from a.cc:1:
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
1855 | visit(_Visitor&& __visitor, _Variants&&... __variants)
| ^~~~~
a.cc:11:6: note: 'bool visit [100000]'
11 | bool visit[MAX];
| ^~~~~
a.cc:15:4: error: reference to 'visit' is ambiguous
15 | visit[x] = true;
| ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
1855 | visit(_Visitor&& __visitor, _Variants&&... __variants)
| ^~~~~
a.cc:11:6: note: 'bool visit [100000]'
11 | bool visit[MAX];
| ^~~~~
a.cc:20:10: error: reference to 'visit' is ambiguous
20 | if(visit[i]) continue;
| ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
1855 | visit(_Visitor&& __visitor, _Variants&&... __variants)
| ^~~~~
a.cc:11:6: note: 'bool visit [100000]'
11 | bool visit[MAX];
| ^~~~~
a.cc: In function 'int main()':
a.cc:46:13: error: reference to 'visit' is ambiguous
46 | rep(i,n) visit[i] = false;
| ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
1855 | visit(_Visitor&& __visitor, _Variants&&... __variants)
| ^~~~~
a.cc:11:6: note: 'bool visit [100000]'
11 | bool visit[MAX];
| ^~~~~
a.cc:51:4: error: expected unqualified-id before 'int'
51 | int b = 0;
| ^~~
a.cc:55:12: error: 'b' was not declared in this scope
55 | else b++;
| ^
a.cc:58:11: error: 'b' was not declared in this scope
58 | if(a > b) cout << "Fennec" << endl;
| ^
|
s136296465 | p03660 | C++ | #include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int INF =1001001001;
const int MAX = 100000;
bool graph[MAX][MAX];
int distA[MAX];
int distB[MAX];
bool visit[MAX];
void dfs(int x, int n, int count, bool a){
if(visit[x]) return;
visit[x] = true;
if(a) distA[x] = count; else distB[x] = count;
++count;
rep(i,n){
if(graph[x][i] == false) continue;
if(visit[i]) continue;
dfs(i,n,count,a);
}
}
int main()
{
int n;
cin >> n;
// 5-7-4-1-2
// L3-6
// 1-4-2-3
rep(i,n-1){
int a,b;
cin >> a >> b;
--a; --b;
graph[a][b] = true;
graph[b][a] = true;
}
//それぞれからの距離を求める
//フェネックA
dfs(0,n,0,true);
//リセット
rep(i,n) visit[i] = false;
//スヌケ
dfs(n-1,n,0,false);
int a = 0,b = 0;
rep(i,n){
if(distA[i] <= distB[i]) a++;
else b++;
}
if(a > b) cout << "Fennec" << endl;
else cout << "Snuke" << endl;
} | a.cc: In function 'void dfs(int, int, int, bool)':
a.cc:14:7: error: reference to 'visit' is ambiguous
14 | if(visit[x]) return;
| ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:80,
from a.cc:1:
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
1855 | visit(_Visitor&& __visitor, _Variants&&... __variants)
| ^~~~~
a.cc:11:6: note: 'bool visit [100000]'
11 | bool visit[MAX];
| ^~~~~
a.cc:15:4: error: reference to 'visit' is ambiguous
15 | visit[x] = true;
| ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
1855 | visit(_Visitor&& __visitor, _Variants&&... __variants)
| ^~~~~
a.cc:11:6: note: 'bool visit [100000]'
11 | bool visit[MAX];
| ^~~~~
a.cc:20:10: error: reference to 'visit' is ambiguous
20 | if(visit[i]) continue;
| ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
1855 | visit(_Visitor&& __visitor, _Variants&&... __variants)
| ^~~~~
a.cc:11:6: note: 'bool visit [100000]'
11 | bool visit[MAX];
| ^~~~~
a.cc: In function 'int main()':
a.cc:46:13: error: reference to 'visit' is ambiguous
46 | rep(i,n) visit[i] = false;
| ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
1855 | visit(_Visitor&& __visitor, _Variants&&... __variants)
| ^~~~~
a.cc:11:6: note: 'bool visit [100000]'
11 | bool visit[MAX];
| ^~~~~
|
s973163915 | p03660 | C++ | #include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int INF =1001001001;
const int MAX = 100000;
bool graph[MAX][MAX];
int distA[MAX];
int distB[MAX];
bool visit[MAX];
void dfs(int x, int n, int count, bool a){
if(visit[x]) return;
visit[x] = true;
if(a) distA[x] = count; else distB[x] = count;
++count;
rep(i,n){
if(graph[x][i] == false) continue;
if(visit[i]) continue;
dfs(i,n,count,a);
}
}
int main()
{
int n;
cin >> n;
// 5-7-4-1-2
// L3-6
// 1-4-2-3
rep(i,n-1){
int a,b;
cin >> a >> b;
--a; --b;
graph[a][b] = true;
graph[b][a] = true;
}
//それぞれからの距離を求める
//フェネックA
dfs(0,n,0,true);
//リセット
rep(i,n) visit[i] = false;
//スヌケ
dfs(n-1,n,0,false);
int a = 0,b = 0;
rep(i,n){
if(distA[i] <= distB[i]) a++;
else b++;
}
// rep(i,n)
// printf("A:%d B:%d\n",distA[i],distB[i]);
if(a > b) cout << "Fennec" << endl;
else cout << "Snuke" << endl;
} | a.cc: In function 'void dfs(int, int, int, bool)':
a.cc:14:7: error: reference to 'visit' is ambiguous
14 | if(visit[x]) return;
| ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:80,
from a.cc:1:
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
1855 | visit(_Visitor&& __visitor, _Variants&&... __variants)
| ^~~~~
a.cc:11:6: note: 'bool visit [100000]'
11 | bool visit[MAX];
| ^~~~~
a.cc:15:4: error: reference to 'visit' is ambiguous
15 | visit[x] = true;
| ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
1855 | visit(_Visitor&& __visitor, _Variants&&... __variants)
| ^~~~~
a.cc:11:6: note: 'bool visit [100000]'
11 | bool visit[MAX];
| ^~~~~
a.cc:20:10: error: reference to 'visit' is ambiguous
20 | if(visit[i]) continue;
| ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
1855 | visit(_Visitor&& __visitor, _Variants&&... __variants)
| ^~~~~
a.cc:11:6: note: 'bool visit [100000]'
11 | bool visit[MAX];
| ^~~~~
a.cc: In function 'int main()':
a.cc:46:13: error: reference to 'visit' is ambiguous
46 | rep(i,n) visit[i] = false;
| ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
1855 | visit(_Visitor&& __visitor, _Variants&&... __variants)
| ^~~~~
a.cc:11:6: note: 'bool visit [100000]'
11 | bool visit[MAX];
| ^~~~~
|
s409017467 | p03660 | C++ | import java.io.PrintWriter
import java.util.*
import java.math.*
import java.lang.*
import kotlin.comparisons.*
val pw = PrintWriter(System.out)
val MOD: Long = (1e+9 + 7).toLong()
// data class Position(val cur: Int)
class Dfs(val n: Int, val edges: Array<MutableList<Int>>) {
fun dfs(start: Int, goal: Int): Int {
val visited = Array(n) { false }.apply {
this[start] = true
}
val st = Stack<Int>()
st.push(start)
while(!st.isEmpty()) {
val cur = st.pop()
if(cur == goal) continue
val nexts = edges[cur]
nexts.forEach { n ->
if(!visited[n]) {
st.push(n)
visited[n] = true
}
}
}
var cnt = 0
for(i in 0 until n) {
if(i != start && i != goal && visited[i]) {
cnt++
}
}
return cnt
}
}
fun main(args: Array<String>) {
val n = readInt()
val edges = Array(n) { mutableListOf<Int>() }
for(i in 0 until n-1) {
val (a, b) = readListOfInt().map { it-1 }
edges[a].add(b)
edges[b].add(a)
}
val dfsObj = Dfs(n, edges)
val aNum = dfsObj.dfs(0, n-1)
val bNum = dfsObj.dfs(n-1, 0)
println(if(aNum >= bNum) "Fennec" else "Snuke")
pw.flush()
}
/****** Declared Functions and Data Structures ******/
// IO
fun read() = readLine()!!
fun readInt() = read().toInt()
fun readLong() = read().toLong()
fun readDouble() = read().toDouble()
fun readListOfString() = read().split(" ")
fun readListOfInt() = readListOfString().map { it.toInt() }
fun readListOfLong() = readListOfString().map { it.toLong() }
fun readListOfDouble() = readListOfString().map { it.toDouble() }
fun Double.format(digits: Int) = String.format("%.${digits}f", this)
fun Float.format(digits: Int) = String.format("%.${digits}f", this)
fun print(value: Any) { pw.print(value) }
fun println(value : Any) { pw.println(value) }
// Extensions
fun<T> List<T>.toBuckets(): Map<T, Int>
= this.groupBy { it }.mapValues { it.value.size }
fun<T: Comparable<T>> List<T>.upperBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {
var l = fromIndex
var r = toIndex
while(l < r) {
val mid = (l+r) / 2
if(element >= this[mid]) {
l = mid + 1
} else {
r = mid
}
}
return l
}
fun<T: Comparable<T>> List<T>.lowerBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {
var l = fromIndex
var r = toIndex
while(l < r) {
val mid = (l+r) / 2
if(element <= this[mid]) {
r = mid
} else {
l = mid + 1
}
}
return r
}
fun <K, V> Map<K, V>.toMutableMap(): MutableMap<K, V> = HashMap(this)
// Util Functions
fun Long.makeDivisors(): List<Long> {
val divisors = mutableListOf<Long>()
for(i in 1L .. Math.sqrt(this.toDouble()).toLong()+1L) {
if(this % i == 0L) {
divisors.add(i)
if(i != this/i) {
divisors.add(this/i)
}
}
}
return divisors.distinct().sorted()
}
fun Long.isPrime(): Boolean {
if(this==1L) return false
for(i in 2L .. Math.sqrt(this.toDouble()).toLong() + 1L) {
if(this % i == 0L && this != i) {
return false
}
}
return true
}
fun<T> permutations(src: List<T>): List<List<T>> {
if(src.size == 1) return listOf(src)
val perms = mutableListOf<List<T>>()
val insertElement = src[0]
permutations(src.drop(1)).forEach { perm ->
for(i in 0..perm.size) {
val newPerm = perm.toMutableList()
newPerm.add(i, insertElement)
perms.add(newPerm.toList())
}
}
return perms
}
// return nCr, if you want nCr, please access v[n][r]
fun combinations(n: Long): List<List<Long>> {
val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()
for(i in 0 until v.size) {
v[i][0] = 1L
v[i][i] = 1L
}
for(i in 0 until v.size) {
for(j in 1 until i) {
v[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD
}
}
return v.map { it.toList() }.toList()
}
fun repeatedModPow(a: Long, n: Long, mod: Long): Long =
when {
n == 1L -> a % mod
n % 2L == 1L -> (a * repeatedModPow(a, n-1L, mod)) % mod
else -> {
val tmp = repeatedModPow(a, n / 2L, mod)
(tmp * tmp) % mod
}
}
// return nCr % MOD
fun modnCkWithoutArray(n: Long, k: Long, mod: Long): Long {
var ret = 1L
val min = Math.min(k, n-k)
// まず分母の計算
for(i in n downTo (n - min + 1)) {
ret = ret * i % mod
}
for(i in min downTo 1) {
ret = ret * repeatedModPow(i, (mod - 2L), mod) % mod
}
return ret
}
// return nCr % MOD
fun modnCk(n: Int, k: Int, mod: Long): Long {
val factorials = Array(n+1) { 0L }.apply {
this[0] = 1L
if(this.size > 1) this[1] = 1L
}
val inverses = Array(n+1) { 0L }.apply {
this[0] = 1L
if(this.size > 1) this[1] = 1L
}
val factorialInverses = Array(n+1) { 0L }.apply {
this[0] = 1L
if(this.size > 1) this[1] = 1L
}
for(i in 2 .. n) {
factorials[i] = (factorials[i-1] * i.toLong() % mod)
inverses[i] = (mod - inverses[mod.toInt() % i] * (mod / i.toLong()) % mod)
factorialInverses[i] = (factorialInverses[i-1] * inverses[i] % mod)
}
return factorials[n] % mod * (factorialInverses[k] * factorialInverses[n-k] % mod) % mod
}
// should be a >= b
fun gcd(a: Long, b: Long): Long =
if(b == 0L) a else gcd(b, a % b)
// shoud be a >= b
fun lcm(a: Long, b: Long): Long =
a / gcd(a, b) * b
fun sumDigits(num_: Long): Long {
var num = num_
var rtn: Long = 0
while(num != 0.toLong()) {
val tmp = num % 10
rtn += tmp
num /= 10
}
return rtn
}
fun Double.isDecimal(): Boolean = ((this - Math.floor(this)) != 0.0)
// Data Structures
class UnionFind(private val n: Int) {
private val parent: Array<Int> = Array(n) { 0 }
private val rank: Array<Int> = Array(n) { 0 }
private val size: Array<Int> = Array(n) { 0 }
init {
for(i in 0 until n) {
parent[i] = i
rank[i] = 1
size[i] = 1
}
}
fun union(u: Int, v: Int) {
var x = root(u)
var y = root(v)
if(x != y) {
if(rank[y] < rank[x]) {
val tmp = y
y = x
x = tmp
}
parent[x] = y
rank[y] += rank[x]
rank[x] = -1
val totalSize = size[x] + size[y]
size[x] = totalSize
size[y] = totalSize
}
}
fun root(u: Int): Int {
var x = u
while(parent[x] != x) {
x = parent[x]
}
return x
}
fun size(u: Int): Int = size[root(u)]
}
| a.cc:137:26: error: too many decimal points in number
137 | for(i in 0..perm.size) {
| ^~~~~~~~~~~~
a.cc:148:18: error: too many decimal points in number
148 | val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()
| ^~~~
a.cc:148:31: error: too many decimal points in number
148 | val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()
| ^~~~
a.cc:1:1: error: 'import' does not name a type
1 | import java.io.PrintWriter
| ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:39:1: error: 'fun' does not name a type
39 | fun main(args: Array<String>) {
| ^~~
a.cc:58:1: error: 'fun' does not name a type
58 | fun read() = readLine()!!
| ^~~
a.cc:64:1: error: 'fun' does not name a type
64 | fun readListOfLong() = readListOfString().map { it.toLong() }
| ^~~
a.cc:65:1: error: 'fun' does not name a type
65 | fun readListOfDouble() = readListOfString().map { it.toDouble() }
| ^~~
a.cc:67:1: error: 'fun' does not name a type
67 | fun Double.format(digits: Int) = String.format("%.${digits}f", this)
| ^~~
a.cc:71:1: error: 'fun' does not name a type
71 | fun println(value : Any) { pw.println(value) }
| ^~~
a.cc:74:1: error: 'fun' does not name a type
74 | fun<T> List<T>.toBuckets(): Map<T, Int>
| ^~~
a.cc:75:30: error: expected unqualified-id before '.' token
75 | = this.groupBy { it }.mapValues { it.value.size }
| ^
a.cc:77:1: error: 'fun' does not name a type
77 | fun<T: Comparable<T>> List<T>.upperBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {
| ^~~
a.cc:91:1: error: 'fun' does not name a type
91 | fun<T: Comparable<T>> List<T>.lowerBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {
| ^~~
a.cc:105:1: error: 'fun' does not name a type
105 | fun <K, V> Map<K, V>.toMutableMap(): MutableMap<K, V> = HashMap(this)
| ^~~
a.cc:121:1: error: 'fun' does not name a type
121 | fun Long.isPrime(): Boolean {
| ^~~
a.cc:132:1: error: 'fun' does not name a type
132 | fun<T> permutations(src: List<T>): List<List<T>> {
| ^~~
a.cc:147:1: error: 'fun' does not name a type
147 | fun combinations(n: Long): List<List<Long>> {
| ^~~
a.cc:161:1: error: 'fun' does not name a type
161 | fun repeatedModPow(a: Long, n: Long, mod: Long): Long =
| ^~~
a.cc:172:1: error: 'fun' does not name a type
172 | fun modnCkWithoutArray(n: Long, k: Long, mod: Long): Long {
| ^~~
a.cc:186:1: error: 'fun' does not name a type
186 | fun modnCk(n: Int, k: Int, mod: Long): Long {
| ^~~
a.cc:209:1: error: 'fun' does not name a type
209 | fun gcd(a: Long, b: Long): Long =
| ^~~
a.cc:227:1: error: 'fun' does not name a type
227 | fun Double.isDecimal(): Boolean = ((this - Math.floor(this)) != 0.0)
| ^~~
|
s630088549 | p03660 | C++ | #include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a) (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N;
vector<int> Tree[100005];
int DP[100005][100005];
queue<int> q1, q2;
unordered_map<int, bool> S;
// idxの偶奇で先手後手判断する
// どのようにとっても自分が負けるならtrueを返す。相手は必ずそれを打つ
// そうでない場合はfalseを返す
bool dfs(int idx, int prevB, int prevW, queue<int> B, queue<int> W, unordered_map<int, bool> S) {
if (idx==N-1) return true; // 最後までいったならその前の人は勝つ
if (DP[prevB][prevW]>=0) return DP[prevB][prevW];
S[prevB] = true;
S[prevW] = true;
bool flag = true;
if (idx%2==0) {
vector<int> vec = Tree[prevB];
for(auto p : Tree[prevB]) {
if (!S[p]) B.push(p);
}
int queSize = B.size();
rep(i, queSize) {
int q = B.front(); B.pop();
bool tmp = dfs(idx+1, q, prevW, B, W, S);
if (tmp) {
flag = false;
break;
}
B.push(q);
}
} else {
vector<int> vec = Tree[prevW];
for(auto p : Tree[prevW]) {
if (!S[p]) W.push(p);
}
int queSize = W.size();
rep(i, queSize) {
int q = W.front(); W.pop();
bool tmp = dfs(idx+1, prevB, q, B, W, S);
if (tmp) {
flag = false;
break;
}
W.push(q);
}
}
DP[prevB][prevW] = !flag?1:0;
return flag;
}
int main() {
INCANT;
cin >> N;
int a,b;
rep(i, N-1) {
cin >> a >> b;
a--;b--;
Tree[a].push_back(b);
Tree[b].push_back(a);
}
rep(i, N) rep(j, N) DP[i][j] = -1;
bool c = dfs(0, 0, N-1, q1, q2, S);
string ans = !c?"Fennec":"Snuke"; //-1番目の人の勝敗
cout << ans << "\n";
return 0;
} | /tmp/ccr1rEVy.o: in function `main':
a.cc:(.text+0x834): relocation truncated to fit: R_X86_64_PC32 against symbol `S' defined in .bss section in /tmp/ccr1rEVy.o
a.cc:(.text+0x84d): relocation truncated to fit: R_X86_64_PC32 against symbol `q2' defined in .bss section in /tmp/ccr1rEVy.o
a.cc:(.text+0x863): relocation truncated to fit: R_X86_64_PC32 against symbol `q1' defined in .bss section in /tmp/ccr1rEVy.o
/tmp/ccr1rEVy.o: in function `__static_initialization_and_destruction_0()':
a.cc:(.text+0xa5d): relocation truncated to fit: R_X86_64_PC32 against symbol `q1' defined in .bss section in /tmp/ccr1rEVy.o
a.cc:(.text+0xa76): relocation truncated to fit: R_X86_64_PC32 against symbol `q1' defined in .bss section in /tmp/ccr1rEVy.o
a.cc:(.text+0xa8f): relocation truncated to fit: R_X86_64_PC32 against symbol `q2' defined in .bss section in /tmp/ccr1rEVy.o
a.cc:(.text+0xaa8): relocation truncated to fit: R_X86_64_PC32 against symbol `q2' defined in .bss section in /tmp/ccr1rEVy.o
a.cc:(.text+0xac1): relocation truncated to fit: R_X86_64_PC32 against symbol `S' defined in .bss section in /tmp/ccr1rEVy.o
a.cc:(.text+0xada): relocation truncated to fit: R_X86_64_PC32 against symbol `S' defined in .bss section in /tmp/ccr1rEVy.o
collect2: error: ld returned 1 exit status
|
s439398609 | p03660 | C++ | using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
class Program
{
static void Main(string[] args)
{
var N = sc.ReadInt();
var g = new List<int>[N];
for (int i = 0; i < N; i++)
{
g[i] = new List<int>();
}
for (int i = 0; i < N - 1; i++)
{
var a = sc.ReadInt() - 1;
var b = sc.ReadInt() - 1;
g[a].Add(b);
g[b].Add(a);
}
var color = new int[N];
color[0] = 1;
color[N - 1] = 2;
var q1 = new Queue<int>();
q1.Enqueue(0);
var q2 = new Queue<int>();
q2.Enqueue(N - 1);
while (q1.Count > 0 || q2.Count > 0)
{
if (q1.Count > 0)
{
var now = q1.Dequeue();
foreach (var next in g[now])
{
if (color[next] != 0) continue;
color[next] = 1;
q1.Enqueue(next);
}
}
if (q2.Count > 0)
{
var now = q2.Dequeue();
foreach (var next in g[now])
{
if (color[next] != 0) continue;
color[next] = 2;
q2.Enqueue(next);
}
}
}
var c1 = color.Count(c => c == 1);
var c2 = N - c1;
if (c1 > c2)
{
Console.WriteLine("Fennec");
}
else
{
Console.WriteLine("Sunuke");
}
}
static Scanner sc = new Scanner();
}
class Scanner
{
string[] S = new string[0];
int Index = 0;
char[] Separators = new char[] { ' ' };
public string Next()
{
if (this.Index < this.S.Length) return this.S[this.Index++];
var line = "";
while (line == "") line = Console.ReadLine();
this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries);
if (this.S.Length == 0) return this.Next();
this.Index = 0;
return this.S[this.Index++];
}
public string ReadStr()
{
return this.Next();
}
public char ReadChar()
{
return this.Next()[0];
}
public int ReadInt()
{
return int.Parse(this.Next());
}
public uint ReadUInt()
{
return uint.Parse(this.Next());
}
public long ReadLong()
{
return long.Parse(this.Next());
}
public double ReadDouble()
{
return double.Parse(this.Next());
}
public Tuple<int, int> ReadTup(int add = 0)
{
return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add);
}
public Tuple<long, long> ReadTupLong(int add = 0)
{
return Tuple.Create(this.ReadLong() + add, this.ReadLong() + add);
}
public Tuple<int, int, int> ReadTup3(int add = 0)
{
return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add, this.ReadInt() + add);
}
public Tuple<int, int, int, int> ReadTup4(int add = 0)
{
return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add, this.ReadInt() + add, this.ReadInt() + add);
}
public int[] ReadIntArray(int n)
{
var array = new int[n];
for (int i = 0; i < array.Length; i++)
{
array[i] = this.ReadInt();
}
return array;
}
public long[] ReadLongArray(int n)
{
var array = new long[n];
for (int i = 0; i < array.Length; i++)
{
array[i] = this.ReadLong();
}
return array;
}
public double[] ReadDoubleArray(int n)
{
var array = new double[n];
for (int i = 0; i < array.Length; i++)
{
array[i] = this.ReadDouble();
}
return array;
}
public char[] ReadCharArray(int n)
{
var array = new char[n];
for (int i = 0; i < array.Length; i++)
{
array[i] = this.ReadChar();
}
return array;
}
public string[] ReadStrArray(int n)
{
var array = new string[n];
for (int i = 0; i < array.Length; i++)
{
array[i] = this.ReadStr();
}
return array;
}
public Tuple<long, long>[] ReadTupLongArray(int n, int add = 0)
{
var array = new Tuple<long, long>[n];
for (int i = 0; i < n; i++)
{
array[i] = this.ReadTupLong(add);
}
return array;
}
public Tuple<int, int>[] ReadTupArray(int n, int add = 0)
{
var array = new Tuple<int, int>[n];
for (int i = 0; i < n; i++)
{
array[i] = this.ReadTup(add);
}
return array;
}
public Tuple<int, int, int>[] ReadTup3Array(int n, int add = 0)
{
var array = new Tuple<int, int, int>[n];
for (int i = 0; i < n; i++)
{
array[i] = this.ReadTup3(add);
}
return array;
}
public Tuple<int, int, int, int>[] ReadTup4Array(int n, int add = 0)
{
var array = new Tuple<int, int, int, int>[n];
for (int i = 0; i < n; i++)
{
array[i] = this.ReadTup4(add);
}
return array;
}
}
| a.cc:1:7: error: expected nested-name-specifier before 'System'
1 | using System;
| ^~~~~~
a.cc:2:7: error: expected nested-name-specifier before 'System'
2 | using System.Collections.Generic;
| ^~~~~~
a.cc:3:7: error: expected nested-name-specifier before 'System'
3 | using System.IO;
| ^~~~~~
a.cc:4:7: error: expected nested-name-specifier before 'System'
4 | using System.Linq;
| ^~~~~~
a.cc:8:22: error: 'string' has not been declared
8 | static void Main(string[] args)
| ^~~~~~
a.cc:8:31: error: expected ',' or '...' before 'args'
8 | static void Main(string[] args)
| ^~~~
a.cc:69:12: error: 'Scanner' does not name a type
69 | static Scanner sc = new Scanner();
| ^~~~~~~
a.cc:70:2: error: expected ';' after class definition
70 | }
| ^
| ;
a.cc: In static member function 'static void Program::Main(int*)':
a.cc:10:9: error: 'var' was not declared in this scope
10 | var N = sc.ReadInt();
| ^~~
a.cc:11:13: error: expected ';' before 'g'
11 | var g = new List<int>[N];
| ^
a.cc:12:29: error: 'N' was not declared in this scope
12 | for (int i = 0; i < N; i++)
| ^
a.cc:14:13: error: 'g' was not declared in this scope
14 | g[i] = new List<int>();
| ^
a.cc:14:24: error: 'List' does not name a type
14 | g[i] = new List<int>();
| ^~~~
a.cc:14:29: error: expected primary-expression before 'int'
14 | g[i] = new List<int>();
| ^~~
a.cc:16:29: error: 'N' was not declared in this scope
16 | for (int i = 0; i < N - 1; i++)
| ^
a.cc:18:17: error: expected ';' before 'a'
18 | var a = sc.ReadInt() - 1;
| ^
a.cc:19:17: error: expected ';' before 'b'
19 | var b = sc.ReadInt() - 1;
| ^
a.cc:20:13: error: 'g' was not declared in this scope
20 | g[a].Add(b);
| ^
a.cc:20:15: error: 'a' was not declared in this scope
20 | g[a].Add(b);
| ^
a.cc:20:22: error: 'b' was not declared in this scope
20 | g[a].Add(b);
| ^
a.cc:24:13: error: expected ';' before 'color'
24 | var color = new int[N];
| ^~~~~
a.cc:25:9: error: 'color' was not declared in this scope
25 | color[0] = 1;
| ^~~~~
a.cc:26:15: error: 'N' was not declared in this scope
26 | color[N - 1] = 2;
| ^
a.cc:28:13: error: expected ';' before 'q1'
28 | var q1 = new Queue<int>();
| ^~
a.cc:29:9: error: 'q1' was not declared in this scope
29 | q1.Enqueue(0);
| ^~
a.cc:30:13: error: expected ';' before 'q2'
30 | var q2 = new Queue<int>();
| ^~
a.cc:31:9: error: 'q2' was not declared in this scope
31 | q2.Enqueue(N - 1);
| ^~
a.cc:36:21: error: expected ';' before 'now'
36 | var now = q1.Dequeue();
| ^~~
a.cc:37:30: error: expected ')' before 'next'
37 | foreach (var next in g[now])
| ^~~~
a.cc:37:25: note: to match this '('
37 | foreach (var next in g[now])
| ^
a.cc:37:17: error: 'foreach' was not declared in this scope
37 | foreach (var next in g[now])
| ^~~~~~~
a.cc:46:21: error: expected ';' before 'now'
46 | var now = q2.Dequeue();
| ^~~
a.cc:47:30: error: expected ')' before 'next'
47 | foreach (var next in g[now])
| ^~~~
a.cc:47:25: note: to match this '('
47 | foreach (var next in g[now])
| ^
a.cc:47:17: error: 'foreach' was not declared in this scope
47 | foreach (var next in g[now])
| ^~~~~~~
a.cc:56:13: error: expected ';' before 'c1'
56 | var c1 = color.Count(c => c == 1);
| ^~
a.cc:57:13: error: expected ';' before 'c2'
57 | var c2 = N - c1;
| ^~
a.cc:58:13: error: 'c1' was not declared in this scope
58 | if (c1 > c2)
| ^~
a.cc:58:18: error: 'c2' was not declared in this scope
58 | if (c1 > c2)
| ^~
a.cc:60:13: error: 'Console' was not declared in this scope
60 | Console.WriteLine("Fennec");
| ^~~~~~~
a.cc:64:13: error: 'Console' was not declared in this scope
64 | Console.WriteLine("Sunuke");
| ^~~~~~~
a.cc: At global scope:
a.cc:73:5: error: 'string' does not name a type
73 | string[] S = new string[0];
| ^~~~~~
a.cc:75:9: error: expected unqualified-id before '[' token
75 | char[] Separators = new char[] { ' ' };
| ^
a.cc:77:11: error: expected ':' before 'string'
77 | public string Next()
| ^~~~~~~
| :
a.cc:77:12: error: 'string' does not name a type
77 | public string Next()
| ^~~~~~
a.cc:87:11: error: expected ':' before 'string'
87 | public string ReadStr()
| ^~~~~~~
| :
a.cc:87:12: error: 'string' does not name a type
87 | public string ReadStr()
| ^~~~~~
a.cc:91:11: error: expected ':' before 'char'
91 | public char ReadChar()
| ^~~~~
| :
a.cc:95:11: error: expected ':' before 'int'
95 | public int ReadInt()
| ^~~~
| :
a.cc:99:11: error: expected ':' before 'uint'
99 | public uint ReadUInt()
| ^~~~~
| :
a.cc:99:12: error: 'uint' does not name a type; did you mean 'int'?
99 | public uint ReadUInt()
| ^~~~
| int
a.cc:103:11: error: expected ':' before 'long'
103 | public long ReadLong()
| ^~~~~
| :
a.cc:107:11: error: expected ':' before 'double'
107 | public double ReadDouble()
| ^~~~~~~
| :
a.cc:111:11: error: expected ':' before 'Tuple'
111 | public Tuple<int, int> ReadTup(int add = 0)
| ^~~~~~
| :
a.cc:111:12: error: 'Tuple' does not name a type
111 | public Tuple<int, int> ReadTup(int add = 0)
| ^~~~~
a.cc:115:11: error: expected ':' before 'Tuple'
115 | public Tuple<long, long> ReadTupLong(int add = 0)
| ^~~~~~
| :
a.cc:115:12: error: 'Tuple' does not name a type
115 | public Tuple<long, long> ReadTupLong(int add = 0)
| ^~~~~
a.cc:119:11: error: expected ':' before 'Tuple'
119 | public Tuple<int, int, int> ReadTup3(int add = 0)
| ^~~~~~
| :
a.cc:119:12: error: 'Tuple' does not name a type
119 | public Tuple<int, int, int> ReadTup3(int add = 0)
| ^~~~~
a.cc:123:11: error: expected ':' before 'Tuple'
123 | public Tuple<int, int, int, int> ReadTup4(int add = 0)
| ^~~~~~
| :
a.cc:123:12: error: 'Tuple' does not name a type
123 | public Tuple<int, int, int, int> ReadTup4(int add = 0)
| ^~~~~
a.cc:127:11: error: expected ':' before 'int'
127 | public int[] ReadIntArray(int n)
| ^~~~
| :
a.cc:127:15: error: expected unqualified-id before '[' token
127 | public int[] ReadIntArray(int n)
| ^
a.cc:136:11: error: expected ':' before 'long'
136 | public long[] ReadLongArray(int n)
| ^~~~~
| :
a.cc:136:16: error: expected unqualified-id before '[' token
136 | public long[] ReadLongArray(int n)
| ^
a.cc:145:11: error: expected ':' before 'double'
145 | public double[] ReadDoubleArray(int n)
| ^~~~~~~
| :
a.cc:145:18: error: expected unqualified-id before '[' token
145 | public double[] ReadDoubleArray(int n)
| ^
a.cc:154:11: error: expected ':' before 'char'
154 | public char[] ReadCharArray(int n)
| ^~~~~
| :
a.cc:154:16: error: expected unqualified-id before '[' token
154 | public char[] ReadCharArray(int n)
| ^
a.cc:163:11: error: expected ':' before 'string'
163 | public string[] ReadStrArray(int n)
| ^~~~~~~
| :
a.cc:163:12: error: 'string' does not name a type
163 | public string[] ReadStrArray(int n)
| ^~~~~~
a.cc:172:11: error: expected ':' before 'Tuple'
172 | public Tuple<long, long>[] ReadTupLongArray(int n, int add = 0)
| ^~~~~~
| :
a.cc:172:12: error: 'Tuple' does not name a type
172 | public Tuple<long, long>[] ReadTupLongArray(int n, int add = 0)
| ^~~~~
a.cc:181:11: error: expected ':' before 'Tuple'
181 | public Tuple<int, int>[] ReadTupArray(int n, int add = 0)
| ^~~~~~
| :
a.cc:181:12: error: 'Tuple' does not name a type
181 | public Tuple<int, int>[] ReadTupArray(int n, int add = 0)
| ^~~~~
a.cc:190:11: error: expected ':' before 'Tuple'
190 | public Tuple<int, int, int>[] ReadTup3Array(int n, int add = 0)
| ^~~~~~
| :
a.cc:190:12: error: 'Tuple' does not name a type
190 | public Tuple<int, int, int>[] ReadTup3Array(int n, int add = 0)
| ^~~~~
a.cc:199:11: error: expected ':' before 'Tuple'
199 | public Tuple<int, int, int, int>[] ReadTup4Array(int n, int add = 0)
| ^~~~~~
| :
a.cc:199:12: error: 'Tuple' does not name a type
199 | public Tuple<int, int, |
s905174548 | p03660 | C++ | package main
import (
"bufio"
"fmt"
"os"
"strconv"
)
var sc = bufio.NewScanner(os.Stdin)
func Scanner() string {
sc.Scan()
return sc.Text()
}
func main() {
buf := make([]byte, 0)
sc.Buffer(buf, 1000000007)
sc.Split(bufio.ScanWords)
n, _ := strconv.Atoi(Scanner())
tree := make([][]int, n)
for i := 0; i < n-1; i++ {
a, _ := strconv.Atoi(Scanner())
b, _ := strconv.Atoi(Scanner())
a--
b--
tree[a] = append(tree[a], b)
tree[b] = append(tree[b], a)
}
fq := []int{0}
fd := make([]int, n)
for i := 1; i < n; i++ {
fd[i] = -1
}
for {
v := fq[0]
fq = fq[1:]
for _, j := range tree[v] {
if fd[j] == -1 {
fq = append(fq, j)
fd[j] = fd[v] + 1
}
}
if len(fq) == 0 {
break
}
}
sq := []int{n - 1}
sd := make([]int, n)
for i := 0; i < n-1; i++ {
sd[i] = -1
}
for {
v := sq[0]
sq = sq[1:]
for _, j := range tree[v] {
if sd[j] == -1 {
sq = append(sq, j)
sd[j] = sd[v] + 1
}
}
if len(sq) == 0 {
break
}
}
f, s := -1, -1
for i := 0; i < n; i++ {
if fd[i] == sd[i] || sd[i]-1 == fd[i] {
f = i
for _, j := range tree[i] {
if sd[j] == sd[i]-1 {
s = j
}
}
break
}
}
fq = []int{0}
fd[0] = 1
for i := 1; i < n; i++ {
fd[i] = -1
}
fc := 1
for {
v := fq[0]
fq = fq[1:]
for _, j := range tree[v] {
if fd[j] == -1 && j != s {
fq = append(fq, j)
fd[j] = 1
fc++
}
}
if len(fq) == 0 {
break
}
}
sq = []int{n - 1}
sd[n-1] = 1
for i := 0; i < n-1; i++ {
sd[i] = -1
}
sc := 1
for {
v := sq[0]
sq = sq[1:]
for _, j := range tree[v] {
if sd[j] == -1 && j != f {
sq = append(sq, j)
sd[j] = 1
sc++
}
}
if len(sq) == 0 {
break
}
}
if fc > sc {
fmt.Println("Fennec")
} else {
fmt.Println("Snuke")
}
}
| a.cc:1:1: error: 'package' does not name a type
1 | package main
| ^~~~~~~
a.cc:17:1: error: 'func' does not name a type
17 | func main() {
| ^~~~
|
s342513561 | p03660 | C++ | #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
int N;
vector<int> graph[100010];
int memo[100010];
int solve(int indx, bool fennec) {
if (memo[indx] != -1) {
return memo[indx];
}
memo[indx] = 0;
int enemy = N-1;
if (!fennec) {
enemy = 0;
}
if (indx == enemy) {
return memo[indx] = 0;
}
bool flg = false;
for (int i = 0; i < graph[indx].size(); ++i) {
if (memo[graph[indx][i]] == -1) {
flg = true;
break;
}
}
if (!flg) {
return memo[indx] = 0;
}
int ans = 0;
for (int i = 0; i < graph[indx].size(); ++i) {
if (memo[graph[indx][i]] == -1) {
ans += solve(graph[indx][i], fennec) + 1;
}
}
return memo[indx] = ans;
}
int main() {
cin >> N;
for (int i = 0; i < N-1; ++i) {
int a,b;
cin >> a >> b;
--a; --b;
graph[a].emplace_back(b);
graph[b].emplace_back(a);
}
// Fennec
memset(memo, -1, sizeof(memo));
int x = solve(0, true);
//cout << x << endl;
// Snuke
memset(memo, -1, sizeof(memo));
int y = solve(N-1, false);
//cout << y << endl;
puts(x>=y?"Fennec":"Snuke");
return 0;
} | a.cc: In function 'int main()':
a.cc:50:5: error: 'memset' was not declared in this scope
50 | memset(memo, -1, sizeof(memo));
| ^~~~~~
a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
4 | #include <vector>
+++ |+#include <cstring>
5 | using namespace std;
|
s678536707 | p03660 | C++ | #include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64 long long
#define int long long
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T> void SORT_(std::vector<T>& v,bool GREATER = 0){if(GREATER == 0)sort(v.begin(),v.end());else{sort(v.begin(),v.end(),std::greater<T>());}}
void DFS(int V,vector<vector<int> >&GRAPH,vector<int>&dist,int depth)
{
dist[V] = depth;
for (int i = 0; i < GRAPH[V].size(); i++)
{
if(dist[GRAPH[V][i]] == -1)
{
DFS(GRAPH[V][i],GRAPH,dist,depth+1);
}
}
return;
}
void solve(void)
{
int N;
cin>>N;
vector<vector<int> >GRAPH(N);
for (int i = 0; i < N-1; i++)
{
int A,B;
cin>>A>>B;
A--;B--;
GRAPH[A].push_back(B);
GRAPH[B].push_back(A);
}
vector<int> dist0(N,-1);
vector<int> distN(N,-1);
DFS(0,GRAPH,dist0,0);
dist0[0] = 0;
distN[N-1] = 0;
DFS(N-1,GRAPH,distN,0);
int count = 0;
for (int i = 0; i < N; i++)
{
if(dist0[i] =< distN[i])
{
count++;
}
}
if(count*2 > N)
{
cout<<"Fennec"<<endl;
}
else
{
cout<<"Snuke"<<endl;
}
return;
}
int32_t main(int32_t argc, const char *argv[])
{
std::ios::sync_with_stdio(false);
std::cin.tie(0);
std::cout << std::fixed;
std::cout << std::setprecision(9);
solve();
return 0;
} | a.cc: In function 'void solve()':
a.cc:81:18: error: expected primary-expression before '<' token
81 | if(dist0[i] =< distN[i])
| ^
|
s158722467 | p03660 | C++ |
using namespace std;
int main() {
cout << "Snuke" << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:5:3: error: 'cout' was not declared in this scope
5 | cout << "Snuke" << endl;
| ^~~~
a.cc:1:1: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
+++ |+#include <iostream>
1 |
a.cc:5:22: error: 'endl' was not declared in this scope
5 | cout << "Snuke" << endl;
| ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
+++ |+#include <ostream>
1 |
|
s451603094 | p03660 | C++ | #include<bits/stdc++.h>
#define loop(a,b) for(b=0;b<a;b++)
#define append push_back
vector<int>a[10000];
void dfs(int,int,int,int*);
int main(){
// freopen("1.txt","r",stdin);
int black[10000]={},white[10000]={};
int n,i;
cin>>n;
n--;
loop(n,i){
int x,y;
cin>>x>>y;
x--;y--;
a[x].append(y);
a[y].append(x);
}
dfs(0,-1,1,black);
dfs(n,-1,1,white);
int b=0,w=0;
loop(n,i){
if(black[i]<=white[i])b++;
else w++;
}
// cerr<<"B:"<<b<<" ;W:"<<w<<endl;
if(b>w)puts("Fennec");
else puts("Snuck");
return 0;
}
void dfs(int node,int last,int depth,int*graph){
graph[node]=depth;
for(int i=0;i<a[node].size();i++){
if(a[node][i]==last)continue;
dfs(a[node][i],node,depth+1,graph);
}
} | a.cc:4:1: error: 'vector' does not name a type
4 | vector<int>a[10000];
| ^~~~~~
a.cc: In function 'int main()':
a.cc:10:9: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
10 | cin>>n;
| ^~~
| std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146,
from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
62 | extern istream cin; ///< Linked to standard input
| ^~~
a.cc:16:17: error: 'a' was not declared in this scope
16 | a[x].append(y);
| ^
a.cc: In function 'void dfs(int, int, int, int*)':
a.cc:33:23: error: 'a' was not declared in this scope
33 | for(int i=0;i<a[node].size();i++){
| ^
|
s854022733 | p03660 | C++ | #include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <queue>
#include <algorithm> // sort
#include <math.h>
#define DEBUG 0
#define REP(i, n) for (long long i = 0; i < (n); i++)
typedef long long ll;
static const ll mod = 1000000007;
static const ll INF = 1000000000000000000LL;
//999999997000000003
//1000000000000000000
using namespace std;
//2-1-4-7-5
// |
// 3-6
//これが想像できていない
//1-2-3-7
// |
// 5-6-4
//d[0][N-1]の距離をはかる(閉路がないため、一通り)
//先行の方が先に使える
//あまりの数
int main(){
#if DEBUG
std::ifstream in("input.txt");
std::cin.rdbuf(in.rdbuf());
#endif
int N;
cin >> N;
vector <vector <int>> G(N);
REP(i,N-1)
{
int a, b;
cin >> a >> b;
--a;--b;
G[a].push_back(b);
G[b].push_back(a);
}
//0からの最短経路と最短経路でNを使用するか
vector <pair<int, int> > d(N);
vector <int> prev(N);
vector <int> guard(N);
REP(i,N)
{
d[i].first = N+100;
d[i].second = 0;
}
d[0].first = 0;
d[N-1].second = 1;
//0からN-1を経由して到達できる箇所を調べる
queue <int> que;
que.push(0);
int from, to;
while(!que.empty())
{
from = que.front();
que.pop();
for(int i = 0; i < G[from].size(); ++i)
{
to = G[from][i];
if(d[from].first + 1 < d[to].first)
{
d[to].first = d[from].first + 1;
//Nは上書きしてはいけない
if(to != N-1)d[to].second = d[from].second;
prev[to] = from;
que.push(to);
}
}
}
//snukeは Nから1に向かって、(d[N-1] - 1) / 2回移動できる
int pos = N;
REP(i, (d[N-1] - 1) / 2)
{
pos = prev[pos];
guard[pos] = 1;
}
int fen = 0;
que.push(0);
int from, to;
while(!que.empty())
{
from = que.front();
que.pop();
for(int i = 0; i < G[from].size(); ++i)
{
to = G[from][i];
if(guard[to] == 1)continue;
guard[to] = 1;
++fen;
que.push(to);
}
}
string res;
if( fen > (N - 2) / 2 )
{
res = "Fennec";
}
else
{
res = "Snuke";
}
cout << res << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:90:20: error: no match for 'operator-' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} and 'int')
90 | REP(i, (d[N-1] - 1) / 2)
a.cc:11:46: note: in definition of macro 'REP'
11 | #define REP(i, n) for (long long i = 0; i < (n); i++)
| ^
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:618:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__y.base() - __x.base())) std::operator-(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
618 | operator-(const reverse_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:618:5: note: template argument deduction/substitution failed:
a.cc:90:22: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} is not derived from 'const std::reverse_iterator<_Iterator>'
90 | REP(i, (d[N-1] - 1) / 2)
| ^
a.cc:11:46: note: in definition of macro 'REP'
11 | #define REP(i, n) for (long long i = 0; i < (n); i++)
| ^
/usr/include/c++/14/bits/stl_iterator.h:1790:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__x.base() - __y.base())) std::operator-(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
1790 | operator-(const move_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1790:5: note: template argument deduction/substitution failed:
a.cc:90:22: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} is not derived from 'const std::move_iterator<_IteratorL>'
90 | REP(i, (d[N-1] - 1) / 2)
| ^
a.cc:11:46: note: in definition of macro 'REP'
11 | #define REP(i, n) for (long long i = 0; i < (n); i++)
| ^
a.cc:98:9: error: redeclaration of 'int from'
98 | int from, to;
| ^~~~
a.cc:68:9: note: 'int from' previously declared here
68 | int from, to;
| ^~~~
a.cc:98:15: error: redeclaration of 'int to'
98 | int from, to;
| ^~
a.cc:68:15: note: 'int to' previously declared here
68 | int from, to;
| ^~
|
s996845508 | p03660 | C++ | //#include <tourist>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <iomanip>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
//setprecision(15)有効数字15桁
//-std=c++14
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b)
{
return a * b / gcd(a, b);
}
struct edge {
int to, cost;
};
int n, b, c;
int a[10000];
vector<vector<int> > v(100000);
vector<bool> used(100000,false);
int center;
int dfsc(int a,int count){
if(a==n-1) return count;
used[a]=true;
int res=0;
for(int i=0;i<v[a].size();i++){
if(used[v[a][i]]) continue;
res=max(res,dfsc(v[a][i],count+1));
}
if(res/2=count) center=a;
return res;
}
int dfs(int a){
used[a]=true;
int res=1;
for(int i=0;i<v[a].size();i++){
if(used[v[a][i]]) continue;
res+=dfs(v[a][i]);
}
return res;
}
int main()
{
cin.tie(0);
ios::sync_with_stdio(false);
cin >> n;
for (int i = 0; i < n-1; i++)
{
int tempa, tempb;
cin >> tempa>>tempb;
tempa--;
tempb--;
v[tempa].push_back(tempb);
v[tempb].push_back(tempa);
}
center=0;
int c=dfsc(0,0);
used=vector<bool> (100000,false);
cout<<center<<"\n";
used[center]=true;
int ans=dfs(n-1);
cout<<ans<<"\n";
if(ans*2>=n)
return cout <<"Snuke"<< "\n",0;
else{
return cout <<"Fennec"<< "\n",0;
}
}
| a.cc: In function 'int dfsc(int, int)':
a.cc:63:11: error: lvalue required as left operand of assignment
63 | if(res/2=count) center=a;
| ~~~^~
|
s520592390 | p03660 | C++ | #include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;
const ll mod = 1000000007;
int main() {
int n;
cin >> n;
Graph to(n), cost(n);
rep(i, n-1) {
ll a, b;
cin >> a >> b;
a--; b--;
to[a].push_back(b);
to[b].push_back(a);
cost[a].push_back(1LL);
cost[b].push_back(1LL);
}
vector<ll> dist0(n, -1LL), distN(n, -1LL);
queue<ll> Q0, QN;
dist0[0] = 0;
Q0.push(root0);
while(!Q0.empty()) {
ll v = Q0.front();
Q0.pop();
rep(i, to[v].size()) {
ll u = to[v][i];
if(dist0[u] != -1) {
continue;
}
dist0[u] = dist0[v] + cost[v][i];
Q0.push(u);
}
}
distN[n-1] = 0;
QN.push(rootN);
while(!QN.empty()) {
ll v = QN.front();
QN.pop();
rep(i, to[v].size()) {
ll u = to[v][i];
if(distN[u] != -1) {
continue;
}
distN[u] = distN[v] + cost[v][i];
QN.push(u);
}
}
int cnt0 = 0, cntN = 0;
rep(i, n) {
if(dist0[i] <= distN[i]) {
cnt0++;
}
else {
cntN++;
}
}
if(cnt0 > cntN) {
cout << "Fennec";
}
else {
cout << "Snuke";
}
cout << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:36:13: error: 'root0' was not declared in this scope
36 | Q0.push(root0);
| ^~~~~
a.cc:56:13: error: 'rootN' was not declared in this scope
56 | QN.push(rootN);
| ^~~~~
|
s395427459 | p03660 | C++ | #include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;
const ll mod = 1000000007;
int main() {
int n;
cin >> n;
Graph to(n), cost(n);
rep(i, n-1) {
ll a, b;
cin >> a >> b;
a--; b--;
to[a].push_back(b);
to[b].push_back(a);
cost[a].push_back(1LL);
cost[b].push_back(1LL);
}
vector<ll> dist0(n, -1LL), distN(n, -1LL);
queue<ll> Q0, QN;
const ll root0 = 0LL,
dist0[root0] = 0;
Q0.push(root0);
while(!Q0.empty()) {
ll v = Q0.front();
Q0.pop();
rep(i, to[v].size()) {
ll u = to[v][i];
if(dist0[u] != -1) {
continue;
}
dist0[u] = dist0[v] + cost[v][i];
Q0.push(u);
}
}
const ll rootN = n-1;
distN[rootN] = 0;
QN.push(rootN);
while(!QN.empty()) {
ll v = QN.front();
QN.pop();
rep(i, to[v].size()) {
ll u = to[v][i];
if(distN[u] != -1) {
continue;
}
distN[u] = distN[v] + cost[v][i];
QN.push(u);
}
}
int cnt0 = 0, cntN = 0;
rep(i, n) {
if(dist0[i] <= distN[i]) {
cnt0++;
}
else {
cntN++;
}
}
if(cnt0 > cntN) {
cout << "Fennec";
}
else {
cout << "Snuke";
}
cout << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:36:5: error: conflicting declaration 'const ll dist0 [0]'
36 | dist0[root0] = 0;
| ^~~~~
a.cc:32:16: note: previous declaration as 'std::vector<long long int> dist0'
32 | vector<ll> dist0(n, -1LL), distN(n, -1LL);
| ^~~~~
|
s689581800 | p03660 | C++ | #include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;
const ll mod = 1000000007;
int main() {
int n;
cin >> n;
Graph to(n), cost(n);
rep(i, n-1) {
ll a, b;
cin >> a >> b;
a--; b--;
to[a].push_back(b);
to[b].push_back(a);
cost[a].push_back(1LL);
cost[b].push_back(1LL);
}
vector<ll> dist0(n, -1), distN(n, -1);
queue<ll> Q0, QN;
const int root0 = 0,
dist0[root0] = 0;
Q0.push(root0);
while(!Q0.empty()) {
ll v = Q0.front();
Q0.pop();
rep(i, to[v].size()) {
ll u = to[v][i];
if(dist0[u] != -1) {
continue;
}
dist0[u] = dist0[v] + cost[v][i];
Q0.push(u);
}
}
const int rootN = n-1;
distN[rootN] = 0;
QN.push(rootN);
while(!QN.empty()) {
ll v = QN.front();
QN.pop();
rep(i, to[v].size()) {
ll u = to[v][i];
if(distN[u] != -1) {
continue;
}
distN[u] = distN[v] + cost[v][i];
QN.push(u);
}
}
int cnt0 = 0, cntN = 0;
rep(i, n) {
if(dist0[i] <= distN[i]) {
cnt0++;
}
else {
cntN++;
}
}
if(cnt0 > cntN) {
cout << "Fennec";
}
else {
cout << "Snuke";
}
cout << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:36:5: error: conflicting declaration 'const int dist0 [0]'
36 | dist0[root0] = 0;
| ^~~~~
a.cc:32:16: note: previous declaration as 'std::vector<long long int> dist0'
32 | vector<ll> dist0(n, -1), distN(n, -1);
| ^~~~~
|
s432650991 | p03660 | C++ | //どうしてもフェネちゃん VS きすけくん にしたかった..........
/* include */
#include <cstdio>
/* using namespace */
using namespace std;
/* local var */
vector<int> グラフ[100005];
/* define */
#define loop(i,j) for(int i = 0; i < j; i++)
/* typedef */
typedef long long ll;
/* function */
void dfs(int マス,int 前回いた場所,int 距離差,int 距離配列[])
{
/* 距離差の設定 */
距離配列[マス]=距離差;
loop(i,sizeof(グラフ[マス])){
/* 前回いた場所でなければ行ってないので行く */
if(グラフ[マス][i] != 前回いた場所 ) dfs(グラフ[マス][i],マス,距離差+1,距離配列);
}
}
/* main program */
int main()
{
int フェネック[100005];
int きすけ[100005];
int マス数;
int 連結A,連結B;
int フェネちゃんが塗れるマス数=0;
scanf("%d",&マス数);
loop(i,マス数-1){
scanf("%d %d",&連結A,&連結B);
連結A--,連結B--; //連結A 連結Bの数を一つ減らし、0からマス数-1の数で表現
グラフ[連結A].push_back(連結B); //グラフに辺を追加する この時点では「有向グラフ(AからBにしか行けない)」
グラフ[連結B].push_back(連結A); //上記同様。「BからAへの辺を追加して無向グラフにする」
}
dfs(0,-1,0,フェネック); //フェネちゃんはマス0からスタート。スタートなので前回いたところは -1 とする。 距離差はもちろん0
dfs(マス数-1,-1,0,きすけ); //上記同様。ただし きすけくんはマス数-1の数からのスタートなので マス数-1からスタートする。
loop(i,マス数){
//フェネちゃんは先手だから「自分がiマス目に到着する手数が相手の手数"以下"であれば良い。」
(フェネック[i]<=きすけ[i])?フェネちゃんが塗れるマス数++:フェネちゃんが塗れるマス数--;
}
/*後は塗った数が同数であった場合、フェネちゃんが塗れなくなるためきすけくんの勝利とすればよい。*/
printf("%s\n",(フェネちゃんが塗れるマス数>0)?"Fennec":"Snuke");
}
| a.cc:10:1: error: 'vector' does not name a type
10 | vector<int> グラフ[100005];
| ^~~~~~
a.cc: In function 'void dfs(int, int, int, int*)':
a.cc:23:23: error: '\U000030b0\U000030e9\U000030d5' was not declared in this scope
23 | loop(i,sizeof(グラフ[マス])){
| ^~~~~~
a.cc:13:38: note: in definition of macro 'loop'
13 | #define loop(i,j) for(int i = 0; i < j; i++)
| ^
a.cc: In function 'int main()':
a.cc:43:17: error: '\U000030b0\U000030e9\U000030d5' was not declared in this scope
43 | グラフ[連結A].push_back(連結B); //グラフに辺を追加する この時点では「有向グラフ(AからBにしか行けない)」
| ^~~~~~
|
s017761360 | p03660 | C++ | //どうしてもフェネちゃん VS きすけくん にしたかった..........
/* include */
#include <cstdio>
/* using namespace */
using namespace std;
/* local var */
int グラフ[100][100];
/* define */
#define loop(i,j) for(int i = 0; i < j; i++)
/* typedef */
typedef long long ll;
/* function */
void dfs(int マス,int 前回いた場所,int 距離差,int 距離配列[])
{
/* 距離差の設定 */
距離配列[マス]=距離差;
loop(i,sizeof(グラフ[マス])){
/* 前回いた場所でなければ行ってないので行く */
if(グラフ[マス][i] != 前回いた場所 ) dfs(グラフ[マス][i],マス,距離差+1,距離配列);
}
}
/* main program */
int main()
{
int フェネック[100005];
int きすけ[100005];
int マス数;
int 連結A,連結B;
int フェネちゃんが塗れるマス数=0;
scanf("%d",&マス数);
loop(i,マス数-1){
scanf("%d %d",&連結A,&連結B);
連結A--,連結B--; //連結A 連結Bの数を一つ減らし、0からマス数-1の数で表現
グラフ[連結A].push_back(連結B); //グラフに辺を追加する この時点では「有向グラフ(AからBにしか行けない)」
グラフ[連結B].push_back(連結A); //上記同様。「BからAへの辺を追加して無向グラフにする」
}
dfs(0,-1,0,フェネック); //フェネちゃんはマス0からスタート。スタートなので前回いたところは -1 とする。 距離差はもちろん0
dfs(マス数-1,-1,0,きすけ); //上記同様。ただし きすけくんはマス数-1の数からのスタートなので マス数-1からスタートする。
loop(i,マス数){
//フェネちゃんは先手だから「自分がiマス目に到着する手数が相手の手数"以下"であれば良い。」
(フェネック[i]<=きすけ[i])?フェネちゃんが塗れるマス数++:フェネちゃんが塗れるマス数--;
}
/*後は塗った数が同数であった場合、フェネちゃんが塗れなくなるためきすけくんの勝利とすればよい。*/
printf("%s\n",(フェネちゃんが塗れるマス数>0)?"Fennec":"Snuke");
}
| a.cc: In function 'int main()':
a.cc:43:31: error: request for member 'push_back' in '\U000030b0\U000030e9\U000030d5[\U00009023\U00007d50A]', which is of non-class type 'int [100]'
43 | グラフ[連結A].push_back(連結B); //グラフに辺を追加する この時点では「有向グラフ(AからBにしか行けない)」
| ^~~~~~~~~
a.cc:44:31: error: request for member 'push_back' in '\U000030b0\U000030e9\U000030d5[\U00009023\U00007d50B]', which is of non-class type 'int [100]'
44 | グラフ[連結B].push_back(連結A); //上記同様。「BからAへの辺を追加して無向グラフにする」
| ^~~~~~~~~
|
s707702623 | p03660 | C++ | //どうしてもフェネちゃん VS きすけくん にしたかった..........
/* include */
#include <cstdio>
/* using namespace */
using namespace std;
/* local var */
int グラフ[100][100];
/* define */
#define loop(i,j) for(int i = 0; i < j; i++)
/* typedef */
typedef long long ll;
/* function */
void dfs(int マス,int 前回いた場所,int 距離差,int 距離配列[])
{
/* 距離差の設定 */
距離配列[マス]=距離差;
loop(i,sizeof(グラフ[マス])){
/* 前回いた場所でなければ行ってないので行く */
if(グラフ[マス][i] != 前回いた場所 ) dfs(グラフ[マス][i],マス,距離差+1,距離配列);
}
}
x
/* main program */
int main()
{
int フェネック[100005];
int きすけ[100005];
int マス数;
int 連結A,連結B;
int フェネちゃんが塗れるマス数=0;
scanf("%d",&マス数);
loop(i,マス数-1){
scanf("%d %d",&連結A,&連結B);
連結A--,連結B--; //連結A 連結Bの数を一つ減らし、0からマス数-1の数で表現
グラフ[連結A].push_back(連結B); //グラフに辺を追加する この時点では「有向グラフ(AからBにしか行けない)」
グラフ[連結B].push_back(連結A); //上記同様。「BからAへの辺を追加して無向グラフにする」
}
dfs(0,-1,0,フェネック); //フェネちゃんはマス0からスタート。スタートなので前回いたところは -1 とする。 距離差はもちろん0
dfs(マス数-1,-1,0,きすけ); //上記同様。ただし きすけくんはマス数-1の数からのスタートなので マス数-1からスタートする。
loop(i,マス数){
//フェネちゃんは先手だから「自分がiマス目に到着する手数が相手の手数"以下"であれば良い。」
(フェネック[i]<=きすけ[i])?フェネちゃんが塗れるマス数++:フェネちゃんが塗れるマス数--;
}
/*後は塗った数が同数であった場合、フェネちゃんが塗れなくなるためきすけくんの勝利とすればよい。*/
printf("%s\n",(フェネちゃんが塗れるマス数>0)?"Fennec":"Snuke");
} | a.cc:28:1: error: 'x' does not name a type
28 | x
| ^
|
s417765249 | p03660 | C++ | #include <set>
#include "algorithm-lib.hpp"
using graph = map<i32, vector<i32>>;
void dfs(i32 depth, i32 curr, graph& g, vector<i32>& d)
{
d[curr] = depth;
for (const auto& next : g[curr]) {
if (d[next] >= 0) continue;
dfs(depth + 1, next, g, d);
}
}
int main() {
i32 N;
graph g;
cin >> N;
REP(i, N-1) {
i32 a, b;
cin >> a >> b;
g[a].emplace_back(b);
g[b].emplace_back(a);
}
vector<i32> distance_fennec(N + 1, -1);
dfs(0, 1, g, distance_fennec);
vector<i32> distance_snuke(N + 1, -1);
dfs(0, N, g, distance_snuke);
i32 fennec_visited = 0;
i32 snuke_visited = 0;
for (i32 i = 1; i <= N; i++) {
if (distance_fennec[i] <= distance_snuke[i]) {
fennec_visited++;
} else {
snuke_visited++;
}
}
if (fennec_visited <= snuke_visited) {
puts("Snuke");
} else {
puts("Fennec");
}
return 0;
}
| a.cc:2:10: fatal error: algorithm-lib.hpp: No such file or directory
2 | #include "algorithm-lib.hpp"
| ^~~~~~~~~~~~~~~~~~~
compilation terminated.
|
s904369581 | p03660 | C++ | #include <stdio.h>
#include <vector>
#include <algorithm>
#define FOR(i, a, b) for(int (i) = (a); (i) < (b); ++(i))
#define REP(i, n) FOR(i, 0, n)
std::vector<std::vector<int>> Edge;
std::vector<int> Dist[2];
std::vector<bool> yet;
int main(void){
int n; scanf("%d", &n);
Edge.resize(n);
FOR(_, 1, n){
int a, b; scanf("%d%d", &a, &b); a--; b--;
Edge[a].push_back(b);
Edge[b].push_back(a);
}
yet.resize(n);
REP(p, 2){
std::fill(yet.begin(), yet.end(), true);
Dist[p].resize(n);
int s = (p == 0 ? 0 : n - 1);
std::queue<int> Q;
Q.push(s); Dist[p][s] = 0; yet[s] = false;
while(not Q.empty()){
int v = Q.front(); Q.pop();
for(int nv : Edge[v]) if(yet[nv]){
yet[nv] = false;
Dist[p][nv] = Dist[p][v] + 1;
Q.push(nv);
}
}
}
int a = 0, b = 0;
REP(i, n){
if(Dist[0][i] <= Dist[1][i]) a++;
else b++;
}
puts(a > b ? "Fennec" : "Snuke");
return 0;
} | a.cc: In function 'int main()':
a.cc:25:14: error: 'queue' is not a member of 'std'
25 | std::queue<int> Q;
| ^~~~~
a.cc:4:1: note: 'std::queue' is defined in header '<queue>'; this is probably fixable by adding '#include <queue>'
3 | #include <algorithm>
+++ |+#include <queue>
4 |
a.cc:25:20: error: expected primary-expression before 'int'
25 | std::queue<int> Q;
| ^~~
a.cc:26:9: error: 'Q' was not declared in this scope
26 | Q.push(s); Dist[p][s] = 0; yet[s] = false;
| ^
|
s733807050 | p03660 | C++ | //#include "pch.h"
#include "stdafx.h"
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>
#include <cstring>
using namespace std;
/*-----------------------------------------------------------------------------
定義
-------------------------------------------------------------------------------*/
#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define INF 2e9
#define MOD (1000 * 1000 * 1000 + 7)
#define MIN(a, b) ((a) < (b) ? a : b)
#define MAX(a, b) ((a) > (b) ? a : b)
#define IsOdd(x) (((x)&0x01UL) == 0x01UL) /* 奇数 */
#define IsEven(x) (!IsOdd((x))) /* 偶数 */
#define ArrayLength(x) (sizeof(x) / sizeof(x[0]))
#define DWORD_MAX (0xFFFFFFFF)
typedef short SWORD;
typedef unsigned short WORD;
typedef long SDWORD;
typedef unsigned long DWORD;
typedef long long int QWORD;
#define N_MAX (1000 * 100 + 1)
#define M_MAX (1000 * 100 + 1)
/*-----------------------------------------------------------------------------
処理
-------------------------------------------------------------------------------*/
int N;
int dist[2][100000], id;
vector<int> g[100000];
void dfs(int nowTo, int nowFrom = -1)
{
if (0 <= nowFrom) {
dist[id][nowTo] = dist[id][nowFrom] + 1;
}
for (auto &nextTo : g[nowTo]) {
// 来た道は省く
if (nextTo != nowFrom) {
dfs(nextTo, nowTo);
}
}
}
int main()
{
cin >> N;
for (int i = 0; i < N - 1; i++) {
int a, b;
cin >> a >> b;
--a, --b;
g[a].emplace_back(b);
g[b].emplace_back(a);
}
id = 0;
dfs(0);
id = 1;
dfs(N - 1);
int ret = 0;
for (int i = 0; i < N; i++) {
if (dist[0][i] <= dist[1][i]) {
++ret;
}
}
if (ret >= (N + 2) / 2) {
cout << "Fennec" << endl;
} else {
cout << "Snuke" << endl;
}
}
| a.cc:2:10: fatal error: stdafx.h: No such file or directory
2 | #include "stdafx.h"
| ^~~~~~~~~~
compilation terminated.
|
s825821572 | p03660 | C++ | #include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <limits.h>
#include <bitset>
#define int long long
using namespace std;
using P = pair<int, int>;
using ll = long long;
using prique = priority_queue<int>;
const int MOD = 1000000007;
const int INF = LLONG_MAX/3;
const int MAX = 510000;
vector<int> e[114514];
bool reached[114514];
int n;
int dfs(int s){
int re=1;
for(int i=0;i<e[s].size();i++){
if(!reached[e[s][i]]&&e[s][i]!=0&&e[s][i]!=n-1){
reached[e[s][i]]=true;
re+=dfs(e[s][i]);
}
}
return re;
}
signed main(){
cin>>n;
for(int i=0;i<n-1;i++){
int a,b;
cin>>a>>b;
e[a-1].push_back(b-1);
e[b-1].push_back(a-1);
}
for(int i=0;i<n;i++)reached[i]=false;
int a=dfs(0);
for(int i=0;i<n;i++)reached[i]=false;
int b=dfs(n-1);
cout<<(a=>b?"Fennec":"Snuke")<<endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:51:14: error: expected primary-expression before '>' token
51 | cout<<(a=>b?"Fennec":"Snuke")<<endl;
| ^
|
s037338165 | p03660 | C++ | #include<iostream>
#include<queue>
#include<vector>
using namespace std;
const int MAXN=100000+10;
vector<int> edge[MAXN];
int n,cnt[3];
int tree[MAXN];
void bfs()
{
queue<int> q;
q.push(1),q.push(n);
while(!q.empty())
{
int temp=q.front();
q.pop();
cnt[tree[temp]]++;
for(int i=0;i<edge[temp].size();++i)
{
int v=edge[temp][i];
if(tree[v])continue;
else tree[v]=tree[temp];
q.push(v);
}
}
}
int main()
{
ios::sync_with_stdio(false);
memset(tree,0,sizeof(tree));
cin>>n;
for(int i=1;i<n;++i)
{
int x,y;
cin>>x>>y;
edge[x].push_back(y);
edge[y].push_back(x);
}
tree[1]=1,tree[n]=2;
bfs();
if(cnt[2]>=cnt[1])
cout<<"Snuke"<<endl;
else
cout<<"Fennec"<<endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:34:5: error: 'memset' was not declared in this scope
34 | memset(tree,0,sizeof(tree));
| ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
2 | #include<queue>
+++ |+#include <cstring>
3 | #include<vector>
|
s451582410 | p03660 | C++ | #include<iostream>
#include<queue>
#include<vector>
using namespace std;
const int MAXN=100000+10;
vector<int> edge[MAXN];
int n,cnt[3];
int tree[MAXN];
void bfs()
{
queue<int> q;
q.push(1),q.push(n);
while(!q.empty())
{
int temp=q.front();
q.pop();
cnt[tree[temp]]++;
for(int i=0;i<edge[temp].size();++i)
{
int v=edge[temp][i];
if(tree[v])continue;
else tree[v]=tree[temp];
q.push(v);
}
}
}
int main()
{
ios::sync_with_stdio(false);
memset(tree,0,sizeof(tree));
cin>>n;
for(int i=1;i<n;++i)
{
int x,y;
cin>>x>>y;
edge[x].push_back(y);
edge[y].push_back(x);
}
tree[1]=1,tree[n]=2;
bfs();
if(cnt[2]>=cnt[1])
cout<<"Snuke"<<endl;
else
cout<<"Fennec"<<endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:34:5: error: 'memset' was not declared in this scope
34 | memset(tree,0,sizeof(tree));
| ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
2 | #include<queue>
+++ |+#include <cstring>
3 | #include<vector>
|
s182150428 | p03660 | C++ | #include <iostream>
#include <vector>
#include <queue>
using namespace std;
const int INF = 1000000000;
int N;
vector<int> bfs(vector<int> G[N], int s) {
queue<int> que;
vector<int> dist(N, INF);
que.push(s);
dist[s] = 0;
while (!que.empty()) {
int u = que.front(); que.pop();
for (int i = 0; i < G[u].size(); i++) {
int v = G[u][i];
if (dist[v] != INF) continue;
dist[v] = dist[u] + 1;
que.push(v);
}
}
return dist;
}
int main() {
cin >> N;
vector<int> G[N];
for (int i = 0; i < N - 1; i++) {
int a, b;
cin >> a >> b;
a--; b--;
G[a].push_back(b);
G[b].push_back(a);
}
vector<int> dist1 = bfs(G, 0);
vector<int> dist2 = bfs(G, N - 1);
int cnt_f = 0, cnt_s = 0;
for (int i = 0; i < N; i++) {
if (dist1[i] <= dist2[i]) cnt_f++;
else cnt_s++;
}
if (cnt_f > cnt_s) {
cout << "Fennec" << endl;
} else {
cout << "Snuke" << endl;
}
return 0;
} | a.cc:9:31: error: size of array 'G' is not an integral constant-expression
9 | vector<int> bfs(vector<int> G[N], int s) {
| ^
|
s569660606 | p03660 | C++ | #include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
using namespace std;
#define INF 110000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
vector<int> V[110000];
int mycount=0;
int N,a,b;
ll dis[110000];
void dfs(int x){
if(nx==N) return;
mycount++;
for(int i=0;i<(int)V[x].size();i++){
int nx=V[x][i];
if(dis[nx]==-1){
dis[nx]=dis[x]+1;
dfs(nx);
}
}
}
int main(){
cin>>N;
//cout<<"unko"<<endl;
for(int i=0;i<N-1;i++){
cin>>a>>b;
V[a].push_back(b);
V[b].push_back(a);
}
for(int i=0;i<110000;i++) dis[i]=-1;
dis[1]=0;
dfs(1);
cout<<dis[N]<<endl;
cout<<mycount<<endl;
if(N%2==0 && mycount+dis[N]/2==N/2) cout<<"Snuke"<<endl;
else if((mycount+dis[N]/2)*2>N) cout<<"Fennec"<<endl;
else cout<<"Snuke"<<endl;
}
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
using namespace std;
#define INF 110000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
vector<int> V[110000];
int mycount=0;
int N,a,b;
ll dis[110000];
void dfs(int x){
if(nx==N) return;
mycount++;
for(int i=0;i<(int)V[x].size();i++){
int nx=V[x][i];
if(dis[nx]==-1){
dis[nx]=dis[x]+1;
dfs(nx);
}
}
}
int main(){
cin>>N;
//cout<<"unko"<<endl;
for(int i=0;i<N-1;i++){
cin>>a>>b;
V[a].push_back(b);
V[b].push_back(a);
}
for(int i=0;i<110000;i++) dis[i]=-1;
dis[1]=0;
dfs(1);
cout<<dis[N]<<endl;
cout<<mycount<<endl;
if(N%2==0 && mycount+dis[N]/2==N/2) cout<<"Snuke"<<endl;
else if((mycount+dis[N]/2)*2>N) cout<<"Fennec"<<endl;
else cout<<"Snuke"<<endl;
}
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
using namespace std;
#define INF 110000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
vector<int> V[110000];
int mycount=0;
int N,a,b;
ll dis[110000];
void dfs(int x){
if(nx==N) return;
mycount++;
for(int i=0;i<(int)V[x].size();i++){
int nx=V[x][i];
if(dis[nx]==-1){
dis[nx]=dis[x]+1;
dfs(nx);
}
}
}
int main(){
cin>>N;
//cout<<"unko"<<endl;
for(int i=0;i<N-1;i++){
cin>>a>>b;
V[a].push_back(b);
V[b].push_back(a);
}
for(int i=0;i<110000;i++) dis[i]=-1;
dis[1]=0;
dfs(1);
cout<<dis[N]<<endl;
cout<<mycount<<endl;
if(N%2==0 && mycount+dis[N]/2==N/2) cout<<"Snuke"<<endl;
else if((mycount+dis[N]/2)*2>N) cout<<"Fennec"<<endl;
else cout<<"Snuke"<<endl;
}
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
using namespace std;
#define INF 110000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
vector<int> V[110000];
int mycount=0;
int N,a,b;
ll dis[110000];
void dfs(int x){
if(nx==N) return;
mycount++;
for(int i=0;i<(int)V[x].size();i++){
int nx=V[x][i];
if(dis[nx]==-1){
dis[nx]=dis[x]+1;
dfs(nx);
}
}
}
int main(){
cin>>N;
//cout<<"unko"<<endl;
for(int i=0;i<N-1;i++){
cin>>a>>b;
V[a].push_back(b);
V[b].push_back(a);
}
for(int i=0;i<110000;i++) dis[i]=-1;
dis[1]=0;
dfs(1);
cout<<dis[N]<<endl;
cout<<mycount<<endl;
if(N%2==0 && mycount+dis[N]/2==N/2) cout<<"Snuke"<<endl;
else if((mycount+dis[N]/2)*2>N) cout<<"Fennec"<<endl;
else cout<<"Snuke"<<endl;
}
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
using namespace std;
#define INF 110000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
vector<int> V[110000];
int mycount=0;
int N,a,b;
ll dis[110000];
void dfs(int x){
if(nx==N) return;
mycount++;
for(int i=0;i<(int)V[x].size();i++){
int nx=V[x][i];
if(dis[nx]==-1){
dis[nx]=dis[x]+1;
dfs(nx);
}
}
}
int main(){
cin>>N;
//cout<<"unko"<<endl;
for(int i=0;i<N-1;i++){
cin>>a>>b;
V[a].push_back(b);
V[b].push_back(a);
}
for(int i=0;i<110000;i++) dis[i]=-1;
dis[1]=0;
dfs(1);
cout<<dis[N]<<endl;
cout<<mycount<<endl;
if(N%2==0 && mycount+dis[N]/2==N/2) cout<<"Snuke"<<endl;
else if((mycount+dis[N]/2)*2>N) cout<<"Fennec"<<endl;
else cout<<"Snuke"<<endl;
}
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
using namespace std;
#define INF 110000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
vector<int> V[110000];
int mycount=0;
int N,a,b;
ll dis[110000];
void dfs(int x){
if(nx==N) return;
mycount++;
for(int i=0;i<(int)V[x].size();i++){
int nx=V[x][i];
if(dis[nx]==-1){
dis[nx]=dis[x]+1;
dfs(nx);
}
}
}
int main(){
cin>>N;
//cout<<"unko"<<endl;
for(int i=0;i<N-1;i++){
cin>>a>>b;
V[a].push_back(b);
V[b].push_back(a);
}
for(int i=0;i<110000;i++) dis[i]=-1;
dis[1]=0;
dfs(1);
cout<<dis[N]<<endl;
cout<<mycount<<endl;
if(N%2==0 && mycount+dis[N]/2==N/2) cout<<"Snuke"<<endl;
else if((mycount+dis[N]/2)*2>N) cout<<"Fennec"<<endl;
else cout<<"Snuke"<<endl;
}
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
using namespace std;
#define INF 110000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
vector<int> V[110000];
int mycount=0;
int N,a,b;
ll dis[110000];
void dfs(int x){
if(nx==N) return;
mycount++;
for(int i=0;i<(int)V[x].size();i++){
int nx=V[x][i];
if(dis[nx]==-1){
dis[nx]=dis[x]+1;
dfs(nx);
}
}
}
int main(){
cin>>N;
//cout<<"unko"<<endl;
for(int i=0;i<N-1;i++){
cin>>a>>b;
V[a].push_back(b);
V[b].push_back(a);
}
for(int i=0;i<110000;i++) dis[i]=-1;
dis[1]=0;
dfs(1);
cout<<dis[N]<<endl;
cout<<mycount<<endl;
if(N%2==0 && mycount+dis[N]/2==N/2) cout<<"Snuke"<<endl;
else if((mycount+dis[N]/2)*2>N) cout<<"Fennec"<<endl;
else cout<<"Snuke"<<endl;
}
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
using namespace std;
#define INF 110000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
vector<int> V[110000];
int mycount=0;
int N,a,b;
ll dis[110000];
void dfs(int x){
if(nx==N) return;
mycount++;
for(int i=0;i<(int)V[x].size();i++){
int nx=V[x][i];
if(dis[nx]==-1){
dis[nx]=dis[x]+1;
dfs(nx);
}
}
}
int main(){
cin>>N;
//cout<<"unko"<<endl;
for(int i=0;i<N-1;i++){
cin>>a>>b;
V[a].push_back(b);
V[b].push_back(a);
}
for(int i=0;i<110000;i++) dis[i]=-1;
dis[1]=0;
dfs(1);
cout<<dis[N]<<endl;
cout<<mycount<<endl;
if(N%2==0 && mycount+dis[N]/2==N/2) cout<<"Snuke"<<endl;
else if((mycount+dis[N]/2)*2>N) cout<<"Fennec"<<endl;
else cout<<"Snuke"<<endl;
}
| a.cc: In function 'void dfs(int)':
a.cc:22:6: error: 'nx' was not declared in this scope; did you mean 'x'?
22 | if(nx==N) return;
| ^~
| x
a.cc: At global scope:
a.cc:68:13: error: redefinition of 'std::vector<int> V [110000]'
68 | vector<int> V[110000];
| ^
a.cc:15:13: note: 'std::vector<int> V [110000]' previously declared here
15 | vector<int> V[110000];
| ^
a.cc:70:5: error: redefinition of 'int mycount'
70 | int mycount=0;
| ^~~~~~~
a.cc:17:5: note: 'int mycount' previously defined here
17 | int mycount=0;
| ^~~~~~~
a.cc:71:5: error: redefinition of 'int N'
71 | int N,a,b;
| ^
a.cc:18:5: note: 'int N' previously declared here
18 | int N,a,b;
| ^
a.cc:71:7: error: redefinition of 'int a'
71 | int N,a,b;
| ^
a.cc:18:7: note: 'int a' previously declared here
18 | int N,a,b;
| ^
a.cc:71:9: error: redefinition of 'int b'
71 | int N,a,b;
| ^
a.cc:18:9: note: 'int b' previously declared here
18 | int N,a,b;
| ^
a.cc:72:4: error: redefinition of 'll dis [110000]'
72 | ll dis[110000];
| ^~~
a.cc:19:4: note: 'll dis [110000]' previously declared here
19 | ll dis[110000];
| ^~~
a.cc:74:6: error: redefinition of 'void dfs(int)'
74 | void dfs(int x){
| ^~~
a.cc:21:6: note: 'void dfs(int)' previously defined here
21 | void dfs(int x){
| ^~~
a.cc: In function 'void dfs(int)':
a.cc:75:6: error: 'nx' was not declared in this scope; did you mean 'x'?
75 | if(nx==N) return;
| ^~
| x
a.cc: At global scope:
a.cc:89:5: error: redefinition of 'int main()'
89 | int main(){
| ^~~~
a.cc:36:5: note: 'int main()' previously defined here
36 | int main(){
| ^~~~
a.cc:121:13: error: redefinition of 'std::vector<int> V [110000]'
121 | vector<int> V[110000];
| ^
a.cc:15:13: note: 'std::vector<int> V [110000]' previously declared here
15 | vector<int> V[110000];
| ^
a.cc:123:5: error: redefinition of 'int mycount'
123 | int mycount=0;
| ^~~~~~~
a.cc:17:5: note: 'int mycount' previously defined here
17 | int mycount=0;
| ^~~~~~~
a.cc:124:5: error: redefinition of 'int N'
124 | int N,a,b;
| ^
a.cc:18:5: note: 'int N' previously declared here
18 | int N,a,b;
| ^
a.cc:124:7: error: redefinition of 'int a'
124 | int N,a,b;
| ^
a.cc:18:7: note: 'int a' previously declared here
18 | int N,a,b;
| ^
a.cc:124:9: error: redefinition of 'int b'
124 | int N,a,b;
| ^
a.cc:18:9: note: 'int b' previously declared here
18 | int N,a,b;
| ^
a.cc:125:4: error: redefinition of 'll dis [110000]'
125 | ll dis[110000];
| ^~~
a.cc:19:4: note: 'll dis [110000]' previously declared here
19 | ll dis[110000];
| ^~~
a.cc:127:6: error: redefinition of 'void dfs(int)'
127 | void dfs(int x){
| ^~~
a.cc:21:6: note: 'void dfs(int)' previously defined here
21 | void dfs(int x){
| ^~~
a.cc: In function 'void dfs(int)':
a.cc:128:6: error: 'nx' was not declared in this scope; did you mean 'x'?
128 | if(nx==N) return;
| ^~
| x
a.cc: At global scope:
a.cc:142:5: error: redefinition of 'int main()'
142 | int main(){
| ^~~~
a.cc:36:5: note: 'int main()' previously defined here
36 | int main(){
| ^~~~
a.cc:174:13: error: redefinition of 'std::vector<int> V [110000]'
174 | vector<int> V[110000];
| ^
a.cc:15:13: note: 'std::vector<int> V [110000]' previously declared here
15 | vector<int> V[110000];
| ^
a.cc:176:5: error: redefinition of 'int mycount'
176 | int mycount=0;
| ^~~~~~~
a.cc:17:5: note: 'int mycount' previously defined here
17 | int mycount=0;
| ^~~~~~~
a.cc:177:5: error: redefinition of 'int N'
177 | int N,a,b;
| ^
a.cc:18:5: note: 'int N' previously declared here
18 | int N,a,b;
| ^
a.cc:177:7: error: redefinition of 'int a'
177 | int N,a,b;
| ^
a.cc:18:7: note: 'int a' previously declared here
18 | int N,a,b;
| ^
a.cc:177:9: error: redefinition of 'int b'
177 | int N,a,b;
| ^
a.cc:18:9: note: 'int b' previously declared here
18 | int N,a,b;
| ^
a.cc:178:4: error: redefinition of 'll dis [110000]'
178 | ll dis[110000];
| ^~~
a.cc:19:4: note: 'll dis [110000]' previously declared here
19 | ll dis[110000];
| ^~~
a.cc:180:6: error: redefinition of 'void dfs(int)'
180 | void dfs(int x){
| ^~~
a.cc:21:6: note: 'void dfs(int)' previously defined here
21 | void dfs(int x){
| ^~~
a.cc: In function 'void dfs(int)':
a.cc:181:6: error: 'nx' was not declared in this scope; did you mean 'x'?
181 | if(nx==N) return;
| ^~
| x
a.cc: At global scope:
a.cc:195:5: error: redefinition of 'int main()'
195 | int main(){
| ^~~~
a.cc:36:5: note: 'int main()' previously defined here
36 | int main(){
| ^~~~
a.cc:227:13: error: redefinition of 'std::vector<int> V [110000]'
227 | vector<int> V[110000];
| ^
a.cc:15:13: note: 'std::vector<int> V [110000]' previously declared here
15 | vector<int> V[110000];
| ^
a.cc:229:5: error: redefinition of 'int mycount'
229 | int mycount=0;
| ^~~~~~~
a.cc:17:5: note: 'int mycount' previously defined here
17 | int mycount=0;
| ^~~~~~~
a.cc:230:5: error: redefinition of 'int N'
230 | int N,a,b;
| ^
a.cc:18:5: note: 'int N' previously declared here
18 | int N,a,b;
| ^
a.cc:230:7: error: redefinition of 'int a'
230 | int N,a,b;
| ^
a.cc:18:7: note: 'int a' previously declared here
18 | int N,a,b;
| ^
a.cc:230:9: error: redefinition of 'int b'
230 | int N,a,b;
| ^
a.cc:18:9: note: 'int b' previously declared here
18 | int N,a,b;
| ^
a.cc:231:4: error: redefinition of 'll dis [110000]'
231 | ll dis[110000];
| ^~~
a.cc:19:4: note: 'll dis [110000]' previously declared here
19 | ll dis[110000];
| ^~~
a.cc:233:6: error: redefinition of 'void dfs(int)'
233 | void dfs(int x){
| ^~~
a.cc:21:6: note: 'void dfs(int)' previously defined here
21 | void dfs(int x){
| ^~~
a.cc: In function 'void dfs(int)':
a.cc:234:6: error: 'nx' was not declared in this scope; did you mean 'x'?
234 | if(nx==N) return;
| ^~
| x
a.cc: At global scope:
a.cc:248:5: error: redefinition of 'int main()'
248 | int main(){
| ^~~~
a.cc:36:5: note: 'int main()' previously defined here
36 | int main(){
| ^~~~
a.cc:280:13: error: redefinition of 'std::vector<int> V [110000]'
280 | vector<int> V[110000];
| ^
a.cc:15:13: note: 'std::vector<int> V [110000]' previously declared here
15 | vector<int> V[110000];
| ^
a.cc:282:5: error: redefinition of 'int mycount'
282 | int mycount=0;
| ^~~~~~~
a.cc:17:5: note: 'int mycount' previously defined here
17 | int mycount=0;
| ^~~~~~~
a.cc:283:5: error: redefinition of 'int N'
283 | int N,a,b;
| ^
a.cc:18:5: note: 'int N' previously declared here
18 | int N,a,b;
| ^
a.cc:283:7: error: redefinition of 'int a'
283 | int N,a,b;
| ^
a.cc:18:7: note: 'int a' previously declared here
18 | int N,a,b;
| ^
a.cc:283:9: error: redefinition of 'int b'
283 | int N,a,b;
| ^
a.cc:18:9: note: 'int b' previously declared here
18 | int N,a,b;
| ^
a.cc:284:4: error: redefinition of 'll dis [110000]'
284 | ll dis[110000];
| ^~~
a.cc:19:4: note: 'll dis [110000]' previously declared here
19 | ll dis[110000];
| ^~~
a.cc:286:6: error: redefinition of 'void dfs(int)'
286 | void dfs(int x){
| ^~~
a.cc:21:6: note: 'void dfs(int)' previously defined here
21 | void dfs(int x){
| ^~~
a.cc: In function 'void dfs(int)':
a.cc:287:6: error: 'nx' was not declared in this scope; did you mean 'x'?
287 | if(nx==N) return;
| ^~
| x
a.cc: At global scope:
a.cc:301:5: error: redefinition of 'int main()'
301 | int main(){
| ^~~~
a.cc:36:5: note: 'int main()' previously defined here
36 | int main(){
| ^~~~
a.cc:333:13: error: redefinition of 'std::vector<int> V [110000]'
333 | vector<int> V[110000];
| ^
a.cc:15:13: note: 'std::vector<int> V [110000]' previously declared here
15 | vector<int> V[110000];
| ^
a.cc:335:5: error: redefinition of 'int mycount'
335 | int mycount=0;
| ^~~~~~~
a.cc:17:5: note: 'int mycount' previously defined here
17 | int mycount=0;
| ^~~~~~~
a.cc:336:5: error: redefinition of 'int N'
336 | int N,a,b;
| ^
a.cc:18:5: note: 'int N' previously declared here
18 | int N,a,b;
| ^
a.cc:336:7: error: redefinition of 'int a'
336 | int N,a,b;
| ^
a.cc:18:7: note: 'int a' previously declared here
18 | int N,a,b;
| ^
a.cc:336:9: error: redefinition of 'int b'
336 | int N,a,b;
| ^
a.cc:18:9: note: 'int b' previously declared here
18 | int N,a,b;
| ^
a.cc:337:4: error: redefinition of 'll dis [110000]'
337 | ll dis[110000];
| ^~~
a.cc:19:4: note: 'll dis [110000]' previously declared here
19 | ll dis[110000];
| ^~~
a.cc:339:6: error: redefinition of 'void dfs(int)'
339 | void dfs(int x){
| ^~~
a.cc:21:6: note: 'void dfs(int)' previously defined here
21 | void dfs(int x){
| ^~~
a.cc: In function 'void dfs(int)':
a.cc:340:6: error: 'nx' was not declared in this scope; did you mean 'x'?
340 | if(nx==N) return;
| ^~
| x
a.cc: At global scope:
a.cc:354:5: error: redefinition of 'int main()'
354 | int main(){
| ^~~~
a.cc:36:5: note: 'int main()' previously defined here
36 | int main(){
| ^~~~
a.cc:386:13: err |
s096160944 | p03660 | C++ | #include <iostream>
#include <queue>
#include <vector>
using namespace std;
const int maxn=200010;
vector<int>v[maxn];
queue<int> q1,q2;
int n,m,col[maxn],g[maxn];
void dfs(int x,int f,int t)
{
if(x==n-1)
return;
col[x]=col[f];
g[x]=t;
for(int i=0;i<v[x].size();i++)
{
if(v[x][i]==f)continue;
dfs(v[x][i],x,t+1);
}
return;
}
void dfs2(int x,int f,int t)
{
if(t<g[x])
col[x]=2;
else
return;
for(int i=0;i<v[x].size();i++)
{
if(v[x][i]==f)continue;
dfs(v[x][i],x,t+1);
}
return;
}
int main()
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
const int INF=0x3f3f3f3f,maxn=200010;
vector<int>v[maxn];
queue<int> q1,q2;
int n,m,col[maxn];
int bfs()
{
int i;
while(1)
{
int x=q1.front();q1.pop();
col[x]=1;
for(i=0;i<v[x].size();i++)
{
if(col[v[x][i]]==0)
q1.push(v[x][i]);
}
if(q1.empty()==1)
return 1;
int y=q2.front();q2.pop();
while(1)
{
if(col[y]!=0)
{
y=q2.front();q2.pop();
}
else
break;
}
col[y]=2;
for(i=0;i<v[y].size();i++)
if(!col[v[y][i]]==0)
q2.push(v[x][i]);
if(q2.empty()==1)
return 2;
}
}
int main()
{
int i,j,k,ans=0;
cin>>n;
for(i=0;i<n-1;i++)
{
int x,y;
cin>>x>>y;
x--;
y--;
v[x].push_back(y);
v[y].push_back(x);
}
col[0]=1;
col[n-1]=2;
q1.push(0);
q2.push(n-1);
if(bfs()==1)
cout<<"Snuke"<<endl;
else
cout<<"Fennec"<<endl;
return 0;
}
| a.cc:39:1: error: expected initializer before 'using'
39 | using namespace std;
| ^~~~~
a.cc:40:26: error: redefinition of 'const int maxn'
40 | const int INF=0x3f3f3f3f,maxn=200010;
| ^~~~
a.cc:5:11: note: 'const int maxn' previously defined here
5 | const int maxn=200010;
| ^~~~
a.cc:41:12: error: redefinition of 'std::vector<int> v [200010]'
41 | vector<int>v[maxn];
| ^
a.cc:6:12: note: 'std::vector<int> v [200010]' previously declared here
6 | vector<int>v[maxn];
| ^
a.cc:42:12: error: redefinition of 'std::queue<int> q1'
42 | queue<int> q1,q2;
| ^~
a.cc:7:12: note: 'std::queue<int> q1' previously declared here
7 | queue<int> q1,q2;
| ^~
a.cc:42:15: error: redefinition of 'std::queue<int> q2'
42 | queue<int> q1,q2;
| ^~
a.cc:7:15: note: 'std::queue<int> q2' previously declared here
7 | queue<int> q1,q2;
| ^~
a.cc:43:5: error: redefinition of 'int n'
43 | int n,m,col[maxn];
| ^
a.cc:8:5: note: 'int n' previously declared here
8 | int n,m,col[maxn],g[maxn];
| ^
a.cc:43:7: error: redefinition of 'int m'
43 | int n,m,col[maxn];
| ^
a.cc:8:7: note: 'int m' previously declared here
8 | int n,m,col[maxn],g[maxn];
| ^
a.cc:43:9: error: redefinition of 'int col [200010]'
43 | int n,m,col[maxn];
| ^~~
a.cc:8:9: note: 'int col [200010]' previously declared here
8 | int n,m,col[maxn],g[maxn];
| ^~~
|
s480786499 | p03660 | C++ | #include <iostream>
#include <queue>
#include <vector>
using namespace std;
const int INF=0x3f3f3f3f,maxn=200010;
vector<int>v[maxn];
queue<int> q1,q2;
int n,m,col[maxn],g[maxn];
void dfs(int x,int f,int t)
{
if(x==n-1)
return;
col[x]=col[f];
g[x]=t;
for(int i=0;i<v[x].size();i++)
{
if(v[x][i]==f)continue;
dfs(v[x][i],x,t+1);
}
return;
}
void dfs2(int x,int f,int t)
{
if(t<g[x])
col[x]=2;
else
return;
for(int i=0;i<v[x].size();i++)
{
if(v[x][i]==f)continue;
dfs(v[x][i],x,t+1);
}
return;
}
int main()
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
const int INF=0x3f3f3f3f,maxn=200010;
vector<int>v[maxn];
queue<int> q1,q2;
int n,m,col[maxn];
int bfs()
{
int i;
while(1)
{
int x=q1.front();q1.pop();
col[x]=1;
for(i=0;i<v[x].size();i++)
{
if(col[v[x][i]]==0)
q1.push(v[x][i]);
}
if(q1.empty()==1)
return 1;
int y=q2.front();q2.pop();
while(1)
{
if(col[y]!=0)
{
y=q2.front();q2.pop();
}
else
break;
}
col[y]=2;
for(i=0;i<v[y].size();i++)
if(!col[v[y][i]]==0)
q2.push(v[x][i]);
if(q2.empty()==1)
return 2;
}
}
int main()
{
int i,j,k,ans=0;
cin>>n;
for(i=0;i<n-1;i++)
{
int x,y;
cin>>x>>y;
x--;
y--;
v[x].push_back(y);
v[y].push_back(x);
}
col[0]=1;
col[n-1]=2;
q1.push(0);
q2.push(n-1);
if(bfs()==1)
cout<<"Snuke"<<endl;
else
cout<<"Fennec"<<endl;
return 0;
}
| a.cc:39:1: error: expected initializer before 'using'
39 | using namespace std;
| ^~~~~
a.cc:40:11: error: redefinition of 'const int INF'
40 | const int INF=0x3f3f3f3f,maxn=200010;
| ^~~
a.cc:5:11: note: 'const int INF' previously defined here
5 | const int INF=0x3f3f3f3f,maxn=200010;
| ^~~
a.cc:40:26: error: redefinition of 'const int maxn'
40 | const int INF=0x3f3f3f3f,maxn=200010;
| ^~~~
a.cc:5:26: note: 'const int maxn' previously defined here
5 | const int INF=0x3f3f3f3f,maxn=200010;
| ^~~~
a.cc:41:12: error: redefinition of 'std::vector<int> v [200010]'
41 | vector<int>v[maxn];
| ^
a.cc:6:12: note: 'std::vector<int> v [200010]' previously declared here
6 | vector<int>v[maxn];
| ^
a.cc:42:12: error: redefinition of 'std::queue<int> q1'
42 | queue<int> q1,q2;
| ^~
a.cc:7:12: note: 'std::queue<int> q1' previously declared here
7 | queue<int> q1,q2;
| ^~
a.cc:42:15: error: redefinition of 'std::queue<int> q2'
42 | queue<int> q1,q2;
| ^~
a.cc:7:15: note: 'std::queue<int> q2' previously declared here
7 | queue<int> q1,q2;
| ^~
a.cc:43:5: error: redefinition of 'int n'
43 | int n,m,col[maxn];
| ^
a.cc:8:5: note: 'int n' previously declared here
8 | int n,m,col[maxn],g[maxn];
| ^
a.cc:43:7: error: redefinition of 'int m'
43 | int n,m,col[maxn];
| ^
a.cc:8:7: note: 'int m' previously declared here
8 | int n,m,col[maxn],g[maxn];
| ^
a.cc:43:9: error: redefinition of 'int col [200010]'
43 | int n,m,col[maxn];
| ^~~
a.cc:8:9: note: 'int col [200010]' previously declared here
8 | int n,m,col[maxn],g[maxn];
| ^~~
|
s709197478 | p03660 | C++ | #include <iostream>
#include <queue>
#include <vector>
using namespace std;
const int INF=0x3f3f3f3f,maxn=200010;
vector<int>v[maxn];
queue<int> q1,q2;
int n,m,col[maxn],g[maxn];
void dfs(int x,int f,int t)
{
if(x==n-1)
return;
col[x]=col[f];
g[x]=t;
for(int i=0;i<v[x].size();i++)
{
if(v[x][i]==f)continue;
dfs(v[x][i],x,t+1);
}
return;
}
void dfs2(int x,int f,int t)
{
if(t<g[x])
col[x]=2;
else
return;
for(int i=0;i<v[x].size();i++)
{
if(v[x][i]==f)continue;
dfs(v[x][i],x,t+1);
}
return;
}
int main()
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
const int INF=0x3f3f3f3f,maxn=200010;
vector<int>v[maxn];
queue<int> q1,q2;
int n,m,col[maxn];
int bfs()
{
int i;
while(1)
{
int x=q1.front();q1.pop();
col[x]=1;
for(i=0;i<v[x].size();i++)
{
if(col[v[x][i]]==0)
q1.push(v[x][i]);
}
if(q1.empty()==1)
return 1;
int y=q2.front();q2.pop();
while(1)
{
if(col[y]!=0)
{
y=q2.front();q2.pop();
}
else
break;
}
col[y]=2;
for(i=0;i<v[y].size();i++)
if(!col[v[y][i]]==0)
q2.push(v[x][i]);
if(q2.empty()==1)
return 2;
}
}
int main()
{
int i,j,k,ans=0;
cin>>n;
for(i=0;i<n-1;i++)
{
int x,y;
cin>>x>>y;
x--;
y--;
v[x].push_back(y);
v[y].push_back(x);
}
col[0]=1;
col[n-1]=2;
q1.push(0);
q2.push(n-1);
if(bfs()==1)
cout<<"Snuke"<<endl;
else
cout<<"Fennec"<<endl;
return 0;
}
| a.cc:39:1: error: expected initializer before 'using'
39 | using namespace std;
| ^~~~~
a.cc:40:11: error: redefinition of 'const int INF'
40 | const int INF=0x3f3f3f3f,maxn=200010;
| ^~~
a.cc:5:11: note: 'const int INF' previously defined here
5 | const int INF=0x3f3f3f3f,maxn=200010;
| ^~~
a.cc:40:26: error: redefinition of 'const int maxn'
40 | const int INF=0x3f3f3f3f,maxn=200010;
| ^~~~
a.cc:5:26: note: 'const int maxn' previously defined here
5 | const int INF=0x3f3f3f3f,maxn=200010;
| ^~~~
a.cc:41:12: error: redefinition of 'std::vector<int> v [200010]'
41 | vector<int>v[maxn];
| ^
a.cc:6:12: note: 'std::vector<int> v [200010]' previously declared here
6 | vector<int>v[maxn];
| ^
a.cc:42:12: error: redefinition of 'std::queue<int> q1'
42 | queue<int> q1,q2;
| ^~
a.cc:7:12: note: 'std::queue<int> q1' previously declared here
7 | queue<int> q1,q2;
| ^~
a.cc:42:15: error: redefinition of 'std::queue<int> q2'
42 | queue<int> q1,q2;
| ^~
a.cc:7:15: note: 'std::queue<int> q2' previously declared here
7 | queue<int> q1,q2;
| ^~
a.cc:43:5: error: redefinition of 'int n'
43 | int n,m,col[maxn];
| ^
a.cc:8:5: note: 'int n' previously declared here
8 | int n,m,col[maxn],g[maxn];
| ^
a.cc:43:7: error: redefinition of 'int m'
43 | int n,m,col[maxn];
| ^
a.cc:8:7: note: 'int m' previously declared here
8 | int n,m,col[maxn],g[maxn];
| ^
a.cc:43:9: error: redefinition of 'int col [200010]'
43 | int n,m,col[maxn];
| ^~~
a.cc:8:9: note: 'int col [200010]' previously declared here
8 | int n,m,col[maxn],g[maxn];
| ^~~
|
s852449943 | p03660 | C++ | #include <bits\stdc++.h>
#include <queue>
using namespace std;
const int INF=0x3f3f3f3f,maxn=200010;
vector<int>v[maxn];
queue<int> q1,q2;
int n,m,col[maxn];
int bfs()
{
int i;
while(1)
{
int x=q1.front();q1.pop();
col[x]=1;
for(i=0;i<v[x].size();i++)
{
if(col[v[x][i]]==0)
q1.push(v[x][i]);
}
if(q1.empty()==1)
return 1;
int y=q2.front();q2.pop();
col[y]=2;
for(i=0;i<v[y].size();i++)
if(!col[v[y][i]]==0)
q2.push(v[x][i]);
if(q2.empty()==1)
return 2;
}
}
int main()
{
int i,j,k,ans=0;
cin>>n;
for(i=0;i<n-1;i++)
{
int x,y;
cin>>x>>y;
x--;
y--;
v[x].push_back(y);
v[y].push_back(x);
}
// cout<<q1.empty();
col[0]=1;
col[n-1]=2;
q1.push(0);
q2.push(n-1);
if(bfs()==1)
cout<<"Snuke"<<endl;
else
cout<<"Fennec"<<endl;
return 0;
}
| a.cc:1:10: fatal error: bits\stdc++.h: No such file or directory
1 | #include <bits\stdc++.h>
| ^~~~~~~~~~~~~~~
compilation terminated.
|
s587197895 | p03660 | C++ | #pragma GCC optimize("Ofast",3,"inline")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const MAXN=1<<18;
int n;
vector<int> e[MAXN];
int cnt[MAXN];
vector<int> vct;
int first;
void dfs(int v,int pr){
cnt[v]=1;
vct.pushback(v);
if(v==n-1){
first=vct[((int) vct.size()+1)/2];
}
for(int to:e[v]){
if(to==pr) continue;
dfs(to,v);
cnt[v]+=cnt[to];
}
vct.pop_back();
}
int main(){
ios_base::sync_with_stdio(false);
while(scanf("%d",&n)==1){
for(int i=0;i<n;i++){
e[i].clear();
}
for(int i=0;i<n-1;i++){
int u,v;
scanf("%d%d",&u,&v);
u--;
v--;
e[u].push_back(v);
e[v].push_back(u);
}
}
first=-1;
dfs(0,0);
bool win=cnt[first]*2<n;
//优秀判断
string ans=win?"Fennec":"Snuke";
cout<<ans;
return 0;
}
| a.cc:5:7: error: 'MAXN' does not name a type
5 | const MAXN=1<<18;
| ^~~~
a.cc:7:15: error: 'MAXN' was not declared in this scope
7 | vector<int> e[MAXN];
| ^~~~
a.cc:8:9: error: 'MAXN' was not declared in this scope
8 | int cnt[MAXN];
| ^~~~
a.cc: In function 'void dfs(int, int)':
a.cc:12:9: error: 'cnt' was not declared in this scope; did you mean 'int'?
12 | cnt[v]=1;
| ^~~
| int
a.cc:13:13: error: 'class std::vector<int>' has no member named 'pushback'; did you mean 'push_back'?
13 | vct.pushback(v);
| ^~~~~~~~
| push_back
a.cc:17:20: error: 'e' was not declared in this scope
17 | for(int to:e[v]){
| ^
a.cc: In function 'int main()':
a.cc:29:25: error: 'e' was not declared in this scope
29 | e[i].clear();
| ^
a.cc:36:25: error: 'e' was not declared in this scope
36 | e[u].push_back(v);
| ^
a.cc:42:18: error: 'cnt' was not declared in this scope; did you mean 'int'?
42 | bool win=cnt[first]*2<n;
| ^~~
| int
|
s353499416 | p03660 | C | #include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
using namespace std;
const long long MOD = 1000000007;
typedef long long ll;
int
main(int argc, const char *argv[])
{
vector<int> g[100010];
int n;
scanf("%d", &n);
int a, b;
for (int i = 0; i < n - 1; i++) {
scanf("%d %d", &a, &b);
a--; b--;
g[a].push_back(b);
g[b].push_back(a);
}
queue<int> p, q;
p.push(0); p.push(-1);
q.push(n); q.push(-1);
int color[100010] = {}, x, y;
color[0] = 1; color[n - 1] = 2;
while (!p.empty() && !q.empty()) {
if (!p.empty()) {
while (1) {
x = p.front(); p.pop();
if (x == -1) break;
for (int i = 0; i < g[x].size(); i++) {
if (color[g[x][i]] == 0) {
color[g[x][i]] = 1;
p.push(g[x][i]);
}
}
}
if (!p.empty()) p.push(-1);
}
if (!q.empty()) {
while (1) {
y = q.front(); q.pop();
if (y == -1) break;
for (int i = 0; i < g[y].size(); i++) {
if (color[g[y][i]] == 0) {
color[g[y][i]] = 1;
q.push(g[y][i]);
}
}
}
if (!q.empty()) q.push(-1);
}
}
int f = 0, s = 0;
for (int i = 0; i < n; i++) {
if (color[i] == 1) f++;
else s++;
}
if (f <= s) printf("Snuke\n");
else printf("Fennec\n");
return 0;
}
| main.c:1:10: fatal error: cstdio: No such file or directory
1 | #include <cstdio>
| ^~~~~~~~
compilation terminated.
|
s257157965 | p03660 | 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;
}
};
vector<int> G[100010];
vector<int> dist1(100010,-1);//1からの距離を持つ配列
vector<int> distN(100010,-1);//nからの距離を持つ配列
void dfs1(int now){
for(int i:G[now]){
if(dist1[i]>0)continue;
dist1[i] = dist1[now] + 1;
dfs1(i);
}
return;
}
void dfsN(int now){
for(int i:G[now]){
if(distN[i]>0)continue;
distN[i] = distN[now] + 1;
dfsN(i);
}
return;
}
int main(){
int n;
cin>>n;
int a,b;
REP(i,n-1){
cin>>a>>b;
a--;b--;
G[a].push_back(b);
G[b].push_back(a);
}
dist1[0]=0;
dfs1(0);
distN[n-1]=0;
dfsN(n-1);
int cnt=0;
REP(i,n){
if(dist[i]<=distN[i]){
cnt++;
}
}
if(cnt>n-cnt){
cout<<"Fennec"<<endl;
}else{
cout<<"Sunuke"<<endl;
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:130:8: error: 'dist' was not declared in this scope; did you mean 'distN'?
130 | if(dist[i]<=distN[i]){
| ^~~~
| distN
|
s997335592 | p03660 | C++ | #include<iostream>
#include<queue>
#include<vector>
using namespace std;
const int MAXN=100000+10;
vector<int> edge[MAXN];//用邻接表来实现树的存储
int n,cnt[3];//cnt用来记录颜色数量
int tree[MAXN];//tree数组储存每个节点的颜色,1是指black,2指white
void bfs()
{
queue<int> q;
q.push(1),q.push(n);//Fennec先,Snuke后,所以先后入队
while(!q.empty())
{
int temp=q.front();
q.pop();
cnt[tree[temp]]++;//注意位置!!(咳咳)
for(int i=0;i<edge[temp].size();++i)//枚举所有节点
{
int v=edge[temp][i];
//cnt[tree[temp]]++; 不要在意细节(^_^)
if(tree[v])continue;
else tree[v]=tree[temp];//判断是否涂过色
q.push(v);
}
}
}
int main()
{
ios::sync_with_stdio(false);
memset(tree,0,sizeof(tree));
cin>>n;
for(int i=1;i<n;++i)
{
int x,y;
cin>>x>>y;
edge[x].push_back(y);
edge[y].push_back(x);//邻接表建树
}
tree[1]=1,tree[n]=2;
bfs();
if(cnt[2]>=cnt[1])//因为Fennec先手,所以如果最终结果相同,很明显是Snuke赢了
cout<<"Snuke"<<endl;
else
cout<<"Fennec"<<endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:35:5: error: 'memset' was not declared in this scope
35 | memset(tree,0,sizeof(tree));
| ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
2 | #include<queue>
+++ |+#include <cstring>
3 | #include<vector>
|
s943650043 | p03660 | C++ | //file_name:ABC67_D.cpp
#include <bits/stdc++.h>
#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 srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
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;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;
// int scan
/*
int x;
scanf("%d",&x);
int y;
scanf("%d",&y);
int z;
scanf("%d",&z);
// matrix scan
/*
ll a[n] = {};
rep(i,n){
scanf("%lld",&a[i]);
}
*/
// string scan
/*
string s;
cin >> s;
*/
struct edge{ int to, cost; };
int INF = 1001001001;
int V = 200005;
vector<edge> G[200005];
int d[200005];
int d2[200005];
void dijkstra(int s){
// greater<P>を指定することでfirstが小さい順に取り出せるようにする
priority_queue<P, vector<P>, greater<P> > que;
fill(d, d+V, INF);
d[s] = 0;
que.push(P(0, s));
while(!que.empty()){
P p = que.top();
que.pop();
int v = p.second;
for(int i=0; i<G[v].size(); i++){
edge e = G[v][i];
if(d[e.to] > d[v] + e.cost){
d[e.to] = d[v] + e.cost;
que.push(P(d[e.to], e.to));
}
}
}
}
void dijkstra2(int s){
// greater<P>を指定することでfirstが小さい順に取り出せるようにする
priority_queue<P, vector<P>, greater<P> > que;
fill(d2, d2+V, INF);
d2[s] = 0;
que.push(P(0, s));
while(!que.empty()){
P p = que.top();
que.pop();
int v = p.second;
for(int i=0; i<G[v].size(); i++){
edge e = G[v][i];
if(d2[e.to] > d2[v] + e.cost){
d2[e.to] = d2[v] + e.cost;
que.push(P(d2[e.to], e.to));
}
}
}
}
int main() {
int n;
scanf("%d",&n);
rep(i,n){
int from,to;
cin >> from >> to;
edge e1, e2;
e1.to = to; e1.cost = 1;
e2.to = from; e2.cost = 1;
G[from].push_back(e1);
G[to].push_back(e2);
}
dijkstra(1);
dijkstra(n);
int countf = 0;
int counts = 0;
srep(i,1,n+1){
if(d1<=d2){
countf++;
}else{
counts++;
}
}
if(counts<countf){
cout << "Fennec" << endl;
}else{
cout << "Snuke" << endl;
}
return 0;
}
| a.cc:78:5: error: conflicting declaration 'int INF'
78 | int INF = 1001001001;
| ^~~
a.cc:50:11: note: previous declaration as 'const int INF'
50 | const int INF = 1001001001;
| ^~~
a.cc: In function 'int main()':
a.cc:145:12: error: 'd1' was not declared in this scope; did you mean 'y1'?
145 | if(d1<=d2){
| ^~
| y1
|
s140756482 | p03660 | C++ | #include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>
#include <iomanip>
#include <tuple>
using namespace std;
bool d[100005][100005];
bool used[100005];
int res=0;
int dfs(int s,int t,int n){
for(int i=0;i<n;i++){
if(d[s][i] && !used[i] && i!=t){
used[i]=true;
res++;
dfs(i,t,n);
}
}
return res;
}
int main(){
int n;
cin>>n;
vector<int> a(n-1),b(n-1);
for(int i=0;i<n-1;i++){
cin>>a[i]>>b[i];
a[i]--;b[i]--;
d[a[i]][b[i]]=true;
d[b[i]][a[i]]=true;
}
int p=dfs(0,n-1,n);
for(int i=0;i<n;i++)used[i]=false;
res=0;
int q=dfs(n-1,0,n);
if(p>=q)cout<<"Fennec"<<endl;
else cout<<"Snuke"<<endl;
}
| /tmp/ccJcGYzI.o: in function `dfs(int, int, int)':
a.cc:(.text+0x48): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccJcGYzI.o
a.cc:(.text+0x67): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccJcGYzI.o
a.cc:(.text+0x71): relocation truncated to fit: R_X86_64_PC32 against symbol `res' defined in .bss section in /tmp/ccJcGYzI.o
a.cc:(.text+0x7a): relocation truncated to fit: R_X86_64_PC32 against symbol `res' defined in .bss section in /tmp/ccJcGYzI.o
a.cc:(.text+0xa2): relocation truncated to fit: R_X86_64_PC32 against symbol `res' defined in .bss section in /tmp/ccJcGYzI.o
/tmp/ccJcGYzI.o: in function `main':
a.cc:(.text+0x28d): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccJcGYzI.o
a.cc:(.text+0x2a3): relocation truncated to fit: R_X86_64_PC32 against symbol `res' defined in .bss section in /tmp/ccJcGYzI.o
collect2: error: ld returned 1 exit status
|
s053106562 | p03660 | C++ | #include<iostream>
#include<queue>
#include<vector>
using namespace std;
const int MAXN=100000+10;
vector<int> edge[MAXN];//用邻接表来实现树的存储
int n,cnt[3];//cnt用来记录颜色数量
int tree[MAXN];//tree数组储存每个节点的颜色,1是指black,2指white
void bfs()
{
queue<int> q;
q.push(1),q.push(n);//Fennec先,Snuke后,所以先后入队
while(!q.empty())
{
int temp=q.front();
q.pop();
cnt[tree[temp]]++;//注意位置!!(咳咳)
for(int i=0;i<edge[temp].size();++i)//枚举所有节点
{
int v=edge[temp][i];
//cnt[tree[temp]]++; 不要在意细节(^_^)
if(tree[v])continue;
else tree[v]=tree[temp];//判断是否涂过色
q.push(v);
}
}
}
int main()
{
ios::sync_with_stdio(false);
memset(tree,0,sizeof(tree));
cin>>n;
for(int i=1;i<n;++i)
{
int x,y;
cin>>x>>y;
edge[x].push_back(y);
edge[y].push_back(x);//邻接表建树
}
tree[1]=1,tree[n]=2;
bfs();
if(cnt[2]>=cnt[1])//因为Fennec先手,所以如果最终结果相同,很明显是Snuke赢了
cout<<"Snuke"<<endl;
else
cout<<"Fennec"<<endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:35:5: error: 'memset' was not declared in this scope
35 | memset(tree,0,sizeof(tree));
| ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
2 | #include<queue>
+++ |+#include <cstring>
3 | #include<vector>
|
s217914211 | p03660 | C++ | #include<iostream>
#include<queue>
#include<vector>
using namespace std;
const int MAXN=100000+10;
vector<int> edge[MAXN];//用邻接表来实现树的存储
int n,cnt[3];//cnt用来记录颜色数量
int tree[MAXN];//tree数组储存每个节点的颜色,1是指black,2指white
void bfs()
{
queue<int> q;
q.push(1),q.push(n);//Fennec先,Snuke后,所以先后入队
while(!q.empty())
{
int temp=q.front();
q.pop();
cnt[tree[temp]]++;//注意位置!!(咳咳)
for(int i=0;i<edge[temp].size();++i)//枚举所有节点
{
int v=edge[temp][i];
//cnt[tree[temp]]++; 不要在意细节(^_^)
if(tree[v])continue;
else tree[v]=tree[temp];//判断是否涂过色
q.push(v);
}
}
}
int main()
{
ios::sync_with_stdio(false);
memset(tree,0,sizeof(tree));
cin>>n;
for(int i=1;i<n;++i)
{
int x,y;
cin>>x>>y;
edge[x].push_back(y);
edge[y].push_back(x);//邻接表建树
}
tree[1]=1,tree[n]=2;
bfs();
if(cnt[2]>=cnt[1])//因为Fennec先手,所以如果最终结果相同,很明显是Snuke赢了
cout<<"Snuke"<<endl;
else
cout<<"Fennec"<<endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:35:5: error: 'memset' was not declared in this scope
35 | memset(tree,0,sizeof(tree));
| ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
2 | #include<queue>
+++ |+#include <cstring>
3 | #include<vector>
|
s232428205 | p03660 | C++ | #ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif
#include <algorithm>
#include <bitset>
#include <complex>
#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>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
#define y0 qvya13579
#define y1 qvyb24680
#define j0 qvja13579
#define j1 qvjb24680
#define next qvne13579xt
#define prev qvpr13579ev
#define INF 1000000007
#define MOD 1000000007
#define PI acos(-1.0)
#define endl "\n"
#define IOS cin.tie(0);ios::sync_with_stdio(false)
#define M_P make_pair
#define PU_B push_back
#define PU_F push_front
#define PO_B pop_back
#define PO_F pop_front
#define U_B upper_bound
#define L_B lower_bound
#define B_S binary_search
#define PR_Q priority_queue
#define FIR first
#define SEC second
#if __cplusplus < 201103L
#define stoi(argument_string) atoi((argument_string).c_str())
#endif
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP_R(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 FOR_R(i,m,n) for(int i=((int)(m)-1);i>=(int)(n);--i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define SIZ(x) ((int)(x).size())
#define COUT(x) cout<<(x)<<endl
#define CIN(x) cin>>(x)
#define CIN2(x,y) cin>>(x)>>(y)
#define CIN3(x,y,z) cin>>(x)>>(y)>>(z)
#define CIN4(x,y,z,w) cin>>(x)>>(y)>>(z)>>(w)
#define SCAND(x) scanf("%d",&(x))
#define SCAND2(x,y) scanf("%d%d",&(x),&(y))
#define SCAND3(x,y,z) scanf("%d%d%d",&(x),&(y),&(z))
#define SCAND4(x,y,z,w) scanf("%d%d%d%d",&(x),&(y),&(z),&(w))
#define SCANLLD(x) scanf("%lld",&(x))
#define SCANLLD2(x,y) scanf("%lld%lld",&(x),&(y))
#define SCANLLD3(x,y,z) scanf("%lld%lld%lld",&(x),&(y),&(z))
#define SCANLLD4(x,y,z,w) scanf("%lld%lld%lld%lld",&(x),&(y),&(z),&(w))
#define PRINTD(x) printf("%d\n",(x))
#define PRINTLLD(x) printf("%lld\n",(x))
typedef long long int lli;
using namespace std;
bool compare_by_2nd(pair<int,int> a, pair<int,int> b)
{
if( a.second != b.second )
{
return a.second < b.second;
}
else
{
return a.first < b.first;
}
}
int ctoi(char c)
{
if( c >= '0' and c <= '9' )
{
return (int)(c-'0');
}
return -1;
}
int alphabet_pos(char c)
{
if( c >= 'a' and c <= 'z' )
{
return (int)(c-'a');
}
return -1;
}
int alphabet_pos_capital(char c)
{
if( c >= 'A' and c <= 'Z' )
{
return (int)(c-'A');
}
return -1;
}
vector<string> split(string str, char ch)
{
int first = 0;
int last = str.find_first_of(ch);
if(last == string::npos)
{
last = SIZ(str);
}
vector<string> result;
while( first < SIZ(str) )
{
string Ssubstr(str, first, last - first);
result.push_back(Ssubstr);
first = last + 1;
last = str.find_first_of(ch, first);
if(last == string::npos)
{
last = SIZ(str);
}
}
return result;
}
int gcd( int a , int b ) // assuming a,b >= 1
{
if( a < b )
{
return gcd( b , a );
}
if( a % b == 0 )
{
return b;
}
return gcd( b , a % b );
}
int lcm( int a , int b ) // assuming a,b >= 1
{
return a * b / gcd( a , b );
}
lli pow_fast( lli x, lli n_power , lli modulus )
{
if( n_power == 0 )
{
return 1;
}
if( n_power % 2 == 0)
{
return pow_fast( x * x % modulus , n_power / 2 , modulus );
}
return x * pow_fast( x , n_power - 1 , modulus ) % modulus;
}
/*------------------ the end of the template -----------------------*/
int main()
{
IOS; /* making cin faster */
int N;
SCAND(N);
int a,b;
vector<int> d(N,INF);
vector<vector<int> > adj(N);
vector<int> flag_cango(N,1);
priority_queue<pair<int,int> > p;
REP(i,N-1)
{
SCAND2(a,b);
-- a;
-- b;
adj[a].push_back(b);
adj[b].push_back(a);
}
d[0] = 0;
p.push(make_pair(0,0));
while( !p.empty() )
{
pair<int,int> r = p.top();
p.pop();
int u = r.second;
flag_cango[u] = 0;
if( d[u] < -r.first )
{
continue;
}
REP(i,SIZ(adj[u]))
{
int v = adj[u][i];
if( d[v] > d[u] + 1 and flag_cango[v] )
{
d[v] = d[u] + 1;
p.push(make_pair(-d[v],v));
}
}
}
if( d[N-1] % 2 )
{
COUT(Snuke);
}
else
{
COUT(Fennec);
}
}
| a.cc: In function 'int main()':
a.cc:318:12: error: 'Snuke' was not declared in this scope
318 | COUT(Snuke);
| ^~~~~
a.cc:115:24: note: in definition of macro 'COUT'
115 | #define COUT(x) cout<<(x)<<endl
| ^
a.cc:322:12: error: 'Fennec' was not declared in this scope
322 | COUT(Fennec);
| ^~~~~~
a.cc:115:24: note: in definition of macro 'COUT'
115 | #define COUT(x) cout<<(x)<<endl
| ^
|
s505230250 | p03660 | C++ | #include<iostream>
#include<queue>
#include<vector>
using namespace std;
const int MAXN=100000+10;
vector<int> edge[MAXN];//用邻接表来实现树的存储
int n,cnt[3];//cnt用来记录颜色数量
int tree[MAXN];//tree数组储存每个节点的颜色,1是指black,2指white
void bfs()
{
queue<int> q;
q.push(1),q.push(n);//Fennec先,Snuke后,所以先后入队
while(!q.empty())
{
int temp=q.front();
q.pop();
cnt[tree[temp]]++;//注意位置!!(咳咳)
for(int i=0;i<edge[temp].size();++i)//枚举所有节点
{
int v=edge[temp][i];
//cnt[tree[temp]]++; 不要在意细节(^_^)
if(tree[v])continue;
else tree[v]=tree[temp];//判断是否涂过色
q.push(v);
}
}
}
int main()
{
ios::sync_with_stdio(false);
memset(tree,0,sizeof(tree));
cin>>n;
for(int i=1;i<n;++i)
{
int x,y;
cin>>x>>y;
edge[x].push_back(y);
edge[y].push_back(x);//邻接表建树
}
tree[1]=1,tree[n]=2;
bfs();
if(cnt[2]>=cnt[1])//因为Fennec先手,所以如果最终结果相同,很明显是Snuke赢了
cout<<"Snuke"<<endl;
else
cout<<"Fennec"<<endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:35:5: error: 'memset' was not declared in this scope
35 | memset(tree,0,sizeof(tree));
| ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
2 | #include<queue>
+++ |+#include <cstring>
3 | #include<vector>
|
s370425069 | p03660 | C++ | #include "bits/stdc++.h"
using namespace std;
const ll MAX_V = 100100;
ll V, E;
vector<ll> G[MAX_V];
ll cnt[2], mark[MAX_V];
bool f[2][MAX_V];
void dfs(ll s, ll n) {
for (ll i = 0; i < G[s].size(); i++) {
ll u = G[s][i];
if(f[n][u]) continue;
f[n][u] = true;
cnt[n]++;
mark[u]++;
dfs(u, n);
}
}
int main() {
cin >> V;
for (ll i = 0; i < V-1; i++) {
ll a, b; cin >> a >> b;
a--; b--;
G[a].push_back(b);
G[b].push_back(a);
}
f[0][0] = f[0][V-1] = true;
f[1][0] = f[1][V-1] = true;
dfs(0, 0);
dfs(V-1, 1);
ll bw=0;
for (ll i = 0; i < V; i++) {
if(mark[i]==2) bw++;
}
cnt[0] -= bw/2;
cnt[1] -= (bw/2)+(bw%2);
//cout << cnt[0] <<" "<< cnt[1] << endl;
if(cnt[0] > cnt[1]) cout << "Fennec" << endl;
else cout << "Snuke" << endl;
} | a.cc:4:7: error: 'll' does not name a type
4 | const ll MAX_V = 100100;
| ^~
a.cc:6:1: error: 'll' does not name a type
6 | ll V, E;
| ^~
a.cc:7:8: error: 'll' was not declared in this scope
7 | vector<ll> G[MAX_V];
| ^~
a.cc:7:10: error: template argument 1 is invalid
7 | vector<ll> G[MAX_V];
| ^
a.cc:7:10: error: template argument 2 is invalid
a.cc:7:14: error: 'MAX_V' was not declared in this scope
7 | vector<ll> G[MAX_V];
| ^~~~~
a.cc:9:1: error: 'll' does not name a type
9 | ll cnt[2], mark[MAX_V];
| ^~
a.cc:10:11: error: 'MAX_V' was not declared in this scope
10 | bool f[2][MAX_V];
| ^~~~~
a.cc:12:6: error: variable or field 'dfs' declared void
12 | void dfs(ll s, ll n) {
| ^~~
a.cc:12:10: error: 'll' was not declared in this scope
12 | void dfs(ll s, ll n) {
| ^~
a.cc:12:16: error: 'll' was not declared in this scope
12 | void dfs(ll s, ll n) {
| ^~
a.cc: In function 'int main()':
a.cc:25:16: error: 'V' was not declared in this scope
25 | cin >> V;
| ^
a.cc:26:14: error: 'll' was not declared in this scope
26 | for (ll i = 0; i < V-1; i++) {
| ^~
a.cc:26:24: error: 'i' was not declared in this scope
26 | for (ll i = 0; i < V-1; i++) {
| ^
a.cc:27:19: error: expected ';' before 'a'
27 | ll a, b; cin >> a >> b;
| ^~
| ;
a.cc:27:33: error: 'a' was not declared in this scope
27 | ll a, b; cin >> a >> b;
| ^
a.cc:27:38: error: 'b' was not declared in this scope
27 | ll a, b; cin >> a >> b;
| ^
a.cc:29:17: error: 'G' was not declared in this scope
29 | G[a].push_back(b);
| ^
a.cc:33:9: error: 'f' was not declared in this scope
33 | f[0][0] = f[0][V-1] = true;
| ^
a.cc:36:9: error: 'dfs' was not declared in this scope; did you mean 'ffs'?
36 | dfs(0, 0);
| ^~~
| ffs
a.cc:39:9: error: 'll' was not declared in this scope
39 | ll bw=0;
| ^~
a.cc:40:16: error: expected ';' before 'i'
40 | for (ll i = 0; i < V; i++) {
| ^~
| ;
a.cc:40:24: error: 'i' was not declared in this scope
40 | for (ll i = 0; i < V; i++) {
| ^
a.cc:41:20: error: 'mark' was not declared in this scope
41 | if(mark[i]==2) bw++;
| ^~~~
a.cc:41:32: error: 'bw' was not declared in this scope
41 | if(mark[i]==2) bw++;
| ^~
a.cc:43:9: error: 'cnt' was not declared in this scope; did you mean 'int'?
43 | cnt[0] -= bw/2;
| ^~~
| int
a.cc:43:19: error: 'bw' was not declared in this scope
43 | cnt[0] -= bw/2;
| ^~
|
s331314457 | p03660 | C++ | #include <bits/stdc++.h>
//#include <mylib.h>
using namespace std;
//cin.sync_with_stdio(false);
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FOR_EQ(i,a,b) for(int i = (a); i <= (b); ++i)
#define FOR_RE(i,a,b) for(int i = (a); i > (b); --i)
#define rep(i,n) FOR(i,0,n)
#define rep_eq(i,n) FOR_EQ(i,0,n)
#define rep_re(i,n) FOR_RE(i,n,0)
#define DEBUG_VARIABLE(variable) cout << #variable << ":" << variable << endl
#define WHITE 1//(未訪問)
#define GRAY 2//(訪問)未だに訪問していない頂点への辺を持っている。スタックに退避。
#define BLACK 3//(訪問完了)未訪問への頂点への辺を持たない
#define N 100000
#define INFTY (1 << 21) //10^21
int M[N][N];//隣接行列
int color[N];
//1個上から時計周り
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//上右下左
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {-1, 0, 1, 0};
static const int NIL = -1;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> Vector;
typedef vector<Vector> DVector;
int n;
void printArray(int *array, int);
void printDimention(DVector);
int dis_F[N];
int dis_S[N];
int dis = -1;
void dfs_visit(int u, bool flg){
int v;
dis++;
//探索中、未探索の辺を持つ
color[u] = GRAY;
if(flg){
dis_F[u] = dis;
}else{
dis_S[u] = dis;
}
rep(v, n){
//隣接行列に辺がない
if(M[u][v] == 0) continue;
//初探索の状態
if(color[v] == WHITE){
dfs_visit(v, flg);
dis--;
}
}
color[u] = BLACK;
}
void dfs(){
int u;
//初期化
rep(u, n) color[u] = WHITE;
/*
rep(u, n){
//未訪問のuを始点として深さ優先探索
if(color[u] == WHITE) dfs_visit(u);
}*/
dfs_visit(0, true);
dis = -1;
rep(u, n) color[u] = WHITE;
dfs_visit(n - 1, false);
//出力(略)
}
int main(int argc, char const *argv[])
{
cin.tie(0);
ios::sync_with_stdio(false);
int a, b;
cin >> n;
memset(M, 0, n * n);
rep(i, n - 1){
cin >> a >> b;
M[a - 1][b - 1] = M[b - 1][a - 1] = 1;
}
//cout << "dfs start" << endl;
dfs();
//printArray(dis_F, n);
//printArray(dis_S, n);
int black = 0, white = 0;
rep(i, n){
if(dis_F[i] <= dis_S[i]){
black++;
}else{
white++;
}
}
if(black > white){
cout << "Fennec" << endl;
}else{
cout << "Snuke" << endl;
}
}
//配列の表示
void printArray(int array[], int n){
rep(i, n){
if(i) cout << " ";
cout << array[i];
}
cout << endl;
}
//二次元配列の表示
void printDimention(DVector &dv){
rep(i, (int)dv.size()){
rep(j, (int)dv[i].size()){
if(j) cout << " ";
cout << dv[i][j];
}
cout << endl;
}
} | /tmp/cc1JGL9w.o: in function `dfs_visit(int, bool)':
a.cc:(.text+0x2f): relocation truncated to fit: R_X86_64_PC32 against symbol `color' defined in .bss section in /tmp/cc1JGL9w.o
a.cc:(.text+0x57): relocation truncated to fit: R_X86_64_PC32 against symbol `dis_F' defined in .bss section in /tmp/cc1JGL9w.o
a.cc:(.text+0x77): relocation truncated to fit: R_X86_64_PC32 against symbol `dis_S' defined in .bss section in /tmp/cc1JGL9w.o
a.cc:(.text+0xc2): relocation truncated to fit: R_X86_64_PC32 against symbol `color' defined in .bss section in /tmp/cc1JGL9w.o
a.cc:(.text+0xf6): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cc1JGL9w.o
a.cc:(.text+0x10f): relocation truncated to fit: R_X86_64_PC32 against symbol `color' defined in .bss section in /tmp/cc1JGL9w.o
/tmp/cc1JGL9w.o: in function `dfs()':
a.cc:(.text+0x13e): relocation truncated to fit: R_X86_64_PC32 against symbol `color' defined in .bss section in /tmp/cc1JGL9w.o
a.cc:(.text+0x14f): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cc1JGL9w.o
a.cc:(.text+0x18a): relocation truncated to fit: R_X86_64_PC32 against symbol `color' defined in .bss section in /tmp/cc1JGL9w.o
a.cc:(.text+0x19b): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cc1JGL9w.o
a.cc:(.text+0x1a6): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
|
s849779144 | p03660 | C++ | #include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")
const ll mod = 1e9 + 7;
const ll inf = 1e18;
const int N_MAX = 100010;
bool visited[N_MAX];
void reset_visited(){
FOR(i, 0, N_MAX){
visited[i] = false;
}
}
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
// input
int N;
cin >> N;
vector<vector<int> > graph(N+1);
FOR(i, 0, N){
int a, b;
cin >> a >> b;
graph[a].push_back(b);
graph[b].push_back(a);
}
// fennecからの距離
reset_visited();
int d[N+1];
queue<int> que;
d[1] = 0;
que.push(1);
while(!que.empty()){
int front = que.front();
que.pop();
auto list = graph[front];
FOR(i, 0, list.size()){
int dest = list[i];
if(!visited[dest]){
visited[dest] = true;
que.push(dest);
d[dest] = d[front] + 1;
}
}
}
int d0[N+1];
memcpy(d0, d, sizeof(d));
// snukeからの距離
reset_visited();
d[N] = 0;
que.push(N);
while(!que.empty()){
int front = que.front();
que.pop();
auto list = graph[front];
FOR(i, 0, list.size()){
int dest = list[i];
if(!visited[dest]){
visited[dest] = true;
que.push(dest);
d[dest] = d[front] + 1;
}
}
}
int d1[N+1];
memcpy(d1, d, sizeof(d));
int black = 0;
int white = 0;
FOR(i, 2, N-1){
if(d0[i] <= d1[i]){
black++;
}else{
white++;
}
}
if(black==white){
p("Snuke");
}
else if(black > white){
p("Fennec");
}
else{
p("Snuke");
}
return 0;
} | a.cc: In function 'int main()':
a.cc:78:5: error: 'memcpy' was not declared in this scope
78 | memcpy(d0, d, sizeof(d));
| ^~~~~~
a.cc:12:1: note: 'memcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
11 | #include<stack>
+++ |+#include <cstring>
12 | #include<stdio.h>
|
s914277923 | p03660 | C++ | #include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#define v_exists(elem, v) find(v.begin(),v.end(),elem)!=v.end()
#define s_exists(elem, s) s.find(elem)!=s.end()
using namespace std;
const int MOD = 1000000007;
long gcd(long a, long b) {
return b == 0 ? a : gcd(b, a % b);
}
long lcm( long m, long n ){
if ( ( 0 == m ) || ( 0 == n ) )
return 0;
return ((m / gcd(m, n)) * n);
}
long kake(long x, long y){
return x * y % MOD;
}
long fact_mod(long x){
long ans = x;
x-=1;
while(x>1){
ans = ans * x % MOD;
x-=1;
}
return ans;
}
std::map<int, std::vector<int>> adj;
std::set<long> visited;
long l1 [100001];
long l2 [100001];
void dfs1(long s, long d){
l1[s] = d;
visited.insert(s);
for(int i=0; i<adj[s].size(); i++){
if(s_exists(adj[s][i], visited)==false){
dfs(adj[s][i], d+1);
}
}
}
void dfs2(long s, long d){
l2[s] = d;
visited.insert(s);
for(int i=0; i<adj[s].size(); i++){
if(s_exists(adj[s][i], visited)==false){
dfs(adj[s][i], d+1);
}
}
}
int main(){
long N;
scanf("%ld",&N);
for(int i=0; i<N;i++){
std::vector<int> v = {};
adj[i]=v;
}
for(int i=0; i<N-1;i++){
long a,b;
scanf("%ld %ld",&a,&b);
adj[a].push_back(b);
adj[b].push_back(a);
}
dfs1(0, 0);
visited.clear();
dfs2(N-1, 0);
long score = 0;
for(int i=0; i<N; i++){
if(l1[i] <= l2[i]){
score+=1;
} else{
score-=1;
}
}
if(score>=0){
cout << "Fennec" << endl;
} else{
cout << "Snuke" << endl;
}
} | a.cc: In function 'void dfs1(long int, long int)':
a.cc:54:25: error: 'dfs' was not declared in this scope; did you mean 'dfs1'?
54 | dfs(adj[s][i], d+1);
| ^~~
| dfs1
a.cc: In function 'void dfs2(long int, long int)':
a.cc:65:25: error: 'dfs' was not declared in this scope; did you mean 'dfs2'?
65 | dfs(adj[s][i], d+1);
| ^~~
| dfs2
|
s009501549 | p03660 | C++ | #include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#define v_exists(elem, v) find(v.begin(),v.end(),elem)!=v.end()
#define s_exists(elem, s) s.find(elem)!=s.end()
using namespace std;
const int MOD = 1000000007;
long gcd(long a, long b) {
return b == 0 ? a : gcd(b, a % b);
}
long lcm( long m, long n ){
if ( ( 0 == m ) || ( 0 == n ) )
return 0;
return ((m / gcd(m, n)) * n);
}
long kake(long x, long y){
return x * y % MOD;
}
long fact_mod(long x){
long ans = x;
x-=1;
while(x>1){
ans = ans * x % MOD;
x-=1;
}
return ans;
}
std::map<int, std::vector<int>> adj;
std::set<long> visited;
long l1 [100001];
long l2 [100001];
void dfs1(long s, long d){
l1[s] = d;
visited.insert(s);
for(int i=0; i<adj[s].size(); i++){
if(s_exists(adj[s][i], visited)==false){
dfs(adj[s][i], d+1, visited, d_list);
}
}
}
void dfs2(long s, long d){
l2[s] = d;
visited.insert(s);
for(int i=0; i<adj[s].size(); i++){
if(s_exists(adj[s][i], visited)==false){
dfs(adj[s][i], d+1, visited, d_list);
}
}
}
int main(){
long N;
scanf("%ld",&N);
for(int i=0; i<N;i++){
std::vector<int> v = {};
adj[i]=v;
}
for(int i=0; i<N-1;i++){
long a,b;
scanf("%ld %ld",&a,&b);
adj[a].push_back(b);
adj[b].push_back(a);
}
dfs1(0, 0);
visited.clear();
dfs2(N-1, 0);
long score = 0;
for(int i=0; i<N; i++){
if(l1[i] <= l2[i]){
score+=1;
} else{
score-=1;
}
}
if(score>=0){
cout << "Fennec" << endl;
} else{
cout << "Snuke" << endl;
}
} | a.cc: In function 'void dfs1(long int, long int)':
a.cc:54:54: error: 'd_list' was not declared in this scope; did you mean 'va_list'?
54 | dfs(adj[s][i], d+1, visited, d_list);
| ^~~~~~
| va_list
a.cc:54:25: error: 'dfs' was not declared in this scope; did you mean 'dfs1'?
54 | dfs(adj[s][i], d+1, visited, d_list);
| ^~~
| dfs1
a.cc: In function 'void dfs2(long int, long int)':
a.cc:65:54: error: 'd_list' was not declared in this scope; did you mean 'va_list'?
65 | dfs(adj[s][i], d+1, visited, d_list);
| ^~~~~~
| va_list
a.cc:65:25: error: 'dfs' was not declared in this scope; did you mean 'dfs2'?
65 | dfs(adj[s][i], d+1, visited, d_list);
| ^~~
| dfs2
|
s279293511 | p03660 | C++ | #include <iostream>
using namespace std;
int main()
{
int N;
int i,j;
int a[1000],b[1000];
for(i=0;i<N;i++){
for(j=0;j<2;j++){
cin>>a[i][j]>>b[i][j];
}
}
if(N%2){
cout<<"Fennec"<<endl;
}else{
cout<<"Snuke"<<endl;
}
}
| a.cc: In function 'int main()':
a.cc:10:34: error: invalid types 'int[int]' for array subscript
10 | cin>>a[i][j]>>b[i][j];
| ^
a.cc:10:43: error: invalid types 'int[int]' for array subscript
10 | cin>>a[i][j]>>b[i][j];
| ^
|
s484996497 | p03660 | C++ |
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include <numeric>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define m0(x) memset(x,0,sizeof(x))
using namespace std;
int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };
int dxx[8] = { 0,0,1,1,1,-1,-1,-1 };
int dyy[8] = { 1,-1,0,1,-1,0,1,-1 };
ll m = 1000000007;
ll gcd(ll x, ll y) {
ll m = max(x, y), n = min(x, y);
if (m%n == 0)return n;
else return gcd(m%n, n);
}
ll lcm(ll x, ll y) {
return x / gcd(x, y)*y;
}
ll myPow(ll x, ll n, ll m) {
if (n == 0)
return 1;
if (n % 2 == 0)
return myPow(x * x % m, n / 2, m);
else
return x * myPow(x, n - 1, m) % m;
}
bool vis1[100010], visN[100010];
int dist1[100010], distN[100010];
vector<int> tree1[100010];
void dfs1(int pos) {
for (auto i : tree1[pos]) {
if (!vis1[i]) {
vis1[i] = true;
dist1[i] = dist1[pos] + 1;
dfs1(i);
}
}
return;
}
void dfsN(int pos) {
for (auto i : tree1[pos]) {
if (!visN[i]) {
visN[i] = true;
distN[i] = distN[pos] + 1;
dfsN(i);
}
}
return;
}
int main() {
int N; cin >> N;
memset(vis1, 0, sizeof(vis1)); memset(visN, 0, sizeof(visN));
vis1[0] = true; visN[N - 1] = true;
dist1[0] = 0;
distN[N-1] = 0;
REP(i, N-1) {
int a, b;
cin >> a >> b;
a--, b--;
tree1[a].push_back(b);
}
dfs1(0);
dfsN(N - 1);
int Fen=0, Snu=0;
FOR(i,1, N-1) {
if (dist1[i] <= distN[i]) {
Fen++;
}
else {
Snu++;
}
}
if (Fen > Snu) {
cout << "Fennec" << endl;
}
else {
cout << "Snuke" << endl;
}
}
| a.cc: In function 'int main()':
a.cc:83:9: error: 'memset' was not declared in this scope
83 | memset(vis1, 0, sizeof(vis1)); memset(visN, 0, sizeof(visN));
| ^~~~~~
a.cc:12:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
11 | #include <numeric>
+++ |+#include <cstring>
12 | #define REP(i, n) for(int i = 0;i < n;i++)
|
s573844640 | p03660 | C++ |
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include <numeric>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define m0(x) memset(x,0,sizeof(x))
using namespace std;
int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };
int dxx[8] = { 0,0,1,1,1,-1,-1,-1 };
int dyy[8] = { 1,-1,0,1,-1,0,1,-1 };
ll m = 1000000007;
ll gcd(ll x, ll y) {
ll m = max(x, y), n = min(x, y);
if (m%n == 0)return n;
else return gcd(m%n, n);
}
ll lcm(ll x, ll y) {
return x / gcd(x, y)*y;
}
ll myPow(ll x, ll n, ll m) {
if (n == 0)
return 1;
if (n % 2 == 0)
return myPow(x * x % m, n / 2, m);
else
return x * myPow(x, n - 1, m) % m;
}
bool vis1[100010], visN[100010];
int dist1[100010], distN[100010];
vector<int> tree1[100010];
void dfs1(int pos) {
for (auto i : tree1[pos]) {
if (!vis1[i]) {
vis1[i] = true;
dist1[i] = dist1[pos] + 1;
dfs1(i);
}
}
return;
}
void dfsN(int pos) {
for (auto i : tree1[pos]) {
if (!visN[i]) {
visN[i] = true;
distN[i] = distN[pos] + 1;
dfsN(i);
}
}
return;
}
int main() {
int N; cin >> N;
m0(vis1); m0(visN);
vis1[0] = true; visN[N - 1] = true;
dist1[0] = 0;
distN[N-1] = 0;
REP(i, N-1) {
int a, b;
cin >> a >> b;
a--, b--;
tree1[a].push_back(b);
}
dfs1(0);
dfsN(N - 1);
int Fen=0, Snu=0;
FOR(i,1, N-1) {
if (dist1[i] <= distN[i]) {
Fen++;
}
else {
Snu++;
}
}
if (Fen > Snu) {
cout << "Fennec" << endl;
}
else {
cout << "Snuke" << endl;
}
}
| a.cc: In function 'int main()':
a.cc:23:15: error: 'memset' was not declared in this scope
23 | #define m0(x) memset(x,0,sizeof(x))
| ^~~~~~
a.cc:80:9: note: in expansion of macro 'm0'
80 | m0(vis1); m0(visN);
| ^~
a.cc:12:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
11 | #include <numeric>
+++ |+#include <cstring>
12 | #define REP(i, n) for(int i = 0;i < n;i++)
|
s751733648 | p03660 | C++ |
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include <numeric>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define m0(x) memset(x,0,sizeof(x))
using namespace std;
int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };
int dxx[8] = { 0,0,1,1,1,-1,-1,-1 };
int dyy[8] = { 1,-1,0,1,-1,0,1,-1 };
ll m = 1000000007;
ll gcd(ll x, ll y) {
ll m = max(x, y), n = min(x, y);
if (m%n == 0)return n;
else return gcd(m%n, n);
}
ll lcm(ll x, ll y) {
return x / gcd(x, y)*y;
}
ll myPow(ll x, ll n, ll m) {
if (n == 0)
return 1;
if (n % 2 == 0)
return myPow(x * x % m, n / 2, m);
else
return x * myPow(x, n - 1, m) % m;
}
bool vis1[100010], visN[100010];
int dist1[100010], distN[100010];
vector<int> tree1[100010];
void dfs1(int pos) {
for (auto i : tree1[pos]) {
if (!vis1[i]) {
vis1[i] = true;
dist1[i] = dist1[pos] + 1;
dfs1(i);
}
}
return;
}
void dfsN(int pos) {
for (auto i : tree1[pos]) {
if (!visN[i]) {
visN[i] = true;
distN[i] = distN[pos] + 1;
dfsN(i);
}
}
return;
}
int main() {
int N; cin >> N;
m0(vis1); m0(visN);
vis1[0] = true; visN[N - 1] = true;
dist1[0] = 0;
distN[N-1] = 0;
REP(i, N-1) {
int a, b;
cin >> a >> b;
a--, b--;
tree1[a].push_back(b);
}
dfs1(0);
dfsN(N - 1);
int Fen=0, Snu=0;
FOR(i,1, N-1) {
if (dist1[i] <= distN[i]) {
Fen++;
}
else {
Snu++;
}
}
if (Fen > Snu) {
cout << "Fennec" << endl;
}
else {
cout << "Snuke" << endl;
}
}
| a.cc: In function 'int main()':
a.cc:23:15: error: 'memset' was not declared in this scope
23 | #define m0(x) memset(x,0,sizeof(x))
| ^~~~~~
a.cc:80:9: note: in expansion of macro 'm0'
80 | m0(vis1); m0(visN);
| ^~
a.cc:12:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
11 | #include <numeric>
+++ |+#include <cstring>
12 | #define REP(i, n) for(int i = 0;i < n;i++)
|
s190505705 | p03660 | Java | import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
public class Main {
static int n;
static List<List<Integer>> list;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
n = sc.nextInt();
list = new ArrayList<>(n);
for(int i = 0; i < n; i++) list.add(new ArrayList<>());
for(int i = 0; i < n - 1; i++) {
int a = sc.nextInt() - 1;
int b = sc.nextInt() - 1;
list.get(a).add(b);
list.get(b).add(a);
}
int[] list1 = dfs(0, -1, new int[n]);
int[] list2 = dfs(n - 1, -1, new int[n]);
int a = 0, b = 0;
for(int i = 0; i < n; i++) {
if(list1[i] <= list2[i]) a++;
else b++;
}
if(a > b) {
System.out.println("Fennec");
} else {
System.out.println("Snuke");
}
// System.out.println(Arrays.toString(list1));
// System.out.println(Arrays.toString(list2));
// }
static int[] dfs(int s, int p, int[] ret) {
List<Integer> edge = list.get(s);
for(int v : edge) {
if(p != v) {
ret[v] += ret[s] + 1;
dfs(v, s, ret);
}
}
return ret;
}
}
| Main.java:38: error: illegal start of expression
static int[] dfs(int s, int p, int[] ret) {
^
1 error
|
s531969964 | p03660 | C++ | #include <bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
vector<int>edge[n];
for(int i=0;i<n-1;i++){
int a,b;
cin>>a>>b;
a--;
b--;
edge[a].push_back(b);
edge[b].push_back(a);
}
int black[n];
memset(black,-1,sizeof black);
queue<int>q;
q.push(0);
while(!q.empty()){
int now=q.front();
q.pop();
for(int i=0;i<edge[now].size();i++){
int nex=edge[now][i];
if(black[nex]==-1)continue;
black[nex]=black[now]+1;
q.push(nex);
}
}
int white[n];
memset(white,-1,sizeof white);
q.push(n-1);
while(!q.empty()){
int now=q.front();
q.pop();
for(int i=0;i<edge[now].size();i++){
int nex=edge[now][i];
if(white[nex]==-1)continue;
white[nex]=white[now]+1;
q.push(nex);
}
}
int a,b;
a=0;
b=0;
for(int i=0;i<n;i++){
if(black[i]>=white[i]){
a++;
}else{
b++;
}
}
if(b>=a)cout<<"Snuke";else cout<<"Fennec"<<endl;
return 0;
}\ | a.cc:59:2: error: stray '\' in program
59 | }\
| ^
|
s026006212 | p03660 | C++ |
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#define N 654321
using namespace std;
int n,rt,size[N],fa[N],cnt=0,sum1,sum2;
int TOT,EN[N],LA[N],NE[N];
void ADD(int x,int y)
{
TOT++;
EN[TOT]=y;
NE[TOT]=LA[x];
LA[x]=TOT;
}
void DFS(int u,int f)
{
int i,v;
fa[u]=f;
size[u]=1;
for(i=LA[u];i;i=NE[i])
{
v=EN[i];
if(v!=f)
{
DFS(v,u);
size[u]+=size[v];
}
}
}
int main()
{
int i,x,y;
scanf("%d",&n);
for(i=1;i<n;i++)
{
scanf("%d%d",&x,&y);
ADD(x,y);ADD(y,x);
}
DFS(1,0);i=n;
while(i!=1)i=fa[i],cnt++;
cnt--;i=0;x=n;
while(i<cnt/2)x=fa[x],i++;
y=fa[x];
DFS(x,0);
sum1=size[y];sum2=n-sum1;
if(sum1>sum2)cout<<"Fennec";
else cout<<"Snuke";
| a.cc: In function 'void DFS(int, int)':
a.cc:21:9: error: reference to 'size' is ambiguous
21 | size[u]=1;
| ^~~~
In file included from /usr/include/c++/14/string:53,
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:3:
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:8:10: note: 'int size [654321]'
8 | int n,rt,size[N],fa[N],cnt=0,sum1,sum2;
| ^~~~
a.cc:28:25: error: reference to 'size' is ambiguous
28 | size[u]+=size[v];
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:8:10: note: 'int size [654321]'
8 | int n,rt,size[N],fa[N],cnt=0,sum1,sum2;
| ^~~~
a.cc:28:34: error: reference to 'size' is ambiguous
28 | size[u]+=size[v];
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:8:10: note: 'int size [654321]'
8 | int n,rt,size[N],fa[N],cnt=0,sum1,sum2;
| ^~~~
a.cc: In function 'int main()':
a.cc:47:14: error: reference to 'size' is ambiguous
47 | sum1=size[y];sum2=n-sum1;
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:8:10: note: 'int size [654321]'
8 | int n,rt,size[N],fa[N],cnt=0,sum1,sum2;
| ^~~~
a.cc:49:28: error: expected '}' at end of input
49 | else cout<<"Snuke";
| ^
a.cc:33:1: note: to match this '{'
33 | {
| ^
|
s997384956 | p03660 | C++ | #include <iostream>
#include <deque>
using namespace std;
int matrix[100001][100001] = {};
int n;
deque<int> path;
bool visited[100001] = {};
bool dfs(int current){
//cout << current;
path.push_back(current);
visited[current]=true;
if(current==n)return true;
for(int j = 1; j <= n; j++){
if(matrix[current][j]==0)continue;
if(visited[j])continue;
if(dfs(j))return true;
visited[j]=false;
path.pop_back();
}
return false;
}
int cnt = 1;
bool visited1[100001]={};
void dfs1(int current){
visited1[current]=true;
for(int j = 1; j <= n; j++){
if(matrix[current][j]==0)continue;
if(visited1[j])continue;
cnt++;
dfs1(j);
visited1[j]=false;
}
return ;
}
int main(){
cin >> n;
for(int i = 0; i < n - 1; i++){
int a,b;
cin >> a >> b;
matrix[a][b] = matrix[b][a] = 1;
}
dfs(1);
int index = (path.size() + 1) / 2;
matrix[path[index-1]][path[index]] = matrix[path[index]][path[index-1]] = 0;
dfs1(1);
cout << cnt;
if(cnt > n - cnt)cout << "Fennec" << endl;
else cout << "Snuke" << endl;
return 0;
} | /tmp/ccpCCIK1.o: in function `dfs(int)':
a.cc:(.text+0x15): relocation truncated to fit: R_X86_64_PC32 against symbol `path' defined in .bss section in /tmp/ccpCCIK1.o
a.cc:(.text+0x29): relocation truncated to fit: R_X86_64_PC32 against symbol `visited' defined in .bss section in /tmp/ccpCCIK1.o
a.cc:(.text+0x36): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccpCCIK1.o
a.cc:(.text+0x84): relocation truncated to fit: R_X86_64_PC32 against symbol `visited' defined in .bss section in /tmp/ccpCCIK1.o
a.cc:(.text+0xad): relocation truncated to fit: R_X86_64_PC32 against symbol `visited' defined in .bss section in /tmp/ccpCCIK1.o
a.cc:(.text+0xb8): relocation truncated to fit: R_X86_64_PC32 against symbol `path' defined in .bss section in /tmp/ccpCCIK1.o
a.cc:(.text+0xd0): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccpCCIK1.o
/tmp/ccpCCIK1.o: in function `dfs1(int)':
a.cc:(.text+0xf7): relocation truncated to fit: R_X86_64_PC32 against symbol `visited1' defined in .bss section in /tmp/ccpCCIK1.o
a.cc:(.text+0x13b): relocation truncated to fit: R_X86_64_PC32 against symbol `visited1' defined in .bss section in /tmp/ccpCCIK1.o
a.cc:(.text+0x168): relocation truncated to fit: R_X86_64_PC32 against symbol `visited1' defined in .bss section in /tmp/ccpCCIK1.o
a.cc:(.text+0x17c): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
|
s376942239 | p03660 | C++ | #include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#include <fstream>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LLI long long int
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define POS(i) cout<<(i?"POSSIBLE":"IMPOSSIBLE")<<endl
#define Pos(i) cout<<(i?"Possible":"Impossible")<<endl
#define co(i) cout<<i<<endl
using namespace std;
//
const int INF=1e9+7;
const int MOD=1e9+7;
//
const int vmax=100001;
vector<PA> g[vmax];
LLI dist[vmax]={};
void dfs(int s,int t,LLI k){
dist[s]=k;
for(auto &i:g[s]){
if(i.FI==t) continue;
dfs(i.FI,s,k+i.SE);
}
}
void edge_in(int a,int b,LLI c){
g[a].PB(PA(b,c));
}
{int main(){
int n; cin>>n;
FOR(i,0,n-1){
int a,b; cin>>a>>b;
edge_in(a-1,b-1,1);
edge_in(b-1,a-1,1);
}
dfs(0,-1,0);
}
| a.cc:47:1: error: expected unqualified-id before '{' token
47 | {int main(){
| ^
|
s478861444 | p03660 | C++ | #include<queue>
#include<stack>
#include<map>
#include<set>
#include<cstdio>
#include<vector>
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
bool tr[100005][100005]={0};
int n,a,b;
int stepfen[100005]={0},stepsnu[100005]={0};
bool spot[1000005]={0};
int main(){
cin>>n;
for(int i=1;i<=n;i++){
cin>>a>>b;
tr[a][b]=1;
tr[b][a]=1;
}
stepfen[1]=0;
queue<int> q;
q.push(1);
int stepsfen=0;
while(!q.empty()){
int dot=q.front();
q.pop();
for(int i=1;i<=dot;i++){
if(tr[dot][i]==1){
if(stepfen[i]==0){
stepfen[i]=stepfen[dot]+1;
q.push(i);
if(i==n){
stepsfen=stepfen[i];
}
}
}
}
}
stepsnu[n]=0;
q.push(n);
int stepssnu=0;
while(!q.empty()){
int dot=q.front();
q.pop();
for(int i=1;i<=dot;i++){
if(tr[dot][i]==1){
if(stepsnu[i]==0){
stepsnu[i]=stepsnu[dot]+1;
q.push(i);
if(i==n){
stepssnu=stepsnu[i];
}
}
}
}
}
queue<int> q2;
q2.push(n);
while(!q2.empty()){
int dot=q2.front();
spot[dot]=1;
q2.pop();
for(int i=1;i<=dot;i++){
if(tr[dot][i]==1){
if(stepfen[i]==stepfen[dot]-1){
q2.push(i);
}
}
}
}
int fen=0,snu=0;
for(int i=1;i<=n;i++){
if(spot[i]){
if(stepfen[i]<=stepsnu[i]){
fen++;
}else{
snu++;
}
}else{
if(stepfen[i]>=stepsnu[i]){
fen++;
}else{
snu++;
}
}
}
if(fen>snu){
cout<<"Fennec";
}else{
cout<<"Snuke";
}
return 0;
} | /tmp/ccKOfnNr.o: in function `main':
a.cc:(.text+0xf): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccKOfnNr.o
a.cc:(.text+0x34): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccKOfnNr.o
a.cc:(.text+0x50): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccKOfnNr.o
a.cc:(.text+0x61): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccKOfnNr.o
a.cc:(.text+0x67): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccKOfnNr.o
a.cc:(.text+0x89): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccKOfnNr.o
a.cc:(.text+0x8f): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccKOfnNr.o
a.cc:(.text+0xb5): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccKOfnNr.o
a.cc:(.text+0xc4): relocation truncated to fit: R_X86_64_PC32 against symbol `stepfen' defined in .bss section in /tmp/ccKOfnNr.o
a.cc:(.text+0x17a): relocation truncated to fit: R_X86_64_PC32 against symbol `stepfen' defined in .bss section in /tmp/ccKOfnNr.o
a.cc:(.text+0x195): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
|
s059912296 | p03660 | C++ | #include<iostream>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<algorithm>
#include<memory>
using namespace std;
vector<int> con[100001];
int N;
int a[2][100001];
queue<int> q[2];
int main()
{
cin>>N;
for (int i=0;i<N-1;i++)
{
int x,y;
cin>>x>>y;
con[x].push_back(y);
con[y].push_back(x);
}
memset(a,-1,sizeof(a));
q[0].push(1);
a[0][1]=0;
q[1].push(N);
a[1][N]=0;
for (int i=0;i<2;i++)
{
while (q[i].size())
{
int c=q[i].front();
q[i].pop();
for (int i=0;i<con[c].size();i++)
{
if (a[i][con[c][i]]==-1)
a[i][con[c][i]]=a[i][c]+1,q[i].push(con[c][i]);
}
}
}
int k=0;
for (int i=1;i<=N;i++)
{
if (a[0][i]>=a[1][i]) k++;
}
if (k>N-k) cout<<"Fennec\n";
else cout<<"Snuke\n";
//system("pause");
return 0;
} | a.cc: In function 'int main()':
a.cc:24:3: error: 'memset' was not declared in this scope
24 | memset(a,-1,sizeof(a));
| ^~~~~~
a.cc:9:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
8 | #include<memory>
+++ |+#include <cstring>
9 | using namespace std;
|
s612923199 | p03660 | C++ | #include<iostream>
#include<vector>
#include<queue>
using namespace std;
vector<int> sons[100001];
queue<int> q;
int da[100001],db[100001];
bool v[100001];
int main(){
int n,a,b,x,u;
cin >> n;
for(int i=1;i<=n-1;i++){
cin >> a >> b;
sons[a].push_back(b);
sons[b].push_back(a);
}
a=1;
b=n;
memset(v,0,sizeof(v));
for(int i=1;i<=n;i++) da[i]=1e9;
da[a]=0; v[a]=1; q.push(a);
while(!q.empty()){
x=q.front();
for(int i=0;i<sons[x].size();i++){
u=sons[x][i];
if(!v[u]){
da[u]=da[x]+1;
v[u]=1;
q.push(u);
}}
q.pop();
}
memset(v, 0, sizeof(v));
for(int i=1;i<=n;i++) db[i]=1e9;
db[b]=0; v[b]=1; q.push(b);
while(!q.empty()){
x=q.front();
for(int i=0;i<sons[x].size();i++){
u=sons[x][i];
if(!v[u]){
db[u]=db[x]+1;
v[u]=1;
q.push(u);
}}
q.pop();
}
int snuke=0, fennec=0;
for(int i=1;i<=n;i++){
if(da[i]>db[i]) snuke++;
else if(da[i]<=db[i]) fennec++;
}
if(snuke>=fennec) cout << "Snuke" << endl;
else cout << "Fennec" << endl;
//system("pause");
return 0;
} | a.cc: In function 'int main()':
a.cc:19:1: error: 'memset' was not declared in this scope
19 | memset(v,0,sizeof(v));
| ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
3 | #include<queue>
+++ |+#include <cstring>
4 | using namespace std;
|
s603233103 | p03660 | C++ | #include<iostream>
#include<vector>
#include<queue>
using namespace std;
vector<int> sons[100001];
queue<int> q;
int da[100001],db[100001];
bool v[100001];
int main(){
int n,a,b,x,u;
cin >> n;
for(int i=1;i<=n-1;i++){
cin >> a >> b;
sons[a].push_back(b);
sons[b].push_back(a);
}
a=1;
b=n;
memset(v,0,sizeof(v));
for(int i=1;i<=n;i++) da[i]=1e9;
da[a]=0; v[a]=1; q.push(a);
while(!q.empty()){
x=q.front();
for(int i=0;i<sons[x].size();i++){
u=sons[x][i];
if(!v[u]){
da[u]=da[x]+1;
v[u]=1;
q.push(u);
}}
q.pop();
}
memset(v, 0, sizeof(v));
for(int i=1;i<=n;i++) db[i]=1e9;
db[b]=0; v[b]=1; q.push(b);
while(!q.empty()){
x=q.front();
for(int i=0;i<sons[x].size();i++){
u=sons[x][i];
if(!v[u]){
db[u]=db[x]+1;
v[u]=1;
q.push(u);
}}
q.pop();
}
int snuke=0, fennec=0;
for(int i=1;i<=n;i++){
if(da[i]>db[i]) snuke++;
else if(da[i]<=db[i]) fennec++;
}
if(snuke>=fennec) cout << "Snuke" << endl;
else cout << "Fennec" << endl;
system("pause");
return 0;
} | a.cc: In function 'int main()':
a.cc:19:1: error: 'memset' was not declared in this scope
19 | memset(v,0,sizeof(v));
| ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
3 | #include<queue>
+++ |+#include <cstring>
4 | using namespace std;
|
s018702405 | p03660 | C++ | using System;
namespace agc019_b
{
class Program
{
static void Main(string[] args)
{
string s = Console.ReadLine();
long ret = (long)s.Length * (s.Length - 1);
for (int i = 0; i < s.Length; i++)
{
for (int j = 0; j < s.Length; j++) if (s[i] == s[j]) ret--;
}
Console.WriteLine(ret + 1);
}
}
} | a.cc:1:7: error: expected nested-name-specifier before 'System'
1 | using System;
| ^~~~~~
a.cc:7:26: error: 'string' has not been declared
7 | static void Main(string[] args)
| ^~~~~~
a.cc:7:35: error: expected ',' or '...' before 'args'
7 | static void Main(string[] args)
| ^~~~
a.cc:17:6: error: expected ';' after class definition
17 | }
| ^
| ;
a.cc: In static member function 'static void agc019_b::Program::Main(int*)':
a.cc:9:13: error: 'string' was not declared in this scope
9 | string s = Console.ReadLine();
| ^~~~~~
a.cc:10:30: error: 's' was not declared in this scope
10 | long ret = (long)s.Length * (s.Length - 1);
| ^
a.cc:15:13: error: 'Console' was not declared in this scope
15 | Console.WriteLine(ret + 1);
| ^~~~~~~
|
s005784862 | p03660 | C++ | #include <iostream>
#include <ostream>
#include <istream>
#include <cmath>
#include <string>
#include <vector>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <vector>
#include <set>
#define pb push_back
#define ppb pop_back
using namespace std;
#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 forv(i, v) forn(i, v.size())
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
#define CIN_FILE "input.txt"
#define COUT_FILE "output.txt"
#define pi 3.1415926535897932
#define NMAX 100005
typedef pair<int, int> pii;
typedef long long ll;
typedef long double ld;
const int Mod=1e9+7;
const int INF=INT_MAX/2;
vector<int> bfs(int N,vector<vector<int> >& G,int s) {
vector<int> d(N,INF);
d[s]=0;
queue<int> q;
q.push(s);
while(q.size()) {
int u=q.front();
q.pop();
for(int v;v<G[u].size();v++) {
if(d[v]>d[u]+1) {
d[v]=d[u]+1;
q.push(v);
}
}
}
return d;
}
int main() {
int n;
cin>>n;
vector<vector<int> >G(n);
forn(i,n-1) {
int u,v;
scanf("%d%d",&u,&v);
u--;
v--;
G[u].push_back(v),G[v].push_back(u);
}
vector<int>d1=bfs(n,G,0);
vector<int>d2=bfs(n,G,n-1);
int n1=0,n2=0;
forn(u,n)if(d1[u]<=d2[u])n1++;
else n2++;
cout<<(n1>n2?"Snuke":"Fennec")<<endl;
return 0;
} | a.cc:35:15: error: 'INT_MAX' was not declared in this scope
35 | const int INF=INT_MAX/2;
| ^~~~~~~
a.cc:18:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
17 | #include <set>
+++ |+#include <climits>
18 | #define pb push_back
|
s310240235 | p03660 | C++ | #include<bits/stdc++.h>
using namespace std;
const int Mod=1e9+7;
const int INF=INT_MAX/2;
vector<int> bfs(int N,vector<vector<int>>& G,int s) {
vector<int> d(N,INF);
d[s]=0;
queue<int> q;
q.push(s);
while(q.size()) {
int u=q.front();
q.pop();
for(int v:G[u]) {
if(d[v]>d[u]+1) {
d[v]=d[u]+1;
q.push(v);
}
}
}
return d;
}
int main() {
int n;
cin>>n;
vector<vector<int>>G(n);
forn(i,n-1) {
int u,v;
scanf("%d%d",&u,&v);
u--;
v--;
G[u].push_back(v),G[v].push_back(u);
}
vector<int>d1=bfs(n,G,0);
vector<int>d2=bfs(n,G,n-1);
int n1=0,n2=0;
forn(u,n)if(d1[u]<=d2[u])n1++;
else n2++;
cout<<(n1>n2?"Fennec":"Snuke")<<endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:26:14: error: 'i' was not declared in this scope
26 | forn(i,n-1) {
| ^
a.cc:26:9: error: 'forn' was not declared in this scope; did you mean 'fork'?
26 | forn(i,n-1) {
| ^~~~
| fork
a.cc:36:14: error: 'u' was not declared in this scope
36 | forn(u,n)if(d1[u]<=d2[u])n1++;
| ^
a.cc:37:9: error: 'else' without a previous 'if'
37 | else n2++;
| ^~~~
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.