답안 #839195

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
839195 2023-08-29T03:30:32 Z asdfgrace 열대 식물원 (Tropical Garden) (IOI11_garden) C++17
69 / 100
5000 ms 48564 KB
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,unroll-loops,O3")
#pragma GCC target("avx,avx2")
#include "garden.h"
#include "gardenlib.h"
using namespace std;
 
void count_routes(int N, int M, int P, int R[][2], int Q, int G[]) {
  const int LOG = 31;
  vector<vector<int>> edges(N);
  for (int i = 0; i < M; ++i) {
    edges[R[i][0]].push_back(R[i][1]);
    edges[R[i][1]].push_back(R[i][0]);
  }
  vector<int> next(2 * N, -1);
  for (int i = 0; i < N; ++i) {
    int x = edges[i][0];
    next[2 * i] = (i == edges[x][0] ? 2 * x + 1 : 2 * x);
    x = ((int) edges[i].size() == 1 ? edges[i][0] : edges[i][1]);
    next[2 * i + 1] = (i == edges[x][0] ? 2 * x + 1 : 2 * x);
  }
  vector<vector<int>> lift(LOG, vector<int>(2 * N));
  lift[0] = next;
  for (int j = 1; j < LOG; ++j) {
    for (int i = 0; i < 2 * N; ++i) {
      lift[j][i] = lift[j - 1][lift[j - 1][i]];
    }
  }
  auto get = [&](int i, int k) {
    for (int j = LOG - 1; j >= 0; --j) {
      if (k >= 1 << j) {
        i = lift[j][i];
        k -= 1 << j;
      }
    }
    return i;
  };
  for (int j = 0; j < Q; ++j) {
    int k = G[j], cnt = 0;
    for (int i = 0; i < N; ++i) {
      if (get(i * 2, k) / 2 == P) ++cnt;
    }
    answer(cnt);
  }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Correct 1 ms 596 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 596 KB Output is correct
9 Correct 2 ms 724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Correct 1 ms 596 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 596 KB Output is correct
9 Correct 2 ms 724 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 9 ms 7508 KB Output is correct
12 Correct 19 ms 12756 KB Output is correct
13 Correct 33 ms 27688 KB Output is correct
14 Correct 65 ms 43928 KB Output is correct
15 Correct 66 ms 44376 KB Output is correct
16 Correct 52 ms 30524 KB Output is correct
17 Correct 56 ms 26060 KB Output is correct
18 Correct 25 ms 12716 KB Output is correct
19 Correct 64 ms 43900 KB Output is correct
20 Correct 64 ms 44440 KB Output is correct
21 Correct 51 ms 30520 KB Output is correct
22 Correct 47 ms 25940 KB Output is correct
23 Correct 77 ms 48564 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Correct 1 ms 596 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 596 KB Output is correct
9 Correct 2 ms 724 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 9 ms 7508 KB Output is correct
12 Correct 19 ms 12756 KB Output is correct
13 Correct 33 ms 27688 KB Output is correct
14 Correct 65 ms 43928 KB Output is correct
15 Correct 66 ms 44376 KB Output is correct
16 Correct 52 ms 30524 KB Output is correct
17 Correct 56 ms 26060 KB Output is correct
18 Correct 25 ms 12716 KB Output is correct
19 Correct 64 ms 43900 KB Output is correct
20 Correct 64 ms 44440 KB Output is correct
21 Correct 51 ms 30520 KB Output is correct
22 Correct 47 ms 25940 KB Output is correct
23 Correct 77 ms 48564 KB Output is correct
24 Correct 4 ms 340 KB Output is correct
25 Correct 1538 ms 7508 KB Output is correct
26 Correct 2823 ms 12724 KB Output is correct
27 Correct 3589 ms 27736 KB Output is correct
28 Execution timed out 5079 ms 43848 KB Time limit exceeded
29 Halted 0 ms 0 KB -