結果

問題 No.1190 Points
ユーザー hiro71687khiro71687k
提出日時 2023-04-10 16:13:18
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,516 bytes
コンパイル時間 4,551 ms
コンパイル使用メモリ 259,864 KB
実行使用メモリ 14,508 KB
最終ジャッジ日時 2024-04-15 20:36:27
合計ジャッジ時間 10,684 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 113 ms
11,008 KB
testcase_04 AC 71 ms
10,112 KB
testcase_05 AC 141 ms
9,472 KB
testcase_06 AC 89 ms
12,416 KB
testcase_07 AC 165 ms
13,824 KB
testcase_08 AC 220 ms
13,880 KB
testcase_09 AC 205 ms
13,616 KB
testcase_10 AC 222 ms
13,948 KB
testcase_11 AC 144 ms
10,752 KB
testcase_12 AC 199 ms
13,968 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll=long long;
using ld=long double;
ld pie=3.141592653589793;
ll inf=144494;
ll mod=1000000007;
int main(){
    ll n,m,p;
    cin >> n >> m >> p;
    ll s,gg;
    cin >> s >> gg;
    s--,gg--;
    vector<vector<ll>>g(n);
    for (ll i = 0; i < m; i++)
    {
        ll a,b;
        cin >> a >> b;
        a--,b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    vector<ll>a(n,inf),b(n,inf);
    a[s]=0;
    queue<ll>que;
    que.push(s);
    vector<ll>memo(n,0);
    while (!que.empty())
    {
        ll v=que.front();
        que.pop();
        memo[v]=0;
        for (ll i = 0; i < g[v].size(); i++)
        {
            if (a[g[v][i]]>b[v]+1)
            {
                a[g[v][i]]=b[v]+1;
                if (memo[g[v][i]]==0)
                {
                    que.push(g[v][i]);
                    memo[g[v][i]]=1;
                }
            }
            if (b[g[v][i]]>a[v]+1)
            {
                b[g[v][i]]=a[v]+1;
                if (memo[g[v][i]]==0)
                {
                    que.push(g[v][i]);
                    memo[g[v][i]]=1;
                }
            }
        }
    }
    vector<ll>aa(n,inf),bb(n,inf);
    aa[gg]=0;
    que.push(gg);
    while (!que.empty())
    {
        ll v=que.front();
        que.pop();
        memo[v]=0;
        for (ll i = 0; i < g[v].size(); i++)
        {
            if (aa[g[v][i]]>bb[v]+1)
            {
                aa[g[v][i]]=bb[v]+1;
                if (memo[g[v][i]]==0)
                {
                    que.push(g[v][i]);
                    memo[g[v][i]]=1;
                }
            }
            if (bb[g[v][i]]>aa[v]+1)
            {
                bb[g[v][i]]=aa[v]+1;
                if (memo[g[v][i]]==0)
                {
                    que.push(g[v][i]);
                    memo[g[v][i]]=1;
                }
            }
        }
    }
    vector<ll>ans;
    for (ll i = 0; i < n; i++)
    {
        if (p%2)
        {
            if (a[i]+bb[i]<=p||b[i]+aa[i]<=p)
            {
                ans.push_back(i);
            }
        }else{
            if (a[i]+aa[i]<=p||b[i]+bb[i]<=p)
            {
                ans.push_back(i);
            }
        }
    }
    if (ans.empty())
    {
        cout << -1 << endl;
        return 0;
    }
    
    cout << ans.size() << endl;
    for (ll i = 0; i < ans.size(); i++)
    {
        cout << ans[i]+1 << endl;
    }
    
}
0