結果

問題 No.274 The Wall
ユーザー nasadigitalnasadigital
提出日時 2015-08-29 03:24:49
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,882 bytes
コンパイル時間 1,432 ms
コンパイル使用メモリ 154,008 KB
実行使用メモリ 8,760 KB
最終ジャッジ日時 2023-09-25 19:33:19
合計ジャッジ時間 5,238 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n,m;
    cin>>m>>n;
    int l[2*m],r[2*m];
    for(int ctr1=0; ctr1<m; ctr1++)
    {
        cin>>l[ctr1]>>r[ctr1];
        l[m+ctr1]=n-r[ctr1]-1;
        r[m+ctr1]=n-l[ctr1]-1;
    }
    unordered_set<int> hs;
    vector<int> rez;
    for(int ctr1=0; ctr1<m; ctr1++)
    {
        if(hs.count(ctr1) || hs.count(ctr1+m))
            continue;
        rez.push_back(ctr1);
        hs.insert(ctr1);
        for(int ctr2=0; ctr2<rez.size(); ctr2++)
        {
            for(int ctr3=0; ctr3<m; ctr3++)
            {
                if(!hs.count(ctr3) && !hs.count(ctr3+m))
                {
                    bool b1=(l[rez[ctr2]]<=r[ctr3] && l[ctr3] <= r[rez[ctr2]]),b2=(l[rez[ctr2]]<=r[m+ctr3] && l[m+ctr3] <= r[rez[ctr2]]);
                    if(b1==b2)
                    {
                        if(!b1)
                            continue;
                        else
                        {
                            cout<<"NO"<<endl;
                            return 0;
                        }
                    }
                    else
                    {
                        if(b2)
                        {
                            rez.push_back(ctr3);
                            hs.insert(ctr3);
                        }
                        else
                        {
                            rez.push_back(m+ctr3);
                            hs.insert(m+ctr3);
                        }
                    }
                }
            }
        }
    }
    for(int ctr1=0; ctr1<rez.size(); ctr1++)
        for(int ctr2=ctr1+1; ctr2<rez.size(); ctr2++)
            if (l[rez[ctr1]]<=r[rez[ctr2]] && l[rez[ctr2]] <= r[rez[ctr1]])
            {
                cout<<"NO"<<endl;

                return 0;
            }
    cout<<"YES"<<endl;
    return 0;
}
0