// a >> b = a / pow(2,b)
// a << b = a * pow(2,b)
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define sz size()
#define ss second
#define ff first
#define N 200001
#define pii pair<int,int>
using namespace std;
int ans;
vector <pii> adj[N];
void dfs(int nd, int c, int k, int p){
if(c == k){
if(nd == p) ans++;
return;
}
bool a = 0;
if(adj[nd].sz == 1) a = 0;
else a = 1;
dfs(adj[nd][a].ss, c+1, k, p);
}
//int answer(int x){
// return x;
//}
vector<int> count_routes(int n, int m, int p, int r[N][2], int q, int g[2001]){
vector <int> answer;
for(int i = 0; i < m; i++){
adj[r[i][0]].pb({i,r[i][1]});
adj[r[i][1]].pb({i,r[i][0]});
}
for(int i = 0; i < n; i++) sort(adj[i].begin(), adj[i].end());
for(int i = 0; i < q; i++){
for(int j = 0; j < n; j++){
dfs(j,0,g[i],p);
}
answer.pb(ans);
ans = 0;
}
for(auto i : answer){
cout << answer[i] << ' ';
}
}
//int main(){
// int n, m, p, r[N][2], q, g[q];
// cin >> n >> m >> p;
// for(int i = 0; i < m; i++) cin >> r[i][0] >> r[i][1];
// cin >> q;
// for(int i = 0; i < q; i++) cin >> g[i];
// count_routes(n,m,p,r,q,g);
//}
Compilation message
garden.cpp: In function 'std::vector<int> count_routes(int, int, int, int (*)[2], int, int*)':
garden.cpp:50:1: warning: no return statement in function returning non-void [-Wreturn-type]
50 | }
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
7 ms |
9960 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
7 ms |
9960 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
7 ms |
9960 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |