結果

問題 No.1244 Black Segment
ユーザー tempura_pptempura_pp
提出日時 2020-08-08 21:35:55
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,221 bytes
コンパイル時間 1,627 ms
コンパイル使用メモリ 126,736 KB
実行使用メモリ 9,344 KB
最終ジャッジ日時 2024-04-10 05:59:16
合計ジャッジ時間 3,575 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 2 ms
6,940 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 1 ms
6,944 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 WA -
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 WA -
testcase_14 AC 22 ms
6,940 KB
testcase_15 AC 3 ms
6,940 KB
testcase_16 AC 23 ms
6,944 KB
testcase_17 AC 2 ms
6,940 KB
testcase_18 AC 26 ms
7,552 KB
testcase_19 AC 36 ms
7,936 KB
testcase_20 WA -
testcase_21 AC 36 ms
8,576 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 40 ms
8,576 KB
testcase_25 AC 40 ms
8,832 KB
testcase_26 AC 38 ms
8,576 KB
testcase_27 WA -
testcase_28 AC 40 ms
8,832 KB
testcase_29 AC 39 ms
8,832 KB
testcase_30 AC 40 ms
8,912 KB
testcase_31 AC 40 ms
8,704 KB
testcase_32 AC 41 ms
8,704 KB
testcase_33 AC 40 ms
8,832 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 40 ms
9,088 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
constexpr int inf=1e9+7;
constexpr ll longinf=1LL<<60 ;
constexpr ll mod=1e9+7 ;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,m,a,b;
    cin>>n>>m>>a>>b;
    vector<vector<int>> v(n+1);
    rep(i,m){
        int x,y;
        cin>>x>>y;
        assert(x<=y);
        --x;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    vector<int> dist(n+1,inf);
    queue<int> q;
    rep(i,a){
        dist[i] = 0;
        q.push(i);
    }
    while(q.size()){
        int x=q.front();q.pop();
        for(auto to : v[x]){
            if(dist[to]==inf){
                dist[to]=dist[x]+1;
                q.push(to);
            }
        }
    }
    int ans=inf;
    REP(i,b-1,n+1)ans=min(ans,dist[i]);
    if(ans==inf)cout<<-1<<endl;
    else cout<<ans<<endl;
    return 0;
}
0