結果
問題 | No.1190 Points |
ユーザー | akun0716 |
提出日時 | 2020-10-17 00:01:51 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,892 bytes |
コンパイル時間 | 937 ms |
コンパイル使用メモリ | 91,420 KB |
実行使用メモリ | 12,136 KB |
最終ジャッジ日時 | 2023-09-28 06:43:55 |
合計ジャッジ時間 | 6,056 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 2 ms
4,376 KB |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | AC | 53 ms
11,480 KB |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | AC | 14 ms
7,600 KB |
testcase_15 | WA | - |
testcase_16 | AC | 8 ms
4,652 KB |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | AC | 11 ms
8,268 KB |
testcase_20 | WA | - |
testcase_21 | AC | 16 ms
6,808 KB |
testcase_22 | AC | 23 ms
9,464 KB |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | AC | 51 ms
11,760 KB |
testcase_26 | AC | 47 ms
11,164 KB |
testcase_27 | AC | 50 ms
11,696 KB |
ソースコード
#include <iostream> #include<vector> #include<algorithm> #include<string> #include<map> #include<set> #include<stack> #include<queue> #include<math.h> using namespace std; typedef long long ll; #define int long long #define double long double typedef vector<int> VI; typedef pair<int, int> pii; typedef vector<pii> VP; typedef vector<string> VS; typedef priority_queue<int> PQ; template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; } #define fore(i,a) for(auto &i:a) #define REP(i,n) for(int i=0;i<n;i++) #define eREP(i,n) for(int i=0;i<=n;i++) #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define eFOR(i,a,b) for(int i=(a);i<=(b);++i) #define SORT(c) sort((c).begin(),(c).end()) #define rSORT(c) sort((c).rbegin(),(c).rend()) #define LB(x,a) lower_bound((x).begin(),(x).end(),(a)) #define UB(x,a) upper_bound((x).begin(),(x).end(),(a)) #define INF 1000000000 #define LLINF 9223372036854775807 #define mod 1000000007 #define eps 1e-12 //priority_queue<int,vector<int>, greater<int> > q2; int N, M, P, s, g; vector<VI> G; VI d; int q[200005]; void bfs(int s) { REP(i, N)d[i] = INF; int qh = 0, qt = 0; q[qh++] = s; d[s] = 0; while (qt < qh) { int x = q[qt++]; for (int y : G[x]) { if (d[y] == INF) { d[y] = d[x] + 1; q[qh++] = y; } } } } signed main() { cin.tie(0); ios::sync_with_stdio(false); cin >> N >> M >> P >> s >> g; G.resize(N); d.resize(N); s--; g--; REP(i, M) { int v, u; cin >> u >> v; u--; v--; G[v].push_back(u); G[u].push_back(v); } VI ans; bfs(s); VI dis1 = d; bfs(g); VI dis2 = d; REP(i, N) if (dis1[i] + dis2[i] == P)ans.push_back(i); if (ans.size() == 0) { cout << -1 << endl; return 0; } SORT(ans); cout << ans.size() << endl; fore(i, ans)cout << i + 1 << '\n'; return 0; }