結果
問題 | No.1190 Points |
ユーザー | cn_449 |
提出日時 | 2020-08-22 14:13:39 |
言語 | C++17 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 311 ms / 2,000 ms |
コード長 | 2,465 bytes |
コンパイル時間 | 1,754 ms |
コンパイル使用メモリ | 153,656 KB |
実行使用メモリ | 57,948 KB |
最終ジャッジ日時 | 2024-04-23 08:35:29 |
合計ジャッジ時間 | 8,265 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,816 KB |
testcase_01 | AC | 2 ms
6,944 KB |
testcase_02 | AC | 2 ms
6,940 KB |
testcase_03 | AC | 174 ms
42,588 KB |
testcase_04 | AC | 145 ms
38,616 KB |
testcase_05 | AC | 123 ms
34,560 KB |
testcase_06 | AC | 248 ms
54,012 KB |
testcase_07 | AC | 276 ms
56,736 KB |
testcase_08 | AC | 239 ms
56,864 KB |
testcase_09 | AC | 236 ms
53,184 KB |
testcase_10 | AC | 246 ms
56,748 KB |
testcase_11 | AC | 160 ms
40,568 KB |
testcase_12 | AC | 252 ms
55,988 KB |
testcase_13 | AC | 218 ms
34,508 KB |
testcase_14 | AC | 90 ms
32,720 KB |
testcase_15 | AC | 295 ms
56,256 KB |
testcase_16 | AC | 30 ms
13,252 KB |
testcase_17 | AC | 262 ms
53,372 KB |
testcase_18 | AC | 90 ms
24,056 KB |
testcase_19 | AC | 87 ms
40,164 KB |
testcase_20 | AC | 131 ms
30,464 KB |
testcase_21 | AC | 77 ms
27,156 KB |
testcase_22 | AC | 122 ms
45,352 KB |
testcase_23 | AC | 310 ms
57,788 KB |
testcase_24 | AC | 311 ms
57,768 KB |
testcase_25 | AC | 245 ms
57,776 KB |
testcase_26 | AC | 211 ms
57,300 KB |
testcase_27 | AC | 256 ms
57,948 KB |
ソースコード
#include <iostream> #include <vector> #include <algorithm> #include <cmath> #include <string> #include <queue> #include <stack> #include <set> #include <map> #include <iomanip> #include <utility> #include <tuple> #include <functional> #include <bitset> #include <cassert> #include <complex> #include <stdio.h> #include <time.h> #include <numeric> #include <random> #include <unordered_map> #include <unordered_set> #define all(a) a.begin(),a.end() #define rep(i, n) for (ll i = 0; i < (n); i++) #define pb push_back #define debug(x) cerr << __LINE__ << ' ' << #x << ':' << x << '\n' #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef pair<ll, ll> P; typedef complex<ld> com; constexpr int inf = 1000000010; constexpr ll INF = 1000000000000000010; constexpr ld eps = 1e-12; constexpr ld pi = 3.141592653589793238; template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; } template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; } vector<vector<ll>> bfs(int s, vector<vector<vector<P>>> graph) { int n = graph.size(); queue<P> que; que.push({ s,0 }); vector<vector<ll>> res(n, { inf,inf }); vector<vector<bool>> vis(n, vector<bool>(2)); res[s][0] = 0; vis[s][0] = 1; while (!que.empty()) { P p = que.front(); que.pop(); ll pf = p.first, ps = p.second; for (P nxt : graph[pf][ps]) { ll nf = nxt.first; ll ns = nxt.second; if (!vis[nf][ns]) { vis[nf][ns] = 1; res[nf][ns] = res[pf][ps] + 1; que.push({ nf,ns }); } } } return res; } int main() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); int n, m, p; cin >> n >> m >> p; int s, g; cin >> s >> g; s--; g--; vector<vector<vector<P>>> graph(n, vector<vector<P>>(2, vector<P>())); rep(i, m) { int u, v; cin >> u >> v; u--; v--; rep(j, 2){ graph[u][j].pb({ v,j ^ 1 }); graph[v][j].pb({ u,j ^ 1 }); } } vector<vector<ll>> x = bfs(s, graph); vector<vector<ll>> y = bfs(g, graph); int check = p & 1; vector<int> ans; rep(i, n) { int val1 = x[i][0] + y[i][0 ^ check]; int val2 = x[i][1] + y[i][1 ^ check]; if (val1 <= p || val2 <= p) ans.pb(i); } if (ans.size() == 0) { cout << "-1\n"; return 0; } cout << ans.size() << '\n'; for (int i : ans) cout << i + 1 << '\n'; }