답안 #749886

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
749886 2023-05-28T20:06:16 Z 1ne 사이버랜드 (APIO23_cyberland) C++17
13 / 100
955 ms 30896 KB
#include "cyberland.h"
#include <bits/stdc++.h>
#include <vector>
using namespace std;
struct node{
  int x,y;
  double v;
  bool operator < (const node& P)const{
  	return P.v < v;
  }
};
double solve(int N, int M, int K, int H, std::vector<int> x, std::vector<int> y, std::vector<int> c, std::vector<int> arr) {
	 vector<vector<pair<int,int>>>adj(N);
	 for (int i = 0;i<M;++i){
	 	adj[x[i]].push_back({y[i],c[i]});
	 	adj[y[i]].push_back({x[i],c[i]});
	 }
	 K = min(100,K);	
	 priority_queue<node>q;
	 q.push({0,K,0});
	 vector<vector<double>>dist(N,vector<double>(K + 1,1e12));
	 vector<vector<int>>visited(N,vector<int>(K + 1,0));
	 dist[0][K] = 0;
	 visited[0][K] = 1;
	 while(!q.empty()){
	 	auto u = q.top();
	 	q.pop();          
	 	visited[u.x][u.y] = 0;
	 	if (u.x == H)continue;
	 	if (u.v != dist[u.x][u.y])continue;
	 	for (auto x:adj[u.x]){
	 		long long v = x.second;
	 		if (arr[x.first] == 0){
	 			v = -dist[u.x][u.y];	
	 		}
	 		if (dist[x.first][u.y] > dist[u.x][u.y] + v){
	 			dist[x.first][u.y] = dist[u.x][u.y] + v;
	 			if (!visited[x.first][u.y]){
	 				q.push({x.first,u.y,dist[x.first][u.y]});
	 				visited[x.first][u.y] = 1;	
	 			}
	 		}
	 		if (arr[x.first] == 2 && u.y > 0){
	 			if (dist[x.first][u.y - 1] > (dist[u.x][u.y] + x.second)/2){
	 				dist[x.first][u.y - 1] = (dist[u.x][u.y] + x.second)/2;
	 				if (!visited[x.first][u.y - 1]){
	 					q.push({x.first,u.y - 1,dist[x.first][u.y - 1]});
	 					visited[x.first][u.y - 1] = 1;
	 				}	
	 			}
	 			//nx = dist[u.first][u.second] + x.second)/2 + 2 * vx) / 2 + 2 * vx ) / 2 
	 		}		
	 	}
	 }
	 double ans = 1e12;
	 for (int i = 0;i<=K;++i){
	 	ans = min(ans,dist[H][i]);
	 }	
	 if (ans == 1e12)return -1;		
	 return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 460 KB Correct.
2 Correct 22 ms 452 KB Correct.
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 840 KB Correct.
2 Correct 31 ms 832 KB Correct.
3 Correct 30 ms 828 KB Correct.
4 Correct 32 ms 856 KB Correct.
5 Correct 31 ms 936 KB Correct.
6 Correct 29 ms 5516 KB Correct.
7 Correct 36 ms 5420 KB Correct.
8 Correct 20 ms 10708 KB Correct.
9 Correct 30 ms 444 KB Correct.
10 Correct 30 ms 464 KB Correct.
# 결과 실행 시간 메모리 Grader output
1 Incorrect 29 ms 824 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 347 ms 30896 KB Correct.
2 Incorrect 472 ms 904 KB Wrong Answer.
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 26 ms 836 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 29 ms 864 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 276 ms 1008 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 955 ms 2196 KB Wrong Answer.
2 Halted 0 ms 0 KB -