Submission #85651

# Submission time Handle Problem Language Result Execution time Memory
85651 2018-11-21T09:51:55 Z mirbek01 Tropical Garden (IOI11_garden) C++17
49 / 100
5000 ms 3704 KB
#include "garden.h"
#include "gardenlib.h"
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 1e5 + 2;

int k, ans, p, cnt[MAXN], used[MAXN];
vector <int> g[MAXN];

bool dfs(int v){
      int c = k;
      int pr = v;
      while(c --){
            if(g[v][0] == pr && g[v].size() > 1){
                  pr = v;
                  v = g[v][1];
            } else {
                  pr = v;
                  v = g[v][0];
            }
      }
      return v == p;
}

void count_routes(int N, int M, int P, int R[][2], int Q, int G[]){
      for(int i = 0; i < M; i ++){
            int u = R[i][0], v = R[i][1];
            if(g[u].size() < 2)
            g[u].push_back(v);
            if(g[v].size() < 2)
            g[v].push_back(u);
      }
      p = P;
      for(int i = 0; i < Q; i ++){
            k = G[i];
            ans = 0;
            for(int i = 0; i < N; i ++){
                  ans += dfs(i);
            }
            answer(ans);
      }
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2680 KB Output is correct
2 Correct 5 ms 2680 KB Output is correct
3 Correct 5 ms 2680 KB Output is correct
4 Correct 4 ms 2680 KB Output is correct
5 Correct 4 ms 2680 KB Output is correct
6 Correct 5 ms 2680 KB Output is correct
7 Correct 4 ms 2680 KB Output is correct
8 Correct 5 ms 2752 KB Output is correct
9 Correct 7 ms 2808 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2680 KB Output is correct
2 Correct 5 ms 2680 KB Output is correct
3 Correct 5 ms 2680 KB Output is correct
4 Correct 4 ms 2680 KB Output is correct
5 Correct 4 ms 2680 KB Output is correct
6 Correct 5 ms 2680 KB Output is correct
7 Correct 4 ms 2680 KB Output is correct
8 Correct 5 ms 2752 KB Output is correct
9 Correct 7 ms 2808 KB Output is correct
10 Correct 9 ms 2680 KB Output is correct
11 Execution timed out 5006 ms 3704 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2680 KB Output is correct
2 Correct 5 ms 2680 KB Output is correct
3 Correct 5 ms 2680 KB Output is correct
4 Correct 4 ms 2680 KB Output is correct
5 Correct 4 ms 2680 KB Output is correct
6 Correct 5 ms 2680 KB Output is correct
7 Correct 4 ms 2680 KB Output is correct
8 Correct 5 ms 2752 KB Output is correct
9 Correct 7 ms 2808 KB Output is correct
10 Correct 9 ms 2680 KB Output is correct
11 Execution timed out 5006 ms 3704 KB Time limit exceeded
12 Halted 0 ms 0 KB -