Submission #769951

# Submission time Handle Problem Language Result Execution time Memory
769951 2023-06-30T14:39:51 Z Dan4Life Cyberland (APIO23_cyberland) C++17
44 / 100
229 ms 8500 KB
#include "cyberland.h"
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using ar = pair<double,int>;
const int mxN = (int)1e5+10;
const double LINF = 1e105;
double ans;
int n, m, h;
bool vis[mxN];
double dis[mxN], dis2[mxN];
vector<pair<int,int>> adj[mxN];
priority_queue<ar,vector<ar>,greater<ar>> pq;
 
void dijkstra(){
	fill(vis,vis+n+1,0);
	for(int i = 0; i < n; i++) 
		if(dis[i]<LINF) pq.push({dis[i],i});
	while(!pq.empty()){
		auto [D,a] = pq.top(); pq.pop(); 
		if(vis[a] or a==h) continue; vis[a]=1;
		for(auto [b,w] : adj[a]) if(dis[b]>dis[a]+w) 
			dis[b]=dis[a]+w, pq.push({dis[b],b});
	}
	ans = min(ans, dis[h]);
}
 
double solve(int N, int M, int K, int H, vi x, vi y, vi c, vi A) {
	n = N, m = M, h = H, K = min(K, 67);
	fill(dis,dis+n,LINF); ans = LINF;
	for(int i = 0; i < n; i++) adj[i].clear();
	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]});
	dis[0]=0; dijkstra(); if(dis[h]>=LINF) return -1;
	for(int i = 0; i < n; i++)
		if(dis[i]!=LINF) dis[i]=A[i]&&i?LINF:0;
	for(int i = 0; i <= K; i++){
		dijkstra(); fill(dis2,dis2+n,LINF);
		for(int j = 0; j < n; j++)
			for(auto [u,w] : adj[j])
              	if(A[u]>1) dis2[u]=min(dis2[u],(dis[j]+w)/2);
		for(int j = 0; j < n; j++) dis[j]=dis2[j];
	}
	return ans;
}

Compilation message

cyberland.cpp: In function 'void dijkstra()':
cyberland.cpp:21:3: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   21 |   if(vis[a] or a==h) continue; vis[a]=1;
      |   ^~
cyberland.cpp:21:32: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   21 |   if(vis[a] or a==h) continue; vis[a]=1;
      |                                ^~~
# Verdict Execution time Memory Grader output
1 Incorrect 19 ms 2736 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 26 ms 2828 KB Correct.
2 Correct 31 ms 2812 KB Correct.
3 Correct 30 ms 2772 KB Correct.
4 Correct 30 ms 2792 KB Correct.
5 Correct 30 ms 2800 KB Correct.
6 Correct 30 ms 3528 KB Correct.
7 Correct 44 ms 3560 KB Correct.
8 Correct 18 ms 4308 KB Correct.
9 Correct 27 ms 2720 KB Correct.
10 Correct 26 ms 2644 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 32 ms 2804 KB Correct.
2 Correct 33 ms 2812 KB Correct.
3 Correct 29 ms 2796 KB Correct.
4 Correct 29 ms 2740 KB Correct.
5 Correct 30 ms 2644 KB Correct.
6 Correct 8 ms 3548 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 229 ms 7904 KB Correct.
2 Incorrect 148 ms 2768 KB Wrong Answer.
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 28 ms 2868 KB Correct.
2 Correct 25 ms 2920 KB Correct.
3 Correct 25 ms 2772 KB Correct.
4 Correct 32 ms 3680 KB Correct.
5 Correct 20 ms 2644 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 25 ms 2772 KB Correct.
2 Correct 21 ms 2828 KB Correct.
3 Correct 36 ms 8500 KB Correct.
4 Correct 19 ms 3540 KB Correct.
5 Correct 23 ms 2724 KB Correct.
6 Correct 24 ms 2872 KB Correct.
# Verdict Execution time Memory Grader output
1 Incorrect 91 ms 2848 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 163 ms 2832 KB Wrong Answer.
2 Halted 0 ms 0 KB -