結果

問題 No.2674 k-Walk on Bipartite
ユーザー tour2sttour2st
提出日時 2024-03-15 22:35:36
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,732 bytes
コンパイル時間 1,056 ms
コンパイル使用メモリ 104,180 KB
実行使用メモリ 17,856 KB
最終ジャッジ日時 2024-03-15 22:35:41
合計ジャッジ時間 4,944 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
9,536 KB
testcase_01 AC 5 ms
9,536 KB
testcase_02 AC 5 ms
9,536 KB
testcase_03 AC 5 ms
9,536 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 5 ms
9,536 KB
testcase_07 AC 121 ms
14,016 KB
testcase_08 AC 166 ms
16,192 KB
testcase_09 AC 112 ms
13,632 KB
testcase_10 AC 208 ms
17,600 KB
testcase_11 AC 118 ms
14,144 KB
testcase_12 AC 226 ms
17,856 KB
testcase_13 AC 105 ms
13,376 KB
testcase_14 AC 26 ms
11,072 KB
testcase_15 AC 212 ms
17,216 KB
testcase_16 AC 149 ms
14,912 KB
testcase_17 AC 144 ms
15,296 KB
testcase_18 AC 58 ms
12,096 KB
testcase_19 AC 132 ms
14,400 KB
testcase_20 AC 111 ms
13,888 KB
testcase_21 AC 185 ms
15,552 KB
testcase_22 AC 219 ms
17,216 KB
testcase_23 AC 4 ms
9,536 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 5 ms
9,536 KB
testcase_27 AC 5 ms
9,536 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 5 ms
9,536 KB
testcase_31 AC 5 ms
9,536 KB
testcase_32 AC 5 ms
9,536 KB
testcase_33 AC 5 ms
9,536 KB
testcase_34 AC 5 ms
9,536 KB
testcase_35 AC 5 ms
9,536 KB
testcase_36 AC 5 ms
9,536 KB
testcase_37 AC 5 ms
9,536 KB
testcase_38 AC 5 ms
9,536 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:57:22: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
   57 |                 auto [idx, len] = idx_len.front();
      |                      ^
main.cpp:69:13: warning: 'dst' may be used uninitialized [-Wmaybe-uninitialized]
   69 |             if(dst<=k)
      |             ^~
main.cpp:51:17: note: 'dst' was declared here
   51 |             int dst;
      |                 ^~~

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <random>
#include <time.h>
#include <map>
using namespace std;

int n,m,s,t,k,a,b;
vector<int>e[200000];
pair<int,int> color[200000];
bool visited[200000];
bool length[200000];

void dfs(int now, int sta, int col)
{
    if(visited[now]) return;
    visited[now] = true;
    color[now] = {sta,col};
    for(int nxt:e[now])
    {
        dfs(nxt, sta, col^1);
    }
}

int main()
{
    cin >> n >> m >> s >> t >> k;
    for(int i=0;i<m;i++)
    {
        cin >> a >> b;
        a--;b--;
        e[a].push_back(b);
        e[b].push_back(a);
    }
    for(int i=0;i<n;i++)
    {
        dfs(i, i, 0);
    }
    s--;t--;
    if(color[s].first==color[t].first)
    {
        int bi1 = color[s].second;
        int bi2 = color[t].second;
        if(k%2 == bi1^bi2)
        {
            int dst;
            //到達できるか?
            queue<pair<int,int>>idx_len;
            idx_len.push({s,0});
            while(!idx_len.empty())
            {
                auto [idx, len] = idx_len.front();
                idx_len.pop();

                if(length[idx]) continue;
                length[idx] = true;

                if(idx==t) dst = len;
                for(int nxt:e[idx])
                {
                    idx_len.push({nxt, len+1});
                }
            }
            if(dst<=k)
            {
                cout << "Yes" << endl;
            }
            else
            {
                cout << "Unknown" << endl;
            }
        }
        else
        {
            cout << "No" << endl;
        }
    }
    else
    {
        cout << "Unknown" << endl;
    }
}
0