답안 #1033841

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1033841 2024-07-25T06:52:10 Z vjudge1 열대 식물원 (Tropical Garden) (IOI11_garden) C
49 / 100
5000 ms 900 KB
#include "garden.h"
#include "gardenlib.h"

void count_routes(int N, int M, int P, int R[][2], int Q, int G[])
{
  static int graph[150000][2];
  static int sz[150000];
  for (int i = 0; i < M; i++) {
    int u = R[i][0];
    int v = R[i][1];
    if (sz[u] < 2)
      graph[u][sz[u]++] = v;
    if (sz[v] < 2)
      graph[v][sz[v]++] = u;
  }

  for (int i = 0; i < Q; i++) {
    int res = 0;
    for (int j = 0; j < N; j++) {
      int cur = j;
      int prv = -1;
      for (int k = 0; k < G[i]; k++) {
        int old = cur;
        if (prv != graph[cur][0] || sz[cur] <= 1)
          cur = graph[cur][0];
        else
          cur = graph[cur][1];
        prv = old;
      }
      res += cur == P;
    }
    answer(res);
  }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 592 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 592 KB Output is correct
10 Correct 2 ms 348 KB Output is correct
11 Execution timed out 5092 ms 900 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 592 KB Output is correct
10 Correct 2 ms 348 KB Output is correct
11 Execution timed out 5092 ms 900 KB Time limit exceeded
12 Halted 0 ms 0 KB -