Submission #185443

# Submission time Handle Problem Language Result Execution time Memory
185443 2020-01-11T18:34:07 Z awlintqaa Tropical Garden (IOI11_garden) C++14
0 / 100
36 ms 1436 KB
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#include <bits/stdc++.h>
using namespace std;
#define sqr 500
#define mid (l+r)/2
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define era erase
#define C continue
#define mem(dp,i) memset(dp,i,sizeof(dp))
#define mset multiset
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const ll mod=1000000007;//998244353;
const ll inf=1e18*4;
const ld pai=acos(-1);
#include "garden.h"
#include "gardenlib.h"
int n,m,to,k,sum,z;
vpi v[10009];
int done[100099],Pa[100009];
void dfs(int node,int num){
        if(z)return ;
        if(node==-1){
                z=1;
                return ;
        }
        if(num>k){
                z=1;
                return ;
        }
        if(num==k){
                sum+=(node==to);
                z=1;
                return;
        }
        for(auto U: v[node]){
                int x=U.fi,u=U.se;
                if(done[x])C;
                done[x]=1;
                Pa[u]=node;
                dfs(u,num+1);
                if(z)return ;
        }
        if(z)return ;
        dfs(Pa[node],num+1);
}
void count_routes(int N, int M, int P, int R[][2], int Q, int G[]){
        n=N,m=M,to=P,k=G[0];
        for(int i=0;i<m;i++){
                int a,b;
                a=R[i][0],b=R[i][1];
                v[a].pb({i,b});
                v[b].pb({i,a});
        }
        for(int i=0;i<n;i++)sort(v[i].begin(),v[i].end());
        for(int i=0;i<n;i++){
                mem(done,0);
                mem(Pa,-1);
                z=0;
                dfs(i,0);
        }
        return answer(sum);
}
# Verdict Execution time Memory Grader output
1 Incorrect 36 ms 1436 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 36 ms 1436 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 36 ms 1436 KB Output isn't correct
2 Halted 0 ms 0 KB -