Submission #849349

# Submission time Handle Problem Language Result Execution time Memory
849349 2023-09-14T14:08:01 Z Mr_Ph Tropical Garden (IOI11_garden) C++14
49 / 100
5000 ms 3676 KB
#include "garden.h"
#include "gardenlib.h"
//#include "grader.cpp"
#include <bits/stdc++.h>
using namespace std;
vector<vector<int>>adj;
bool valid=false;
void dfs(int node,int prv,int k,int p)
{
    if(k==0)
    {
        valid=(node==p);
        return;
    }
    if(adj[node].size()==1)
        dfs(adj[node][0],node,k-1,p);
    else
    {
        if(prv==adj[node][0])
            dfs(adj[node][1],node,k-1,p);
        else
            dfs(adj[node][0],node,k-1,p);
    }
}
void count_routes(int n, int m, int p, int r[][2], int q, int g[])
{
    adj.resize(n+1);
    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]);
    }
    int ans=0;
    for(int j=0;j<q;j++){
    for(int i=0;i<n;i++)
    {
        valid=false;
        dfs(i,-1,g[j],p);
        ans+=valid;
    }
    answer(ans);
    }
}
 
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
10 Correct 4 ms 348 KB Output is correct
11 Execution timed out 5016 ms 3676 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
10 Correct 4 ms 348 KB Output is correct
11 Execution timed out 5016 ms 3676 KB Time limit exceeded
12 Halted 0 ms 0 KB -