답안 #839170

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
839170 2023-08-28T23:11:27 Z asdfgrace 열대 식물원 (Tropical Garden) (IOI11_garden) C++17
49 / 100
5000 ms 1892 KB
#include <bits/stdc++.h>
#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[]) {
  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]);
  }
  for (int q = 0; q < Q; ++q) {
    int ans = 0;
    for (int i = 0; i < N; ++i) {
      int cur = i, prev = i;
      for (int it = 0; it < G[q]; ++it) {
        if (prev != edges[cur][0] || (int) edges[cur].size() == 1) {
          prev = cur;
          cur = edges[cur][0];
        } else {
          prev = cur;
          cur = edges[cur][1];
        }
      }
      if (cur == P) {
        ++ans;
      }
    }
    answer(ans);
  }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 308 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 1 ms 312 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 2 ms 596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 308 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 1 ms 312 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 2 ms 596 KB Output is correct
10 Correct 5 ms 212 KB Output is correct
11 Execution timed out 5032 ms 1892 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 308 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 1 ms 312 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 2 ms 596 KB Output is correct
10 Correct 5 ms 212 KB Output is correct
11 Execution timed out 5032 ms 1892 KB Time limit exceeded
12 Halted 0 ms 0 KB -