// #pragma once
#include "gardenlib.h"
#include "garden.h"
#include <vector>
#include <iostream>
using namespace std;
const int N1=1e5;
vector<int> ma[N1];
int in=0;
int fin=-1;
int wnt;
bool vis[N1];
void dfs(int x,int last=-1)
{
if(in>wnt)
return;
if(in==wnt)
fin=x;
for(int y:ma[x])
{
if(in==wnt)
fin=x;
if(y!=last)
{
in++;
dfs(y,x);
if(in==wnt)
fin=x;
}
if(in==wnt)
fin=x;
}
if(in==wnt)
fin=x;
in++;
}
void count_routes(int n, int m, int p, int r[][2], int q, int g[])
{
for(int i=0;i<m;i++)
{
ma[r[i][0]].push_back(r[i][1]);
ma[r[i][1]].push_back(r[i][0]);
}
for(int qp=0;qp<q;qp++)
{
int ans=0;
wnt=g[qp];
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
vis[j]=0;
in=0;
fin=-1;
dfs(i);
ans+=(fin==p);
}
answer(ans);
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
4440 KB |
Output is correct |
2 |
Correct |
3 ms |
4444 KB |
Output is correct |
3 |
Correct |
3 ms |
4684 KB |
Output is correct |
4 |
Incorrect |
1 ms |
4440 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
4440 KB |
Output is correct |
2 |
Correct |
3 ms |
4444 KB |
Output is correct |
3 |
Correct |
3 ms |
4684 KB |
Output is correct |
4 |
Incorrect |
1 ms |
4440 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
4440 KB |
Output is correct |
2 |
Correct |
3 ms |
4444 KB |
Output is correct |
3 |
Correct |
3 ms |
4684 KB |
Output is correct |
4 |
Incorrect |
1 ms |
4440 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |