Submission #823079

#TimeUsernameProblemLanguageResultExecution timeMemory
823079nemethmTropical Garden (IOI11_garden)C++17
49 / 100
5061 ms4944 KiB
#include "garden.h"
#include "gardenlib.h"

#include <bits/stdc++.h>

using namespace std;

vector<pair<int,int>> g[150100];
int p;

int simulate(int node, int k){
  int prev = -1;
  while(k--){
    int nxt = g[node][0].first;
    if(nxt == prev && g[node].size() > 1){
      nxt = g[node][1].first;
    }
    prev = node;
    node = nxt;
  }
  return p == node;
}

void count_routes(int N, int M, int P, int R[][2], int Q, int G[])
{
  p = P;
  for(int i = 0; i < M; ++i){
    g[R[i][0]].push_back({R[i][1], i});   //nem kéne minden él
    g[R[i][1]].push_back({R[i][0], i});
  }
  int ans = 0;
  for(int i = 0; i < N; ++i){
    ans += simulate(i, G[0]);
  }
  answer(ans);
}


#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...