結果

問題 No.274 The Wall
ユーザー nasadigitalnasadigital
提出日時 2015-08-29 03:28:27
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,132 bytes
コンパイル時間 1,321 ms
コンパイル使用メモリ 154,672 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-09-25 19:33:23
合計ジャッジ時間 3,167 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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);
                        }
                    }
                }
            }
            if(ctr2==rez.size()-1){
                for(int ctr3=0;ctr3<m;ctr3++){
                    if(hs.count(ctr3) || hs.count(ctr3+m))
            continue;
        rez.push_back(ctr3);
        hs.insert(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