Submission #1104552

# Submission time Handle Problem Language Result Execution time Memory
1104552 2024-10-24T03:17:21 Z Ninedesu Tropical Garden (IOI11_garden) C++14
49 / 100
5000 ms 5504 KB
#include "garden.h"
#include "gardenlib.h"
#include<bits/stdc++.h>
using namespace std;

int ans;
vector<int>adj[100001];

void dfs(int u,int p,int P,int G,int dis){
  if(dis==G){
    if(u==P)ans++;
    return ;
  }
  if(adj[u][0]!=p||adj[u].size()==1)dfs(adj[u][0],u,P,G,dis+1);
  else dfs(adj[u][1],u,P,G,dis+1);
}

void count_routes(int N, int M, int P, int R[][2], int Q, int G[])
{
  for(int i=0; i<M; i++){
    adj[R[i][0]].push_back(R[i][1]);
    adj[R[i][1]].push_back(R[i][0]);
  }

  for(int i=0; i<Q; i++){
    ans=0;
    for(int u=0; u<N; u++){
      dfs(u,-1,P,G[i],0);
    }
    answer(ans);
  }
}


# Verdict Execution time Memory Grader output
1 Correct 2 ms 4688 KB Output is correct
2 Correct 2 ms 4860 KB Output is correct
3 Correct 2 ms 4856 KB Output is correct
4 Correct 1 ms 4700 KB Output is correct
5 Correct 1 ms 4688 KB Output is correct
6 Correct 3 ms 4688 KB Output is correct
7 Correct 2 ms 4688 KB Output is correct
8 Correct 2 ms 4688 KB Output is correct
9 Correct 4 ms 4688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4688 KB Output is correct
2 Correct 2 ms 4860 KB Output is correct
3 Correct 2 ms 4856 KB Output is correct
4 Correct 1 ms 4700 KB Output is correct
5 Correct 1 ms 4688 KB Output is correct
6 Correct 3 ms 4688 KB Output is correct
7 Correct 2 ms 4688 KB Output is correct
8 Correct 2 ms 4688 KB Output is correct
9 Correct 4 ms 4688 KB Output is correct
10 Correct 5 ms 4856 KB Output is correct
11 Execution timed out 5087 ms 5504 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4688 KB Output is correct
2 Correct 2 ms 4860 KB Output is correct
3 Correct 2 ms 4856 KB Output is correct
4 Correct 1 ms 4700 KB Output is correct
5 Correct 1 ms 4688 KB Output is correct
6 Correct 3 ms 4688 KB Output is correct
7 Correct 2 ms 4688 KB Output is correct
8 Correct 2 ms 4688 KB Output is correct
9 Correct 4 ms 4688 KB Output is correct
10 Correct 5 ms 4856 KB Output is correct
11 Execution timed out 5087 ms 5504 KB Time limit exceeded
12 Halted 0 ms 0 KB -