結果
問題 | No.1190 Points |
ユーザー | outline |
提出日時 | 2020-12-27 01:03:17 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,211 bytes |
コンパイル時間 | 1,559 ms |
コンパイル使用メモリ | 142,952 KB |
実行使用メモリ | 9,848 KB |
最終ジャッジ日時 | 2023-10-25 09:50:53 |
合計ジャッジ時間 | 7,248 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,348 KB |
testcase_01 | AC | 2 ms
4,348 KB |
testcase_02 | AC | 2 ms
4,348 KB |
testcase_03 | AC | 34 ms
8,128 KB |
testcase_04 | AC | 29 ms
7,592 KB |
testcase_05 | AC | 29 ms
7,192 KB |
testcase_06 | AC | 42 ms
8,980 KB |
testcase_07 | AC | 47 ms
9,756 KB |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | AC | 11 ms
6,376 KB |
testcase_15 | WA | - |
testcase_16 | AC | 7 ms
4,508 KB |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | AC | 9 ms
7,132 KB |
testcase_20 | WA | - |
testcase_21 | AC | 14 ms
5,892 KB |
testcase_22 | AC | 22 ms
7,924 KB |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | AC | 39 ms
9,244 KB |
testcase_26 | AC | 38 ms
8,980 KB |
testcase_27 | AC | 39 ms
9,244 KB |
ソースコード
#include <iostream> #include <vector> #include <algorithm> #include <cmath> #include <queue> #include <string> #include <map> #include <set> #include <stack> #include <tuple> #include <deque> #include <array> #include <numeric> #include <bitset> #include <iomanip> #include <cassert> #include <chrono> #include <random> #include <limits> #include <iterator> #include <functional> #include <sstream> #include <fstream> #include <complex> #include <cstring> #include <unordered_map> #include <unordered_set> using namespace std; using ll = long long; using P = pair<int, int>; constexpr int INF = 1001001001; // constexpr int mod = 1000000007; constexpr int mod = 998244353; template<class T> inline bool chmax(T& x, T y){ if(x < y){ x = y; return true; } return false; } template<class T> inline bool chmin(T& x, T y){ if(x > y){ x = y; return true; } return false; } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int n, m, p, s, g; cin >> n >> m >> p >> s >> g; --s, --g; vector<vector<int>> graph(n); for(int i = 0; i < m; ++i){ int u, v; cin >> u >> v; --u, --v; graph[u].emplace_back(v); graph[v].emplace_back(u); } vector<int> dist(n, INF); queue<int> que; dist[s] = 0; que.emplace(s); while(!que.empty()){ int from = que.front(); que.pop(); for(int to : graph[from]){ if(chmin(dist[to], dist[from] + 1)){ que.emplace(to); } } } vector<int> dist2(n, INF); dist2[g] = 0; que.emplace(g); while(!que.empty()){ int from = que.front(); que.pop(); for(int to : graph[from]){ if(chmin(dist2[to], dist2[from] + 1)){ que.emplace(to); } } } vector<int> ans; for(int v = 0; v < n; ++v){ if(dist[v] + dist2[v] <= p && (p - dist[v] - dist2[v]) % 2 == 0){ ans.emplace_back(v); } } if(ans.size() == 0) cout << -1 << '\n'; else{ cout << ans.size() << '\n'; for(int v : ans) cout << v + 1 << '\n'; } return 0; }