結果

問題 No.274 The Wall
ユーザー Tsuneo YoshiokaTsuneo Yoshioka
提出日時 2015-08-28 22:48:28
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,210 bytes
コンパイル時間 1,488 ms
コンパイル使用メモリ 62,296 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-25 19:13:28
合計ジャッジ時間 2,275 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>

using namespace std;
int main(void){
    // Here your code !
    int N, M;
    cin >> N >> M;
    vector< vector<int> > ls(M);
    vector<int> counts(M);
    
    for(int i=0;i<N;i++){
        int l, r;
        cin >> l >> r;
        if(M-1-r<l){
            int l2,r2;
            l2 = M-1-r;
            r2 = M-1-l;
            l=l2;
            r=r2;
        }
        ls[l].push_back(r);
    }
    for(int l=0;l<M;l++){
        vector<int> rs = ls[l];
        if(rs.size()==0){
            continue;
        }
        if(rs.size()>2){
            cout << "NO" << endl;
            exit(0);
        }
        {
            int r = rs[0];
            for(int i=l;i<=r;i++){
                counts[i]++;
            }
        }
        if(rs.size()==2){
            int r = rs[1];
            
            int l2 = M-1-l;
            int r2 = M-1-r;
            for(int i=l2;i<=r2;i++){
                counts[i]++;
            }
        }
    }
    bool flag = true;
    for(int i=0;i<M;i++){
        if(counts[i]>=2){
            flag = false;
        }
    }
    if(flag){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}
0