답안 #1104543

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1104543 2024-10-24T02:44:04 Z Nxmkxing 열대 식물원 (Tropical Garden) (IOI11_garden) C++14
0 / 100
2 ms 4856 KB
#include "garden.h"
#include "gardenlib.h"
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using pii = pair<int, int>;
const int inf = 1e9;

const int MxN = 1e5 + 10;
int n, m, p, q, ans[MxN], g[MxN];
vector<pii> adj[MxN];

int cnt = -1;

void dfs(int u, int pa, int i) {
  if (++cnt == g[i] && u == p) ans[i]++;
  for (auto [j, v] : adj[u]) {
    if (v == pa || cnt > g[i]) continue;
    dfs(v, u, i);
    if (++cnt == g[i] && u == p) ans[i]++;
  }
}

void count_routes(int N, int M, int P, int R[][2], int Q, int G[]) {
  n = N, m = M, p = P;
  for (int i = 0; i < M; i++) {
    int u = R[i][0];
    int v = R[i][1];
    adj[u].push_back({i, v});
    adj[v].push_back({i, u});
  }
  q = Q;
  for (int i = 0; i < Q; i++) {
    g[i] = G[i];
  }
  for (int i = 0; i < n; i++) {
    sort(adj[i].begin(), adj[i].end());
  }
  for (int i = 0; i < q; i++) {
    for (int j = 0; j < n; j++) {
      cnt = -1;
      dfs(j, -1, i);
    }
  }
  for (int i = 0; i < q; i++) {
    answer(ans[i]);
  }
}


Compilation message

garden.cpp: In function 'void dfs(int, int, int)':
garden.cpp:18:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   18 |   for (auto [j, v] : adj[u]) {
      |             ^
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4688 KB Output is correct
2 Correct 2 ms 4688 KB Output is correct
3 Correct 2 ms 4688 KB Output is correct
4 Incorrect 2 ms 4856 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4688 KB Output is correct
2 Correct 2 ms 4688 KB Output is correct
3 Correct 2 ms 4688 KB Output is correct
4 Incorrect 2 ms 4856 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4688 KB Output is correct
2 Correct 2 ms 4688 KB Output is correct
3 Correct 2 ms 4688 KB Output is correct
4 Incorrect 2 ms 4856 KB Output isn't correct
5 Halted 0 ms 0 KB -