제출 #1171852

#제출 시각아이디문제언어결과실행 시간메모리
1171852rayan_bd사이버랜드 (APIO23_cyberland)C++20
컴파일 에러
0 ms0 KiB
// not my code,, code by gpt #include <bits/stdc++.h> using namespace std; const double INF = 5e18; const int mxN = 2e5+100; const int mxK = 32; double dp[mxN][mxK]; vector<pair<int, double>> adj[mxN]; bool clean[mxN]; void solve(int N, int M, int K, int H, vector<int>& x, vector<int>& y, vector<int>& c, vector<int>& arr) { // Initialize adjacency list for the linear graph for (int i = 0; i < N; ++i) adj[i].clear(); for (int i = 0; i < M; ++i) { adj[x[i]].emplace_back(y[i], c[i]); adj[y[i]].emplace_back(x[i], c[i]); } // Initialize DP table for (int i = 0; i < N; ++i) { for (int j = 0; j <= K; ++j) { dp[i][j] = INF; } } dp[0][0] = 0; // Traverse the linear graph from country 0 to country H for (int u = 0; u < N; ++u) { for (int k = 0; k <= K; ++k) { if (dp[u][k] == INF) continue; for (auto& edge : adj[u]) { int v = edge.first; double cost = edge.second; // If the next country is H, we cannot move further if (v == H) continue; // Apply the special ability of the current country if (arr[u] == 0) { // Reset the travel time to 0 dp[v][k] = min(dp[v][k], 0.0); } else if (arr[u] == 2 && k < K) { // Divide the travel time by 2 dp[v][k+1] = min(dp[v][k+1], (dp[u][k] + cost) / 2); } else { // No special ability, just add the cost dp[v][k] = min(dp[v][k], dp[u][k] + cost); } } } } // Find the minimum time to reach H with at most K divide-by-2 operations double min_time = INF; for (int k = 0; k <= K; ++k) { min_time = min(min_time, dp[H][k]); } if (min_time == INF) { cout << -1 << endl; } else { cout << min_time << endl; } }

컴파일 시 표준 에러 (stderr) 메시지

/usr/bin/ld: /tmp/ccLoPacl.o: in function `main':
grader.cpp:(.text.startup+0x71e): undefined reference to `solve(int, int, int, int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status