#include "garden.h"
#include "gardenlib.h"
#include <bits/stdc++.h>
using namespace std;
void count_routes(int N, int M, int P, int R[][2], int Q, int G[]){
vector<int> vc[200200], ans(Q, 0), dis(N, 0), vis(N, 0);
queue<pair<int, int>> q;
for(int i = 0; i < M; ++i) vc[R[i][0]].push_back(R[i][1]), vc[R[i][1]].push_back(R[i][0]);
q.emplace(P, 0);
vis[P] = 1;
while(!q.empty()){
int u = q.front().first, w = q.front().second; q.pop();
for(auto v:vc[u]){
if(vis[v]) continue;
dis[v] = w + 1;
vis[v] = 1;
q.emplace(v, w + 1);
}
}
int n = -1;
for(int i = 0; i < Q; ++i) n = max(n, G[i]);
vector<int> dp(n+1, 0);
dp[0] = 1;
for(int i = 1; i <= n; ++i){
for(int j = 0; j < N; ++j){
if(i - 2*dp[j] >= 0) dp[i] += dp[i - 2*dp[j]];
}
}
for(int i = 0; i < Q; ++i) answer(dp[G[i]]);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
4944 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
4944 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
4944 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |