submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s711432672
p03805
Java
import java.util.Arrays; import java.util.Scanner; public class Main { private static int N = 0; private static int M = 0; private static int[][] abArray; private static Boolean[] flagArray; private static int count = 0; public static void main(String[] args) { try (Scanner sc = new Scanner(System.in)) { N = Integer.parseInt(sc.next()); M = Integer.parseInt(sc.next()); sc.nextLine(); abArray = new int[M][2]; flagArray = new Boolean[N]; for (int i = 0; i < N; i++) { abArray[i][0] = Integer.parseInt(sc.next()); abArray[i][1] = Integer.parseInt(sc.next()); sc.nextLine(); flagArray[i] = false; } exe(1); System.out.println(count); } } private static void exe(int now) { // nowは探索済み flagArray[now -1] = true; for (int i = 0; i < M; i++) { //toがnowでfrom値が探索済みでない if (abArray[i][0] == now && !flagArray[abArray[i][1] - 1]) { // fromへ飛ぶ exe(abArray[i][1]); //fromがnowでto値が探索済みでない } else if (abArray[i][1] == now && !flagArray[abArray[i][0] - 1]) { // toへ飛ぶ exe(abArray[i][0]); } } // 全て探索済みか? if(!Arrays.asList(flagArray).contains(false)) { count++; } // 探索済みでなくす flagArray[now -1] = false; } } }
Main.java:56: error: class, interface, enum, or record expected } ^ 1 error
s580929359
p03805
C++
#include <iostream> #include <vector> #include <set> #include <utility> #include <string> #include <algorithm> #include <cmath> typedef long long ll; #define INF 1e9 using namespace std; int nmax = 8; int graph[nmax][nmax]; int dfs(int v, int n, bool visited[nmax]){ bool all_visited = true; for (int i = 0; i < n; i++){ if(visited[i] == false) all_visited = false; } //辺を全部通ったら1を返す if(all_visited == true) return 1; int ret = 0;//回数 for (int i = 0; i < n; i++){ if(graph[v][i] == false) continue;//辺訪問済み if(visited[i]) continue; //点訪問済み visited[i] = true; ret += dfs(i, n, visited); visited[i] = false;//訪問前に再設定 } return ret; } int main() { int n, m; cin >> n >> m; for (int i = 0, i < m; i++){ int a, b; graph[a - 1][b - 1] = graph[b - 1][a - 1] = true; } bool visited[nmax]; for (int i = 0; i < n; i++){ visited[i] = false; } visited[0] = true; //出発点 cout << dfs(0, n, visited); return 0; }
a.cc:14:17: error: size of array 'graph' is not an integral constant-expression 14 | int graph[nmax][nmax]; | ^~~~ a.cc:14:11: error: size of array 'graph' is not an integral constant-expression 14 | int graph[nmax][nmax]; | ^~~~ a.cc:16:36: error: size of array 'visited' is not an integral constant-expression 16 | int dfs(int v, int n, bool visited[nmax]){ | ^~~~ a.cc: In function 'int main()': a.cc:44:22: error: expected ';' before '<' token 44 | for (int i = 0, i < m; i++){ | ^~ | ; a.cc:44:23: error: expected primary-expression before '<' token 44 | for (int i = 0, i < m; i++){ | ^
s371186324
p03805
C++
#include<iostream> #include<vector> using namespace std; bool graph[8][8]={}; int DFS (int v,int N,bool visited[8]/*訪れたノード*/){ //最後かどうか確認する bool all_visited=true; for(int i=0;i<N;++i){ if(visited[i]==false){ all_visited=false; } } //最後だったら if(all_visited){ return 1; } int ret=0; for(int i=0;i<N;++i){ //道がなければ無視 if(graph[v][i]==false)continue; //訪れたことがあればむし if(visited[i])continue; visited[i]=true; ret+=DFS(i,N,visited); visited[i]=false; } return res; } int main(){ int N,M; cin>>N>>M; for(int i=0;i<M;++i){ int A,B; cin>>A>>B; graph[A-1][B-1]=graph[B-1][A-1]=true; } bool visited[8]={}; visited[0]=true; cout<<DFS(0,N,visited)<<endl; return 0; }
a.cc: In function 'int DFS(int, int, bool*)': a.cc:34:12: error: 'res' was not declared in this scope; did you mean 'ret'? 34 | return res; | ^~~ | ret
s228623902
p03805
C++
#include<cstdio> #include<vector> #include<queue> using namespace std; int N,M; struct Edge { int to; bool visited; }; vector<Edge>V[10]; bool visited[10]; int ans; void dfs(int x,int count) { if(count==N-1) { ans++; return ; } visited[x]=true; for(int i=0;i<V[x].size();i++) { Edge e=V[x][i]; if(!e.visited&&!visited[e.to]) { V[x][i].visited=true; dfs(e.to,++count); visited[x]=false; return ; } } return ; } int main() { scanf("%d%d",&N,&M); int u,v; Edge edge; for(int i=0;i<M;i++) { scanf("%d%d",&u,&v); edge.visited=false; edge.to=v; V[u].push_back(edge); edge.to=u; V[v].push_back(edge); } ans=0; memset(visited,false,sizeof(visited)); for(int i=0;i<V[1].size();i++) { Edge e=V[1][i]; visited[1]=true; V[1][i].visited=true; dfs(e.to,1); visited[1]=false; } printf("%d\n",ans); return 0; }
a.cc: In function 'int main()': a.cc:50:5: error: 'memset' was not declared in this scope 50 | memset(visited,false,sizeof(visited)); | ^~~~~~ 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;
s739539419
p03805
C++
N,M = map(int,input().split()) T = {} for i in range(M): a,b = map(int,input().split()) if a not in T.keys(): T[a] = [] if b not in T.keys(): T[b] = [] T[a].append(b) T[b].append(a) ans = 0 def dfs(graph,start,path): global ans global N path = path + [start] if len(path) == N: ans += 1 for node in graph[start]: if node not in path: new = dfs(graph,node,path) return ans print(dfs(T,1,[]))
a.cc:1:1: error: 'N' does not name a type 1 | N,M = map(int,input().split()) | ^ a.cc:3:1: error: expected unqualified-id before 'for' 3 | for i in range(M): | ^~~
s006386915
p03805
C++
#include <stdio.h> #include <iostream> #include <vector> #include <algorithm> #define MAX_N 100 #define INF 100000 #define rep(i, n) for(int i=0; i<n; ++i) #define REP(i, s, t) for(int i=s; i<=s; ++i) using namespace std; const int nmax=8; bool graph[nmax][nmax]; int main(void) { cin.tie(0); ios::sync_with_stdio(false); int N, M; cin >> N >> M; rep(i, M) { int A, B; cin >> A >> B; graph[A-1][B-1]=graph[B-1][A-1]=true; } bool visited[nmax]; rep(i, N) visited[i]=false; visited[0]=true; cout << dfs(0, N, visited) << endl; return 0; } int dfs(int v, int N, bool visited[nmax]) { bool all_visited=true; // if all points are visited, add 1 to answer rep(i, N) { if(visited[i]==false) all_visited=false; } if(all_visited) return 1; int ret=0; rep(i, N) { // adjacent && not visited if(graph[v][i]==false) continue; if(visited[i]) continue; visited[i]=true; ret+=dfs(i, N, visited); visited[i]=false; } return ret; }
a.cc: In function 'int main()': a.cc:35:13: error: 'dfs' was not declared in this scope 35 | cout << dfs(0, N, visited) << endl; | ^~~
s227609063
p03805
C++
#include<iostream> #include<vector> using namespace std; vector used; vector connect; int N, M; int dfs(int now, int depth) { if (used[now]) return 0; if (depth == N) return 1; used[now] == 1; int ans =0: for (int i = 0; i < N; i++) { if (connect[now][i])ans += dfs(i, depth + 1); } used[now] = 0; return ans; } int main() { cin >> N >> M; vector a(M), b(M); for (int i = 0; i < M; i++) { cin >> a[i] >> b[i]; a[i]--; b[i]--; } used = vector(N, 0); connect = vector(N, vector(N, 0)); for (int i = 0; i < M; i++) { connect[a[i]][b[i]] = connect[b[i]][a[i]] = 1; } cout << dfs(0, 1) << endl; }
a.cc:5:8: error: class template argument deduction failed: 5 | vector used; | ^~~~ a.cc:5:8: error: no matching function for call to 'vector()' In file included from /usr/include/c++/14/vector:66, from a.cc:2: /usr/include/c++/14/bits/stl_vector.h:707:9: note: candidate: 'template<class _Tp, class _Alloc, class _InputIterator, class> vector(_InputIterator, _InputIterator, const _Alloc&)-> std::vector<_Tp, _Alloc>' 707 | vector(_InputIterator __first, _InputIterator __last, | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:707:9: note: candidate expects 2 arguments, 0 provided /usr/include/c++/14/bits/stl_vector.h:678:7: note: candidate: 'template<class _Tp, class _Alloc> vector(std::initializer_list<_Tp>, const _Alloc&)-> std::vector<_Tp, _Alloc>' 678 | vector(initializer_list<value_type> __l, | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:678:7: note: candidate expects 1 argument, 0 provided /usr/include/c++/14/bits/stl_vector.h:659:7: note: candidate: 'template<class _Tp, class _Alloc> vector(std::vector<_Tp, _Alloc>&&, std::__type_identity_t<_Alloc>&)-> std::vector<_Tp, _Alloc>' 659 | vector(vector&& __rv, const __type_identity_t<allocator_type>& __m) | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:659:7: note: candidate expects 2 arguments, 0 provided /usr/include/c++/14/bits/stl_vector.h:640:7: note: candidate: 'template<class _Tp, class _Alloc> vector(std::vector<_Tp, _Alloc>&&, const _Alloc&, std::false_type)-> std::vector<_Tp, _Alloc>' 640 | vector(vector&& __rv, const allocator_type& __m, false_type) | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:640:7: note: candidate expects 3 arguments, 0 provided /usr/include/c++/14/bits/stl_vector.h:635:7: note: candidate: 'template<class _Tp, class _Alloc> vector(std::vector<_Tp, _Alloc>&&, const _Alloc&, std::true_type)-> std::vector<_Tp, _Alloc>' 635 | vector(vector&& __rv, const allocator_type& __m, true_type) noexcept | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:635:7: note: candidate expects 3 arguments, 0 provided /usr/include/c++/14/bits/stl_vector.h:624:7: note: candidate: 'template<class _Tp, class _Alloc> vector(const std::vector<_Tp, _Alloc>&, std::__type_identity_t<_Alloc>&)-> std::vector<_Tp, _Alloc>' 624 | vector(const vector& __x, const __type_identity_t<allocator_type>& __a) | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:624:7: note: candidate expects 2 arguments, 0 provided /usr/include/c++/14/bits/stl_vector.h:620:7: note: candidate: 'template<class _Tp, class _Alloc> vector(std::vector<_Tp, _Alloc>&&)-> std::vector<_Tp, _Alloc>' 620 | vector(vector&&) noexcept = default; | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:620:7: note: candidate expects 1 argument, 0 provided /usr/include/c++/14/bits/stl_vector.h:601:7: note: candidate: 'template<class _Tp, class _Alloc> vector(const std::vector<_Tp, _Alloc>&)-> std::vector<_Tp, _Alloc>' 601 | vector(const vector& __x) | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:601:7: note: candidate expects 1 argument, 0 provided /usr/include/c++/14/bits/stl_vector.h:569:7: note: candidate: 'template<class _Tp, class _Alloc> vector(std::size_t, const _Tp&, const _Alloc&)-> std::vector<_Tp, _Alloc>' 569 | vector(size_type __n, const value_type& __value, | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:569:7: note: candidate expects 2 arguments, 0 provided /usr/include/c++/14/bits/stl_vector.h:556:7: note: candidate: 'template<class _Tp, class _Alloc> vector(std::size_t, const _Alloc&)-> std::vector<_Tp, _Alloc>' 556 | vector(size_type __n, const allocator_type& __a = allocator_type()) | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:556:7: note: candidate expects 1 argument, 0 provided /usr/include/c++/14/bits/stl_vector.h:542:7: note: candidate: 'template<class _Tp, class _Alloc> vector(const _Alloc&)-> std::vector<_Tp, _Alloc>' 542 | vector(const allocator_type& __a) _GLIBCXX_NOEXCEPT | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:542:7: note: candidate expects 1 argument, 0 provided /usr/include/c++/14/bits/stl_vector.h:531:7: note: candidate: 'template<class _Tp, class _Alloc> vector()-> std::vector<_Tp, _Alloc>' 531 | vector() = default; | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:531:7: note: template argument deduction/substitution failed: a.cc:5:8: note: couldn't deduce template parameter '_Tp' 5 | vector used; | ^~~~ /usr/include/c++/14/bits/stl_vector.h:428:11: note: candidate: 'template<class _Tp, class _Alloc> vector(std::vector<_Tp, _Alloc>)-> std::vector<_Tp, _Alloc>' 428 | class vector : protected _Vector_base<_Tp, _Alloc> | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:428:11: note: candidate expects 1 argument, 0 provided /usr/include/c++/14/bits/stl_vector.h:2033:5: note: candidate: 'template<class _InputIterator, class _ValT, class _Allocator, class, class> std::vector(_InputIterator, _InputIterator, _Allocator)-> vector<_ValT, _Allocator>' 2033 | vector(_InputIterator, _InputIterator, _Allocator = _Allocator()) | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:2033:5: note: candidate expects 2 arguments, 0 provided a.cc:6:8: error: class template argument deduction failed: 6 | vector connect; | ^~~~~~~ a.cc:6:8: error: no matching function for call to 'vector()' /usr/include/c++/14/bits/stl_vector.h:707:9: note: candidate: 'template<class _Tp, class _Alloc, class _InputIterator, class> vector(_InputIterator, _InputIterator, const _Alloc&)-> std::vector<_Tp, _Alloc>' 707 | vector(_InputIterator __first, _InputIterator __last, | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:707:9: note: candidate expects 2 arguments, 0 provided /usr/include/c++/14/bits/stl_vector.h:678:7: note: candidate: 'template<class _Tp, class _Alloc> vector(std::initializer_list<_Tp>, const _Alloc&)-> std::vector<_Tp, _Alloc>' 678 | vector(initializer_list<value_type> __l, | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:678:7: note: candidate expects 1 argument, 0 provided /usr/include/c++/14/bits/stl_vector.h:659:7: note: candidate: 'template<class _Tp, class _Alloc> vector(std::vector<_Tp, _Alloc>&&, std::__type_identity_t<_Alloc>&)-> std::vector<_Tp, _Alloc>' 659 | vector(vector&& __rv, const __type_identity_t<allocator_type>& __m) | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:659:7: note: candidate expects 2 arguments, 0 provided /usr/include/c++/14/bits/stl_vector.h:640:7: note: candidate: 'template<class _Tp, class _Alloc> vector(std::vector<_Tp, _Alloc>&&, const _Alloc&, std::false_type)-> std::vector<_Tp, _Alloc>' 640 | vector(vector&& __rv, const allocator_type& __m, false_type) | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:640:7: note: candidate expects 3 arguments, 0 provided /usr/include/c++/14/bits/stl_vector.h:635:7: note: candidate: 'template<class _Tp, class _Alloc> vector(std::vector<_Tp, _Alloc>&&, const _Alloc&, std::true_type)-> std::vector<_Tp, _Alloc>' 635 | vector(vector&& __rv, const allocator_type& __m, true_type) noexcept | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:635:7: note: candidate expects 3 arguments, 0 provided /usr/include/c++/14/bits/stl_vector.h:624:7: note: candidate: 'template<class _Tp, class _Alloc> vector(const std::vector<_Tp, _Alloc>&, std::__type_identity_t<_Alloc>&)-> std::vector<_Tp, _Alloc>' 624 | vector(const vector& __x, const __type_identity_t<allocator_type>& __a) | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:624:7: note: candidate expects 2 arguments, 0 provided /usr/include/c++/14/bits/stl_vector.h:620:7: note: candidate: 'template<class _Tp, class _Alloc> vector(std::vector<_Tp, _Alloc>&&)-> std::vector<_Tp, _Alloc>' 620 | vector(vector&&) noexcept = default; | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:620:7: note: candidate expects 1 argument, 0 provided /usr/include/c++/14/bits/stl_vector.h:601:7: note: candidate: 'template<class _Tp, class _Alloc> vector(const std::vector<_Tp, _Alloc>&)-> std::vector<_Tp, _Alloc>' 601 | vector(const vector& __x) | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:601:7: note: candidate expects 1 argument, 0 provided /usr/include/c++/14/bits/stl_vector.h:569:7: note: candidate: 'template<class _Tp, class _Alloc> vector(std::size_t, const _Tp&, const _Alloc&)-> std::vector<_Tp, _Alloc>' 569 | vector(size_type __n, const value_type& __value, | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:569:7: note: candidate expects 2 arguments, 0 provided /usr/include/c++/14/bits/stl_vector.h:556:7: note: candidate: 'template<class _Tp, class _Alloc> vector(std::size_t, const _Alloc&)-> std::vector<_Tp, _Alloc>' 556 | vector(size_type __n, const allocator_type& __a = allocator_type()) | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:556:7: note: candidate expects 1 argument, 0 provided /usr/include/c++/14/bits/stl_vector.h:542:7: note: candidate: 'template<class _Tp, class _Alloc> vector(const _Alloc&)-> std::vector<_Tp, _Alloc>' 542 | vector(const allocator_type& __a) _GLIBCXX_NOEXCEPT | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:542:7: note: candidate expects 1 argument, 0 provided /usr/include/c++/14/bits/stl_vector.h:531:7: note: candidate: 'template<class _Tp, class _Alloc> vector()-> std::vector<_Tp, _Alloc>' 531 | vector() = default; | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:531:7: note: template argument deduction/substitution failed: a.cc:6:8: note: couldn't deduce template parameter '_Tp' 6 | vector connect; | ^~~~~~~ /usr/include/c++/14/bits/stl_vector.h:428:11: note: candidate: 'template<class _Tp, class _Alloc> vector(std::vector<_Tp, _Alloc>)-> std::vector<_Tp, _Alloc>' 428 | class vector : protected _Vector_base<_Tp, _Alloc> | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:428:11: note: candida
s922394467
p03805
C++
#include<iostream> using namespace std; int nmax=8; bool graph[nmax][nmax]; int dfs(in v,int N,bool visited[nmax]){ bool all_visited=true; for(int i=;i<n;i++){ if(visited[i]==false)all_visited=false; } if(all_visited){ return 1; } int ret=0; for(int i=0;i<N;i++){ if(graph[v][i]==false)continue; if(visited[j])continue; visited[j]=true; ret+=dfs(i,N,visited); visited[j]=false; } return ret; } int main(){ int N,M; cin>>N>>M; for(int i=0;i<M;i++){ int a,b; cin>>a>>b; graph[a-1][b-1]=graph[b-1][a-1]=true; } bool visited[nmax]; for(int i=0;i<n;i;+){ visied[i]=false; } visied[0]=true; cout<<dfs(,N,visited)<<endl; return 0; }
a.cc:4:18: error: size of array 'graph' is not an integral constant-expression 4 | bool graph[nmax][nmax]; | ^~~~ a.cc:4:12: error: size of array 'graph' is not an integral constant-expression 4 | bool graph[nmax][nmax]; | ^~~~ a.cc:6:9: error: 'in' was not declared in this scope; did you mean 'int'? 6 | int dfs(in v,int N,bool visited[nmax]){ | ^~ | int a.cc:6:14: error: expected primary-expression before 'int' 6 | int dfs(in v,int N,bool visited[nmax]){ | ^~~ a.cc:6:20: error: expected primary-expression before 'bool' 6 | int dfs(in v,int N,bool visited[nmax]){ | ^~~~ a.cc:6:38: error: expression list treated as compound expression in initializer [-fpermissive] 6 | int dfs(in v,int N,bool visited[nmax]){ | ^ a.cc: In function 'int main()': a.cc:34:17: error: 'n' was not declared in this scope 34 | for(int i=0;i<n;i;+){ | ^ a.cc:34:20: error: expected ')' before ';' token 34 | for(int i=0;i<n;i;+){ | ~ ^ | ) a.cc:34:22: error: expected primary-expression before ')' token 34 | for(int i=0;i<n;i;+){ | ^ a.cc:37:3: error: 'visied' was not declared in this scope; did you mean 'visited'? 37 | visied[0]=true; | ^~~~~~ | visited a.cc:38:13: error: expected primary-expression before ',' token 38 | cout<<dfs(,N,visited)<<endl; | ^ a.cc:38:12: error: 'dfs' cannot be used as a function 38 | cout<<dfs(,N,visited)<<endl; | ~~~^~~~~~~~~~~~
s388519464
p03805
C++
#include <iostream> using namespace std; const int nmax=8; bool graph[nmax][nmax] int dfs(int v,int N, bool visited[nmax]) { bool all_visited=true; for (int i=0; i<N; ++i) { if (visited[i]==false) all_visited=false; } if (all_visited){ return 1; } int ret=0; for (int i=0; i<N; ++i) { if (graph[v][i]==false) continue; if (visited[i]) continue; visited[i]=true; ret+=dfs(i,N,visited); visited[i]=false; } return ret; } int main() { int N, M; for (int i = 0; i < M; i++) { int a, b; cin >> a >> b; graph[a-1][b-1] = graph[b-1][a-1] = true; } bool visited[nmax]; for (int i=0; i<N; ++i) { visited[i] = false; } visited[0] =true; cout << dfs(0, N, visited) << endl; return 0; }
a.cc:6:1: error: expected initializer before 'int' 6 | int dfs(int v,int N, bool visited[nmax]) { | ^~~ a.cc: In function 'int main()': a.cc:39:9: error: 'graph' was not declared in this scope; did you mean 'isgraph'? 39 | graph[a-1][b-1] = graph[b-1][a-1] = true; | ^~~~~ | isgraph a.cc:48:13: error: 'dfs' was not declared in this scope 48 | cout << dfs(0, N, visited) << endl; | ^~~
s653135050
p03805
C++
#include <iostream> #include <vector> using namespace std; int ans; bool visited[8]; bool all_visited; vector<int> G[8]; void dfs(int cur, int n) { visited[cur] = true; all_visited = true; for (int i = 0; i < n; i++) { if (!visited[i]) { all_visited = false; break; } } if (all_visited) { ans++; } for (auto e: G[cur]) { if (!visited[e]) { dfs(e); visited[e] = false; } } } int main() { int n, m; cin >> n >> m; for (int i = 0; i < m; i++) { int s, t; cin >> s >> t; s--; t--; G[s].push_back(t); G[t].push_back(s); } dfs(0, n); cout << ans << endl; return 0; }
a.cc: In function 'void dfs(int, int)': a.cc:23:16: error: too few arguments to function 'void dfs(int, int)' 23 | dfs(e); | ~~~^~~ a.cc:11:6: note: declared here 11 | void dfs(int cur, int n) { | ^~~
s998932502
p03805
C++
#include <iostream> #include <string> #include <vector> #include <utility> #include <functional> #include <numeric> #include <list> #include <set> #include <map> #include <cmath> #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; } int N,M,cnt; int adj[8][8]; bool visited[8]; void dfs(int node){ visited[node] = true; int passed = 0; for(int i=0; i<N; i++){ passed += visited[i]; } if(passed == N){ cnt+=1; } for(int i=0; i<N; i++){ if(adj[node][i]==1 && visited[i]==false){ dfs(i); visited[i] = false; } } } int main(){ memset(adj, 0, sizeof(adj)); memset(visited, 0, sizeof(visited)); cnt = 0; cin >> N >> M; for(int i=0; i<M; i++){ int a,b; cin >> a >> b; adj[a-1][b-1] = 1; adj[b-1][a-1] = 1; } dfs(0); cout << cnt << endl; }
a.cc: In function 'int main()': a.cc:72:9: error: 'memset' was not declared in this scope 72 | memset(adj, 0, sizeof(adj)); | ^~~~~~ a.cc:11:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 10 | #include <cmath> +++ |+#include <cstring> 11 |
s316164164
p03805
C++
#include<iostream> #include<algorithm> #include<vector> #include<string> #include<list> #include<cmath> #include<map> using namespace std; using ll = long long; const int INF = 1e9; #define rep(i,n)for(int i=0;i<n;++i) #define p pair<int,int> vector<int>used; vector<int>connect; int N, M; vector<int>G[10]; vector<int>used(8, 0); int ans = 0; int dfs(int now, int depth) { if (depth == 0) { bool c = true; for (int i = 0; i < N; ++i) { if (used[i] == 0) { c = false; } if (c)ans++; used[now]--; return 0; } } for (int i = 0; i < G[now].size(); ++i) { used[G[now][i]]++; dfs(G[now][i], depth - 1); } used[now]--; } int main() { cin >> N >> M; for (int i = 0; i < M; ++i) { int a, b; cin >> a >> b; a--; b--; G[a].push_back(b); G[b].push_back(a); } used[0]++; dfs(0,N-1); cout << ans << endl; return 0; }
a.cc:17:12: error: redefinition of 'std::vector<int> used' 17 | vector<int>used(8, 0); | ^~~~ a.cc:13:12: note: 'std::vector<int> used' previously declared here 13 | vector<int>used; | ^~~~ a.cc: In function 'int dfs(int, int)': a.cc:36:18: warning: control reaches end of non-void function [-Wreturn-type] 36 | used[now]--;
s078854846
p03805
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef struct { bool to[8]; } node; node _node[8]; int n,m; int ans = 0; void go(int now,int x[8],int cnt) { if (cnt == n) { ans++; return 0; } for(int i = 0;i < 8;i++) { if (x[_node[now].to[i]] = false) { int y[8]; for (int j = 0;j < 8;j++) { y[j] = x[j]; } y[_node[now].to[i]] = true; go(_node[now].to[i],y,cnt+1); } } return 0; } int main() { cin >> n >> m; for (int i = 0;i < 8;i++) { for (int j = 0;j < 8;j++) { _node[i].to[j] = false; } } for (int i = 0;i < m;i++) { int a,b; cin >> a >> b; _node[a-1].to[b-1] = true; } int start[8] = {false,false,false,false,false,false,false,false}; go(0,start,0); cout << ans << endl; }
a.cc: In function 'void go(int, int*, int)': a.cc:18:24: error: return-statement with a value, in function returning 'void' [-fpermissive] 18 | return 0; | ^ a.cc:30:16: error: return-statement with a value, in function returning 'void' [-fpermissive] 30 | return 0; | ^
s301455497
p03805
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef struct { bool to[8]; } node; _node[8]; int n,m; int ans = 0; void go(int now,int x[8],int cnt) { if (cnt == n) { ans++; return 0; } for(int i = 0;i < 8;i++) { if (x[_node[now].to[i]] = false) { int y[8]; for (int j = 0;j < 8;j++) { y[j] = x[j]; } y[_node[now].to[i]] = true; go(_node[now].to[i],y,cnt+1); } } return 0; } int main() { cin >> n >> m; for (int i = 0;i < 8;i++) { for (int j = 0;j < 8;j++) { _node[i].to[j] = false; } } for (int i = 0;i < m;i++) { int a,b; cin >> a >> b; _node[a-1].to[b-1] = true; } int start[8] = {false,false,false,false,false,false,false,false}; go(0,start,0); cout << ans << endl; }
a.cc:10:1: error: '_node' does not name a type; did you mean 'node'? 10 | _node[8]; | ^~~~~ | node a.cc: In function 'void go(int, int*, int)': a.cc:18:24: error: return-statement with a value, in function returning 'void' [-fpermissive] 18 | return 0; | ^ a.cc:21:23: error: '_node' was not declared in this scope; did you mean 'node'? 21 | if (x[_node[now].to[i]] = false) { | ^~~~~ | node a.cc:30:16: error: return-statement with a value, in function returning 'void' [-fpermissive] 30 | return 0; | ^ a.cc: In function 'int main()': a.cc:37:25: error: '_node' was not declared in this scope; did you mean 'node'? 37 | _node[i].to[j] = false; | ^~~~~ | node a.cc:43:17: error: '_node' was not declared in this scope; did you mean 'node'? 43 | _node[a-1].to[b-1] = true; | ^~~~~ | node
s578296346
p03805
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef struct { bool to[8]; } node; _node[8]; int n,m; int ans = 0; void go(int now,int x[8],int cnt) { if (cnt == n) { ans++; return 0; } for(int i = 0;i < 8;i++) { if (x[_node[now].to[i]] = false) { int y[8]; for (int j = 0;j < 8;j++) { y[j] = x[j]; } y[_node[now].to[i]] = true; go(_node[now].to[i],y,cnt+1); } } return 0; } int main() { cin >> n >> m; for (int i = 0;i < 8;i++) { for (int j = 0;j < 8;j++) { node[i].to[j] = false; } } for (int i = 0;i < m;i++) { int a,b; cin >> a >> b; node[a-1].to[b-1] = true; } int start[8] = {false,false,false,false,false,false,false,false}; go(0,start,0); cout << ans << endl; }
a.cc:10:1: error: '_node' does not name a type; did you mean 'node'? 10 | _node[8]; | ^~~~~ | node a.cc: In function 'void go(int, int*, int)': a.cc:18:24: error: return-statement with a value, in function returning 'void' [-fpermissive] 18 | return 0; | ^ a.cc:21:23: error: '_node' was not declared in this scope; did you mean 'node'? 21 | if (x[_node[now].to[i]] = false) { | ^~~~~ | node a.cc:30:16: error: return-statement with a value, in function returning 'void' [-fpermissive] 30 | return 0; | ^ a.cc: In function 'int main()': a.cc:37:29: error: structured binding declaration cannot have type 'node' 37 | node[i].to[j] = false; | ^~~ a.cc:37:29: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto' a.cc:37:32: error: expected initializer before '.' token 37 | node[i].to[j] = false; | ^ a.cc:37:32: error: expected ';' before '.' token a.cc:43:23: error: expected ']' before '-' token 43 | node[a-1].to[b-1] = true; | ^ | ] a.cc:43:21: error: structured binding declaration cannot have type 'node' 43 | node[a-1].to[b-1] = true; | ^ a.cc:43:21: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto' a.cc:43:22: error: conflicting declaration 'auto a' 43 | node[a-1].to[b-1] = true; | ^ a.cc:41:21: note: previous declaration as 'int a' 41 | int a,b; | ^ a.cc:43:26: error: expected initializer before '.' token 43 | node[a-1].to[b-1] = true; | ^
s532136325
p03805
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef struct { bool to[8]; } node; int n,m; int ans = 0; void go(int now,int x[8],int cnt) { if (cnt == n) { ans++; return 0; } for(int i = 0;i < 8;i++) { if (x[node[now].to[i]] = false) { int y[8]; for (int j = 0;j < 8;j++) { y[j] = x[j]; } y[node[now].to[i]] = true; go(node[now].to[i],y,cnt+1); } } return 0; } int main() { cin >> n >> m; node[8]; for (int i = 0;i < 8;i++) { for (int j = 0;j < 8;j++) { node[i].to[j] = false; } } for (int i = 0;i < m;i++) { int a,b; cin >> a >> b; node[a-1].to[b-1] = true; } int start[8] = {false,false,false,false,false,false,false,false}; go(0,start,0); cout << ans << endl; }
a.cc: In function 'void go(int, int*, int)': a.cc:16:24: error: return-statement with a value, in function returning 'void' [-fpermissive] 16 | return 0; | ^ a.cc:19:27: error: expected primary-expression before '[' token 19 | if (x[node[now].to[i]] = false) { | ^ a.cc:24:31: error: expected primary-expression before '[' token 24 | y[node[now].to[i]] = true; | ^ a.cc:25:32: error: expected primary-expression before '[' token 25 | go(node[now].to[i],y,cnt+1); | ^ a.cc:28:16: error: return-statement with a value, in function returning 'void' [-fpermissive] 28 | return 0; | ^ a.cc: In function 'int main()': a.cc:33:14: error: expected identifier before numeric constant 33 | node[8]; | ^ a.cc:33:14: error: expected ']' before numeric constant 33 | node[8]; | ^ | ] a.cc:33:13: error: structured binding declaration cannot have type 'node' 33 | node[8]; | ^ a.cc:33:13: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto' a.cc:33:13: error: empty structured binding declaration a.cc:33:16: error: expected initializer before ';' token 33 | node[8]; | ^ a.cc:36:29: error: structured binding declaration cannot have type 'node' 36 | node[i].to[j] = false; | ^~~ a.cc:36:29: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto' a.cc:36:32: error: expected initializer before '.' token 36 | node[i].to[j] = false; | ^ a.cc:36:32: error: expected ';' before '.' token a.cc:42:23: error: expected ']' before '-' token 42 | node[a-1].to[b-1] = true; | ^ | ] a.cc:42:21: error: structured binding declaration cannot have type 'node' 42 | node[a-1].to[b-1] = true; | ^ a.cc:42:21: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto' a.cc:42:22: error: conflicting declaration 'auto a' 42 | node[a-1].to[b-1] = true; | ^ a.cc:40:21: note: previous declaration as 'int a' 40 | int a,b; | ^ a.cc:42:26: error: expected initializer before '.' token 42 | node[a-1].to[b-1] = true; | ^
s873688447
p03805
C++
#!/usr/bin/env python from collections import deque import itertools as it import sys import math sys.setrecursionlimit(1000000) INF = 10 ** 18 MOD = 10 ** 9 + 7 N, M = map(int, raw_input().split()) edge = [[False] * N for i in range(N)] for i in range(M): a, b = map(int, raw_input().split()) a, b = a - 1, b - 1 edge[a][b] = True edge[b][a] = True def func(num, used): if not True in used: return 1 ret = 0 for i in range(N): if used[i] and edge[num][i]: used[i] = False ret += func(i, used) used[i] = True return ret print func(0, [False] + [True] * (N - 1))
a.cc:1:2: error: invalid preprocessing directive #! 1 | #!/usr/bin/env python | ^ a.cc:3:1: error: 'from' does not name a type 3 | from collections import deque | ^~~~
s693087684
p03805
C++
#include <iostream> #include <cstdio> #include <string> #include <algorithm> #include <vector> #include <climits> #include <sstream> using namespace std; const int nmax = 8; bool graph[nmax][nmax]; int dfs(int v, int N, bool visited[nmax]){ bool all_visit = true; for(int i = 0; i < N; i++){ if(visited[i] == false){ all_visited = false; } } if(all_visited){ return 1; } int ret = 0; for(int i = 0; i < N; i++){ if(graph[v][i] == false) continue; if(visited[i]) continue; visited[i] = true; ret += dfs(i, N, visited); visited[i] = false; } return ret; } int main(){ int N, M; cin >> N >> M; for(int i = 0; i < M; i++){ int A, B; cin >> A >> B; graph[A-1][B-1] = graph[B-1][A-1] = true; } bool visited[nmax]; for(int i = 0; i < N; i++){ visited[i] = false; } visited[0] = true; cout << dfs(0, N, visited) << endl; return 0; }
a.cc: In function 'int dfs(int, int, bool*)': a.cc:21:13: error: 'all_visited' was not declared in this scope; did you mean 'all_visit'? 21 | all_visited = false; | ^~~~~~~~~~~ | all_visit a.cc:25:8: error: 'all_visited' was not declared in this scope; did you mean 'all_visit'? 25 | if(all_visited){ | ^~~~~~~~~~~ | all_visit
s943983279
p03805
C++
//include //------------------------------------------ #include <vector> #include <list> #include <map> #include <set> #include <deque> #include <queue> #include <stack> #include <bitset> #include <algorithm> #include <functional> #include <numeric> #include <utility> #include <sstream> #include <iostream> #include <iomanip> #include <cstdio> #include <cmath> #include <cstdlib> #include <string> #include <cstring> #include <ctime> using namespace std; //conversion //------------------------------------------ inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; } template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); } //math //------------------------------------------- template<class T> inline T sqr(T x) { return x*x; } //typedef //------------------------------------------ typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<string> VS; typedef pair<int, int> PII; typedef long long LL; //container util //------------------------------------------ #define ALL(a) (a).begin(),(a).end() #define RALL(a) (a).rbegin(), (a).rend() #define PB push_back #define MP make_pair #define SZ(a) int((a).size()) #define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i) #define EXIST(s,e) ((s).find(e)!=(s).end()) #define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1) #define SORT(c) sort((c).begin(),(c).end()) //repetition //------------------------------------------ #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define rep(i,n) FOR(i,0,n) #define loop(n) FOR(i,0,n) #define rrep(i,a,b) for(int i=(a);i>=(b);--i) //constant //-------------------------------------------- const double EPS = 1e-10; const double PI = acos(-1.0); const int INF = (int)1000000007; const LL MOD = (LL)1000000007;//10^9+7 const LL INF2 = (LL)100000000000000000;//10^18 int n, m; int G[10][10]; int main() { cin >> n >> m; for (int i = 0; i < m; i++) { int a, b; cin >> a >> b; a--; b--; G[a][b] = G[b][a] = 1; } vector<int> v(n - 1); for (int i = 1; i < n; i++)v[i - 1] = i; sort(v.begin(), v.end()); int ans = 0; //必ず0からスタート。 do { int now = 0; for (int i = 0; i < v.size(); i++) { if (G[now][v[i]] == 0)break; //つながってたら。更新。 now = v[i]; if (i == v.size() - 1)ans++; } } while (next_permutation(v.begin(), v.end()))); cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:102:55: error: expected ';' before ')' token 102 | } while (next_permutation(v.begin(), v.end()))); | ^ | ; a.cc:102:55: error: expected primary-expression before ')' token
s437935105
p03805
C++
#include<iostream> #include<set> using namespace std; int res,start[56],end[56],n,m; int pass(int k,int in,set<int> a){ int num; if(k==n){ res++; return 0; } for(int i=0;i<n*2;i++){ if(start[i]==in&&a.count(end[i])==0){ a.insert(in); pass(k+1,end[i],a); } } return 0; } int main(){ cin>>n>>m; set<int> a; a.insert(1); for(int i=0;i<m;i++){ cin>>start[i*2]>>end[i*2]; start[i*2+1]=end[i*2]; end[i*2+1]=start[i*2]; } pass(1,1,a); cout<<res; return 0; }
a.cc: In function 'int pass(int, int, std::set<int>)': a.cc:12:42: error: reference to 'end' is ambiguous 12 | if(start[i]==in&&a.count(end[i])==0){ | ^~~ 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:1: /usr/include/c++/14/bits/range_access.h:116:37: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)' 116 | template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept; | ^~~ /usr/include/c++/14/bits/range_access.h:115:31: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)' 115 | template<typename _Tp> _Tp* end(valarray<_Tp>&) noexcept; | ^~~ /usr/include/c++/14/bits/range_access.h:106:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])' 106 | end(_Tp (&__arr)[_Nm]) noexcept | ^~~ /usr/include/c++/14/bits/range_access.h:85:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)' 85 | end(const _Container& __cont) -> decltype(__cont.end()) | ^~~ /usr/include/c++/14/bits/range_access.h:74:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)' 74 | end(_Container& __cont) -> decltype(__cont.end()) | ^~~ In file included from /usr/include/c++/14/bits/range_access.h:36: /usr/include/c++/14/initializer_list:99:5: note: 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)' 99 | end(initializer_list<_Tp> __ils) noexcept | ^~~ a.cc:4:19: note: 'int end [56]' 4 | int res,start[56],end[56],n,m; | ^~~ a.cc:14:34: error: reference to 'end' is ambiguous 14 | pass(k+1,end[i],a); | ^~~ /usr/include/c++/14/bits/range_access.h:116:37: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)' 116 | template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept; | ^~~ /usr/include/c++/14/bits/range_access.h:115:31: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)' 115 | template<typename _Tp> _Tp* end(valarray<_Tp>&) noexcept; | ^~~ /usr/include/c++/14/bits/range_access.h:106:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])' 106 | end(_Tp (&__arr)[_Nm]) noexcept | ^~~ /usr/include/c++/14/bits/range_access.h:85:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)' 85 | end(const _Container& __cont) -> decltype(__cont.end()) | ^~~ /usr/include/c++/14/bits/range_access.h:74:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)' 74 | end(_Container& __cont) -> decltype(__cont.end()) | ^~~ /usr/include/c++/14/initializer_list:99:5: note: 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)' 99 | end(initializer_list<_Tp> __ils) noexcept | ^~~ a.cc:4:19: note: 'int end [56]' 4 | int res,start[56],end[56],n,m; | ^~~ a.cc: In function 'int main()': a.cc:24:34: error: reference to 'end' is ambiguous 24 | cin>>start[i*2]>>end[i*2]; | ^~~ /usr/include/c++/14/bits/range_access.h:116:37: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)' 116 | template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept; | ^~~ /usr/include/c++/14/bits/range_access.h:115:31: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)' 115 | template<typename _Tp> _Tp* end(valarray<_Tp>&) noexcept; | ^~~ /usr/include/c++/14/bits/range_access.h:106:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])' 106 | end(_Tp (&__arr)[_Nm]) noexcept | ^~~ /usr/include/c++/14/bits/range_access.h:85:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)' 85 | end(const _Container& __cont) -> decltype(__cont.end()) | ^~~ /usr/include/c++/14/bits/range_access.h:74:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)' 74 | end(_Container& __cont) -> decltype(__cont.end()) | ^~~ /usr/include/c++/14/initializer_list:99:5: note: 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)' 99 | end(initializer_list<_Tp> __ils) noexcept | ^~~ a.cc:4:19: note: 'int end [56]' 4 | int res,start[56],end[56],n,m; | ^~~ a.cc:25:30: error: reference to 'end' is ambiguous 25 | start[i*2+1]=end[i*2]; | ^~~ /usr/include/c++/14/bits/range_access.h:116:37: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)' 116 | template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept; | ^~~ /usr/include/c++/14/bits/range_access.h:115:31: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)' 115 | template<typename _Tp> _Tp* end(valarray<_Tp>&) noexcept; | ^~~ /usr/include/c++/14/bits/range_access.h:106:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])' 106 | end(_Tp (&__arr)[_Nm]) noexcept | ^~~ /usr/include/c++/14/bits/range_access.h:85:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)' 85 | end(const _Container& __cont) -> decltype(__cont.end()) | ^~~ /usr/include/c++/14/bits/range_access.h:74:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)' 74 | end(_Container& __cont) -> decltype(__cont.end()) | ^~~ /usr/include/c++/14/initializer_list:99:5: note: 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)' 99 | end(initializer_list<_Tp> __ils) noexcept | ^~~ a.cc:4:19: note: 'int end [56]' 4 | int res,start[56],end[56],n,m; | ^~~ a.cc:26:17: error: reference to 'end' is ambiguous 26 | end[i*2+1]=start[i*2]; | ^~~ /usr/include/c++/14/bits/range_access.h:116:37: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)' 116 | template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept; | ^~~ /usr/include/c++/14/bits/range_access.h:115:31: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)' 115 | template<typename _Tp> _Tp* end(valarray<_Tp>&) noexcept; | ^~~ /usr/include/c++/14/bits/range_access.h:106:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])' 106 | end(_Tp (&__arr)[_Nm]) noexcept | ^~~ /usr/include/c++/14/bits/range_access.h:85:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)' 85 | end(const _Container& __cont) -> decltype(__cont.end()) | ^~~ /usr/include/c++/14/bits/range_access.h:74:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)' 74 | end(_Container& __cont) -> decltype(__cont.end()) | ^~~ /usr/include/c++/14/initializer_list:99:5: note: 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)' 99 | end(initializer_list<_Tp> __ils) noexcept | ^~~ a.cc:4:19: note: 'int end [56]' 4 | int res,start[56],end[56],n,m; | ^~~
s990147962
p03805
C++
#include<iostream> #include<set> using namespace std; int n,m; int start[8]; int end[8]; int result=0; /**判断是否所有点都遍历过,passPoint表示已经遍历过的点*/ bool allPassed(set<int> passPoint){ for(int i =1;i<=n;i++){ //从1到n,只要有一个在passPoint 里面不存在,说明没有都遍历过 if(passPoint.count(i)==0){ return 0; } } return 1; } void printSet(set<int> s){ set<int>::iterator iter = s.begin(); while (iter!=s.end()){ cout<<*iter<<"\t"; iter++; } cout<<endl; } /** 往前走一步,current表示当前节点 passPoint 表示已经遍历过的点 passEdge 表示已经遍历过的边 */ void goOneStep(int current,set<int> passPoint,set<int> passEdge){ /**每走一步,需要判断当前这个点有哪些下一步可以走 但是已经遍历过的点不能再走了 已经用过的边,不能再走了 往前走一步,把走过的点和边记录下来 如果判断所有的点走过,那么就可以返回,并且结果+1 如果没有边可以走,那么也返回,但是结果不+1 */ if(allPassed(passPoint)) { result ++; cout << "success!\n"; return ; } for(int i=0;i<m;i++){ int next; if(passEdge.count(i)>0){ //走过的边不能再走了 continue; } //如果开始节点和当前节点一致,那么下一步就是结束节点 //如果结束节点和当前节点一致,那么下一步就是开始节点 //如果都不一致,就和不在候选之列 if(start[i]==current ){ next=end[i]; }else if(end[i] == current){ next = start[i]; }else{ continue; } if(passPoint.count(next)>0){ //走过的点不能走 continue; } set<int> thisPassPoint = passPoint; thisPassPoint.insert(next); set<int> thisPassEdge = passEdge; thisPassEdge.insert(i); //cout<<"from:"<<current<<"to"<<next<<endl; /** cout<<"passPoint:"; printSet(thisPassPoint); cout<<"passEdge:"; printSet(thisPassEdge); */ goOneStep(next,thisPassPoint,thisPassEdge); } } int main(){ set<int> passPoint,passEdge; cin>>n>>m; for(int i=0;i<m;i++){ cin >> start[i] >> end[i]; } passPoint.insert(1); goOneStep(1,passPoint,passEdge); cout<<result; }
a.cc: In function 'void goOneStep(int, std::set<int>, std::set<int>)': a.cc:57:30: error: reference to 'end' is ambiguous 57 | next=end[i]; | ^~~ 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:1: /usr/include/c++/14/bits/range_access.h:116:37: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)' 116 | template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept; | ^~~ /usr/include/c++/14/bits/range_access.h:115:31: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)' 115 | template<typename _Tp> _Tp* end(valarray<_Tp>&) noexcept; | ^~~ /usr/include/c++/14/bits/range_access.h:106:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])' 106 | end(_Tp (&__arr)[_Nm]) noexcept | ^~~ /usr/include/c++/14/bits/range_access.h:85:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)' 85 | end(const _Container& __cont) -> decltype(__cont.end()) | ^~~ /usr/include/c++/14/bits/range_access.h:74:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)' 74 | end(_Container& __cont) -> decltype(__cont.end()) | ^~~ In file included from /usr/include/c++/14/bits/range_access.h:36: /usr/include/c++/14/initializer_list:99:5: note: 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)' 99 | end(initializer_list<_Tp> __ils) noexcept | ^~~ a.cc:6:5: note: 'int end [8]' 6 | int end[8]; | ^~~ a.cc:58:26: error: reference to 'end' is ambiguous 58 | }else if(end[i] == current){ | ^~~ /usr/include/c++/14/bits/range_access.h:116:37: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)' 116 | template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept; | ^~~ /usr/include/c++/14/bits/range_access.h:115:31: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)' 115 | template<typename _Tp> _Tp* end(valarray<_Tp>&) noexcept; | ^~~ /usr/include/c++/14/bits/range_access.h:106:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])' 106 | end(_Tp (&__arr)[_Nm]) noexcept | ^~~ /usr/include/c++/14/bits/range_access.h:85:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)' 85 | end(const _Container& __cont) -> decltype(__cont.end()) | ^~~ /usr/include/c++/14/bits/range_access.h:74:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)' 74 | end(_Container& __cont) -> decltype(__cont.end()) | ^~~ /usr/include/c++/14/initializer_list:99:5: note: 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)' 99 | end(initializer_list<_Tp> __ils) noexcept | ^~~ a.cc:6:5: note: 'int end [8]' 6 | int end[8]; | ^~~ a.cc: In function 'int main()': a.cc:89:36: error: reference to 'end' is ambiguous 89 | cin >> start[i] >> end[i]; | ^~~ /usr/include/c++/14/bits/range_access.h:116:37: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)' 116 | template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept; | ^~~ /usr/include/c++/14/bits/range_access.h:115:31: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)' 115 | template<typename _Tp> _Tp* end(valarray<_Tp>&) noexcept; | ^~~ /usr/include/c++/14/bits/range_access.h:106:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])' 106 | end(_Tp (&__arr)[_Nm]) noexcept | ^~~ /usr/include/c++/14/bits/range_access.h:85:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)' 85 | end(const _Container& __cont) -> decltype(__cont.end()) | ^~~ /usr/include/c++/14/bits/range_access.h:74:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)' 74 | end(_Container& __cont) -> decltype(__cont.end()) | ^~~ /usr/include/c++/14/initializer_list:99:5: note: 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)' 99 | end(initializer_list<_Tp> __ils) noexcept | ^~~ a.cc:6:5: note: 'int end [8]' 6 | int end[8]; | ^~~
s645123154
p03805
C++
#include<iostream> #include<set> using namespace std; int n,m; int start[8],end[8]; int result=0; /**判断是否所有点都遍历过,passPoint表示已经遍历过的点*/ bool allPassed(set<int> passPoint){ for(int i =1;i<=n;i++){ //从1到n,只要有一个在passPoint 里面不存在,说明没有都遍历过 if(passPoint.count(i)==0){ return 0; } } return 1; } void printSet(set<int> s){ set<int>::iterator iter = s.begin(); while (iter!=s.end()){ cout<<*iter<<"\t"; iter++; } cout<<endl; } /** 往前走一步,current表示当前节点 passPoint 表示已经遍历过的点 passEdge 表示已经遍历过的边 */ void goOneStep(int current,set<int> passPoint,set<int> passEdge){ /**每走一步,需要判断当前这个点有哪些下一步可以走 但是已经遍历过的点不能再走了 已经用过的边,不能再走了 往前走一步,把走过的点和边记录下来 如果判断所有的点走过,那么就可以返回,并且结果+1 如果没有边可以走,那么也返回,但是结果不+1 */ if(allPassed(passPoint)) { result ++; cout << "success!\n"; return ; } for(int i=0;i<m;i++){ int next; if(passEdge.count(i)>0){ //走过的边不能再走了 continue; } //如果开始节点和当前节点一致,那么下一步就是结束节点 //如果结束节点和当前节点一致,那么下一步就是开始节点 //如果都不一致,就和不在候选之列 if(start[i]==current ){ next=end[i]; }else if(end[i] == current){ next = start[i]; }else{ continue; } if(passPoint.count(next)>0){ //走过的点不能走 continue; } set<int> thisPassPoint = passPoint; thisPassPoint.insert(next); set<int> thisPassEdge = passEdge; thisPassEdge.insert(i); //cout<<"from:"<<current<<"to"<<next<<endl; /** cout<<"passPoint:"; printSet(thisPassPoint); cout<<"passEdge:"; printSet(thisPassEdge); */ goOneStep(next,thisPassPoint,thisPassEdge); } } int main(){ set<int> passPoint,passEdge; cin>>n>>m; for(int i=0;i<m;i++){ cin >> start[i] >> end[i]; } passPoint.insert(1); goOneStep(1,passPoint,passEdge); cout<<result; }
a.cc: In function 'void goOneStep(int, std::set<int>, std::set<int>)': a.cc:56:30: error: reference to 'end' is ambiguous 56 | next=end[i]; | ^~~ 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:1: /usr/include/c++/14/bits/range_access.h:116:37: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)' 116 | template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept; | ^~~ /usr/include/c++/14/bits/range_access.h:115:31: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)' 115 | template<typename _Tp> _Tp* end(valarray<_Tp>&) noexcept; | ^~~ /usr/include/c++/14/bits/range_access.h:106:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])' 106 | end(_Tp (&__arr)[_Nm]) noexcept | ^~~ /usr/include/c++/14/bits/range_access.h:85:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)' 85 | end(const _Container& __cont) -> decltype(__cont.end()) | ^~~ /usr/include/c++/14/bits/range_access.h:74:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)' 74 | end(_Container& __cont) -> decltype(__cont.end()) | ^~~ In file included from /usr/include/c++/14/bits/range_access.h:36: /usr/include/c++/14/initializer_list:99:5: note: 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)' 99 | end(initializer_list<_Tp> __ils) noexcept | ^~~ a.cc:5:14: note: 'int end [8]' 5 | int start[8],end[8]; | ^~~ a.cc:57:26: error: reference to 'end' is ambiguous 57 | }else if(end[i] == current){ | ^~~ /usr/include/c++/14/bits/range_access.h:116:37: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)' 116 | template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept; | ^~~ /usr/include/c++/14/bits/range_access.h:115:31: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)' 115 | template<typename _Tp> _Tp* end(valarray<_Tp>&) noexcept; | ^~~ /usr/include/c++/14/bits/range_access.h:106:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])' 106 | end(_Tp (&__arr)[_Nm]) noexcept | ^~~ /usr/include/c++/14/bits/range_access.h:85:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)' 85 | end(const _Container& __cont) -> decltype(__cont.end()) | ^~~ /usr/include/c++/14/bits/range_access.h:74:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)' 74 | end(_Container& __cont) -> decltype(__cont.end()) | ^~~ /usr/include/c++/14/initializer_list:99:5: note: 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)' 99 | end(initializer_list<_Tp> __ils) noexcept | ^~~ a.cc:5:14: note: 'int end [8]' 5 | int start[8],end[8]; | ^~~ a.cc: In function 'int main()': a.cc:88:36: error: reference to 'end' is ambiguous 88 | cin >> start[i] >> end[i]; | ^~~ /usr/include/c++/14/bits/range_access.h:116:37: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)' 116 | template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept; | ^~~ /usr/include/c++/14/bits/range_access.h:115:31: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)' 115 | template<typename _Tp> _Tp* end(valarray<_Tp>&) noexcept; | ^~~ /usr/include/c++/14/bits/range_access.h:106:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])' 106 | end(_Tp (&__arr)[_Nm]) noexcept | ^~~ /usr/include/c++/14/bits/range_access.h:85:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)' 85 | end(const _Container& __cont) -> decltype(__cont.end()) | ^~~ /usr/include/c++/14/bits/range_access.h:74:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)' 74 | end(_Container& __cont) -> decltype(__cont.end()) | ^~~ /usr/include/c++/14/initializer_list:99:5: note: 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)' 99 | end(initializer_list<_Tp> __ils) noexcept | ^~~ a.cc:5:14: note: 'int end [8]' 5 | int start[8],end[8]; | ^~~
s039989461
p03805
C++
#include<iostream> #include <algorithm> #include<string> #include <bitset> #include <vector> #include <functional> #include <climits> #include <iomanip> #include <utility> #include <stack> #include <queue> #include <math.h> #include <iomanip> using namespace std; using ll = long long; ll n, m; ll sum = 0; ll memo[50][50] = {}; void kansuu(ll num, ll visited[10]) { ll flag = 0; for (int i = 2; i <= n; i++) { if (visited[i]==0) { flag = 1; } } if (flag==0) { sum++; return; } ll x[10] = {}; for (ll i = 1; i <= n; i++) { if (memo[num][i]==1&&visited[i]==0) { memcpy(x, visited, sizeof(ll)*10); /*cout << "x=" ; for (ll z = 1; z <= n; z++) { cout << x[z]; } cout << endl; cout << "visited="; for (ll z = 1; z <= n; z++) { cout << visited[z]; } cout << endl; cout << endl; */ x[i]=1; kansuu(i, x); } } } int main() { ll a, b = 0, c = 0, d = 0; ll l; char C[1000][1000] = {}; ll h, w, sy, sx, gy, gx; queue<int> x, y; cin >> n; cin >> m; for (int i = 0; i < m; i++) { cin >> a; cin >> b; memo[a][b] = 1; memo[b][a] = 1; } ll zz[10] = {}; zz[1] = 1; kansuu(1,zz); cout << sum << endl; return 0; }
a.cc: In function 'void kansuu(ll, ll*)': a.cc:38:25: error: 'memcpy' was not declared in this scope 38 | memcpy(x, visited, sizeof(ll)*10); | ^~~~~~ a.cc:13:1: note: 'memcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 12 | #include <math.h> +++ |+#include <cstring> 13 | #include <iomanip>
s956870519
p03805
C++
#include<iostream> #include <algorithm> #include<string> #include <bitset> #include <vector> #include <functional> #include <climits> #include <iomanip> #include <utility> #include <stack> #include <queue> #include <math.h> #include <iomanip> using namespace std; using ll = long long; ll n, m; ll sum = 0; ll memo[50][50] = {}; void kansuu(ll num, ll visited[10]) { ll flag = 0; for (int i = 2; i <= n; i++) { if (visited[i]==0) { flag = 1; } } if (flag==0) { sum++; return; } ll x[10] = {}; for (ll i = 1; i <= n; i++) { if (memo[num][i]==1&&visited[i]==0) { memcpy(x, visited, sizeof(ll)*n); /*cout << "x=" ; for (ll z = 1; z <= n; z++) { cout << x[z]; } cout << endl; cout << "visited="; for (ll z = 1; z <= n; z++) { cout << visited[z]; } cout << endl; cout << endl; */ x[i]=1; kansuu(i, x); } } } int main() { ll a, b = 0, c = 0, d = 0; ll l; char C[1000][1000] = {}; ll h, w, sy, sx, gy, gx; queue<int> x, y; cin >> n; cin >> m; for (int i = 0; i < m; i++) { cin >> a; cin >> b; memo[a][b] = 1; memo[b][a] = 1; } ll zz[10] = {}; zz[1] = 1; kansuu(1,zz); cout << sum << endl; return 0; }
a.cc: In function 'void kansuu(ll, ll*)': a.cc:38:25: error: 'memcpy' was not declared in this scope 38 | memcpy(x, visited, sizeof(ll)*n); | ^~~~~~ a.cc:13:1: note: 'memcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 12 | #include <math.h> +++ |+#include <cstring> 13 | #include <iomanip>
s761879300
p03805
C++
#include<iostream> #include <algorithm> #include<string> #include <bitset> #include <vector> #include <functional> #include <climits> #include <iomanip> #include <utility> #include <stack> #include <queue> #include <math.h> #include <iomanip> using namespace std; using ll = long long; ll n, m; ll sum = 0; ll memo[50][50] = {}; void kansuu(ll num, ll visited[10]) { ll flag = 0; for (int i = 2; i <= n; i++) { if (visited[i]==0) { flag = 1; } } if (flag==0) { sum++; return; } ll x[10] = {}; for (ll i = 1; i <= n; i++) { if (memo[num][i]==1&&visited[i]==0) { memcpy(x, visited, 10*8); /*cout << "x=" ; for (ll z = 1; z <= n; z++) { cout << x[z]; } cout << endl; cout << "visited="; for (ll z = 1; z <= n; z++) { cout << visited[z]; } cout << endl; cout << endl; */ x[i]=1; kansuu(i, x); } } } int main() { ll a, b = 0, c = 0, d = 0; ll l; char C[1000][1000] = {}; ll h, w, sy, sx, gy, gx; queue<int> x, y; cin >> n; cin >> m; for (int i = 0; i < m; i++) { cin >> a; cin >> b; memo[a][b] = 1; memo[b][a] = 1; } ll zz[10] = {}; zz[1] = 1; kansuu(1,zz); cout << sum << endl; return 0; }
a.cc: In function 'void kansuu(ll, ll*)': a.cc:38:25: error: 'memcpy' was not declared in this scope 38 | memcpy(x, visited, 10*8); | ^~~~~~ a.cc:13:1: note: 'memcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 12 | #include <math.h> +++ |+#include <cstring> 13 | #include <iomanip>
s098869627
p03805
C++
#include<iostream> #include <algorithm> #include<string> #include <bitset> #include <vector> #include <functional> #include <climits> #include <iomanip> #include <utility> #include <stack> #include <queue> #include <math.h> #include <iomanip> using namespace std; using ll = long long; ll n, m; ll sum = 0; ll memo[50][50] = {}; void kansuu(ll num, ll visited[10]) { ll flag = 0; for (int i = 2; i <= n; i++) { if (visited[i]==0) { flag = 1; } } if (flag==0) { sum++; return; } ll x[10] = {}; for (ll i = 1; i <= n; i++) { if (memo[num][i]==1&&visited[i]==0) { memcpy(x, visited, n*8); /*cout << "x=" ; for (ll z = 1; z <= n; z++) { cout << x[z]; } cout << endl; cout << "visited="; for (ll z = 1; z <= n; z++) { cout << visited[z]; } cout << endl; cout << endl; */ x[i]=1; kansuu(i, x); } } } int main() { ll a, b = 0, c = 0, d = 0; ll l; char C[1000][1000] = {}; ll h, w, sy, sx, gy, gx; queue<int> x, y; cin >> n; cin >> m; for (int i = 0; i < m; i++) { cin >> a; cin >> b; memo[a][b] = 1; memo[b][a] = 1; } ll zz[10] = {}; zz[1] = 1; kansuu(1,zz); cout << sum << endl; return 0; }
a.cc: In function 'void kansuu(ll, ll*)': a.cc:38:25: error: 'memcpy' was not declared in this scope 38 | memcpy(x, visited, n*8); | ^~~~~~ a.cc:13:1: note: 'memcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 12 | #include <math.h> +++ |+#include <cstring> 13 | #include <iomanip>
s760861148
p03805
C++
import itertools na = lambda: list(map(int, input().split())) n, m = na() t = [[0] * 10 for _ in range(10)] for _ in range(m): a, b = na() a -= 1 b -= 1 t[a][b] = t[b][a] = 1 ans = 0 for l in itertools.permutations(range(m)): if l[0]: continue flag = 1 for i in range(1, n): if t[l[i]][l[i-1]] == 0: flag = 0 if flag: ans += 1 print(ans)
a.cc:1:1: error: 'import' does not name a type 1 | import itertools | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
s739257188
p03805
C++
#include <iostream> #include <vector> #include <queue> #include <cmath> #include <bitset> #define rep(i, N) for(int (i) = 0; (i) < (N); (i) ++) typedef long long ll; using namespace std; vector<vector<int>> dp; vector<vector<bool>> edges; ll memo(int a, int p, int end){ if(dp[a][p] != -1){ return dp[a][p]; } if(p == end){ return dp[a][p] = 1; } ll ans = 0; rep(i, edges.size()){ bitset<TMP> pb = (p); if(edges[a][i] && !(pb[i])){ pb.set(i); int p_n = pb.to_ulong(); ans += memo(i, p_n, end); } } return (dp[a][p] = ans); } int main(){ int N, M; cin >> N >> M; int size = (1 << (N)); dp = vector<vector<int>>(N, vector<int>(size, -1)); edges = vector<vector<bool>>(N, vector<bool>(N, false)); rep(i, M){ int a, b; cin >> a >> b; a --; b --; edges[a][b] = edges[b][a] = true; } ll ans = memo(0, 1, size - 1); cout << ans << endl; return 0; }
a.cc: In function 'll memo(int, int, int)': a.cc:22:16: error: 'TMP' was not declared in this scope 22 | bitset<TMP> pb = (p); | ^~~ a.cc:22:19: error: template argument 1 is invalid 22 | bitset<TMP> pb = (p); | ^ a.cc:23:31: error: invalid types 'int[int]' for array subscript 23 | if(edges[a][i] && !(pb[i])){ | ^ a.cc:24:16: error: request for member 'set' in 'pb', which is of non-class type 'int' 24 | pb.set(i); | ^~~ a.cc:25:26: error: request for member 'to_ulong' in 'pb', which is of non-class type 'int' 25 | int p_n = pb.to_ulong(); | ^~~~~~~~
s717663581
p03805
C++
#include <iostream> #include <vector> #include <queue> #include <cmath> #include <bitset> #define rep(i, N) for(int (i) = 0; (i) < (N); (i) ++) typedef long long ll; using namespace std; #define TMP 9 void print_dp(vector<vector<int>> dp){ int y = dp.size(); int x = dp[0].size(); cout << endl; rep(i, x){ cout.width(TMP - 1); cout << bitset<TMP - 1>(i) << " "; } cout << endl; rep(i, y){ rep(j, x){ cout.width(TMP - 1); cout << dp[i][j] << " "; } cout << endl; } } vector<vector<int>> dp; vector<vector<bool>> edges; ll memo(int a, int p, int end){ if(dp[a][p] != -1){ return dp[a][p]; } if(p == end){ return dp[a][p] = 1; } ll ans = 0; rep(i, edges.size()){ bitset<TMP> pb = (p); if(edges[a][i] && !(pb[i])){ pb.set(i); int p_n = pb.to_ulong(); ans += memo(i, p_n, end); } } return (dp[a][p] = ans); }
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start': (.text+0x17): undefined reference to `main' collect2: error: ld returned 1 exit status
s614880234
p03805
C++
#include<cstdio> #include<vector> using namespace std; vector<int> G[100] int dfs(int n, int mask, int now) { int res = 0; if(mask == (1<<n)-1) return 1; for(auto v : G[now]) { if(~mask & (1<<v)) res += dfs(n, mask | (1<<v), v); } return res; } int main(void) { int n,m; scanf("%d%d",&n,&m); for(int i=0; i<m; i++) { int a,b; scanf("%d%d",&a,&b); a--, b--; G[a].push_back(b); G[b].push_back(a); } printf("%d\n",dfs(n, 0, 0)); }
a.cc:7:1: error: expected initializer before 'int' 7 | int dfs(int n, int mask, int now) { | ^~~ a.cc: In function 'int main()': a.cc:24:5: error: 'G' was not declared in this scope 24 | G[a].push_back(b); | ^ a.cc:27:17: error: 'dfs' was not declared in this scope 27 | printf("%d\n",dfs(n, 0, 0)); | ^~~
s442489698
p03805
C++
#include <cstdio> using namespace std; const int nmax = 8; bool graph[nmax][nmax]; int n; int dfs(int v, bool visited[nmax]) { bool all_visited = true; for (int i = 0; i < n; i++) { if (visited[i] = false) all_visited = false; } if (all_visited) return 1; int ret = 0; for (int i = 0; i < n; i++) { if (graph[v][i] == false) continue; if (visited[i]) continue; visitet[i] = true; ret += dfs(i, n, visited); visited[i] = false; } return ret; } int main(void) { int m; scanf("%d%d", &n, &m); for (int i = 0; i < m; i++) { int A, B; scanf("%d%d", &A, &B); graph[A-1][B-1] = graph[B-1][A-1] = true; } bool visitetd[nmax]; for (int i = 0; i < n; i++) visitet[i] = false; visitet[0] = true; printf("%d\n", dfs(0, n, visited)); return 0; }
a.cc: In function 'int dfs(int, bool*)': a.cc:30:9: error: 'visitet' was not declared in this scope; did you mean 'visited'? 30 | visitet[i] = true; | ^~~~~~~ | visited a.cc:31:23: error: invalid conversion from 'int' to 'bool*' [-fpermissive] 31 | ret += dfs(i, n, visited); | ^ | | | int a.cc:31:19: error: too many arguments to function 'int dfs(int, bool*)' 31 | ret += dfs(i, n, visited); | ~~~^~~~~~~~~~~~~~~ a.cc:10:5: note: declared here 10 | int dfs(int v, bool visited[nmax]) | ^~~ a.cc: In function 'int main()': a.cc:51:9: error: 'visitet' was not declared in this scope; did you mean 'visitetd'? 51 | visitet[i] = false; | ^~~~~~~ | visitetd a.cc:53:5: error: 'visitet' was not declared in this scope; did you mean 'visitetd'? 53 | visitet[0] = true; | ^~~~~~~ | visitetd a.cc:54:30: error: 'visited' was not declared in this scope; did you mean 'visitetd'? 54 | printf("%d\n", dfs(0, n, visited)); | ^~~~~~~ | visitetd
s018047534
p03805
C++
#include<bits/stdc++.h> using namespace std; int temp[10][10] = {}, N, M; int foo(int n,int coun,int bb[]){//cout<<coun<<" "<<n<<endl; if(coun == N)return 1; int tee[10][10], ans =0, aa[10]={},C=0; for(int i = 1; i <= coun;i++){aa[bb[i]]=1; for(int i = 1; i <= N; i++){ if(aa[i]==1)continue; //tee[n][i]=1; bb[coun+1]=i; if(temp[n][i])ans += foo(i,coun+1,bb); //tee[n][i]=0; } return ans; } int main(){ int a, b, te[10][10]={}, bb[10] = {}; cin>>N>>M; te[1][1] = 1;bb[1]=1; for(int i = 0; i < M; i++){ cin>>a>>b; temp[a][b]=1; temp[b][a]=1; } cout<<foo(1,1,bb)<<endl; return 0; }
a.cc: In function 'int foo(int, int, int*)': a.cc:21:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse] 21 | int main(){ | ^~ a.cc:21:9: note: remove parentheses to default-initialize a variable 21 | int main(){ | ^~ | -- a.cc:21:9: note: or replace parentheses with braces to value-initialize a variable a.cc:21:11: error: a function-definition is not allowed here before '{' token 21 | int main(){ | ^ a.cc:34:2: error: expected '}' at end of input 34 | } | ^ a.cc:5:33: note: to match this '{' 5 | int foo(int n,int coun,int bb[]){//cout<<coun<<" "<<n<<endl; | ^ a.cc:34:2: warning: control reaches end of non-void function [-Wreturn-type] 34 | } | ^
s430257028
p03805
C++
#include <iostream> #include <vector> #include <algorithm> #include <string> int numlen( int n ) { std::string s = std::to_string( n ); return s.size(); } bool chk_permu( int n, int i ) { std::string ns = std::to_string( n ); std::sort( ns.begin(), ns.end() ); std::string is = std::to_string( i ); std::sort( is.begin(), is.end() ); return ( ns == is ); } int next_permu( int n ) { int len = numlen( n ); int nmax = std::pow( 10, len - 1 ) * 2; int p = 0; for( int i = n + 1; i < nmax; i++ ) { bool ispermu = chk_permu( n, i ); if( ispermu ) { p = i; break; } } return p; } bool isallconnected( int n, int m, int a[], int b[] ) { std::vector<int> nv; while( n > 0 ) { nv.insert( nv.begin(), n % 10 ); n = n / 10; } int branch = 0; for( int i = 0; i < nv.size() - 1; i++ ) { for( int j = 0; j < m; j++ ) { if( ( nv[ i ] == a[ j ] and nv[ i + 1 ] == b[ j ] ) or ( nv[ i ] == b[ j ] and nv[ i + 1 ] == a[ j ] ) ) { branch += 1; } } } return ( branch == m - 1 ? true : false ); } int main( void ) { int n, m; std::cin >> n >> m; const int dmax = 28; int a[ dmax ], b[ dmax ]; for( int i = 0; i < m; i++ ) { std::cin >> a[ i ] >> b[ i ]; } int np = 0; for( int i = 1; i <= n; i++ ) { np = np * 10 + i; } int cnt = 0; while( np > 0 ) { bool isall = isallconnected( np, m, a, b ); if( isall ) { cnt += 1; } np = next_permu( np ); } std::cout << cnt << std::endl; return 0; }
a.cc: In function 'int next_permu(int)': a.cc:23:25: error: 'pow' is not a member of 'std' 23 | int nmax = std::pow( 10, len - 1 ) * 2; | ^~~
s449151581
p03805
C++
#include <iostream> using namespace std; /* define const */ /* finish defineing const */ int n, m; long cnt = 0; int a[10] = {}; int b[10] = {}; string table[50000]; pair<int, int> p[10]; bool allt(bool *b) { bool f = true; for (int i = 1; i <= n; i++) { if (b[i] == false) { f = false; } } return f; } void solve(int a, bool *b) { bool tmp[10]; for (int i = 1; i <= n; i++) { tmp[i] = b[i]; } // コピー tmp[a] = true; if (allt(tmp)) { cnt++; return; } else { for (int i = 0; i < m; i++) { if (p[i].first == a) { if (tmp[p[i].second] == false) { // tmp[p[i].second] = true; solve(p[i].second, tmp); } else { continue; } } else if (p[i].second == a) { if (tmp[p[i].first] == false) { // tmp[p[i].first] = true; solve(p[i].first, tmp); } else { continue; } } } } } int main() { cin >> n >> m; for (int i = 0; i < m; i++) { cin >> a[i] >> b[i]; p[i] = make_pair(a[i], b[i]); } sort(p, p + n); bool b[10] = {false, true}; solve(1, b); cout << cnt << endl; }
a.cc: In function 'int main()': a.cc:83:5: error: 'sort' was not declared in this scope; did you mean 'short'? 83 | sort(p, p + n); | ^~~~ | short
s038112456
p03805
C++
#include <iostream> #include <algorithm> #include <cmath> #include <limits> #include <vector> #include <cstdio> #include <bits/stdc++.h> #include <set> #include <map> #include <stdio.h> using namespace std; using ll =int long long; map <int ,int> mpa,mpb; const int nmax= 8; bool graph[nmax][nmax]; int DFS(int v, int N, bool visited[nmax]){ bool all_visited=true; for(int i=0;i<N;i++){ if(visited[i]==false){ all_visited=false; } if(all_visited){ return 1; } int ret=0; for(int i=0;i<N;i++){ if(graph[v][i]==false) continue; if(visited[i]) continue; visited[i]=true; ret+=DFS(i,N,visited); visited[i]=false; } return ret; } int main(void){ int N,M; cin >> N >> M; for(int i=0;i<M;i++){ int A,B; cin >> A>> B; graph[A-1][B-1]=graph[B-1][A-1]=true; } bool visited[nmax]; for(int i=0;i<N;i++){ visited[i]=false; } visited[0]=true; cout << DFS(0,N,visited) << endl; return 0; }
a.cc: In function 'int DFS(int, int, bool*)': a.cc:44:15: error: a function-definition is not allowed here before '{' token 44 | int main(void){ | ^ a.cc:61:2: error: expected '}' at end of input 61 | } | ^ a.cc:18:42: note: to match this '{' 18 | int DFS(int v, int N, bool visited[nmax]){ | ^ a.cc:61:2: warning: control reaches end of non-void function [-Wreturn-type] 61 | } | ^
s187088001
p03805
C++
#include <iostream> #include <numeric> using namespace std; int adj[8][8]; int N, M; int answer; void search(int src, int visited[]) { // cout << "search(" << src << ", ["; // for (int i = 1; i <= N; i++) { // cout << visited[i] << ", "; // } // cout << "])" << endl; int newVisited[9]; if (accumulate(visited, visited + 9, 0) == N) { // cout << "finish!" << endl; answer++; } else { for (int dst = 1; dst <= N; dst++) { if (adj[src][dst] && !visited[dst]) { memcpy(newVisited, visited, sizeof(int) * 9); newVisited[dst] = 1; search(dst, newVisited); } } } } int main() { memset(adj, 0, sizeof(adj)); answer = 0; cin >> N >> M; for (int i = 0; i < M; i++) { int a, b; cin >> a >> b; adj[a][b] = 1; adj[b][a] = 1; } int visited[9] = {0, 1, 0, 0, 0, 0, 0, 0, 0}; search(1, visited); cout << answer << endl; }
a.cc: In function 'void search(int, int*)': a.cc:22:17: error: 'memcpy' was not declared in this scope 22 | memcpy(newVisited, visited, sizeof(int) * 9); | ^~~~~~ a.cc:3:1: note: 'memcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 2 | #include <numeric> +++ |+#include <cstring> 3 | using namespace std; a.cc: In function 'int main()': a.cc:31:5: error: 'memset' was not declared in this scope 31 | memset(adj, 0, sizeof(adj)); | ^~~~~~ a.cc:31:5: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
s877921589
p03805
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; int n, m; bool used[10]; vector<int> g[10]; int dfs(int s, int num) { if(num == n-1) { //cout << s << endl; return 1; } int ret = 0; for(int i=0;i<g[s].size();i++) { if(!used[g[s][i]]) { used[g[s][i]] = true; ret += dfs(g[s][i], num+1); used[g[s][i]] = false; } } return ret; } int main() { cin.tie(0); ios::sync_with_stdio(false); cin >> n >> m; vector<int> v(n); iota(v.begin(), v.end(), 0); for(int i=0;i<n;i++) { int ai, bi; cin >> ai >> bi; ai--;bi--; g[ai].push_back(bi); g[bi].push_back(ai); } ll ans = 0; memset(used, false, sizseof(used)); used[0] = true; ans += dfs(0, 0); /*do { } while(next_permutation(v.begin(), v.end()); */ cout << ans << endl; }
a.cc: In function 'int main()': a.cc:42:23: error: 'sizseof' was not declared in this scope 42 | memset(used, false, sizseof(used)); | ^~~~~~~
s684295800
p03805
C++
#include <bits/stdc++.h> using namespace std; int main() { int N,M,i,j; int ans=0; cin>>N>>M; vector<int>a(M),b(M),c(M),r(N); for(i=0;i<M;i++){ cin>>a[i]>>b[i]; c[i]=a[i]*b[i]*100+a[i]+b[i]; } for(i=0;i<N;i++)r[i]=i+1; if(r[0]!=1)continue; for(i=0;i<N-1;i++){ for(j=0;j<M;j++){ if(r[i]*r[i+1]*100+r[i]+r[i+1]==c[j])break; } if(j==M)break; } if(i==N-1)ans++; while(next_permutation(r.begin(),r.end())){ if(r[0]!=1)continue; for(i=0;i<N-1;i++){ for(j=0;j<M;j++){ if(r[i]*r[i+1]*100+r[i]+r[i+1]==c[j])break; } if(j==M)break; } if(i==N-1)ans++; } cout<<ans<<endl; }
a.cc: In function 'int main()': a.cc:14:14: error: continue statement not within a loop 14 | if(r[0]!=1)continue; | ^~~~~~~~
s746814423
p03805
Java
import java.util.Scanner; /* * AtCoder Beginner Contest 054 * 2017/02/11 * C - One-stroke Path * * https://beta.atcoder.jp/contests/abc054/tasks/abc054_c * */ public class OneStrokePath { static int[] a, b; static int N, M, ans; public static void main(String[] args) { Scanner sc = new Scanner(System.in); N = sc.nextInt(); M = sc.nextInt(); a = new int[M]; b = new int[M]; boolean[] flg = new boolean[N]; for (int i = 0; i < M; i++) { a[i] = sc.nextInt() - 1; b[i] = sc.nextInt() - 1; } int now = 0; flg[now] = true; dfs(now, flg); System.out.println(ans); } public static void dfs(int now, boolean[] flg) { for (int i = 0; i < M; i++) { if (a[i] == now && !flg[b[i]]) { flg[b[i]] = true; dfs(b[i], flg); flg[b[i]] = false; } if (b[i] == now && !flg[a[i]]) { flg[a[i]] = true; dfs(a[i], flg); flg[a[i]] = false; } } for ( int i = 0; i < N; i++) { if ( flg[i] == false) { return; } } ans++; return; } }
Main.java:10: error: class OneStrokePath is public, should be declared in a file named OneStrokePath.java public class OneStrokePath { ^ 1 error
s938444217
p03805
C++
#include <iostream> #include <list> using namespace std; const int nmax = 8; int N = nmax; bool graph[nmax][nmax]; int dsf(int v,bool visited[nmax]){ int i; for(i = 0;i < N;++i)if(!visited[i])break; if(i == N)return 1; int ret=0; for (i = 0; i < N; ++i) { if(visited[i])continue; visited[i]=true; ret+=dsf(i,visited); visited[i]=false; } return ret; } int main(){ int n,m,a,b; cin >> N >> m; for(int i = 0;i < m;i++){ cin >> a >> b; graph[a - 1][b - 1] = graph[b - 1][a - 1] = true; } bool visited[max]; visited[0] = true; cout << dsf(0,visited) << endl; }
a.cc: In function 'int main()': a.cc:31:25: error: cannot resolve overloaded function 'max' based on conversion to type 'long unsigned int' 31 | bool visited[max]; | ^ a.cc:31:14: error: size of array 'visited' has non-integral type '<unresolved overloaded function type>' 31 | bool visited[max]; | ^~~~~~~
s471947343
p03805
C++
#include <iostream> #include <list> using namespace std; const int nmax = 8; int N = nmax; bool graph[nmax][nmax]; int dsf(int v,bool visited[nmax]){ int i; for(i = 0;i < N;++i)if(!visited[i])break; if(i == N)return 1; int ret=0; for (i = 0; i < N; ++i) { if(visited[i])continue; visited[i]=true; ret+=dsf(i,visited); visited[i]=false; } return ret; } int main(){ int n,m,a,b; cin >> N >> m; for(i = 0;i < m;i++){ cin >> a >> b; graph[a - 1][b - 1] = graph[b - 1][a - 1] = true; } bool visited[max]; visited[0] = true; cout << dsf(0,visited) << endl; }
a.cc: In function 'int main()': a.cc:27:13: error: 'i' was not declared in this scope 27 | for(i = 0;i < m;i++){ | ^ a.cc:31:25: error: cannot resolve overloaded function 'max' based on conversion to type 'long unsigned int' 31 | bool visited[max]; | ^ a.cc:31:14: error: size of array 'visited' has non-integral type '<unresolved overloaded function type>' 31 | bool visited[max]; | ^~~~~~~
s664276428
p03805
C++
#include <iostream> #include <list> using namespace std; const int nmax = 8 int N = nmax; bool graph[nmax][nmax]; int dsf(int v,bool visited[nmax]){ int i; for(i = 0;i < N;++i)if(!visited[i])break; if(i == N)return 1; int ret=0; for (i = 0; i < N; ++i) { if(visited[i])continue; visited[i]=true; ret+=dsf(i,visited); visited[i]=false; } return ret; } int main(){ int n,m,a,b; cin >> N >> m; for(i = 0;i < m;i++){ cin >> a >> b; graph[a - 1][b - 1] = graph[b - 1][a - 1] = true; } bool visited[max]; visited[0] = true; cout << dsf(0,visited) << endl; }
a.cc:5:1: error: expected ',' or ';' before 'int' 5 | int N = nmax; | ^~~ a.cc: In function 'int dsf(int, bool*)': a.cc:10:23: error: 'N' was not declared in this scope 10 | for(i = 0;i < N;++i)if(!visited[i])break; | ^ a.cc:11:17: error: 'N' was not declared in this scope 11 | if(i == N)return 1; | ^ a.cc:13:25: error: 'N' was not declared in this scope 13 | for (i = 0; i < N; ++i) | ^ a.cc: In function 'int main()': a.cc:26:16: error: 'N' was not declared in this scope 26 | cin >> N >> m; | ^ a.cc:27:13: error: 'i' was not declared in this scope 27 | for(i = 0;i < m;i++){ | ^ a.cc:31:25: error: cannot resolve overloaded function 'max' based on conversion to type 'long unsigned int' 31 | bool visited[max]; | ^ a.cc:31:14: error: size of array 'visited' has non-integral type '<unresolved overloaded function type>' 31 | bool visited[max]; | ^~~~~~~
s872543860
p03805
C++
#include <iostream> #include <algorithm> #include <vector> #include <list> #include <string> #include <cstdlib> #include <stack> #include <queue> #include <set> #include <map> #include <cstring> #include <climits> using namespace std; typedef long long ll; typedef vector<int> ivec; typedef pair<int, int> ipair; int N, M; bool ab[10][10]; int main() { int a, b; cin >> N >> M; memset(ab, 0, sizeof ab); for (int i = 0; i < M; i++) { cin >> a >> b; ab[a-1][b-1] = true; ab[b-1][a-1] = true; } ivec p(N); p[0] = 0; iota(p.begin() + 1, p.end(), 1); int count = 0; do { count++; for (int i = 0; i < N - 1; i++) { a = p[i]; b = p[i+1]; if (!ab[a][b]) { count--; break; } } } while (next_permutation(p.begin()+ 1, p.end())); cout << count << endl; return 0; }
a.cc: In function 'int main()': a.cc:35:5: error: 'iota' was not declared in this scope 35 | iota(p.begin() + 1, p.end(), 1); | ^~~~
s708404618
p03805
C++
#include <bits/stdc++.h> using namespace std; int main(void) { int n, m, ans = 0; vector<int> g[8]; cin >> n >> m; for (int i = 0; i < n; i++) { int a, b; cin >> a >> b; a--, b--; g[a].push_back(b); g[b].push_back(a); } queue<pair<int, vector<bool>>> que; pair<int, vector<bool>> s; s.first = 0; s.second.resize(8, false); que.push(temp); while (!que.empty()) { auto p = que.front(); que.pop(); p.second[p.first] = true; bool flag = true; for (int i = 0; i < n; i++) { if (!p.second[i]) { flag = false; break; } } if (flag) { ans++; continue; } for (int i = 0; i < g[p.first].size(); i++) { if (!p.second[g[p.first][i]]) que.push({g[p.first][i], p.second}); } } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:19:14: error: 'temp' was not declared in this scope; did you mean 'tm'? 19 | que.push(temp); | ^~~~ | tm
s914489007
p03805
C++
int v=p.second; if(d[v]<p.first)continue; for(int i=0;i<(signed)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)); } } } } int main(){ cout<<boolalpha; cin>>N>>M; REP(i,M){ int a,b; cin>>a>>b; info[i]=P(a,b); } REP(Bit,1<<M){//111 REP(i,10){ G[i].clear(); } int cost=0; for(int i=M-1;0<=i;i--){ if (__builtin_popcount(Bit)!=N-1)continue; if(Bit&(1<<i)){ cost++; int a=info[i].first; int b=info[i].second; edge e; e.to=b-1,e.cost=1; G[a-1].push_back(e); e.to=a-1; G[b-1].push_back(e); } } Dijkstra(0); for(int i=1;i<N;i++){ if(d[i]==N-1)ans++; ARDEB(i,d)END } DEB("restwe4twtw3t")END DEB(G[0].empty())END } cout<<ans<<endl; return 0; } cin>>n>>m;
a.cc:1:23: error: 'p' was not declared in this scope 1 | int v=p.second; | ^ a.cc:2:17: error: expected unqualified-id before 'if' 2 | if(d[v]<p.first)continue; | ^~ a.cc:3:17: error: expected unqualified-id before 'for' 3 | for(int i=0;i<(signed)G[v].size();i++){ | ^~~ a.cc:3:29: error: 'i' does not name a type 3 | for(int i=0;i<(signed)G[v].size();i++){ | ^ a.cc:3:51: error: 'i' does not name a type 3 | for(int i=0;i<(signed)G[v].size();i++){ | ^ a.cc:10:9: error: expected declaration before '}' token 10 | } | ^ a.cc:11:1: error: expected declaration before '}' token 11 | } | ^ a.cc: In function 'int main()': a.cc:14:9: error: 'cout' was not declared in this scope 14 | cout<<boolalpha; | ^~~~ a.cc:14:15: error: 'boolalpha' was not declared in this scope 14 | cout<<boolalpha; | ^~~~~~~~~ a.cc:15:9: error: 'cin' was not declared in this scope 15 | cin>>N>>M; | ^~~ a.cc:15:14: error: 'N' was not declared in this scope 15 | cin>>N>>M; | ^ a.cc:15:17: error: 'M' was not declared in this scope 15 | cin>>N>>M; | ^ a.cc:16:13: error: 'i' was not declared in this scope 16 | REP(i,M){ | ^ a.cc:16:9: error: 'REP' was not declared in this scope 16 | REP(i,M){ | ^~~ a.cc:21:13: error: 'Bit' was not declared in this scope 21 | REP(Bit,1<<M){//111 | ^~~ a.cc:47:15: error: 'ans' was not declared in this scope 47 | cout<<ans<<endl; | ^~~ a.cc:47:20: error: 'endl' was not declared in this scope 47 | cout<<ans<<endl; | ^~~~ a.cc: At global scope: a.cc:51:5: error: 'cin' does not name a type 51 | cin>>n>>m; | ^~~
s966965426
p03805
C++
#include <iostream> #include <string> using namespace std; int main() { int N, M; cin >> N >> M; bool path[N][N]; memset(path,false,sizeof(path)); for (int i=0; i<M; i++) { int a, b; cin >> a >> b; a--; b--; path[a][b]=true; path[b][a]=true; } int vertex[N]; for (int i=0; i<N; i++) { vertex[i]=i; } int ans=0; do { if (vertex[0]!=0) { continue; } for (int i=0; i<N-1; i++) { if (!path[vertex[i]][vertex[i+1]]) { break; } if (i==N-2) { ans++; } } } while (next_permutation(vertex,vertex+N)); cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:9:3: error: 'memset' was not declared in this scope 9 | memset(path,false,sizeof(path)); | ^~~~~~ a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 1 | #include <iostream> +++ |+#include <cstring> 2 | #include <string> a.cc:35:12: error: 'next_permutation' was not declared in this scope 35 | } while (next_permutation(vertex,vertex+N)); | ^~~~~~~~~~~~~~~~
s307437923
p03805
C++
#include <iostream> using namespace std; int main() { int N, M; cin >> N >> M; bool path[N][N]; memset(path,false,sizeof(path)); for (int i=0; i<M; i++) { int a, b; cin >> a >> b; a--; b--; path[a][b]=true; path[b][a]=true; } int vertex[N]; for (int i=0; i<N; i++) { vertex[i]=i; } int ans=0; do { if (vertex[0]!=0) { continue; } for (int i=0; i<N-1; i++) { if (!path[vertex[i]][vertex[i+1]]) { break; } if (i==N-2) { ans++; } } } while (next_permutation(vertex,vertex+N)); cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:8:3: error: 'memset' was not declared in this scope 8 | memset(path,false,sizeof(path)); | ^~~~~~ a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 1 | #include <iostream> +++ |+#include <cstring> 2 | using namespace std; a.cc:34:12: error: 'next_permutation' was not declared in this scope 34 | } while (next_permutation(vertex,vertex+N)); | ^~~~~~~~~~~~~~~~
s217393137
p03805
C++
#include <algorithm> #include <cctype> #include <complex> #include <iomanip> #include <iostream> #include <queue> #include <set> #include <string> #include <vector> using std::cin; using std::cout; using std::endl; using std::string; using std::to_string; using std::vector; using std::set; using std::queue; using std::priority_queue; using std::min; using std::max; using std::sort; using std::abs; bool solve(int n, const vector<vector<bool>>& g, const vector<int>& p) { int me = 0; for (int i = 0; i < n - 1; i++) { if (!g[me][p[i]]) { return false; } me = p[i]; } return true; } int main(void) { int n, m; cin >> n >> m; vector<vector<bool>> g(n, vector<bool>(n)); for (int i = 0; i < m; i++) { int a, b; cin >> a >> b; g[a - 1][b - 1] = true; g[b - 1][a - 1] = true; } int cnt = 0; vector<int> p(n - 1); std::iota(p.begin(), p.end(), 1); do { if (solve(n, g, p)) { cnt++; } } while (std::next_permutation(p.begin(), p.end())); cout << cnt << endl; return 0; }
a.cc: In function 'int main()': a.cc:52:10: error: 'iota' is not a member of 'std' 52 | std::iota(p.begin(), p.end(), 1); | ^~~~
s304188754
p03805
C++
#include <algorithm> #include <cctype> #include <complex> #include <iomanip> #include <iostream> #include <queue> #include <set> #include <string> #include <vector> using std::cin; using std::cout; using std::endl; using std::string; using std::to_string; using std::vector; using std::set; using std::queue; using std::priority_queue; using std::min; using std::max; using std::sort; using std::abs; bool solve(int n, const vector<vector<bool>>& g, const vector<int>& p) { int me = 0; for (int i = 0; i < n - 1; i++) { if (!g[me][p[i]]) { return false; } me = p[i]; } return true; } int main(void) { int n, m; cin >> n >> m; vector<vector<bool>> g(n, vector<bool>(n)); for (int i = 0; i < m; i++) { int a, b; cin >> a >> b; g[a - 1][b - 1] = true; g[b - 1][a - 1] = true; } int cnt = 0; vector<int> p(n - 1); iota(p.begin(), p.end(), 1); do { if (solve(n, g, p)) { cnt++; } } while (std::next_permutation(p.begin(), p.end())); cout << cnt << endl; return 0; }
a.cc: In function 'int main()': a.cc:52:5: error: 'iota' was not declared in this scope 52 | iota(p.begin(), p.end(), 1); | ^~~~
s404207287
p03805
C++
#include <algorithm> #include <cctype> #include <complex> #include <iomanip> #include <iostream> #include <queue> #include <set> #include <string> #include <vector> using std::cin; using std::cout; using std::endl; using std::string; using std::to_string; using std::vector; using std::set; using std::queue; using std::priority_queue; using std::min; using std::max; using std::sort; using std::abs; bool solve(int n, const vector<vector<bool>>& g, const vector<int>& p) { int me = 0; for (int i = 0; i < n - 1; i++) { if (!g[me][p[i]]) { return false; } me = p[i]; } return true; } int main(void) { int n, m; cin >> n >> m; vector<vector<bool>> g(n, vector<bool>(n)); for (int i = 0; i < m; i++) { int a, b; cin >> a >> b; g[a - 1][b - 1] = true; g[b - 1][a - 1] = true; } int cnt = 0; vector<int> p(n - 1); iota(p.begin(), p.end(), 1); do { if (solve(n, g, p)) { cnt++; } } while (std::next_permutation(p.begin(), p.end())); cout << cnt << endl; return 0; }
a.cc: In function 'int main()': a.cc:52:5: error: 'iota' was not declared in this scope 52 | iota(p.begin(), p.end(), 1); | ^~~~
s584885653
p03805
C++
{-# LANGUAGE FlexibleContexts, OverloadedStrings #-} import Control.Applicative import Control.Monad import qualified Data.ByteString.Char8 as B import Data.Maybe (fromJust) import Data.List import Text.Printf import Debug.Trace istour g [_] = 1 istour g (x:y:ys) = if [x,y] `elem` g then istour g (y:ys) else 0 main = do [n,m] <- getInts es <- replicateM m $ getInts let g = es ++ map (\(x:y:_) -> [y,x]) es print $ sum $ map (istour g) $ map (1:) $ permutations [2..n] -- util getInts :: IO [Int] getInts = map (fst . fromJust . B.readInt) . B.words <$> B.getLine substr :: Int -> Int -> B.ByteString -> B.ByteString substr b l s = B.take l $ B.drop b s
a.cc:1:3: error: stray '#' in program 1 | {-# LANGUAGE FlexibleContexts, OverloadedStrings #-} | ^ a.cc:1:50: error: stray '#' in program 1 | {-# LANGUAGE FlexibleContexts, OverloadedStrings #-} | ^ a.cc:11:30: error: stray '`' in program 11 | istour g (x:y:ys) = if [x,y] `elem` g | ^ a.cc:11:35: error: stray '`' in program 11 | istour g (x:y:ys) = if [x,y] `elem` g | ^ a.cc:18:22: error: stray '\' in program 18 | let g = es ++ map (\(x:y:_) -> [y,x]) es | ^ a.cc:19:59: error: too many decimal points in number 19 | print $ sum $ map (istour g) $ map (1:) $ permutations [2..n] | ^~~~ a.cc:1:1: error: expected unqualified-id before '{' token 1 | {-# LANGUAGE FlexibleContexts, OverloadedStrings #-} | ^ a.cc:2:1: error: 'import' does not name a type 2 | import Control.Applicative | ^~~~~~ a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
s982593836
p03805
Java
import org.junit.Test; import java.util.HashSet; import java.util.Scanner; import java.util.Set; public class Main { static int n; static boolean[][] connected; static public int countPattern(int pos, Set<Integer> visited) { if (visited.size() == n) return 1; int count = 0; for (int i = 0; i < n; i++) { if (connected[pos][i] && !visited.contains(i)) { visited.add(i); count += countPattern(i, visited); visited.remove(i); } } return count; } static public void main(String[] args) { Scanner sc = new Scanner(System.in); n = sc.nextInt(); int m = sc.nextInt(); connected = new boolean[n][n]; for (int i = 0; i < m; i++) { int a = sc.nextInt() - 1; int b = sc.nextInt() - 1; connected[a][b] = true; connected[b][a] = true; } Set<Integer> visited = new HashSet<>(); visited.add(0); int count = countPattern(0, visited); System.out.println(count); } @Test public void test() { Main m = new Main(); } }
Main.java:1: error: package org.junit does not exist import org.junit.Test; ^ Main.java:45: error: cannot find symbol @Test ^ symbol: class Test location: class Main 2 errors
s573660793
p03805
Java
import org.junit.Test; import java.util.HashSet; import java.util.Scanner; import java.util.Set; public class Main { static int n; static boolean[][] connected; static public int countPattern(int pos, Set<Integer> visited) { if (visited.size() == n) return 1; int count = 0; for (int i = 0; i < n; i++) { if (connected[pos][i] && !visited.contains(i)) { visited.add(i); count += countPattern(i, visited); visited.remove(i); } } return count; } static public void main(String[] args) { Scanner sc = new Scanner(System.in); n = sc.nextInt(); int m = sc.nextInt(); connected = new boolean[n][n]; for (int i = 0; i < m; i++) { int a = sc.nextInt() - 1; int b = sc.nextInt() - 1; connected[a][b] = true; connected[b][a] = true; } Set<Integer> visited = new HashSet<>(); visited.add(0); int count = countPattern(0, visited); System.out.println(count); } @Test public void test() { Main m = new Main(); } }
Main.java:2: error: package org.junit does not exist import org.junit.Test; ^ Main.java:46: error: cannot find symbol @Test ^ symbol: class Test location: class Main 2 errors
s147908219
p03805
Java
package atcoder.beginnercontest.abc054.c; import org.junit.Test; import java.util.HashSet; import java.util.Scanner; import java.util.Set; public class Main { static int n; static boolean[][] connected; static public int countPattern(int pos, Set<Integer> visited) { if (visited.size() == n) return 1; int count = 0; for (int i = 0; i < n; i++) { if (connected[pos][i] && !visited.contains(i)) { visited.add(i); count += countPattern(i, visited); visited.remove(i); } } return count; } static public void main(String[] args) { Scanner sc = new Scanner(System.in); n = sc.nextInt(); int m = sc.nextInt(); connected = new boolean[n][n]; for (int i = 0; i < m; i++) { int a = sc.nextInt() - 1; int b = sc.nextInt() - 1; connected[a][b] = true; connected[b][a] = true; } Set<Integer> visited = new HashSet<>(); visited.add(0); int count = countPattern(0, visited); System.out.println(count); } @Test public void test() { Main m = new Main(); } }
Main.java:3: error: package org.junit does not exist import org.junit.Test; ^ Main.java:47: error: cannot find symbol @Test ^ symbol: class Test location: class Main 2 errors
s198097687
p03805
C++
#include<iostream> #include<string> #include<vector> #include<algorithm> using namespace std; struct node { vector<int> next; }; int calc(vector<node> &n, int index, vector<bool> &map) { map[index] = true; int result = 0; if (all_of(map.begin(), map.end(), [](auto &v) {return v; })) { result = 1; } for (auto&& v : n[index].next) { if (!map[v]) result += calc(n, v, map); } map[index] = false; return result; } int main() { int n, m; cin >> n >> m; vector<node> a(n); for (int i = 0; i < m; i++) { int x, y; cin >> x >> y; a[x - 1].next.push_back(y - 1); a[y - 1].next.push_back(x - 1); } vector<bool> map(n,false); cout << calc(a, 0, map) << endl; }
In file included from /usr/include/c++/14/bits/stl_algobase.h:71, 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/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_negate<_Predicate>::operator()(_Iterator) [with _Iterator = std::_Bit_iterator; _Predicate = calc(std::vector<node>&, int, std::vector<bool>&)::<lambda(auto:1&)>]': /usr/include/c++/14/bits/stl_algobase.h:2107:14: required from '_RandomAccessIterator std::__find_if(_RandomAccessIterator, _RandomAccessIterator, _Predicate, random_access_iterator_tag) [with _RandomAccessIterator = _Bit_iterator; _Predicate = __gnu_cxx::__ops::_Iter_negate<calc(std::vector<node>&, int, std::vector<bool>&)::<lambda(auto:1&)> >]' 2107 | if (__pred(__first)) | ~~~~~~^~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:112:28: required from '_InputIterator std::__find_if_not(_InputIterator, _InputIterator, _Predicate) [with _InputIterator = _Bit_iterator; _Predicate = __gnu_cxx::__ops::_Iter_pred<calc(std::vector<node>&, int, std::vector<bool>&)::<lambda(auto:1&)> >]' 112 | return std::__find_if(__first, __last, | ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ 113 | __gnu_cxx::__ops::__negate(__pred), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 114 | std::__iterator_category(__first)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:471:32: required from '_IIter std::find_if_not(_IIter, _IIter, _Predicate) [with _IIter = _Bit_iterator; _Predicate = calc(std::vector<node>&, int, std::vector<bool>&)::<lambda(auto:1&)>]' 471 | return std::__find_if_not(__first, __last, | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ 472 | __gnu_cxx::__ops::__pred_iter(__pred)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:411:40: required from 'bool std::all_of(_IIter, _IIter, _Predicate) [with _IIter = _Bit_iterator; _Predicate = calc(std::vector<node>&, int, std::vector<bool>&)::<lambda(auto:1&)>]' 411 | { return __last == std::find_if_not(__first, __last, __pred); } | ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:18:12: required from here 18 | if (all_of(map.begin(), map.end(), [](auto &v) {return v; })) | ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h:395:31: error: no match for call to '(calc(std::vector<node>&, int, std::vector<bool>&)::<lambda(auto:1&)>) (std::_Bit_iterator::reference)' 395 | { return !bool(_M_pred(*__it)); } | ~~~~~~~^~~~~~~ a.cc:18:44: note: candidate: 'calc(std::vector<node>&, int, std::vector<bool>&)::<lambda(auto:1&)> [with auto:1 = std::_Bit_reference]' (near match) 18 | if (all_of(map.begin(), map.end(), [](auto &v) {return v; })) | ^ a.cc:18:44: note: conversion of argument 1 would be ill-formed: /usr/include/c++/14/bits/predefined_ops.h:395:32: error: cannot bind non-const lvalue reference of type 'std::_Bit_reference&' to an rvalue of type 'std::_Bit_iterator::reference' 395 | { return !bool(_M_pred(*__it)); } | ^~~~~
s867364893
p03805
C++
#include<iostream> #include<string> #include<vector> #include<algorithm> using namespace std; struct node { vector<int> next; }; int calc(vector<node> &n, int index, vector<bool> &map) { map[index] = true; int result = 0; if (all_of(map.begin(), map.end(), [](auto &v) {return v; })) { result = 1; } for (auto&& v : n[index].next) { if (!map[v]) result += calc(n, v, map); } map[index] = false; return result; } int main() { int n, m; cin >> n >> m; vector<node> a(n); for (int i = 0; i < m; i++) { int x, y; cin >> x >> y; a[x - 1].next.push_back(y - 1); a[y - 1].next.push_back(x - 1); } vector<bool> map(n,false); cout << calc(a, 0, map) << endl; }
In file included from /usr/include/c++/14/bits/stl_algobase.h:71, 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/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_negate<_Predicate>::operator()(_Iterator) [with _Iterator = std::_Bit_iterator; _Predicate = calc(std::vector<node>&, int, std::vector<bool>&)::<lambda(auto:1&)>]': /usr/include/c++/14/bits/stl_algobase.h:2107:14: required from '_RandomAccessIterator std::__find_if(_RandomAccessIterator, _RandomAccessIterator, _Predicate, random_access_iterator_tag) [with _RandomAccessIterator = _Bit_iterator; _Predicate = __gnu_cxx::__ops::_Iter_negate<calc(std::vector<node>&, int, std::vector<bool>&)::<lambda(auto:1&)> >]' 2107 | if (__pred(__first)) | ~~~~~~^~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:112:28: required from '_InputIterator std::__find_if_not(_InputIterator, _InputIterator, _Predicate) [with _InputIterator = _Bit_iterator; _Predicate = __gnu_cxx::__ops::_Iter_pred<calc(std::vector<node>&, int, std::vector<bool>&)::<lambda(auto:1&)> >]' 112 | return std::__find_if(__first, __last, | ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ 113 | __gnu_cxx::__ops::__negate(__pred), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 114 | std::__iterator_category(__first)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:471:32: required from '_IIter std::find_if_not(_IIter, _IIter, _Predicate) [with _IIter = _Bit_iterator; _Predicate = calc(std::vector<node>&, int, std::vector<bool>&)::<lambda(auto:1&)>]' 471 | return std::__find_if_not(__first, __last, | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ 472 | __gnu_cxx::__ops::__pred_iter(__pred)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:411:40: required from 'bool std::all_of(_IIter, _IIter, _Predicate) [with _IIter = _Bit_iterator; _Predicate = calc(std::vector<node>&, int, std::vector<bool>&)::<lambda(auto:1&)>]' 411 | { return __last == std::find_if_not(__first, __last, __pred); } | ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:18:12: required from here 18 | if (all_of(map.begin(), map.end(), [](auto &v) {return v; })) | ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h:395:31: error: no match for call to '(calc(std::vector<node>&, int, std::vector<bool>&)::<lambda(auto:1&)>) (std::_Bit_iterator::reference)' 395 | { return !bool(_M_pred(*__it)); } | ~~~~~~~^~~~~~~ a.cc:18:44: note: candidate: 'calc(std::vector<node>&, int, std::vector<bool>&)::<lambda(auto:1&)> [with auto:1 = std::_Bit_reference]' (near match) 18 | if (all_of(map.begin(), map.end(), [](auto &v) {return v; })) | ^ a.cc:18:44: note: conversion of argument 1 would be ill-formed: /usr/include/c++/14/bits/predefined_ops.h:395:32: error: cannot bind non-const lvalue reference of type 'std::_Bit_reference&' to an rvalue of type 'std::_Bit_iterator::reference' 395 | { return !bool(_M_pred(*__it)); } | ^~~~~
s090507603
p03805
C++
#include <iostream> #include<sstream> #include<vector> #include<iterator> using namespace std; void wfs(int pos, int& cnt, vector<bool> hist, const vector<vector<bool>>& table) { hist[pos] = true; if(count(hist.begin(), hist.end(), false) == 0) { cnt++; return; } for(int i=1; i<table[pos].size(); i++) { if(table[pos][i] != true || hist[i] != false) continue; wfs(i, cnt, hist, table); } } int main(void) { int N, M; cin >> N >> M; vector<vector<bool>> table(N, vector<bool>(N, false)); for(int i=0; i<M; i++) { int a, b; cin >> a >> b; a--; b--; table[a][b] = true; table[b][a] = true; } int ret = 0; wfs(0, ret, vector<bool>(N, false), table); cout << ret << endl; return 0; }
a.cc: In function 'void wfs(int, int&, std::vector<bool>, const std::vector<std::vector<bool> >&)': a.cc:10:12: error: 'count' was not declared in this scope; did you mean 'cnt'? 10 | if(count(hist.begin(), hist.end(), false) == 0) | ^~~~~ | cnt
s744926484
p03805
C++
#include <bits/stdc++.h> #include "example.h" using namespace std; // Powered by caide (code generator, tester, and library code inliner) class Solution { int n, m; vector<int> edge[8]; public: int dfs(int now, int bits) { if (bits & 1 << now) return 0; bits |= 1 << now; if (bits + 1 == (1 << n)) return 1; int res = 0; for(auto&& i : edge[now]) { if (bits & 1 << i) { continue; } res += dfs(i, bits); } return res; } void solve(std::istream& in, std::ostream& out) { in >> n >> m; for(int i = 0; i < m; i++) { int a, b; in >> a >> b; edge[--a].push_back(--b); edge[b].push_back(a); } out << dfs(0, 0) << "\n"; for(int i = 0; i < n; i++) { edge[i].clear(); } } }; void solve(std::istream& in, std::ostream& out) { out << std::setprecision(12); Solution solution; solution.solve(in, out); }
a.cc:2:10: fatal error: example.h: No such file or directory 2 | #include "example.h" | ^~~~~~~~~~~ compilation terminated.
s219934753
p03805
C++
#include"bits/stdc++.h" //#include<bits/stdc++.h> using namespace std; #define rep(i,a,b) for(int i=a;i<b;i++) #define print(x) cout<<x<<endl; typedef long long ll; int n, m; int a[30], b[30]; bool exist = 0; int cnt = 0; bool check(bool flag[8]) { int c = 0; rep(i, 0, n) { if (flag[i] == 1)c += 1; } if (c == n)return 1; return 0; } bool is(int now, bool flag[8]) { int next[8] = { -1,-1,-1,-1,-1,-1,-1,-1, }; flag[now] = 1; if (check(flag))return 1; rep(i, 0, m) { if (a[i] == now)next[i] = b[i]; if (b[i] == now)next[i] = a[i]; } rep(i, 0, m) { if (next[i] != -1 && flag[next[i]] == 0) { exist = is(next[i], flag); } if (exist)cnt += 1; return 1; flag[next[i]] = 0; } return 0; }
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start': (.text+0x17): undefined reference to `main' collect2: error: ld returned 1 exit status
s969224485
p03805
Java
import java.io.*; import java.util.*; import java.math.BigInteger; public class java{ public static boolean[] visited; public static ArrayList<Integer>[] graph; public static final int MOD = (int) 1e9 + 7; public static void main(String[] args) { InputReader in = new InputReader(System.in); PrintWriter w = new PrintWriter(System.out); int n=in.nextInt(),m=in.nextInt(); visited=new boolean[n]; graph=new ArrayList[n]; for(int i=0;i<n;i++){ graph[i]=new ArrayList<>(); } while (m-->0){ int u=in.nextInt()-1; int v=in.nextInt()-1; graph[u].add(v); graph[v].add(u); } visited[0]=true; w.println(dfs(0)); w.close(); } static int dfs(int v){ if (allvisited()) return 1; else{ int r=0; for(Integer u:graph[v]){ if (!visited[u]){ visited[u]=true; r=r+dfs(u); visited[u]=false; } } return r; } } static boolean allvisited(){ for(int i=0;i<visited.length;i++){ if (!visited[i]) return false; } return true; } static class InputReader { private final InputStream stream; private final byte[] buf = new byte[8192]; private int curChar, snumChars; private SpaceCharFilter filter; public InputReader(InputStream stream) { this.stream = stream; } public int snext() { if (snumChars == -1) throw new InputMismatchException(); if (curChar >= snumChars) { curChar = 0; try { snumChars = stream.read(buf); } catch (IOException e) { throw new InputMismatchException(); } if (snumChars <= 0) return -1; } return buf[curChar++]; } public int nextInt() { int c = snext(); while (isSpaceChar(c)) { c = snext(); } int sgn = 1; if (c == '-') { sgn = -1; c = snext(); } int res = 0; do { if (c < '0' || c > '9') throw new InputMismatchException(); res *= 10; res += c - '0'; c = snext(); } while (!isSpaceChar(c)); return res * sgn; } public long nextLong() { int c = snext(); while (isSpaceChar(c)) { c = snext(); } int sgn = 1; if (c == '-') { sgn = -1; c = snext(); } long res = 0; do { if (c < '0' || c > '9') throw new InputMismatchException(); res *= 10; res += c - '0'; c = snext(); } while (!isSpaceChar(c)); return res * sgn; } public int[] nextIntArray(int n) { int a[] = new int[n]; for (int i = 0; i < n; i++) { a[i] = nextInt(); } return a; } public String readString() { int c = snext(); while (isSpaceChar(c)) { c = snext(); } StringBuilder res = new StringBuilder(); do { res.appendCodePoint(c); c = snext(); } while (!isSpaceChar(c)); return res.toString(); } public String nextLine() { int c = snext(); while (isSpaceChar(c)) c = snext(); StringBuilder res = new StringBuilder(); do { res.appendCodePoint(c); c = snext(); } while (!isEndOfLine(c)); return res.toString(); } public boolean isSpaceChar(int c) { if (filter != null) return filter.isSpaceChar(c); return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; } private boolean isEndOfLine(int c) { return c == '\n' || c == '\r' || c == -1; } public interface SpaceCharFilter { public boolean isSpaceChar(int ch); } } }
Main.java:4: error: class java is public, should be declared in a file named java.java public class java{ ^ Note: Main.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 1 error
s434172543
p03805
C++
#include <stdio.h> #include <string.h> #include <iostream> #include <algorithm> using namespace std; const int MAXN = 15; const int MAXCASE = 25; vector<int> m[MAXN]; int n, p; int sum; int vis[MAXN]; int judge[MAXN][MAXN]; void dfs(int cot,int num) { if(num == n) { sum++; return; } for(int i = 0;i < m[cot].size();i++) { if(vis[m[cot][i]] == 0) { vis[m[cot][i]] = 1; dfs(m[cot][i],num + 1); vis[m[cot][i]] = 0; } } } int main() { int Test, numCase = 0; //cin >> Test; while(cin >> n >> p) { assert(2 <= n && n <= 8); assert(1 <= p && p <= n * (n - 1) / 2); memset(judge, 0, sizeof(judge)); numCase++; for(int i=1;i<=p;i++) { int v,u; cin >> v >> u; m[v].push_back(u); m[u].push_back(v); assert(1 <= v && v <= n); assert(1 <= u && u <= n); assert(u != v && judge[u][v] == judge[v][u] && judge[u][v] == 0); judge[u][v] = judge[v][u] = 1; } sum = 0; vis[1] = 1; dfs(1, 1); cout << sum << endl; } assert(numCase == MAXCASE); return 0; }
a.cc:8:1: error: 'vector' does not name a type 8 | vector<int> m[MAXN]; | ^~~~~~ a.cc: In function 'void dfs(int, int)': a.cc:20:23: error: 'm' was not declared in this scope 20 | for(int i = 0;i < m[cot].size();i++) | ^ a.cc: In function 'int main()': a.cc:37:9: error: 'assert' was not declared in this scope 37 | assert(2 <= n && n <= 8); | ^~~~~~ a.cc:5:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>' 4 | #include <algorithm> +++ |+#include <cassert> 5 | using namespace std; a.cc:46:13: error: 'm' was not declared in this scope 46 | m[v].push_back(u); | ^ a.cc:60:5: error: 'assert' was not declared in this scope 60 | assert(numCase == MAXCASE); | ^~~~~~ a.cc:60:5: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>'
s764625509
p03805
C++
// 簡易競プロテンプレ #include <bits/stdc++.h> using namespace std; int n, m; int f[8][8]; int a,b; int main(void){ cin >> n >> m; for(int i=0;i<m;i++){cin >> a >> b; f[a-1][b-1] = f[b-1][a-1] = 1;} vector<int> p(n); for(int i=0;i<n;i++) p[i] = i; int ans = 0; do{ if (p[0]!=0) continue; int ok = 1; for(int i=0;i+1<n;i++){if (f[p[i]][p[i+1]]==0) ok = 0;} if (ok) ans++; }while(next_permutation(p.begin(), p.end()); cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:18:45: error: expected ')' before ';' token 18 | }while(next_permutation(p.begin(), p.end()); | ~ ^ | )
s727520748
p03805
C++
// 簡易競プロテンプレ #include <bits/stdc++.h> using namespace std; int n, m; int f[8][8]; int a,b; int main(void){ cin >> n >> m; for(int i=0;i<m;i++){cin >> a >> b; f[a-1][b-1] = f[b-1][a-1] = 1;} vector<int> p(n); for(int i=0;i<n;i++) p[i] = i; int ans = 0; do{ if (p[i]!=0) continue; int ok = 1; for(int i=0;i+1<n;i++){if (f[p[i]][p[i+1]]==0) ok = 0;} if (ok) ans++; }while(next_permutation(p.begin(), p.end()); cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:14:9: error: 'i' was not declared in this scope 14 | if (p[i]!=0) continue; | ^ a.cc:18:45: error: expected ')' before ';' token 18 | }while(next_permutation(p.begin(), p.end()); | ~ ^ | )
s678763732
p03805
C++
#include <iostream> #include <string> #include <vector> #include <queue> using namespace std; class Node { public: vector<int> visited; int count; int cur_pos; Node(int n_){ count = 0; visited = vector<int>(n_, 0); } }; class oneStrokePath { private: int n, m; vector<vector<int> > adj; public: oneStrokePath(){ cin >> n >> m; adj.resize(n); for (int i = 0; i < n; ++i) { adj[i].resize(n); for (int j = 0; j < n; ++j) { adj[i][j] = 0; } } for (int i = 0; i < m; ++i) { int tmp_a, tmp_b; cin >> tmp_a >> tmp_b; tmp_a--; tmp_b--; adj[tmp_a][tmp_b] = 1; adj[tmp_b][tmp_a] = 1; } } void execute(); }; void oneStrokePath::execute(){ queue<Node> q; Node start = Node(n); start.visited[0] = 1; start.count = 1; start.cur_pos = 0; q.push(start); int ans = 0; while(!q.empty()){ Node cur = q.front(); q.pop(); if(cur.count == n) ans++; for (int i = 0; i < n; ++i) { if(adj[cur_pos][i] == 1 && cur.visited[i] == 0){ Node next = cur; next.visited[i] = 1; next.count++; next.cur_pos = i; q.push(next); } } } cout << ans << endl; } int main(){ oneStrokePath osp = oneStrokePath(); osp.execute(); }
a.cc: In member function 'void oneStrokePath::execute()': a.cc:65:32: error: 'cur_pos' was not declared in this scope 65 | if(adj[cur_pos][i] == 1 && cur.visited[i] == 0){ | ^~~~~~~
s168804160
p03805
Java
import java.util.*; public class Main { static int count = 0; public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int M = sc.nextInt(); int[][] edge = new int[N][N]; for(int i = 0; i < M; i++) { int a = sc.nextInt(); int b = sc.nextInt(); edge[a - 1][b - 1] = 1; edge[b - 1][a - 1] = 1; } dfs(N, edge, 0, new ArrayList<Integer>()); System.out.println(count); } public static void dfs(int n, int[][] edge, int mask, ArrayList<Integer> list) { if(list.size() == n) { boolean flg = true; for(int i = 0; i < n - 1; i++) { if(edge[list.get(i)][list.get(i + 1)] == 0) { flg = false; break; } } if(flg) count++; } else { for(int j = 0; j < n; j++) { if(mask & (1 << j) == 0) { ArrayList<Integer> list2 = (ArrayList<Integer>)list.clone(); list2.add(j); dfs(n, edge, mask + (1 << j), list2); } } } } }
Main.java:33: error: bad operand types for binary operator '&' if(mask & (1 << j) == 0) { ^ first type: int second type: boolean Note: Main.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 1 error
s126874589
p03805
C++
#include<iostream> using namespace std; int main(void){ int N,Ma,Mb; cin>>N>>Ma>>Mb; //それぞれ物質Aの含有量,Bの含有量,値段の合計の最大値 const int amax=400; const int bmax=400; const int pmax=100000; //リストを作成してすべてを最大値に初期化 int list[N+1][amax+1][bmax+1]; for(int i=0;i<N+1;i++){ for(int a=0;a<amax+1;a++){ for(int b=0;b<bmax+1;b++){ list[i][a][b]=pmax; } } } //物質AもBもないのは何も買わず、コストも0 for(int i=0;i<=N;i++){ list[i][0][0]=0; } //動的計画法のメイン部分 int a,b,p; for(int i=1;i<=N;i++){ cin>>a>>b>>p; for(int anow=0;anow<=amax;anow++){ for(int bnow=0;bnow<=bmax;bnow++){ if(anow<a || bnow<b) list[i][anow][bnow]=list[i-1][anow][bnow]; else list[i][anow][bnow]=min(list[i-1][anow-a][bnow-b]+p,list[i-1][anow][bnow]) } } } int cost=pmax; for(a=1;a<=bmax;a++){ for(b=1;b<=bmax;b++){ if(a*Mb==b*Ma&&list[N][a][b]<cost) cost=list[N][a][b]; } } if(cost==pmax) cost=-1; cout<<cost<<endl; return 0; }
a.cc: In function 'int main()': a.cc:38:112: error: expected ';' before '}' token 38 | else list[i][anow][bnow]=min(list[i-1][anow-a][bnow-b]+p,list[i-1][anow][bnow]) | ^ | ; 39 | } | ~
s773632386
p03805
C++
#include<iostream> using namespace std; int main(void){ int N,Ma,Mb; cin>>N>>Ma>>Mb; //それぞれ物質Aの含有量,Bの含有量,値段の合計の最大値 const int amax=400; const int bmax=400; const int pmax=100000; //リストを作成してすべてを最大値に初期化 int list[N+1][amax+1][bmax+1]; for(int i=0;i<N+1;i++){ for(int a=0;a<amax+1;a++){ for(int b=0;b<bmax+1;b++){ list[i][a][b]=pmax; } } } //物質AもBもないのは何も買わず、コストも0 for(int i=0;i<=N;i++){ list[i][0][0]=0; } //動的計画法のメイン部分 int a,b,p; for(int i=1;i<=N;i++){ cin>>a>>b>>p; for(int anow=0;anow<=amax;anow++){ for(int bnow=0;bnow<=bmax;bnow++){ if(anow<a || bnow<b) list[i][anow][bnow]=list[i-1][anow][bnow]; else list[i][anow][bnow]=min(list[i-1][anow-a][bnow-b]+p,list[i-1][anow][bnow]) } } } for(int anow=a;anow<=amax;anow++){ for(int bnow=b;bnow<=bmax;bnow++){ cout<<list[i][anow][bnow]; } cout<<endl; } int cost=pmax; for(a=1;a<=bmax;a++){ for(b=1;b<=bmax;b++){ if(a*Mb==b*Ma&&list[N][a][b]<cost) cost=list[N][a][b]; } } if(cost==pmax) cost=-1; cout<<cost<<endl; return 0; }
a.cc: In function 'int main()': a.cc:38:112: error: expected ';' before '}' token 38 | else list[i][anow][bnow]=min(list[i-1][anow-a][bnow-b]+p,list[i-1][anow][bnow]) | ^ | ; 39 | } | ~ a.cc:47:44: error: 'i' was not declared in this scope 47 | cout<<list[i][anow][bnow]; | ^
s069963497
p03805
C++
#include <bits/stdc++.h> using namespace std; template <class ForwardIterator, class T> void iota (ForwardIterator first, ForwardIterator last, T val) { while (first!=last) { *first = val; ++first; ++val; } } int g[11][11]; int main() { int n,m,x,y,res=0; cin>>n>>m; vector<int> island(n); iota(island.island(),p.end(),0); for(int i=0;i<m;i++){ cin>>x>>y; g[x-1][y-1] = g[y-1][x-1] = 1; } do{ bool flag = true; if(island[0])break;//始点が0の時のみ考える for(int i=1;i<n;i++){ if(!g[island[i-1]][island[i]])flag=false;//つながってない } if(flag)res++; }while(next_permutation(island.begin(),island.end())); cout<<res<<endl; return 0; }
a.cc: In function 'int main()': a.cc:18:17: error: 'class std::vector<int>' has no member named 'island' 18 | iota(island.island(),p.end(),0); | ^~~~~~ a.cc:18:26: error: 'p' was not declared in this scope 18 | iota(island.island(),p.end(),0); | ^
s258835034
p03805
C++
#include <bits/stdc++.h> using namespace std; template <class ForwardIterator, class T> void iota (ForwardIterator first, ForwardIterator last, T val) { while (first!=last) { *first = val; ++first; ++val; } } int g[11][11]={0}; int main() { int n,m,x,y,res=0; cin>>n>>m; vector<int> island(n); iota(island.island(),p.end(),0); for(int i=0;i<m;i++){ cin>>x>>y; g[x-1][y-1] = g[y-1][x-1] = 1; } do{ bool flag = true; if(island[0])break;//始点が0の時のみ考える for(int i=1;i<n;i++){ if(!g[island[i-1]][island[i]])flag=false;//つながってない } if(flag)res++; }while(next_permutation(island.begin(),island.end())); cout<<res<<endl; return 0; }
a.cc: In function 'int main()': a.cc:18:17: error: 'class std::vector<int>' has no member named 'island' 18 | iota(island.island(),p.end(),0); | ^~~~~~ a.cc:18:26: error: 'p' was not declared in this scope 18 | iota(island.island(),p.end(),0); | ^
s881308598
p03805
C++
#include <bits/stdc++.h> using namespace std; template <class ForwardIterator, class T> void iota (ForwardIterator first, ForwardIterator last, T val) { while (first!=last) { *first = val; ++first; ++val; } } int g[11][11]; int main() { int n,m,x,y,res=0; cin>>n>>m; vector<int> p(n); iota(p.begin(),p.end(),0); for(int i=0;i<m;i++){ cin>>x>>y; g[x-1][y-1] = g[y-1][x-1] = 1; } do{ bool flag = true; if(p[0])break;//視点が1の時はbreak for(int i=1;i<n;i++){ if(!g[p[i-1]][p[i]])flag=false;//つながってない } if(flag)res++; }while(next_permutation(p.begin(),p.end())); cout<<res<<endl; return 0; }
a.cc: In function 'int main()': a.cc:18:9: error: call of overloaded 'iota(std::vector<int>::iterator, std::vector<int>::iterator, int)' is ambiguous 18 | iota(p.begin(),p.end(),0); | ~~~~^~~~~~~~~~~~~~~~~~~~~ a.cc:4:8: note: candidate: 'void iota(ForwardIterator, ForwardIterator, T) [with ForwardIterator = __gnu_cxx::__normal_iterator<int*, std::vector<int> >; T = int]' 4 | void iota (ForwardIterator first, ForwardIterator last, T val) | ^~~~ In file included from /usr/include/c++/14/numeric:62, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:58, from a.cc:1: /usr/include/c++/14/bits/stl_numeric.h:88:5: note: candidate: 'void std::iota(_ForwardIterator, _ForwardIterator, _Tp) [with _ForwardIterator = __gnu_cxx::__normal_iterator<int*, vector<int> >; _Tp = int]' 88 | iota(_ForwardIterator __first, _ForwardIterator __last, _Tp __value) | ^~~~
s943272167
p03805
C++
#include <iostream> #include <vector> int* E; int N, M; int eval(int ind,std::vector<int>& route) { if (route.size() == N) return 1; int ans = 0; for (int i = 0; i < N; i++) { std::vector<int> route_n = route; if (!E[ind*N + i]) continue; std::vector<int>::iterator iter = std::find(route.begin(), route.end(), i); if (iter != route.end()) continue; route_n.push_back(i); ans += eval(i, route_n); } return ans; } int main() { std::cin >> N >> M; E = new int[N*N]; std::fill(E, E + N*N, 0); for (int i = 0; i < M; i++) { int a, b; std::cin >> a >> b; E[(a-1)*N + b-1] = E[(b-1)*N + a-1] = 1; } std::vector<int> route; route.push_back(0); int ans = eval(0,route); std::cout << ans << std::endl; return 0; }
a.cc: In function 'int eval(int, std::vector<int>&)': a.cc:22:60: error: no matching function for call to 'find(std::vector<int>::iterator, std::vector<int>::iterator, int&)' 22 | std::vector<int>::iterator iter = std::find(route.begin(), route.end(), i); | ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/bits/locale_facets.h:48, from /usr/include/c++/14/bits/basic_ios.h:37, from /usr/include/c++/14/ios:46, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)' 435 | find(istreambuf_iterator<_CharT> __first, | ^~~~ /usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: template argument deduction/substitution failed: a.cc:22:60: note: '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'std::istreambuf_iterator<_CharT>' 22 | std::vector<int>::iterator iter = std::find(route.begin(), route.end(), i); | ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
s126064675
p03805
C++
#include <iostream> #include <vector> int* E; int N, M; int eval(int ind,const std::vector<int>& route) { if (route.size() == N) return 1; int ans = 0; for (int i = 0; i < N; i++) { std::vector<int> route_n = route; if (!E[ind*N + i]) continue; std::vector<int>::const_iterator iter = std::find(route.cbegin(), route.cend(), i); if (iter != route.cend()) continue; route_n.push_back(i); ans += eval(i, route_n); } return ans; } int main() { std::cin >> N >> M; E = new int[N*N]; std::fill(E, E + N*N, 0); for (int i = 0; i < M; i++) { int a, b; std::cin >> a >> b; E[(a-1)*N + b-1] = E[(b-1)*N + a-1] = 1; } std::vector<int> route; route.push_back(0); int ans = eval(0,route); std::cout << ans << std::endl; return 0; }
a.cc: In function 'int eval(int, const std::vector<int>&)': a.cc:22:66: error: no matching function for call to 'find(std::vector<int>::const_iterator, std::vector<int>::const_iterator, int&)' 22 | std::vector<int>::const_iterator iter = std::find(route.cbegin(), route.cend(), i); | ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/bits/locale_facets.h:48, from /usr/include/c++/14/bits/basic_ios.h:37, from /usr/include/c++/14/ios:46, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)' 435 | find(istreambuf_iterator<_CharT> __first, | ^~~~ /usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: template argument deduction/substitution failed: a.cc:22:66: note: '__gnu_cxx::__normal_iterator<const int*, std::vector<int> >' is not derived from 'std::istreambuf_iterator<_CharT>' 22 | std::vector<int>::const_iterator iter = std::find(route.cbegin(), route.cend(), i); | ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
s017799674
p03805
C++
#include <iostream> #include <vector> int* E; int N, M; int eval(int ind,const std::vector<int>& route) { if (route.size() == N) return 1; int ans = 0; for (int i = 0; i < N; i++) { std::vector<int> route_n = route; if (!E[ind*N + i]) continue; std::vector<int>::const_iterator iter = std::find(route.cbegin(), route.cend(), i); if (iter != route.end()) continue; route_n.push_back(i); ans += eval(i, route_n); } return ans; } int main() { std::cin >> N >> M; E = new int[N*N]; std::fill(E, E + N*N, 0); for (int i = 0; i < M; i++) { int a, b; std::cin >> a >> b; E[(a-1)*N + b-1] = E[(b-1)*N + a-1] = 1; } std::vector<int> route; route.push_back(0); int ans = eval(0,route); std::cout << ans << std::endl; return 0; }
a.cc: In function 'int eval(int, const std::vector<int>&)': a.cc:22:66: error: no matching function for call to 'find(std::vector<int>::const_iterator, std::vector<int>::const_iterator, int&)' 22 | std::vector<int>::const_iterator iter = std::find(route.cbegin(), route.cend(), i); | ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/bits/locale_facets.h:48, from /usr/include/c++/14/bits/basic_ios.h:37, from /usr/include/c++/14/ios:46, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)' 435 | find(istreambuf_iterator<_CharT> __first, | ^~~~ /usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: template argument deduction/substitution failed: a.cc:22:66: note: '__gnu_cxx::__normal_iterator<const int*, std::vector<int> >' is not derived from 'std::istreambuf_iterator<_CharT>' 22 | std::vector<int>::const_iterator iter = std::find(route.cbegin(), route.cend(), i); | ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
s312684883
p03805
C++
#include <iostream> #include <string> #include <vector> #include <queue> using namespace std; int main() { int N, M, a, b; cin >> N >> M; vector<vector<int>> arr(N); for (int i = 0; i < M; i++) { cin >> a >> b; arr[a - 1].push_back(b - 1); arr[b - 1].push_back(a - 1); } queue<vector<int>> roots; roots.push(vector<int>{ 0 }); int cnt = 0; while (!roots.empty()) { auto root = roots.front(); roots.pop(); for (int val : arr[root.back()]) { if (find(root.begin(), root.end(), val) == root.end()) { vector<int> newRoot(root); newRoot.push_back(val); if (newRoot.size() == N) cnt++; else roots.push(newRoot); } } } cout << cnt << endl; return 0; }
a.cc: In function 'int main()': a.cc:28:33: error: no matching function for call to 'find(std::vector<int>::iterator, std::vector<int>::iterator, int&)' 28 | if (find(root.begin(), root.end(), val) == root.end()) { | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/bits/locale_facets.h:48, from /usr/include/c++/14/bits/basic_ios.h:37, from /usr/include/c++/14/ios:46, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)' 435 | find(istreambuf_iterator<_CharT> __first, | ^~~~ /usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: template argument deduction/substitution failed: a.cc:28:33: note: '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'std::istreambuf_iterator<_CharT>' 28 | if (find(root.begin(), root.end(), val) == root.end()) { | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
s908983306
p03805
C++
#include <iostream> #include <string> #include <vector> #include <queue> using namespace std; int main() { int N, M, a, b; cin >> N >> M; vector<vector<int>> arr(N); for (int i = 0; i < M; i++) { cin >> a >> b; arr[a - 1].push_back(b - 1); arr[b - 1].push_back(a - 1); } queue<vector<int>> roots; roots.push(vector<int>{ 0 }); int cnt = 0; while (!roots.empty()) { auto root = roots.front(); roots.pop(); for each(int val in arr[root.back()]) { if (find(root.begin(), root.end(), val) == root.end()) { vector<int> newRoot(root); newRoot.push_back(val); if (newRoot.size() == N) cnt++; else roots.push(newRoot); } } } cout << cnt << endl; return 0; }
a.cc: In function 'int main()': a.cc:27:21: error: expected '(' before 'each' 27 | for each(int val in arr[root.back()]) { | ^~~~ | ( a.cc:27:26: error: expected primary-expression before 'int' 27 | for each(int val in arr[root.back()]) { | ^~~ a.cc:27:21: error: 'each' was not declared in this scope 27 | for each(int val in arr[root.back()]) { | ^~~~ a.cc:38:9: error: expected primary-expression before '}' token 38 | } | ^ a.cc:37:18: error: expected ';' before '}' token 37 | } | ^ | ; 38 | } | ~ a.cc:38:9: error: expected primary-expression before '}' token 38 | } | ^ a.cc:37:18: error: expected ')' before '}' token 37 | } | ^ | ) 38 | } | ~ a.cc:27:21: note: to match this '(' 27 | for each(int val in arr[root.back()]) { | ^~~~ a.cc:38:9: error: expected primary-expression before '}' token 38 | } | ^
s812089848
p03805
C
#include<cstdio> #include<cstring> int vis[10],map[10][10],n,m; int dfs(int x) { int i; for(i=1;i<=n;i++) if(vis[i]!=1) break; if(i==n+1) return 1; for(i=1;i<=n;i++) if(map[x][i]==1&&vis[i]==0) { vis[i]=1; dfs(i); vis[i]=0; } } int main() { int sum,i,j,x,y; while(scanf("%d%d",&n,&m)!=EOF) { memset(map,0,sizeof(map)); memset(vis,0,sizeof(vis)); for(i=1;i<=m;i++) { scanf("%d%d",&x,&y); map[x][y]=1; map[y][x]=1; } vis[1]=1; sum=0; for(i=2;i<=n;i++) { if(map[1][i]==1) { vis[i]=1; j=dfs(i); vis[i]=0; if(j!=0) sum=sum+1; } } printf("%d\n",sum); } return 0; }
main.c:1:9: fatal error: cstdio: No such file or directory 1 | #include<cstdio> | ^~~~~~~~ compilation terminated.
s712714760
p03805
C++
#include <iostream> using namespace std; const int max = 8; bool graph[max][max]; int dfs(int v, int N, bool visited[max]) { bool all_visited = true; for (int i = 0; i < N; ++i) { if (visited[i] == false) all_visited = false; } if (all_visited) { return 1; } int ret = 0; for (int i = 0; i < N; i++) { if (graph[v][i] == false) continue; if (visited[i]) continue; visited[i] = true; ret += dfs(i, N, visited); visited[i] = false; } return ret; } int main(void) { int N, M; cin >> N >> M; for (int i = 0; i < M; ++i) { int A, B; cin >> A >> B; graph[A - 1][B - 1] = graph[B - 1][A - 1] = true; } bool visited[max]; for (int i = 0; i < N; ++i) { visited[i] = false; } visited[0] = true; cout << dfs(0, N, visited) << endl; return 0; }
a.cc:4:12: error: reference to 'max' is ambiguous 4 | bool graph[max][max]; | ^~~ 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:303:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ a.cc:3:11: note: 'const int max' 3 | const int max = 8; | ^~~ a.cc:4:17: error: reference to 'max' is ambiguous 4 | bool graph[max][max]; | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ a.cc:3:11: note: 'const int max' 3 | const int max = 8; | ^~~ a.cc:6:36: error: reference to 'max' is ambiguous 6 | int dfs(int v, int N, bool visited[max]) { | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ a.cc:3:11: note: 'const int max' 3 | const int max = 8; | ^~~ a.cc: In function 'int dfs(...)': a.cc:10:29: error: 'N' was not declared in this scope 10 | for (int i = 0; i < N; ++i) { | ^ a.cc:11:21: error: 'visited' was not declared in this scope; did you mean 'all_visited'? 11 | if (visited[i] == false) | ^~~~~~~ | all_visited a.cc:21:29: error: 'N' was not declared in this scope 21 | for (int i = 0; i < N; i++) { | ^ a.cc:22:21: error: 'graph' was not declared in this scope; did you mean 'isgraph'? 22 | if (graph[v][i] == false) continue; | ^~~~~ | isgraph a.cc:22:27: error: 'v' was not declared in this scope 22 | if (graph[v][i] == false) continue; | ^ a.cc:23:21: error: 'visited' was not declared in this scope; did you mean 'all_visited'? 23 | if (visited[i]) continue; | ^~~~~~~ | all_visited a.cc:25:17: error: 'visited' was not declared in this scope; did you mean 'all_visited'? 25 | visited[i] = true; | ^~~~~~~ | all_visited a.cc: In function 'int main()': a.cc:39:17: error: 'graph' was not declared in this scope; did you mean 'isgraph'? 39 | graph[A - 1][B - 1] = graph[B - 1][A - 1] = true; | ^~~~~ | isgraph a.cc:43:22: error: reference to 'max' is ambiguous 43 | bool visited[max]; | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ a.cc:3:11: note: 'const int max' 3 | const int max = 8; | ^~~ a.cc:46:17: error: 'visited' was not declared in this scope 46 | visited[i] = false; | ^~~~~~~ a.cc:49:9: error: 'visited' was not declared in this scope 49 | visited[0] = true; | ^~~~~~~
s207260679
p03805
C++
#include <iostream> using namespace std; const int max = 8; bool graph[max][max]; int dfs(int v, int N, bool visited[max]) { bool all_visited = true; for (int i = 0; i < N; ++i) { if (visited[i] == false) all_visited = false; } if (all_visited) { return 1; } int ret = 0; for (int i = 0; i < N; i++) { if (graph[v][i] == false) continue; if (visited[i]) continue; visited[i] = true; ret += dfs(i, N, visited); visited[i] = false; } return ret; } int main(void) { int N, M; cin >> N >> M; for (int i = 0; i < M; ++i) { int A, B; cin >> A >> B; graph[A - 1][B - 1] = graph[B - 1][A - 1] = true; } bool visited[max]; for (int i = 0; i < N; ++i) { visited[i] = false; } visited[0] = true; cout << dfs(0, N, visited) << endl; return 0; }
a.cc:4:12: error: reference to 'max' is ambiguous 4 | bool graph[max][max]; | ^~~ 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:303:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ a.cc:3:11: note: 'const int max' 3 | const int max = 8; | ^~~ a.cc:4:17: error: reference to 'max' is ambiguous 4 | bool graph[max][max]; | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ a.cc:3:11: note: 'const int max' 3 | const int max = 8; | ^~~ a.cc:6:36: error: reference to 'max' is ambiguous 6 | int dfs(int v, int N, bool visited[max]) { | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ a.cc:3:11: note: 'const int max' 3 | const int max = 8; | ^~~ a.cc: In function 'int dfs(...)': a.cc:10:29: error: 'N' was not declared in this scope 10 | for (int i = 0; i < N; ++i) { | ^ a.cc:11:21: error: 'visited' was not declared in this scope; did you mean 'all_visited'? 11 | if (visited[i] == false) | ^~~~~~~ | all_visited a.cc:21:29: error: 'N' was not declared in this scope 21 | for (int i = 0; i < N; i++) { | ^ a.cc:22:21: error: 'graph' was not declared in this scope; did you mean 'isgraph'? 22 | if (graph[v][i] == false) continue; | ^~~~~ | isgraph a.cc:22:27: error: 'v' was not declared in this scope 22 | if (graph[v][i] == false) continue; | ^ a.cc:23:21: error: 'visited' was not declared in this scope; did you mean 'all_visited'? 23 | if (visited[i]) continue; | ^~~~~~~ | all_visited a.cc:25:17: error: 'visited' was not declared in this scope; did you mean 'all_visited'? 25 | visited[i] = true; | ^~~~~~~ | all_visited a.cc: In function 'int main()': a.cc:39:17: error: 'graph' was not declared in this scope; did you mean 'isgraph'? 39 | graph[A - 1][B - 1] = graph[B - 1][A - 1] = true; | ^~~~~ | isgraph a.cc:43:22: error: reference to 'max' is ambiguous 43 | bool visited[max]; | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ a.cc:3:11: note: 'const int max' 3 | const int max = 8; | ^~~ a.cc:46:17: error: 'visited' was not declared in this scope 46 | visited[i] = false; | ^~~~~~~ a.cc:49:9: error: 'visited' was not declared in this scope 49 | visited[0] = true; | ^~~~~~~
s216147330
p03805
C++
#include <iostream> #define REP(i, a, n) for(int (i) = (a); (i) <= (n); (i)++) using namespace std; int N, M, E[10][10]; bool is_valid(int* order) { REP(i, 1, N) cout << order[i] << " "; cout << "]" << endl; REP(i, 1, N - 1) { if(!E[order[i]][order[i + 1]]) return false; } return true; } int main(void) { cin >> N >> M; REP(i, 1, N) REP(j, 1, N) E[i][j] = 0; REP(i, 1, M) { int a, b; cin >> a >> b; E[a][b] = 1; E[b][a] = 1; } int order[10]; REP(i, 1, N) order[i] = i; long cnt = 0; do { if(is_valid(order)) cnt++; } while(next_permutation(order + 2, order + N + 1)); cout << cnt << endl; return 0; }
a.cc: In function 'int main()': a.cc:32:11: error: 'next_permutation' was not declared in this scope 32 | } while(next_permutation(order + 2, order + N + 1)); | ^~~~~~~~~~~~~~~~
s231421041
p03805
C++
#include <iostream> using namespace std; struct Vertice{ int neighbors[8]; int neighbor_count; }; int N, M; Vertice vertices[8]; int main(){ int a, b; cin >> N >> M; while(true) { cin >> a; if(a == '\0') break; cin >> b; vertices[a].neighbors[b] = 1; vertices[a].neighbor_count += 1; } cout << BFS(1, 0); return 0; } int BFS(int a, int lenght) { if (lenght == N) return 1; int answer = 0; for (int i = 0; i < vertices[a].neighbor_count; i++) { if (vertices[a].neighbors[i] == 1) { lenght += 1; answer += BFS(i, lenght); } } return answer; }
a.cc: In function 'int main()': a.cc:25:17: error: 'BFS' was not declared in this scope 25 | cout << BFS(1, 0); | ^~~
s745558883
p03805
C++
#include <iostream> using namespace std; struct Vertice{ int neighbors[8]; int neighbor_count; }; int N, M; Vertice vertices[8]; int main(){ int a, b; cin >> N >> M; while(true) { cin >> a; if(a == NULL) break; cin >> b; vertices[a].neighbors[b] = 1; vertices[a].neighbor_count += 1; } cout << BFS(1, 0); return 0; } int BFS(int a, int lenght) { if (lenght == N) return 1; int answer = 0; for (int i = 0; i < vertices[a].neighbor_count; i++) { if (vertices[a].neighbors[i] == 1) { lenght += 1; answer += BFS(i, lenght); } } return answer; }
a.cc: In function 'int main()': a.cc:19:25: warning: NULL used in arithmetic [-Wpointer-arith] 19 | if(a == NULL) break; | ^~~~ a.cc:25:17: error: 'BFS' was not declared in this scope 25 | cout << BFS(1, 0); | ^~~
s658182463
p03805
C++
#include <iostream> using namespace std; struct Vertice{ int neighbors[8]; int neighbor_count; } int N, M; Vertice vertices[N]; int main(){ int a, b; cin >> N >> M; while(true) { cin >> a; if(a == null) break; cin >> b; vertices[a].neighbors[b] = 1; vertices[a].neighbor_count += 1; } cout << BFS(1, 0); return 0; } int BFS(int a, int lenght) { if (lenght == N) return 1; int answer = 0; for (int i = 0; i < vertices[a].neighbor_count; i++) { if (vertices[a].neighbors[i] == 1) { lenght += 1; answer += BFS(i, lenght); } } return answer; }
a.cc:7:2: error: expected ';' after struct definition 7 | } | ^ | ; a.cc:10:18: error: size of array 'vertices' is not an integral constant-expression 10 | Vertice vertices[N]; | ^ a.cc: In function 'int main()': a.cc:19:25: error: 'null' was not declared in this scope 19 | if(a == null) break; | ^~~~ a.cc:25:17: error: 'BFS' was not declared in this scope 25 | cout << BFS(1, 0); | ^~~
s210207739
p03805
Java
import java.util.*; public class Main { int[] p = new int[10]; static int count = 0; static int[][] edge; static int N; static int M; public static void main(String[] args) { Scanner sc = new Scanner(System.in); N = sc.nextInt(); M = sc.nextInt(); edge = new int[N][N]; for(int i = 0; i < M; i++) { int a = sc.nextInt(); int b = sc.nextInt(); edge[a - 1][b - 1] = 1; edge[b - 1][a - 1] = 1; } dfs(1, (1 << N) - 2); System.out.println(count); } public void dfs(int pos, int mask) { if(pos == N) { int c = 0; for(int i = 0; i < N - 1; i++) { if(edge[p[i]][p[i + 1]] == 0) { c++; break; } } if(c == 0) count++; } for(int i = 0; i < N; i++) { if(mask & (1 << i) != 0) { p[pos] = i; dfs(pos + 1, (mask ^ (1 << i))); } } } }
Main.java:20: error: non-static method dfs(int,int) cannot be referenced from a static context dfs(1, (1 << N) - 2); ^ Main.java:35: error: bad operand types for binary operator '&' if(mask & (1 << i) != 0) { ^ first type: int second type: boolean 2 errors
s850445508
p03805
Java
import java.util.*; public class Main { int[] p = new int[10]; int count = 0; static int[][] edge; public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int M = sc.nextInt(); edge = new int[N][N]; for(int i = 0; i < M; i++) { int a = sc.nextInt(); int b = sc.nextInt(); edge[a - 1][b - 1] = 1; edge[b - 1][a - 1] = 1; } dfs(1, (1 << N) - 2); System.out.println(count); } public static void dfs(int pos, int mask) { if(pos == N) { int c = 0; for(int i = 0; i < N - 1; i++) { if(edge[p[i]][p[i + 1]] == 0) { c++; break; } } if(c == 0) count++; } for(int i = 0; i < N; i++) { if(mask & (1 << i) != 0) { p[pos] = i; dfs(pos + 1, (mask ^ (1 << i))); } } } }
Main.java:19: error: non-static variable count cannot be referenced from a static context System.out.println(count); ^ Main.java:22: error: cannot find symbol if(pos == N) { ^ symbol: variable N location: class Main Main.java:24: error: cannot find symbol for(int i = 0; i < N - 1; i++) { ^ symbol: variable N location: class Main Main.java:25: error: non-static variable p cannot be referenced from a static context if(edge[p[i]][p[i + 1]] == 0) { ^ Main.java:25: error: non-static variable p cannot be referenced from a static context if(edge[p[i]][p[i + 1]] == 0) { ^ Main.java:30: error: non-static variable count cannot be referenced from a static context if(c == 0) count++; ^ Main.java:32: error: cannot find symbol for(int i = 0; i < N; i++) { ^ symbol: variable N location: class Main Main.java:33: error: bad operand types for binary operator '&' if(mask & (1 << i) != 0) { ^ first type: int second type: boolean Main.java:34: error: non-static variable p cannot be referenced from a static context p[pos] = i; ^ 9 errors
s604513261
p03805
Java
import java.util.*; public class Main { int[] p = new int[10]; int count = 0; int[][] edge; public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int M = sc.nextInt(); edge = new int[N][N]; for(int i = 0; i < M; i++) { int a = sc.nextInt(); int b = sc.nextInt(); edge[a - 1][b - 1] = 1; edge[b - 1][a - 1] = 1; } dfs(1, (1 << N) - 2); System.out.println(count); } public static void dfs(int pos, int mask) { if(pos == N) { int c = 0; for(int i = 0; i < N - 1; i++) { if(edge[p[i]][p[i + 1]] == 0) { c++; break; } } if(c == 0) count++; } for(int i = 0; i < N; i++) { if(mask & (1 << i) != 0) { p[pos] = i; dfs(pos + 1, (mask ^ (1 << i))); } } } }
Main.java:11: error: non-static variable edge cannot be referenced from a static context edge = new int[N][N]; ^ Main.java:15: error: non-static variable edge cannot be referenced from a static context edge[a - 1][b - 1] = 1; ^ Main.java:16: error: non-static variable edge cannot be referenced from a static context edge[b - 1][a - 1] = 1; ^ Main.java:19: error: non-static variable count cannot be referenced from a static context System.out.println(count); ^ Main.java:22: error: cannot find symbol if(pos == N) { ^ symbol: variable N location: class Main Main.java:24: error: cannot find symbol for(int i = 0; i < N - 1; i++) { ^ symbol: variable N location: class Main Main.java:25: error: non-static variable edge cannot be referenced from a static context if(edge[p[i]][p[i + 1]] == 0) { ^ Main.java:25: error: non-static variable p cannot be referenced from a static context if(edge[p[i]][p[i + 1]] == 0) { ^ Main.java:25: error: non-static variable p cannot be referenced from a static context if(edge[p[i]][p[i + 1]] == 0) { ^ Main.java:30: error: non-static variable count cannot be referenced from a static context if(c == 0) count++; ^ Main.java:32: error: cannot find symbol for(int i = 0; i < N; i++) { ^ symbol: variable N location: class Main Main.java:33: error: bad operand types for binary operator '&' if(mask & (1 << i) != 0) { ^ first type: int second type: boolean Main.java:34: error: non-static variable p cannot be referenced from a static context p[pos] = i; ^ 13 errors
s123851131
p03805
Java
import java.util.*; public class Main { int[] p = new int[10]; int count = 0; int[][] edge; public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int M = sc.nextInt(); edge = new int[N][N]; for(int i = 0; i < M; i++) { int a = sc.nextInt(); int b = sc.nextInt(); edge[a - 1][b - 1] = 1; edge[b - 1][a - 1] = 1; } } dfs(1, (1 << N) - 2); System.out.println(count); } public static void dfs(int pos, int mask) { if(pos == N) { int c = 0; for(int i = 0; i < N - 1; i++) { if(edge[p[i]][p[i + 1]] == 0) { c++; break; } } if(c == 0) count++; } for(int i = 0; i < N; i++) { if(mask & (1 << i) != 0) { p[pos] = i; dfs(pos + 1, (mask ^ (1 << i))); } } } }
Main.java:19: error: invalid method declaration; return type required dfs(1, (1 << N) - 2); ^ Main.java:19: error: illegal start of type dfs(1, (1 << N) - 2); ^ Main.java:20: error: <identifier> expected System.out.println(count); ^ Main.java:20: error: <identifier> expected System.out.println(count); ^ Main.java:22: error: unnamed classes are a preview feature and are disabled by default. public static void dfs(int pos, int mask) { ^ (use --enable-preview to enable unnamed classes) Main.java:40: error: class, interface, enum, or record expected } ^ 6 errors
s630239915
p03805
Java
import java.util.*; public class Main { int[] p = new int[10]; int count = 0; int[][] edge; public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int M = sc.nextInt(); edge = new int[N][N]; for(int i = 0; i < M; i++) { int a = sc.nextInt(); int b = sc.nextInt(); edge[a - 1][b - 1] = 1; edge[b - 1][a - 1] = 1; } } dfs(1, (1 << N) - 2); System.out.println(count); } public void dfs(int pos, int mask) { if(pos == N) { int c = 0; for(int i = 0; i < N - 1; i++) { if(edge[p[i]][p[i + 1]] == 0) { c++; break; } } if(c == 0) count++; } for(int i = 0; i < N; i++) { if(mask & (1 << i) != 0) { p[pos] = i; dfs(pos + 1, (mask ^ (1 << i))); } } } }
Main.java:19: error: invalid method declaration; return type required dfs(1, (1 << N) - 2); ^ Main.java:19: error: illegal start of type dfs(1, (1 << N) - 2); ^ Main.java:20: error: <identifier> expected System.out.println(count); ^ Main.java:20: error: <identifier> expected System.out.println(count); ^ Main.java:22: error: unnamed classes are a preview feature and are disabled by default. public void dfs(int pos, int mask) { ^ (use --enable-preview to enable unnamed classes) Main.java:40: error: class, interface, enum, or record expected } ^ 6 errors
s690295591
p03805
Java
import java.util.*; public class Main { int[] p; public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int M = sc.nextInt(); p = new int[N]; int[][] edge = new int[N][N]; for(int i = 0; i < M; i++) { int a = sc.nextInt(); int b = sc.nextInt(); edge[a - 1][b - 1] = 1; edge[b - 1][a - 1] = 1; } } System.out.println(dfs(1, (1 << N) - 2)); } int count = 0; public void dfs(int pos, int mask) { if(pos == N) { int c = 0; for(int i = 0; i < N - 1; i++) { if(edge[p[i]][p[i + 1]] == 0) { c++; break; } } if(c == 0) count++; } for(int i = 0; i < N; i++) { if(mask & (1 << i) != 0) { p[pos] = i; dfs(pos + 1, (mask ^ (1 << i))); } } } }
Main.java:18: error: <identifier> expected System.out.println(dfs(1, (1 << N) - 2)); ^ Main.java:18: error: <identifier> expected System.out.println(dfs(1, (1 << N) - 2)); ^ Main.java:20: error: unnamed classes are a preview feature and are disabled by default. int count = 0; ^ (use --enable-preview to enable unnamed classes) Main.java:39: error: class, interface, enum, or record expected } ^ 4 errors
s937914837
p03805
Java
import java.util.*; public class Main { int[] p = new int[N]; Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int M = sc.nextInt(); int[][] edge = new int[N][N]; for(int i = 0; i < M; i++) { int a = sc.nextInt(); int b = sc.nextInt(); edge[a - 1][b - 1] = 1; edge[b - 1][a - 1] = 1; } System.out.println(dfs(1, (1 << N) - 2)); } int count = 0; public void dfs(int pos, int mask) { if(pos == N) { int c = 0; for(int i = 0; i < N - 1; i++) { if(edge[p[i]][p[i + 1]] == 0) { c++; break; } } if(c == 0) count++; } for(int i = 0; i < N; i++) { if(mask & (1 << i) != 0) { p[pos] = i; dfs(pos + 1, (mask ^ (1 << i))); } } } }
Main.java:9: error: illegal start of type for(int i = 0; i < M; i++) { ^ Main.java:9: error: > or ',' expected for(int i = 0; i < M; i++) { ^ Main.java:9: error: <identifier> expected for(int i = 0; i < M; i++) { ^ Main.java:15: error: <identifier> expected System.out.println(dfs(1, (1 << N) - 2)); ^ Main.java:15: error: <identifier> expected System.out.println(dfs(1, (1 << N) - 2)); ^ Main.java:17: error: unnamed classes are a preview feature and are disabled by default. int count = 0; ^ (use --enable-preview to enable unnamed classes) Main.java:36: error: class, interface, enum, or record expected } ^ 7 errors
s542392734
p03805
Java
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int M = sc.nextInt(); int[][] edge = new int[N][N]; for(int i = 0; i < M; i++) { int a = sc.nextInt(); int b = sc.nextInt(); edge[a - 1][b - 1] = 1; edge[b - 1][a - 1] = 1; } int[] p = new int[N]; int count = 0; public void dfs(int pos, int mask) { if(pos == N) { int c = 0; for(int i = 0; i < N - 1; i++) { if(edge[p[i]][p[i + 1]] == 0) { c++; break; } } if(c == 0) count++; } for(int i = 0; i < N; i++) { if(mask & (1 << i) != 0) { p[pos] = i; dfs(pos + 1, (mask ^ (1 << i))); } } } System.out.println(dfs(1, (1 << N) - 2)); } }
Main.java:17: error: illegal start of expression public void dfs(int pos, int mask) { ^ Main.java:35: error: <identifier> expected System.out.println(dfs(1, (1 << N) - 2)); ^ Main.java:35: error: <identifier> expected System.out.println(dfs(1, (1 << N) - 2)); ^ Main.java:37: error: class, interface, enum, or record expected } ^ 4 errors
s128899305
p03805
Java
import java.util.ArrayList; import java.util.Scanner; /** * Created by guoxiang.li on 2017/02/13. */ public class Main { private int count=0; private ArrayList[] graph; boolean[] visited; public int undirectedGraphTraversalWays(int[][] nums,int n){ graph=new ArrayList[n]; for(int i=0;i<n;i++){ graph[i]=new ArrayList(); } visited=new boolean[n]; for(int i=0;i<nums.length;i++){ graph[nums[i][0]-1].add(nums[i][1]-1); graph[nums[i][1]-1].add(nums[i][0]-1); } visited[0]=true; undirectedGraphTraversalWaysHelper(graph[0]); return count; } private boolean undirectedGraphTraversalWaysHelper(ArrayList nodes){ boolean flag=true; for(boolean visitedFlag:visited){ flag&=visitedFlag; } if(flag){ return true; } for(Object node:nodes){ int index=((Integer) node).intValue(); if(visited[index]){ continue; } visited[index]=true; if(undirectedGraphTraversalWaysHelper(graph[index])){ count++; } visited[index]=false; } return false; } public static void main(String[] args) { sol=new (); Scanner sc = new Scanner(System.in); // get a integer int n = sc.nextInt(); // get two integers separated with half-width break int m = sc.nextInt(); int[][] edges=new int[m][2]; for(int i=0;i<m;i++) { edges[i][0] = sc.nextInt(); edges[i][1] = sc.nextInt(); } System.out.println(sol.undirectedGraphTraversalWays(edges,n)); } }
Main.java:74: error: <identifier> expected sol=new (); ^ 1 error
s844646214
p03805
Java
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int M = sc.nextInt(); int[][] edge = new int[N][N]; for(int i = 0; i < M; i++) { int a = sc.nextInt(); int b = sc.nextInt(); edge[a - 1][b - 1] = 1; edge[b - 1][a - 1] = 1; } int[] p = new int[N]; int count = 0; void dfs(int pos, int mask) { if(pos == N) { int c = 0; for(int i = 0; i < N - 1; i++) { if(edge[p[i]][p[i + 1]] == 0) { c++; break; } } if(c == 0) count++; } for(int i = 0; i < N; i++) { if(mask & (1 << i) != 0) { p[pos] = i; dfs(pos + 1, (mask ^ (1 << i))); } } } System.out.println(dfs(1, (1 << N) - 2)); } }
Main.java:17: error: illegal start of expression void dfs(int pos, int mask) { ^ Main.java:17: error: ';' expected void dfs(int pos, int mask) { ^ Main.java:17: error: <identifier> expected void dfs(int pos, int mask) { ^ Main.java:17: error: ';' expected void dfs(int pos, int mask) { ^ 4 errors
s906117833
p03805
C++
#include <math.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #include <assert.h> #include <limits.h> #include <stdbool.h> typedef struct edge{ int u,v; } EDGE; int search(int n,int visited[],int node[n][n],int position){ int node_local[n][n]; int visited_local[n]; memcpy(node_local,node,sizeof(int)*n*n); memcpy(visited_local,visited,sizeof(int)*n); int i,j; int sum=0; visited_local[position]=1; /* puts("=========="); printf("node:%d\n",position+1); for(i=0;i<n;i++){ for(j=0;j<n;j++){ printf("%d",node_local[i][j]); }puts(""); } printf("visited node\n"); for(i=0;i<n;i++){ printf("%d",visited_local[i]); }puts(""); puts("=========="); */ visited_local[position]=1; for(i=0;i<n;i++){ if(node_local[position][i]==1){ node_local[position][i]=0; if(visited_local[i]==0){ sum+=search(n,visited_local,node_local,i); } } } int allVisited=1; for(i=0;i<n;i++){ if(visited_local[i]==0){ allVisited=0; break; } } return sum+allVisited; } int main(){ int n,m; scanf("%d %d",&n,&m); EDGE e[m]; int node[n][n]; int visited[n]; int i,j; for(i=0;i<n;i++){ visited[i]=0; for(j=0;j<n;j++){ node[i][j]=0; } } for(i=0;i<m;i++){ scanf("%d %d",&e[i].u,&e[i].v); e[i].u--;e[i].v--; node[e[i].u][e[i].v]=1; node[e[i].v][e[i].u]=1; } int position=0; printf("%d\n",search(n,visited,node,position)); return 0; }
a.cc:13:42: error: use of parameter outside function body before ']' token 13 | int search(int n,int visited[],int node[n][n],int position){ | ^ a.cc:13:45: error: use of parameter outside function body before ']' token 13 | int search(int n,int visited[],int node[n][n],int position){ | ^ a.cc:13:46: error: expected ')' before ',' token 13 | int search(int n,int visited[],int node[n][n],int position){ | ~ ^ | ) a.cc:13:47: error: expected unqualified-id before 'int' 13 | int search(int n,int visited[],int node[n][n],int position){ | ^~~
s846581120
p03805
C++
#include <string> #include <sstream> #include <iostream> #include <vector> #include <math.h> #include <algorithm> #include <functional> #include <map> #include <climits> #include <queue> using namespace std; #define ll long long class Main { public: int rec(int n, vector<pair<int, int> >& edges, vector<bool>& prevs, int last) { bool isCleared = true; for (int i = 0;i < prevs.size();i++) { isCleared ^= prevs[i]; } if (isCleared) { cout << last << endl; return 1; } int sum = 0; for (auto itr = edges.begin();itr != edges.end();++itr) { auto edge = (*itr); int v = last; if (edge.first == v || edge.second == v) { int u = (edge.first == v ? edge.second : edge.first); if (prevs[u]) continue; prevs[u] = true; sum += rec(n, edges, prevs, u); prevs[u] = false; } } return sum; } int getNum(int n,vector<pair<int, int> >& edges, int start){ vector<bool> prevs(n, false); prevs[start] = true; return rec(n, edges, prevs, start); } };
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start': (.text+0x17): undefined reference to `main' collect2: error: ld returned 1 exit status
s814565829
p03805
Java
import java.util.*; public class Main{ static int result=0; static int N; public static void main(String[] args){ Scanner sc = new Scanner(System.in); N= sc.nextInt(); int M=sc.nextInt(); int[] a=new int[M]; int[] b=new int[M]; for(int i=0;i<M;i++){ a[i]=sc.nextInt()-1; b[i]=sc.nextInt()-1; } sub2(a,b,(int)Math.pow(2, N)-2,0); System.out.println(result); }
Main.java:18: error: reached end of file while parsing } ^ 1 error
s801740232
p03805
C++
import java.util.*; public class Main{ static int result=0; static int N; public static void main(String[] args){ Scanner sc = new Scanner(System.in); N= sc.nextInt(); int M=sc.nextInt(); int[] a=new int[M]; int[] b=new int[M]; for(int i=0;i<M;i++){ a[i]=sc.nextInt()-1; b[i]=sc.nextInt()-1; } sub2(a,b,(int)Math.pow(2, N)-2,0); System.out.println(result); } public static void sub2(int[]a,int[]b,int pass,int pos){ if(pass==0){ result++; return; } for(int i=0;i<N;i++){ if((pass/(int)Math.pow(2,i))%2==1){ if(sub1(a,b,pos,i)){ sub2(a,b,pass-(int)Math.pow(2,i),i); } } } return; } public static boolean sub1(int[] a,int[] b,int n,int m){ for(int i=0;i<a.length;i++){ if(a[i]==n&&b[i]==m){ return true; } if(a[i]==m&&b[i]==n){ return true; } } return false; } }
a.cc:1:1: error: 'import' does not name a type 1 | import java.util.*; | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:2:1: error: expected unqualified-id before 'public' 2 | public class Main{ | ^~~~~~
s934521912
p03805
C++
#include <algorithm> #include <bitset> #include <cassert> #include <deque> #include <fstream> #include <iostream> #include <map> #include <math.h> #include <memory> #include <queue> #include <sstream> #include <stdio.h> #include <string> #include <vector> #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) FOR(i, 0, n) #define POW(n) ((n) * (n)) #define ALL(a) (a).begin(), (a).end() #define dump(v) (cerr << #v << ": " << v << endl) #define cerr \ if (true) \ cerr using namespace std; typedef long long ll; typedef unsigned long long ull; typedef vector<int> vi; typedef vector<double> vd; typedef vector<string> vs; typedef vector<unsigned long long> vull; // ll n = to_T<ll>("114514") template <class T> T to_T(const string &s) { istringstream is(s); T res; is >> res; return res; } template <class T> string to_s(const T &a) { ostringstream os; os << a; return os.str(); } ll N, M; bool E[10][10]; ll ans; int end; void dfs(int n, int flag) { if (flag == end) { ans++; return; } REP(i, N) if (E[n][i]) { if (flag & 0x01 << i) continue; unsigned char buf = flag + (0x01 << i); dfs(i, buf); } } void solve(long long NN, long long MM, vector<long long> a, vector<long long> b) { N = NN; M = MM; REP(i, N) { end += 0x01 << i; } // cout << (int)end << endl; REP(i, M) E[a[i]][b[i]] = E[b[i]][a[i]] = true; dfs(0, 1); cout << ans << endl; } int main() { ios::sync_with_stdio(false); long long M; long long N; cin >> N; cin >> M; vector<long long> a(M - 1 + 1); vector<long long> b(M - 1 + 1); for (int i = 0; i <= M - 1; i++) { cin >> a[i]; a[i]--; cin >> b[i]; b[i]--; } solve(N, M, a, b); return 0; }
a.cc: In function 'void dfs(int, int)': a.cc:54:15: error: reference to 'end' is ambiguous 54 | if (flag == end) { | ^~~ In file included from /usr/include/c++/14/string:53, from /usr/include/c++/14/bitset:52, from a.cc:2: /usr/include/c++/14/bits/range_access.h:116:37: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)' 116 | template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept; | ^~~ /usr/include/c++/14/bits/range_access.h:115:31: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)' 115 | template<typename _Tp> _Tp* end(valarray<_Tp>&) noexcept; | ^~~ /usr/include/c++/14/bits/range_access.h:106:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])' 106 | end(_Tp (&__arr)[_Nm]) noexcept | ^~~ /usr/include/c++/14/bits/range_access.h:85:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)' 85 | end(const _Container& __cont) -> decltype(__cont.end()) | ^~~ /usr/include/c++/14/bits/range_access.h:74:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)' 74 | end(_Container& __cont) -> decltype(__cont.end()) | ^~~ In file included from /usr/include/c++/14/bits/algorithmfwd.h:39, from /usr/include/c++/14/bits/stl_algo.h:59, from /usr/include/c++/14/algorithm:61, from a.cc:1: /usr/include/c++/14/initializer_list:99:5: note: 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)' 99 | end(initializer_list<_Tp> __ils) noexcept | ^~~ a.cc:51:5: note: 'int end' 51 | int end; | ^~~ a.cc: In function 'void solve(long long int, long long int, std::vector<long long int>, std::vector<long long int>)': a.cc:72:15: error: reference to 'end' is ambiguous 72 | REP(i, N) { end += 0x01 << i; } | ^~~ /usr/include/c++/14/bits/range_access.h:116:37: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)' 116 | template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept; | ^~~ /usr/include/c++/14/bits/range_access.h:115:31: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)' 115 | template<typename _Tp> _Tp* end(valarray<_Tp>&) noexcept; | ^~~ /usr/include/c++/14/bits/range_access.h:106:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])' 106 | end(_Tp (&__arr)[_Nm]) noexcept | ^~~ /usr/include/c++/14/bits/range_access.h:85:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)' 85 | end(const _Container& __cont) -> decltype(__cont.end()) | ^~~ /usr/include/c++/14/bits/range_access.h:74:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)' 74 | end(_Container& __cont) -> decltype(__cont.end()) | ^~~ /usr/include/c++/14/initializer_list:99:5: note: 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)' 99 | end(initializer_list<_Tp> __ils) noexcept | ^~~ a.cc:51:5: note: 'int end' 51 | int end; | ^~~
s583591434
p03805
C++
#include <algorithm> #include <bitset> #include <cassert> #include <deque> #include <fstream> #include <iostream> #include <map> #include <math.h> #include <memory> #include <queue> #include <sstream> #include <stdio.h> #include <string> #include <vector> #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) FOR(i, 0, n) #define POW(n) ((n) * (n)) #define ALL(a) (a).begin(), (a).end() #define dump(v) (cerr << #v << ": " << v << endl) #define cerr \ if (true) \ cerr using namespace std; typedef long long ll; typedef unsigned long long ull; typedef vector<int> vi; typedef vector<double> vd; typedef vector<string> vs; typedef vector<unsigned long long> vull; // ll n = to_T<ll>("114514") template <class T> T to_T(const string &s) { istringstream is(s); T res; is >> res; return res; } template <class T> string to_s(const T &a) { ostringstream os; os << a; return os.str(); } ll N, M; bool E[10][10]; ll ans; unsigned char end; void dfs(int n, unsigned char flag) { if (flag == end) { ans++; return; } REP(i, N) if (E[n][i]) { if (flag & 0x01 << i) continue; unsigned char buf = flag + (0x01 << i); dfs(i, buf); } } void solve(long long NN, long long MM, vector<long long> a, vector<long long> b) { N = NN; M = MM; REP(i, N) { end += 0x01 << i; } // cout << (int)end << endl; REP(i, M) E[a[i]][b[i]] = E[b[i]][a[i]] = true; dfs(0, 1); cout << ans << endl; } int main() { ios::sync_with_stdio(false); long long M; long long N; cin >> N; cin >> M; vector<long long> a(M - 1 + 1); vector<long long> b(M - 1 + 1); for (int i = 0; i <= M - 1; i++) { cin >> a[i]; a[i]--; cin >> b[i]; b[i]--; } solve(N, M, a, b); return 0; }
a.cc: In function 'void dfs(int, unsigned char)': a.cc:54:15: error: reference to 'end' is ambiguous 54 | if (flag == end) { | ^~~ In file included from /usr/include/c++/14/string:53, from /usr/include/c++/14/bitset:52, from a.cc:2: /usr/include/c++/14/bits/range_access.h:116:37: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)' 116 | template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept; | ^~~ /usr/include/c++/14/bits/range_access.h:115:31: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)' 115 | template<typename _Tp> _Tp* end(valarray<_Tp>&) noexcept; | ^~~ /usr/include/c++/14/bits/range_access.h:106:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])' 106 | end(_Tp (&__arr)[_Nm]) noexcept | ^~~ /usr/include/c++/14/bits/range_access.h:85:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)' 85 | end(const _Container& __cont) -> decltype(__cont.end()) | ^~~ /usr/include/c++/14/bits/range_access.h:74:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)' 74 | end(_Container& __cont) -> decltype(__cont.end()) | ^~~ In file included from /usr/include/c++/14/bits/algorithmfwd.h:39, from /usr/include/c++/14/bits/stl_algo.h:59, from /usr/include/c++/14/algorithm:61, from a.cc:1: /usr/include/c++/14/initializer_list:99:5: note: 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)' 99 | end(initializer_list<_Tp> __ils) noexcept | ^~~ a.cc:51:15: note: 'unsigned char end' 51 | unsigned char end; | ^~~ a.cc: In function 'void solve(long long int, long long int, std::vector<long long int>, std::vector<long long int>)': a.cc:72:15: error: reference to 'end' is ambiguous 72 | REP(i, N) { end += 0x01 << i; } | ^~~ /usr/include/c++/14/bits/range_access.h:116:37: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)' 116 | template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept; | ^~~ /usr/include/c++/14/bits/range_access.h:115:31: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)' 115 | template<typename _Tp> _Tp* end(valarray<_Tp>&) noexcept; | ^~~ /usr/include/c++/14/bits/range_access.h:106:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])' 106 | end(_Tp (&__arr)[_Nm]) noexcept | ^~~ /usr/include/c++/14/bits/range_access.h:85:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)' 85 | end(const _Container& __cont) -> decltype(__cont.end()) | ^~~ /usr/include/c++/14/bits/range_access.h:74:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)' 74 | end(_Container& __cont) -> decltype(__cont.end()) | ^~~ /usr/include/c++/14/initializer_list:99:5: note: 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)' 99 | end(initializer_list<_Tp> __ils) noexcept | ^~~ a.cc:51:15: note: 'unsigned char end' 51 | unsigned char end; | ^~~
s968324486
p03805
C++
#include <cstdio> #include <cmath> #include <cstring> #include <ctime> #include <iostream> #include <algorithm> #include <set> #include <vector> #include <sstream> #include <typeinfo> #include <fstream> #include <limits> using namespace std; template<class T = int,T divided_by = 10> constexpr T PINF(){ return std::numeric_limits<T>::max()/divided_by; } template<class T = int,T divided_by = 10> constexpr T MINF(){ return std::numeric_limits<T>::lowest()/divided_by; } template<class T = int> T gcd(T a, T b){ return b ? gcd(b,a%b) : a; } template<class T = int> T lcm(T a, T b){ return a / gcd(a,b) * b; } template<class T = int> T lcm_safe(T a, T b){ T p = a/gcd(a,b); return (b <= PINF<T>()/p) ? p*b:PINF<T>(); } //オーバーフローするとき+INFを返す // int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n,m; cin >> n >> m; vector<set<int>> v(n); for(int i = 0; i < m; ++i){ int a,b; cin >> a >> b; a--; b--; v[a].insert(b); v[b].insert(a); } vector<vector<int>> seqs(100000, vector<int>()); vector<int> nodes(n-1); iota(nodes.begin(), nodes.end(), 1); // v に 1, 2, ... N を設定 int ans = 0; do { // for(auto nextNode : nodes) cout << nextNode << " "; cout << "\n"; // v の要素を表示 int curNode = 0; bool isOk = true; for(auto nextNode : nodes) { bool hasNextNode = v[curNode].find(nextNode) != v[curNode].end(); isOk = isOk && hasNextNode; curNode = nextNode; } if(isOk) ans++; } while( next_permutation(nodes.begin(), nodes.end()) ); // 次の順列を生成 cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:44:5: error: 'iota' was not declared in this scope 44 | iota(nodes.begin(), nodes.end(), 1); // v に 1, 2, ... N を設定 | ^~~~
s524729371
p03805
C++
#include<iostream> #include<algorithm> using namespace std; int main(){ int N, M; cin>> N>> M; int g[10][10]; for(int i=0; i<N; i++){ for(int j=0; j<N; j++){ g[i][j]=0; } } for(int i=0; i<M; i++){ int a, b; cin>> a>> b; a--; b--; // g[a].push_back(b); // g[b].push_back(a); g[a][b]=g[b][a]=1; } vector<int> _v; int r=0; for(int i=1; i<N; i++) _v.push_back(i); do{ bool ok=true; int p=0; for(int j: _v){ ok&=g[p][j]; p=j; } if(ok) r++; }while(next_permutation(_v.begin(), _v.end())); cout<< r<< endl; return 0; }
a.cc: In function 'int main()': a.cc:25:4: error: 'vector' was not declared in this scope 25 | vector<int> _v; | ^~~~~~ a.cc:3:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>' 2 | #include<algorithm> +++ |+#include <vector> 3 | a.cc:25:11: error: expected primary-expression before 'int' 25 | vector<int> _v; | ^~~ a.cc:27:27: error: '_v' was not declared in this scope 27 | for(int i=1; i<N; i++) _v.push_back(i); | ^~ a.cc:31:18: error: '_v' was not declared in this scope 31 | for(int j: _v){ | ^~ a.cc:36:28: error: '_v' was not declared in this scope 36 | }while(next_permutation(_v.begin(), _v.end())); | ^~