結果

問題 No.1190 Points
ユーザー mugen_1337mugen_1337
提出日時 2020-08-25 23:24:10
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 194 ms / 2,000 ms
コード長 2,305 bytes
コンパイル時間 2,401 ms
コンパイル使用メモリ 205,440 KB
実行使用メモリ 20,096 KB
最終ジャッジ日時 2024-04-24 04:58:04
合計ジャッジ時間 6,450 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 98 ms
15,616 KB
testcase_04 AC 62 ms
14,080 KB
testcase_05 AC 108 ms
13,056 KB
testcase_06 AC 81 ms
18,688 KB
testcase_07 AC 155 ms
19,712 KB
testcase_08 AC 189 ms
20,096 KB
testcase_09 AC 181 ms
18,304 KB
testcase_10 AC 194 ms
20,040 KB
testcase_11 AC 119 ms
14,208 KB
testcase_12 AC 193 ms
19,712 KB
testcase_13 AC 106 ms
12,160 KB
testcase_14 AC 22 ms
13,440 KB
testcase_15 AC 185 ms
19,584 KB
testcase_16 AC 11 ms
6,400 KB
testcase_17 AC 164 ms
18,816 KB
testcase_18 AC 60 ms
7,680 KB
testcase_19 AC 24 ms
16,640 KB
testcase_20 AC 89 ms
10,112 KB
testcase_21 AC 29 ms
10,880 KB
testcase_22 AC 37 ms
17,280 KB
testcase_23 AC 191 ms
20,096 KB
testcase_24 AC 186 ms
19,968 KB
testcase_25 AC 77 ms
19,584 KB
testcase_26 AC 58 ms
19,328 KB
testcase_27 AC 77 ms
19,584 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define mod 1000000007
using ll=long long;
const int INF=1000000000;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}
 
struct IOSetup{
    IOSetup(){
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(12);
    }
} iosetup;
 
template<typename T1,typename T2>
ostream &operator<<(ostream &os,const pair<T1,T2>&p){
    os<<p.first<<" "<<p.second;
    return os;
}
 
template<typename T>
ostream &operator<<(ostream &os,const vector<T>&v){
    for(int i=0;i<(int)v.size();i++) os<<v[i]<<(i+1==(int)v.size()?"":" ");
    return os;
}

template<typename T1,typename T2>
istream &operator>>(istream &is,pair<T1,T2>&p){
    is>>p.first>>p.second;
    return is;
}

template<typename T>
istream &operator>>(istream &is,vector<T>&v){
    for(T &x:v)is>>x;
    return is;
}

signed main(){
    int n,m,p;cin>>n>>m>>p;
    int s,t;cin>>s>>t;s--,t--;
    vector<vector<int>> g(n);
    rep(i,m){
        int u,v;cin>>u>>v;u--,v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }

    using P=pair<int,int>;

    vector<vector<int>> ds(n,vector<int>(2,INF)),dt(n,vector<int>(2,INF));

    auto fi=[&](int st,vector<vector<int>> &d){
        queue<P> que;
        d[st][0]=0;
        que.push(P(st,0));
        while(!que.empty()){
            auto [now,p]=que.front();que.pop();
            for(auto to:g[now]){
                if(chmin(d[to][p^1],d[now][p]+1)) que.push(P(to,p^1));
            }
        }
    };

    fi(s,ds);
    fi(t,dt);

    vector<int> ans;
    rep(i,n){
        if(p%2){
            // odd
            if(ds[i][0]+dt[i][1]<=p or ds[i][1]+dt[i][0]<=p)ans.push_back(i);
        }else{
            if(ds[i][0]+dt[i][0]<=p or ds[i][1]+dt[i][1]<=p)ans.push_back(i);
        }
    }
    if(ans.empty())cout<<-1<<endl;
    else{
        cout<<ans.size()<<endl;
        for(auto x:ans)cout<<x+1<<endl;
    }
    return 0;
}
0