結果

問題 No.1244 Black Segment
ユーザー auauaauaua
提出日時 2020-10-02 22:14:12
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,231 bytes
コンパイル時間 1,908 ms
コンパイル使用メモリ 176,904 KB
実行使用メモリ 7,264 KB
最終ジャッジ日時 2023-09-24 21:01:30
合計ジャッジ時間 5,527 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 WA -
testcase_14 AC 70 ms
6,196 KB
testcase_15 WA -
testcase_16 AC 69 ms
5,880 KB
testcase_17 AC 3 ms
4,380 KB
testcase_18 AC 44 ms
5,404 KB
testcase_19 AC 65 ms
6,576 KB
testcase_20 AC 70 ms
6,728 KB
testcase_21 AC 70 ms
6,668 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 75 ms
7,048 KB
testcase_28 WA -
testcase_29 AC 76 ms
6,940 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 77 ms
7,000 KB
testcase_35 AC 75 ms
6,992 KB
testcase_36 AC 75 ms
7,056 KB
testcase_37 AC 76 ms
6,940 KB
testcase_38 AC 75 ms
7,096 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define vec vector<ll>
#define mat vector<vector<ll> >
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
typedef long double ld;
typedef complex<double> comp;
const ll INF=1e9+7;
const ll inf=INF;
const ll MOD=998244353;
const ll mod=MOD;
const int MAX=200010;

signed main(){
    ll n,m,a,b;cin>>n>>m>>a>>b;
    vector<pll>p(m);
    vector<pll>q(m);
    rep(i,m){
        cin>>p[i].fi>>p[i].se;
        q[i].se=p[i].fi,q[i].fi=p[i].se;
    }
    sort(all(p));
    sort(rall(q));
    vector<ll>dp(n+2,0);
    REP(i,a,n+2)dp[i]=inf;
    rep(i,m){
        dp[p[i].se]=min(dp[p[i].se],dp[p[i].fi-1]+1);
    }
    rep(i,m){
        dp[q[i].se-1]=min(dp[q[i].se-1],dp[q[i].fi]+1);
    }
    rep(i,m){
        dp[p[i].se]=min(dp[p[i].se],dp[p[i].fi-1]+1);
    }
    ll ans=inf;
    REP(i,b,n+2)ans=min(ans,dp[i]);
    if(ans==inf){
        cout<<-1<<endl;
    }else{
        cout<<ans<<endl;
    }
}
0