結果
| 問題 | No.1190 Points |
| コンテスト | |
| ユーザー |
uzzy
|
| 提出日時 | 2020-08-22 16:41:18 |
| 言語 | C++17(gcc12) (gcc 12.4.0 + boost 1.89.0) |
| 結果 |
RE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 2,038 bytes |
| 記録 | |
| コンパイル時間 | 3,001 ms |
| コンパイル使用メモリ | 238,696 KB |
| 実行使用メモリ | 22,392 KB |
| 最終ジャッジ日時 | 2026-03-08 21:47:03 |
| 合計ジャッジ時間 | 7,195 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 RE * 4 |
ソースコード
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int N, M, P;
cin >> N >> M >> P;
int S, G;
cin >> S >> G;
#define PT pair<ll, int>
vector<PT> E[200001];
rep(i, M) {
int u, v;
cin >> u >> v;
E[u * 2].pb({ 1, v * 2 + 1 });
E[u * 2 + 1].pb({ 1, v * 2 });
E[v * 2].pb({ 1, u * 2 + 1 });
E[v * 2 + 1].pb({ 1, u * 2 });
}
ll DS[200001], DG[200001];
rep1(i, N * 2) DS[i + 1] = 1e18;
rep1(i, N * 2) DG[i + 1] = 1e18;
priority_queue<PT, vector<PT>, greater<PT>> que;
DS[S * 2] = 0;
que.push(mp(0, S * 2));
while (que.size()) {
PT p = que.top();
que.pop();
int i = p.second;
if (DS[i] != p.first) continue;
for (PT p2 : E[i]) {
int j = p2.second;
ll d = DS[i] + p2.first;
if (DS[j] > d) {
DS[j] = d;
que.push(mp(d, j));
}
}
}
DG[G * 2] = 0;
que.push(mp(0, G * 2));
while (que.size()) {
PT p = que.top();
que.pop();
int i = p.second;
if (DG[i] != p.first) continue;
for (PT p2 : E[i]) {
int j = p2.second;
ll d = DG[i] + p2.first;
if (DG[j] > d) {
DG[j] = d;
que.push(mp(d, j));
}
}
}
vector<int> kotae;
rep1(i, N) {
if (P % 2) {
ll tmp = min(DS[i * 2] + DG[i * 2 + 1], DS[i * 2 + 1] + DG[i * 2]);
if (tmp <= P) {
kotae.pb(i);
}
}
else {
ll tmp = min(DS[i * 2] + DG[i * 2], DS[i * 2 + 1] + DG[i * 2 + 1]);
if (tmp <= P) {
kotae.pb(i);
}
}
}
int kazu = kotae.size();
if (kazu == 0) co(-1);
else {
co(kotae.size());
rep(i, kotae.size()) co(kotae[i]);
}
Would you please return 0;
}
uzzy