Submission #749883

# Submission time Handle Problem Language Result Execution time Memory
749883 2023-05-28T20:01:41 Z 1ne Cyberland (APIO23_cyberland) C++17
68 / 100
3000 ms 27980 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));
	 dist[0][K] = 0;
	 while(!q.empty()){
	 	auto u = q.top();
	 	q.pop();
	 	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;
	 			q.push({x.first,u.y,dist[x.first][u.y]});
	 		}
	 		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;
	 				q.push({x.first,u.y - 1,dist[x.first][u.y - 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;
}
# Verdict Execution time Memory Grader output
1 Correct 22 ms 588 KB Correct.
2 Correct 21 ms 436 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 24 ms 724 KB Correct.
2 Correct 28 ms 668 KB Correct.
3 Correct 34 ms 724 KB Correct.
4 Correct 29 ms 684 KB Correct.
5 Correct 29 ms 728 KB Correct.
6 Correct 24 ms 3828 KB Correct.
7 Correct 29 ms 3700 KB Correct.
8 Correct 15 ms 7488 KB Correct.
9 Correct 26 ms 340 KB Correct.
10 Correct 26 ms 428 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 29 ms 680 KB Correct.
2 Correct 27 ms 664 KB Correct.
3 Correct 25 ms 724 KB Correct.
4 Correct 28 ms 340 KB Correct.
5 Correct 28 ms 412 KB Correct.
6 Correct 6 ms 3156 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 500 ms 23372 KB Correct.
2 Correct 799 ms 872 KB Correct.
3 Correct 687 ms 988 KB Correct.
4 Correct 728 ms 948 KB Correct.
5 Correct 610 ms 580 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 106 ms 744 KB Correct.
2 Correct 115 ms 632 KB Correct.
3 Correct 138 ms 652 KB Correct.
4 Correct 1134 ms 3644 KB Correct.
5 Correct 27 ms 340 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 31 ms 712 KB Correct.
2 Correct 32 ms 796 KB Correct.
3 Correct 50 ms 27980 KB Correct.
4 Correct 44 ms 2468 KB Correct.
5 Correct 28 ms 516 KB Correct.
6 Correct 37 ms 684 KB Correct.
# Verdict Execution time Memory Grader output
1 Execution timed out 3057 ms 6660 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3059 ms 26136 KB Time limit exceeded
2 Halted 0 ms 0 KB -