제출 #976236

#제출 시각아이디문제언어결과실행 시간메모리
976236Tsagana사이버랜드 (APIO23_cyberland)C++17
컴파일 에러
0 ms0 KiB
// #include "cyberland.h" #include<bits/stdc++.h> #define IOS ios_base::sync_with_stdio(false);cin.tie();cout.tie(); #define all(x) x.begin(), x.end() #define int long long #define vi vector<int> #define pi pair<int, int > #define pq priority_queue #define lb lower_bound #define ub upper_bound #define pb push_back #define eb emplace_back #define mset multiset #define F first #define S second using namespace std; // START struct country { double cost[31]; }; country cnt[100001]; vector<pi> adj[100001]; vi ar; int h, D; int vs[100001]; vi takes(int s) { vi v; pq<int> q; q.push(s); while (!q.empty()) { s = q.top(); q.pop(); for (auto i: adj[s]) { if (vs[i.S]) continue ; vs[i.S] = 1; if (!ar[i.S]) v.pb(i.S); q.push(i.S); } } return v; } void dfs(int s, int k, double cos) { if (k > D) return ; if (cnt[s].cost[k] <= cos) return ; cnt[s].cost[k] = cos; // cout << s << ' ' << k << ' '; // printf("%.12lf\n", cos); if (s == h) return ; for (auto i: adj[s]) { double c = i.F; int x = i.S; dfs(x, k, c + cos); if (ar[s] == 2 && k <= D) dfs(x, k + 1, c + (cos / 2.0)); } } double solve(int N, int M, int K, int H, vi x, vi y, vi c, vi arr) { ar = arr; h = H; D = K; for (int i = 0; i < M; i++) { adj[x[i]].pb({c[i], y[i]}); adj[y[i]].pb({c[i], x[i]}); } for (int i = 0; i < N; i++) { for (int j = 0; j <= K; j++) { cnt[i].cost[j] = 1e9; } } vi v = takes(0); for (auto i: v) { adj[0].pb({0, i}); } dfs(0, 0, 0.0); double ans = cnt[H].cost[0]; for (int i = 1; i <= K; i++) { if (ans > cnt[H].cost[i]) ans = cnt[H].cost[i]; } return ans; } //END signed main() { int T; assert(1 == scanf("%lld", &T)); while (T--){ int N,M,K,H; assert(4 == scanf("%lld %lld %lld\n%lld", &N, &M, &K, &H)); std::vector<int> x(M); std::vector<int> y(M); std::vector<int> c(M); std::vector<int> arr(N); for (int i=0;i<N;i++) assert(1 == scanf("%lld", &arr[i])); for (int i=0;i<M;i++) assert(3 == scanf("%lld %lld %lld", &x[i], &y[i], &c[i])); printf("%.12lf\n", solve(N, M, K, H, x, y, c, arr)); } }

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

/usr/bin/ld: /tmp/ccRADIWs.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccoCPZrt.o:cyberland.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccRADIWs.o: in function `main':
grader.cpp:(.text.startup+0x696): 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