제출 #977719

#제출 시각아이디문제언어결과실행 시간메모리
977719Unforgettablepl사이버랜드 (APIO23_cyberland)C++17
5 / 100
21 ms4188 KiB
#include <bits/stdc++.h> using namespace std; #define int long long double solve(int32_t N, int32_t M, int32_t K, int32_t H, vector<int32_t> x, vector<int32_t> y, vector<int32_t> c, vector<int32_t> arr) { if(N==2){ return M ? c[0] : -1; } double ans = 3e9; vector<int32_t > lookup; if(H==1)lookup = {0,1,2}; else {lookup = {0,2,1};swap(arr[2],arr[1]);} int c1=2e9+1,c2=2e9+1,c3=2e9+1; for(int i=0;i<M;i++){ x[i] = lookup[x[i]]; y[i] = lookup[y[i]]; if(x[i]>y[i])swap(x[i],y[i]); if(x[i]==0 and y[i]==1)c1=c[i]; if(x[i]==0 and y[i]==2)c2=c[i]; if(x[i]==1 and y[i]==2)c3=c[i]; } if(c1<=2e9)ans=min(ans,(double)c1); if(c2<=2e9 and c3<=2e9){ if(arr[2]==0)ans=min(ans,(double)c3); else if(arr[2]==2 and K)ans=min(ans,(double)(c2)/(double)(2)+c3); else ans = min(ans,(double)(c2+c3)); } return ans>2e9 ? -1 : ans; } //int32_t main() { // int32_t T; // assert(1 == scanf("%d", &T)); // while (T--){ // int32_t N,M,K,H; // assert(4 == scanf("%d %d %d\n%d", &N, &M, &K, &H)); // std::vector<int32_t> x(M); // std::vector<int32_t> y(M); // std::vector<int32_t> c(M); // std::vector<int32_t> arr(N); // for (int32_t i=0;i<N;i++) // assert(1 == scanf("%d", &arr[i])); // for (int32_t i=0;i<M;i++) // assert(3 == scanf("%d %d %d", &x[i], &y[i], &c[i])); // printf("%.12lf\n", solve(N, M, K, H, x, y, c, arr)); // } //}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...