結果

問題 No.1244 Black Segment
ユーザー KudeKude
提出日時 2020-10-02 22:42:50
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,061 bytes
コンパイル時間 3,533 ms
コンパイル使用メモリ 209,088 KB
実行使用メモリ 8,624 KB
最終ジャッジ日時 2023-09-24 22:05:16
合計ジャッジ時間 6,402 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 WA -
testcase_04 AC 1 ms
4,376 KB
testcase_05 WA -
testcase_06 AC 2 ms
4,376 KB
testcase_07 WA -
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,384 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 3 ms
4,376 KB
testcase_18 AC 46 ms
6,444 KB
testcase_19 WA -
testcase_20 AC 73 ms
6,684 KB
testcase_21 AC 72 ms
7,300 KB
testcase_22 WA -
testcase_23 AC 81 ms
7,932 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 89 ms
8,624 KB
testcase_28 WA -
testcase_29 AC 84 ms
8,120 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 88 ms
7,852 KB
testcase_34 AC 81 ms
7,476 KB
testcase_35 AC 67 ms
5,600 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 80 ms
8,128 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<VI>;

int main() {
    int n, m, a, b;
    cin >> n >> m >> a >> b;
    a--;
    VVI to(n-a+1);
    rep(_, m) {
        int l, r;
        cin >> l >> r;
        if (r <= a) continue;
        l--;
        if (l <= a) l = 0;
        else l -= a;
        r -= a;
        to[l].push_back(r);
        to[r].push_back(l);
    }
    queue<P> q;
    q.emplace(0, 0);
    vector<bool> visited(n-a+1);
    visited[0] = true;
    while(!q.empty()) {
        int u, k;
        tie(u, k) = q.front(); q.pop();
        for(int v: to[u]) {
            if (visited[v]) continue;
            visited[v] = true;
            if (v >= b) {
                cout << k + 1 << endl;
                return 0;
            }
            q.emplace(v, k+1);
        }
    }
    cout << -1 << endl;
}
0