結果

問題 No.1190 Points
ユーザー ChanyuhChanyuh
提出日時 2020-08-23 12:38:17
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 341 ms / 2,000 ms
コード長 2,572 bytes
コンパイル時間 1,560 ms
コンパイル使用メモリ 138,144 KB
実行使用メモリ 23,312 KB
最終ジャッジ日時 2024-04-23 17:33:54
合計ジャッジ時間 7,427 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 157 ms
16,692 KB
testcase_04 AC 110 ms
15,364 KB
testcase_05 AC 163 ms
13,860 KB
testcase_06 AC 153 ms
20,856 KB
testcase_07 AC 233 ms
21,700 KB
testcase_08 AC 284 ms
21,332 KB
testcase_09 AC 289 ms
21,584 KB
testcase_10 AC 290 ms
21,352 KB
testcase_11 AC 209 ms
17,256 KB
testcase_12 AC 277 ms
21,324 KB
testcase_13 AC 196 ms
15,824 KB
testcase_14 AC 25 ms
11,836 KB
testcase_15 AC 333 ms
22,672 KB
testcase_16 AC 17 ms
6,656 KB
testcase_17 AC 305 ms
21,264 KB
testcase_18 AC 109 ms
13,620 KB
testcase_19 AC 18 ms
13,244 KB
testcase_20 AC 165 ms
15,372 KB
testcase_21 AC 46 ms
11,092 KB
testcase_22 AC 46 ms
16,180 KB
testcase_23 AC 334 ms
23,312 KB
testcase_24 AC 341 ms
23,288 KB
testcase_25 AC 167 ms
23,284 KB
testcase_26 AC 104 ms
22,388 KB
testcase_27 AC 183 ms
23,272 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, int> LP;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

template <typename T>
vector<T> dijkstra(int s,vector<vector<pair<T,int>>> & G){
    const T inf=INF;
    using edge=pair<T,int>;
    priority_queue<edge, vector<edge>, greater<edge> > que;
    int n=G.size();
    vector<T> d(n,inf);
    vector<int> b(n,-1);
    d[s]=0;
    que.emplace(d[s],s);
    while (!que.empty()){
        edge p = que.top(); que.pop();
        int v = p.second;
        if (d[v]<p.first) continue;
        for(auto& e:G[v]){
            int u=e.second;
            T c=e.first;
            if (d[u]>d[v]+c){
                d[u]=d[v]+c;
                b[u]=v;
                que.emplace(d[u],u);
            }
        }
    }
    return d;
}

int n,m,p;
int s,g;

void solve(){
    cin >> n >> m >> p;
    cin >> s >> g;s--;g--;
    vector<vector<LP>> G(2*n);
    rep(i,m){
        int u,v;cin >> u >> v;u--;v--;
        rep(j,2){
            G[2*v+j].push_back(LP(1,2*u+1-j));
            G[2*u+j].push_back(LP(1,2*v+1-j));
        }
    }
    vector<ll> ds=dijkstra(2*s,G),dg=dijkstra(2*g+p%2,G);
    vector<int> ans={};
    // rep(i,2*n){
    //     cout << i/2 << " " << i%2 << " " << ds[i] << " " << dg[i] << endl;
    // }
    rep(i,n){
        ll mi1=ds[2*i]+dg[2*i],mi2=ds[2*i+1]+dg[2*i+1];
        if(min(mi1,mi2)<=p){
            ans.push_back(i+1);
        }
    }
    if(ans.empty()){
        cout << -1 << endl;
        return;
    }
    cout << ans.size() << endl;
    rep(i,ans.size()){
        cout << ans[i] << endl;
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}
0