Submission #1157753

#TimeUsernameProblemLanguageResultExecution timeMemory
1157753lrnnz사이버랜드 (APIO23_cyberland)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include <iostream> #include <vector> #include <algorithm> #include <cmath> using namespace std; #define all(a) (a).begin(), (a).end() #define sz(a) (int)(a).size() #define pb push_back #define ll long long #define ui uint64_t #define ar array #define us unordered_set #define cont(set, element) ((set).find(element) != (set).end()) /********* DEBUG *********/ template <typename T> void outvec(const vector<T>& Z, int hi = INT_MAX) { int count = 0; for (const T& x : Z) { if (count >= hi) break; cout << x << ' '; count++; } cout << "\n"; } // overloaded function for raw arrays template <typename T, size_t N> void outvec(const T (&arr)[N], int hi = INT_MAX) { int count = 0; for (size_t i = 0; i < N; ++i) { if (count >= hi) break; cout << arr[i] << ' '; count++; } cout << "\n"; } /********* DEBUG *********/ const ll inf = 1e18; const int MOD = 1e9+7; const int MOD2 = 998244353; const int mxN = 200005; // Subtask arr ∈ {0,1} // DSU, find all possible starting places // Push all starting nodes to Djikstra int parent[100005]; int _find(int x){ if (parent[x] != x) parent[x] = _find(parent[x]); return parent[x]; } void _uni(int x, int y){ x = _find(x); y = _find(y); parent[x] = y; } double solve(int N, int M, int K, int H, vector<int> x, vector<int> y, vector<int> c, vector<int> arr) { for (int i = 0; i < N; i++){ parent[i] = i; } // node, cost vector<vector<pair<int,int>>> adj(N); unordered_set<int> starts = {0}; for (int i = 0; i < M; i++){ adj[x[i]].pb({y[i], c[i]}); adj[y[i]].pb({x[i], c[i]}); if (x[i] != H && y[i] != H){ _uni(x[i], y[i]); } } // cost, node vector<bool> visited(N, false); priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>> minheap; minheap.push({0, 0}); for (int i = 1; i < N; i++){ if (arr[i] == 0 && _find(i) == _find(0)){ minheap.push({0, i}); } } int cl = 0; while (minheap.size()){ pair<int,int> x = minheap.top(); minheap.pop(); int cst = x.first; int nd = x.second; visited[nd] = true; if (nd == H){ return cst; } for (auto &z : adj[nd]){ if (visited[z.first]) continue; minheap.push({cst+z.second, z.first}); } } return -1; } int main() { ios::sync_with_stdio(0); cin.tie(0); cout << solve(4, 4, 30, 3, {0, 0, 1, 2}, {1, 2, 3, 3}, {5, 4, 2, 4}, {1, 1, 1, 1}); }

Compilation message (stderr)

/usr/bin/ld: /tmp/ccH2THm7.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccw25ACG.o:cyberland.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status