제출 #1078852

#제출 시각아이디문제언어결과실행 시간메모리
1078852Rawlat_vanak사이버랜드 (APIO23_cyberland)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define speedIO ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define mod 1000000007 #define f first #define s second #define pii pair<double,int> #define pb push_back vector<vector<pii>> graph; vector<int> parent,sz; int find(int u){ while(u!=parent[u]) u=parent[u]; return parent[u]; } void unite(int a,int b){ a=find(a);b=find(b); if(a==b) return; if(sz[b]>sz[a]) swap(a,b); parent[b]=a; sz[a]+=sz[b]; } double solve(int N,int M,int K,int H, vector<int> x, vector<int> y, vector<int> c, vector<int> arr){ int n=N,m=M,k=K,h=H; parent.resize(n); for(int i=0;i<n;i++){ parent[i]=i; } sz.resize(n,1); graph.resize(n); for(int i=0;i<n;i++){ graph[x[i]].pb({y[i],c[i]}); graph[y[i]].pb({x[i],c[i]}); unite(x[i],y[i]); } priority_queue<pii> q; vector<vector<double>> dist(n,vector<double>(k+1,1e15)); vector<bool> visited(n,false); for(int j=0;j<=k;j++){ if(find(0)==find(h)){ dist[0][j]=0; q.push({0,0}); } visited[0]=false; for(int i=1;i<n;i++){ visited[i]=false; if(arr[i]==0 and find(i)==find(h)){ dist[i][j]=0; q.push({0,i}); } } while(!q.empty()){ pii u=q.top(); int v=u.s; q.pop(); if(visited[v]) continue; visited[v]=true; for(pii w: graph[v]){ int x=w.f,c=w.s; if(arr[x]==1){ if(dist[w.f][j]>dist[v][j]+w.s){ dist[w.f][j]=dist[v][j]+w.s; q.push({-dist[w.f][j],w.f}); } }else if(arr[x]==2){ if(dist[w.f][j]>dist[v][j]+w.s){ dist[w.f][j]=dist[v][j]+w.s; q.push({-dist[w.f][j],w.f}); } if(j>=1){ if(dist[x][j]>(dist[v][j-1]+c)/2){ dist[x][j]=(dist[v][j-1]+c)/2; q.push({-dist[x][j],x}); } } } } } } double ans=1e15; for(int i=0;i<=k;i++){ ans=min(ans,dist[h][i]); } for(int i=0;i<n;i++){ graph[i].clear(); dist[i].clear(); parent.clear(); visited.clear(); sz.clear(); } if(ans==1e15){ return -1; }else{ return ans; } }

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

cyberland.cpp: In function 'double solve(long long int, long long int, long long int, long long int, std::vector<long long int>, std::vector<long long int>, std::vector<long long int>, std::vector<long long int>)':
cyberland.cpp:29:10: warning: unused variable 'm' [-Wunused-variable]
   29 |  int n=N,m=M,k=K,h=H;
      |          ^
/usr/bin/ld: /tmp/ccXB5F2l.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