結果

問題 No.2674 k-Walk on Bipartite
ユーザー tnakao0123tnakao0123
提出日時 2024-04-26 13:47:05
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,158 bytes
コンパイル時間 533 ms
コンパイル使用メモリ 59,904 KB
実行使用メモリ 14,508 KB
最終ジャッジ日時 2024-04-26 13:47:11
合計ジャッジ時間 3,056 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
8,396 KB
testcase_01 AC 4 ms
8,372 KB
testcase_02 AC 3 ms
8,504 KB
testcase_03 AC 3 ms
8,416 KB
testcase_04 AC 3 ms
8,256 KB
testcase_05 AC 3 ms
8,648 KB
testcase_06 AC 4 ms
8,400 KB
testcase_07 AC 48 ms
13,000 KB
testcase_08 AC 58 ms
12,560 KB
testcase_09 AC 38 ms
12,616 KB
testcase_10 AC 75 ms
13,512 KB
testcase_11 AC 47 ms
12,272 KB
testcase_12 AC 70 ms
13,124 KB
testcase_13 AC 50 ms
12,356 KB
testcase_14 AC 15 ms
10,176 KB
testcase_15 AC 93 ms
13,836 KB
testcase_16 AC 59 ms
13,380 KB
testcase_17 AC 59 ms
12,484 KB
testcase_18 AC 25 ms
10,864 KB
testcase_19 AC 57 ms
12,832 KB
testcase_20 AC 46 ms
12,764 KB
testcase_21 AC 65 ms
12,952 KB
testcase_22 AC 98 ms
14,508 KB
testcase_23 AC 3 ms
8,404 KB
testcase_24 AC 3 ms
8,516 KB
testcase_25 AC 4 ms
8,540 KB
testcase_26 AC 4 ms
8,500 KB
testcase_27 AC 3 ms
8,384 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 3 ms
8,380 KB
testcase_31 AC 4 ms
8,644 KB
testcase_32 AC 4 ms
8,472 KB
testcase_33 AC 4 ms
8,464 KB
testcase_34 AC 4 ms
8,444 KB
testcase_35 AC 4 ms
8,328 KB
testcase_36 AC 5 ms
8,440 KB
testcase_37 AC 3 ms
8,388 KB
testcase_38 AC 4 ms
8,648 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 2674.cc:  No.2674 k-Walk on Bipartite - yukicoder
 */

#include<cstdio>
#include<vector>
#include<queue>
#include<algorithm>

using namespace std;

/* constant */

const int MAX_N = 200000;

/* typedef */

typedef vector<int> vi;
typedef queue<int> qi;

/* global variables */

vi nbrs[MAX_N];
int ds[MAX_N];

/* subroutines */

/* main */

int main() {
  int n, m, s, t, k;
  scanf("%d%d%d%d%d", &n, &m, &s, &t, &k);
  s--, t--;

  for (int i = 0; i < m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    u--, v--;
    nbrs[u].push_back(v);
    nbrs[v].push_back(u);
  }

  fill(ds, ds + n, -1);
  ds[s] = 0;
  qi q;
  q.push(s);
  int sz = 1;

  while (! q.empty()) {
    int u = q.front(); q.pop();
    for (auto v: nbrs[u])
      if (ds[v] < 0) {
	ds[v] = ds[u] + 1, sz++;
	q.push(v);
      }
  }

  if (ds[t] >= 0) {
    if ((k - ds[t]) & 1) puts("No");
    else if (s == t) {
      if (sz > 1) puts("Yes");
      else if (n == 1) puts("No");
      else puts("Unknown");
    }
    else {
      if (s != t && ds[t] <= k) puts("Yes");
      else puts("Unknown");
    }
  }
  else {
    puts("Unknown");
  }

  return 0;
}
0