CSES - Datatähti 2020 loppu - Results
Submission details
Task:Kierrokset
Sender:Aaron Äärelä
Submission time:2020-02-09 14:20:58 +0200
Language:C++ (C++11)
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int r(int)':
input/code.cpp:9:14: error: no matching function for call to 'std::vector<int>::push_back()'
  p.push_back();
              ^
In file included from /usr/include/c++/7/vector:64:0,
                 from /usr/include/c++/7/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86,
                 from input/code.cpp:1:
/usr/include/c++/7/bits/stl_vector.h:939:7: note: candidate: void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::value_type = int]
       push_back(const value_type& __x)
       ^~~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:939:7: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/7/bits/stl_vector.h:953:7: note: candidate: void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::value_type = int]
       push_back...

Code

#include <bits/stdc++.h>
using namespace std;
const int si = 1e6;
vector<int> t[si] = {};
vector<int> p;
int n, s, d;
int mod = 1e9 + 7;
int r(int k){
	p.push_back();
	if(k == d) return 1;
	for(int i = 0; i < t[k].size(); i++){
		if(r(t[k][i])) return 1;
	}
	p.pop_back();
	return 0;
}
int main(){
	cin >>n >> s >> d;
	for(int i = 0; i < n- 1; i++){
		int a, b;
		cin >> a >> b;
		t[a - 1].push_back(b - 1);
		t[b - 1].push_back(a - 1);
	}
	int v = n - (p.size() - 2);
	int res = 0;
	for(int i = 0; i < v; i++){
		res = (res * 2) % mod;
	}
	cout << '\n';
	return 0;
}