Submission #758684

# Submission time Handle Problem Language Result Execution time Memory
758684 2023-06-15T06:08:46 Z OrazB Cyberland (APIO23_cyberland) C++17
44 / 100
806 ms 2097152 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_set;
//set.find_by_order(x) x-position value
//set.order_of_key(x) number of strictly less elements don't need *set.??
#define N 100005
#define wr cout << "Continue debugging\n";
#define all(x) (x).begin(), (x).end()
#define ll long long int
#define pii pair <int, int>
#define pb push_back
#define ff first
#define ss second

vector<pii> E[N];

void dfs(int nd, int h, vector<int> arr, priority_queue<pii> &q, vector<ll> &dis, vector<bool> &vis){
	if (!arr[nd]){
		q.push({0, nd});
		dis[nd] = 0;
	} 
	vis[nd] = 1;
	for (auto i : E[nd]){
		if (vis[i.ff] or i.ff == h) continue;
		dfs(i.ff, h, arr, q, dis, vis);	
	}
}

double solve(int n, int m, int k, int h, vector<int> x, vector<int> y, vector<int> c, vector<int> arr){
	for (int i = 0; i < n; i++) E[i].clear();
	for (int i = 0; i < m; i++){
		E[x[i]].pb({y[i], c[i]});
		E[y[i]].pb({x[i], c[i]});	
	}
	vector<bool> vis(n, 0);
	vector<ll> dis(n, 1e18);
	priority_queue<pii> q;
	q.push({0, 0});
	dis[0] = 0;
	dfs(0, h, arr, q, dis, vis);
	while(!q.empty()){
		int x = q.top().ss;
		q.pop();
		for (auto i : E[x]){
			if (dis[i.ff] > dis[x]+i.ss){
				dis[i.ff] = dis[x]+i.ss;
				q.push({i.ss, i.ff});
			}
		}
	}
	if (dis[h] == 1e18) return double(-1);
	return double(dis[h]);
}

// int main ()
// {
// }	
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 2816 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 19 ms 2900 KB Correct.
2 Correct 27 ms 2868 KB Correct.
3 Correct 23 ms 2836 KB Correct.
4 Correct 24 ms 2832 KB Correct.
5 Correct 22 ms 2900 KB Correct.
6 Correct 74 ms 4216 KB Correct.
7 Correct 88 ms 4096 KB Correct.
8 Correct 191 ms 5744 KB Correct.
9 Correct 21 ms 2644 KB Correct.
10 Correct 26 ms 2644 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 27 ms 2848 KB Correct.
2 Correct 26 ms 2864 KB Correct.
3 Correct 24 ms 2856 KB Correct.
4 Correct 22 ms 2736 KB Correct.
5 Correct 23 ms 2692 KB Correct.
6 Correct 14 ms 3924 KB Correct.
# Verdict Execution time Memory Grader output
1 Runtime error 806 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 39 ms 3804 KB Correct.
2 Correct 36 ms 3804 KB Correct.
3 Correct 43 ms 3964 KB Correct.
4 Correct 123 ms 57968 KB Correct.
5 Correct 26 ms 2748 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 35 ms 3912 KB Correct.
2 Correct 25 ms 3752 KB Correct.
3 Correct 35 ms 8608 KB Correct.
4 Correct 72 ms 59312 KB Correct.
5 Correct 23 ms 2736 KB Correct.
6 Correct 28 ms 3824 KB Correct.
# Verdict Execution time Memory Grader output
1 Incorrect 37 ms 3840 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 33 ms 3844 KB Wrong Answer.
2 Halted 0 ms 0 KB -