結果

問題 No.2674 k-Walk on Bipartite
ユーザー nononnonon
提出日時 2024-03-15 22:24:14
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,041 bytes
コンパイル時間 2,528 ms
コンパイル使用メモリ 211,744 KB
実行使用メモリ 17,752 KB
最終ジャッジ日時 2024-03-15 22:24:21
合計ジャッジ時間 5,668 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
10,328 KB
testcase_01 AC 4 ms
10,328 KB
testcase_02 AC 5 ms
10,328 KB
testcase_03 AC 5 ms
10,328 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 4 ms
10,328 KB
testcase_07 AC 84 ms
16,088 KB
testcase_08 AC 98 ms
15,192 KB
testcase_09 AC 72 ms
15,960 KB
testcase_10 AC 134 ms
16,216 KB
testcase_11 AC 77 ms
15,064 KB
testcase_12 AC 120 ms
15,576 KB
testcase_13 AC 68 ms
15,320 KB
testcase_14 AC 17 ms
12,888 KB
testcase_15 AC 149 ms
16,856 KB
testcase_16 AC 98 ms
16,600 KB
testcase_17 AC 97 ms
14,936 KB
testcase_18 AC 38 ms
13,656 KB
testcase_19 AC 88 ms
15,832 KB
testcase_20 AC 71 ms
15,832 KB
testcase_21 AC 105 ms
15,576 KB
testcase_22 AC 146 ms
17,752 KB
testcase_23 AC 4 ms
10,328 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 5 ms
10,328 KB
testcase_27 AC 4 ms
10,328 KB
testcase_28 AC 5 ms
10,328 KB
testcase_29 AC 4 ms
10,328 KB
testcase_30 AC 5 ms
10,328 KB
testcase_31 AC 4 ms
10,328 KB
testcase_32 AC 5 ms
10,328 KB
testcase_33 AC 5 ms
10,328 KB
testcase_34 AC 5 ms
10,328 KB
testcase_35 AC 4 ms
10,328 KB
testcase_36 AC 4 ms
10,328 KB
testcase_37 AC 6 ms
10,328 KB
testcase_38 AC 5 ms
10,328 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/dsu>
using namespace std;
int N,M,s,t,K,dist[2<<17];
vector<int>G[2<<17];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>N>>M>>s>>t>>K;
    s--,t--;
    atcoder::dsu uf(2*N),uf2(N);
    for(;M--;)
    {
        int u,v;
        cin>>u>>v;
        u--,v--;
        G[u].push_back(v);
        G[v].push_back(u);
        uf.merge(u,v+N);
        uf.merge(u+N,v);
        uf2.merge(u,v);
    }
    for(int i=0;i<N;i++)dist[i]=1<<30;
    dist[s]=0;
    queue<int>q;
    q.push(s);
    while(!q.empty())
    {
        int u=q.front();
        q.pop();
        for(int v:G[u])if(dist[v]>dist[u]+1)
        {
            dist[v]=dist[u]+1;
            q.push(v);
        }
    }
    if(dist[t]<=K&&(K-dist[t])%2==0)
    {
        cout<<"Yes\n";
        return 0;
    }
    if(uf2.same(s,t))
    {
        assert(dist[t]<(1<<30));
        if((dist[t]-K)%2!=0)
        {
            cout<<"No\n";
            return 0;
        }
    }
    cout<<(K%2==1||N>2?"Unknown\n":"No\n");
}
0