0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-23 18:28:47 +00:00

#1604. 【2022.10.5 联考】骑车(bicycle)

https://sjzezoj.com/submission/59585
This commit is contained in:
Baoshuo Ren 2022-10-05 22:11:43 +08:00
parent beaef8d0d2
commit 5b51138567
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
46 changed files with 241 additions and 0 deletions

106
S2OJ/1604/1604.cpp Normal file
View File

@ -0,0 +1,106 @@
#include <iostream>
#include <algorithm>
#include <array>
#include <functional>
#include <limits>
#include <queue>
#include <tuple>
#include <utility>
#include <vector>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 1e5 + 5;
int n, m;
long long s, alt[N];
std::vector<long long> alts;
std::vector<std::pair<int, long long>> g[N];
std::array<bool, N> vis;
std::array<long long, N> dist;
void dijkstra(long long limit) {
std::fill(vis.begin(), vis.end(), false);
std::fill(dist.begin(), dist.end(), std::numeric_limits<long long>::max() / 3);
std::priority_queue<std::pair<long long, int>, std::vector<std::pair<int, int>>, std::greater<std::pair<int, int>>> q;
q.emplace(0, 1);
dist[1] = 0;
while (!q.empty()) {
int u = q.top().second;
q.pop();
if (vis[u]) continue;
vis[u] = true;
for (auto e : g[u]) {
int v = e.first;
long long w = e.second;
if (dist[v] > dist[u] + w && alt[v] - alt[u] <= limit) {
dist[v] = dist[u] + w;
q.emplace(dist[v], v);
}
}
}
}
bool check(int x) {
dijkstra(alts[x]);
return dist[n] <= s;
}
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> m >> s;
for (int i = 1; i <= n; i++) {
cin >> alt[i];
}
for (int i = 1; i <= m; i++) {
int u, v;
long long w;
cin >> u >> v >> w;
g[u].emplace_back(v, w);
alts.emplace_back(alt[v] - alt[u]);
g[v].emplace_back(u, w);
alts.emplace_back(alt[u] - alt[v]);
}
std::sort(alts.begin(), alts.end());
alts.erase(std::unique(alts.begin(), alts.end()), alts.end());
int l = 0,
r = alts.size() - 1,
res = alts.size();
while (l <= r) {
int mid = l + r >> 1;
if (check(mid)) {
r = mid - 1;
res = mid;
} else {
l = mid + 1;
}
}
if (res == alts.size()) {
cout << "NO" << endl;
} else {
cout << alts[res] << endl;
}
return 0;
}

BIN
S2OJ/1604/data/bicycle1.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1604/data/bicycle1.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1604/data/bicycle10.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1604/data/bicycle10.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1604/data/bicycle11.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1604/data/bicycle11.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1604/data/bicycle12.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1604/data/bicycle12.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1604/data/bicycle13.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1604/data/bicycle13.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1604/data/bicycle14.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1604/data/bicycle14.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1604/data/bicycle15.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1604/data/bicycle15.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1604/data/bicycle16.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1604/data/bicycle16.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1604/data/bicycle17.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1604/data/bicycle17.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1604/data/bicycle18.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1604/data/bicycle18.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1604/data/bicycle19.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1604/data/bicycle19.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1604/data/bicycle2.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1604/data/bicycle2.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1604/data/bicycle20.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1604/data/bicycle20.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1604/data/bicycle3.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1604/data/bicycle3.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1604/data/bicycle4.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1604/data/bicycle4.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1604/data/bicycle5.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1604/data/bicycle5.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1604/data/bicycle6.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1604/data/bicycle6.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1604/data/bicycle7.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1604/data/bicycle7.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1604/data/bicycle8.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1604/data/bicycle8.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1604/data/bicycle9.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1604/data/bicycle9.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1604/data/ex_bicycle1.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1604/data/ex_bicycle1.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1604/data/ex_bicycle2.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1604/data/ex_bicycle2.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1604/data/problem.conf (Stored with Git LFS) Normal file

Binary file not shown.