結果

問題 No.2674 k-Walk on Bipartite
ユーザー GGanariGGanari
提出日時 2024-03-15 22:54:04
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,685 bytes
コンパイル時間 3,282 ms
コンパイル使用メモリ 228,844 KB
実行使用メモリ 14,160 KB
最終ジャッジ日時 2024-03-15 22:54:11
合計ジャッジ時間 5,956 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
8,272 KB
testcase_01 AC 5 ms
8,272 KB
testcase_02 AC 4 ms
8,272 KB
testcase_03 AC 4 ms
8,272 KB
testcase_04 AC 4 ms
8,272 KB
testcase_05 AC 4 ms
8,272 KB
testcase_06 AC 4 ms
8,272 KB
testcase_07 AC 47 ms
12,624 KB
testcase_08 AC 59 ms
12,240 KB
testcase_09 AC 45 ms
12,496 KB
testcase_10 AC 80 ms
13,136 KB
testcase_11 AC 47 ms
11,984 KB
testcase_12 AC 72 ms
12,752 KB
testcase_13 AC 51 ms
11,984 KB
testcase_14 AC 13 ms
9,680 KB
testcase_15 AC 88 ms
13,648 KB
testcase_16 AC 63 ms
13,008 KB
testcase_17 AC 65 ms
12,112 KB
testcase_18 AC 28 ms
10,704 KB
testcase_19 AC 51 ms
12,496 KB
testcase_20 AC 45 ms
12,368 KB
testcase_21 AC 65 ms
12,496 KB
testcase_22 AC 94 ms
14,160 KB
testcase_23 AC 4 ms
8,272 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 4 ms
8,272 KB
testcase_27 AC 5 ms
8,272 KB
testcase_28 AC 5 ms
8,272 KB
testcase_29 AC 4 ms
8,272 KB
testcase_30 AC 4 ms
8,272 KB
testcase_31 AC 4 ms
8,272 KB
testcase_32 AC 4 ms
8,272 KB
testcase_33 AC 4 ms
8,272 KB
testcase_34 AC 4 ms
8,272 KB
testcase_35 AC 4 ms
8,272 KB
testcase_36 AC 4 ms
8,272 KB
testcase_37 AC 4 ms
8,272 KB
testcase_38 AC 4 ms
8,272 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2")
#include <bits/stdc++.h>
#define INF 1000000001LL
#define LNF 1000000000000000001LL
#define MOD 1000000007LL
#define MAX 200001
#define long long long
#define all(x) x.begin(),x.end()
using namespace std;

vector<int> graph[MAX];
int main()
{
	ios_base::sync_with_stdio(0); 
    cin.tie(0);

    int n,m;
    cin >> n >> m;
    int s,e,k;
    cin >> s >> e >> k;

    for(int i = 0; i<m; i++)
    {
        int a,b;
        cin >> a >> b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    
    vector<int> vis(n+1,-1);
    queue<int> q;
    q.push(s);
    
    vis[s] = 0;
    while(!q.empty())
    {
        int x = q.front();
        q.pop();

        for(int y : graph[x])
        {
            if(vis[y] == -1)
            {
                if(vis[x] == -1)
                    vis[y] = 1;
                else
                    vis[y] = vis[x]+1;
                q.push(y);
            }
        }
    }

    if(n == 1)
    {
        cout << "No\n";
        return 0;
    }

    if(vis[e] <= k)
    {
        if(vis[e] == -1)
        {
            if(n == 2 && k%2)
            {
                cout << "Unknown\n";
            }
            else if(n == 2)
            {
                cout << "No\n";
            }
            else
                cout << "Unknown\n";
        } 
        else if(vis[e]%2 == k%2)
            cout << "Yes\n";
        else
            cout << "No\n";
    }
    else
    {
        if(vis[e]%2 == k%2)
            cout << "Unknown\n";
        else
            cout << "No\n";
    }
    return 0;
}
0