Submission #835112

# Submission time Handle Problem Language Result Execution time Memory
835112 2023-08-23T08:34:40 Z Hydrolyzed Crocodile's Underground City (IOI11_crocodile) C++14
0 / 100
2 ms 4180 KB
#include "crocodile.h"
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

const int MxN = 100010;

struct state_t {
	int v;
	ll w;
	int state;
	bool operator < (const state_t &o) const {
		return w > o.w;
	}
	state_t(int _v, ll _w, int _state):
		v(_v), w(_w), state(_state) {}
};

vector<pair<int, ll>> adj[MxN];
bitset<MxN> out;
priority_queue<state_t> pq;
ll dist[MxN][2]; // [0] = best, [1] = secondary

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
	for(int i=0; i<M; ++i) {
		adj[R[i][0]].emplace_back(R[i][1], L[i]);
		adj[R[i][1]].emplace_back(R[i][0], L[i]);
	}
	for(int i=0; i<K; ++i) {
		out[P[i]] = true;
	}
	memset(dist, 0x3f, sizeof dist);
	for(int i=0; i<K; ++i) {
		pq.emplace(P[i], dist[P[i]][0] = 0ll, 0);
	}
	while(!pq.empty()) {
		state_t now = pq.top(); pq.pop();
		for(auto x: adj[now.v]) {
			if(now.state == 0) {
				ll nxt = now.w + x.second;	
				if(dist[x.first][0] <= nxt && dist[x.first][1] > nxt) {
					pq.emplace(x.first, dist[x.first][1] = nxt, 1);
				}
				else if(dist[x.first][0] > nxt){
					pq.emplace(x.first, dist[x.first][1] = dist[x.first][0], 1);
					dist[x.first][0] = nxt;
				}
			}
			else {
				ll nxt = now.w + x.second;
				if(dist[x.first][1] > nxt) {
					pq.emplace(x.first, dist[x.first][1] = nxt, 1);
				}
			}
		}
	}
	return dist[0][1];
}


# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 4180 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 4180 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 4180 KB Output isn't correct
2 Halted 0 ms 0 KB -