結果

問題 No.1190 Points
ユーザー pes_magicpes_magic
提出日時 2020-08-22 14:49:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,365 bytes
コンパイル時間 884 ms
コンパイル使用メモリ 80,900 KB
実行使用メモリ 16,252 KB
最終ジャッジ日時 2024-04-23 09:15:21
合計ジャッジ時間 6,165 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 122 ms
12,656 KB
testcase_04 AC 76 ms
11,564 KB
testcase_05 AC 123 ms
10,752 KB
testcase_06 AC 95 ms
14,844 KB
testcase_07 AC 182 ms
15,896 KB
testcase_08 AC 219 ms
16,236 KB
testcase_09 AC 210 ms
14,828 KB
testcase_10 AC 223 ms
16,252 KB
testcase_11 AC 154 ms
11,648 KB
testcase_12 AC 194 ms
15,984 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 123 ms
9,216 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <queue>

using namespace std;

const int INF = 1LL << 25;

vector<int> getDist(const vector<vector<int>>& g, int start){
    queue<int> qu; qu.emplace(start);
    vector<int> dist(g.size(), INF);
    dist[start] = 0;
    while(!qu.empty()){
        int p = qu.front(); qu.pop();
        for(auto& t : g[p]){
            if(dist[t] <= dist[p]+1) continue;
            dist[t] = dist[p] + 1;
            qu.push(t);
        }
    }
    return dist;
}

int main(){
    int N, M, P;
    while(cin >> N >> M >> P){
        int S, G; cin >> S >> G;
        --S; --G;
        vector<vector<int>> g(2*N);
        for(int i=0;i<M;i++){
            int u, v; cin >> u >> v;
            --u; --v;
            g[u].push_back(N+v);
            g[v].push_back(N+u);
            g[N+u].push_back(v);
            g[N+v].push_back(u);
        }
        auto s = getDist(g, S);
        auto e = getDist(g, G);
        vector<int> res;
        for(int i=0;i<N;i++){
            bool ok = false;
            for(int j=0;j<2;j++){
                if(s[i+j*N] + e[i+(P%2+j)%2*N] <= P) ok = true;
            }
            if(ok) res.push_back(i+1);
        }
        if(res.empty()){
            cout << -1 << endl;
        } else {
            cout << res.size() << endl;
            for(auto& t : res) cout << t << endl;
        }
    }
}
0