結果

問題 No.274 The Wall
ユーザー codershifthcodershifth
提出日時 2016-05-07 15:42:51
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,216 bytes
コンパイル時間 1,360 ms
コンパイル使用メモリ 151,516 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-07-28 03:43:49
合計ジャッジ時間 2,629 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
4,380 KB
testcase_02 WA -
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,384 KB
testcase_11 AC 2 ms
4,384 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 2 ms
4,384 KB
testcase_24 WA -
testcase_25 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int (i)=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define RANGE(vec) (vec).begin(),(vec).end()

using namespace std;

bool rangeIsCross(int s1, int e1, int s2, int e2)
{
    return max(s1,s2) <= min(e1,e2);
}

class TheWall
{
public:
    void solve(void)
    {
        int N,M;
        cin>>N>>M;

        set<pair<int,int>> S;
        REP(i,N)
        {
            int l,r;
            cin>>l>>r;
            S.emplace(l,r);
        }
        int l = M;
        int r = -1;
        while (!S.empty())
        {
            int l1,r1;
            tie(l1,r1) = *S.begin();
            S.erase(S.begin());

            if ( rangeIsCross(-1,r,l1,r1) )
            {
                if ( rangeIsCross(M-1-r1,M-1-l1,l,M) )
                {
                    cout<<"NO"<<endl;
                    return;
                }
                l = M-1-r1;
            }
            r = r1;
        }
        cout<<"YES"<<endl;
    }
};

#if 1
int main(int argc, char *argv[])
{
        ios::sync_with_stdio(false);
        auto obj = new TheWall();
        obj->solve();
        delete obj;
        return 0;
}
#endif
0