結果

問題 No.274 The Wall
ユーザー itezpaceitezpace
提出日時 2016-10-27 07:58:04
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 53 ms / 2,000 ms
コード長 1,001 bytes
コンパイル時間 587 ms
コンパイル使用メモリ 67,812 KB
実行使用メモリ 24,500 KB
最終ジャッジ日時 2023-09-04 02:13:10
合計ジャッジ時間 1,812 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main(){
  int N=0,M=0;cin>>N>>M;
  int L=0,R=0;
  vector<pair<int,int>> vp(N);
  vector<int> vs(M);
  vector<vector<int>> vi(M);
  for(int i=0;i<N;++i){
    cin>>L>>R;
    vp[i]=make_pair(L,R);
    for(int j=L;j<=R;++j){
      vs[j]+=1;
      if(vs[j]>1) vi[j].push_back(i);
    }
  }
  string ans="YES";
  for(int i=0;i<M;++i){
    if(vs[i]>2){
      ans="NO";
      break;
    } else if(vs[i]>1){
      int a=(M-1)-i;
      if(vs[a]!=0){
        ans="NO";
        break;
      }
      vector<int> vs2=vs;
      int cnt=0;
      for(int j=0;j<vi[i].size();++j){
        int b=vp[vi[i][j]].first;
        int c=vp[vi[i][j]].second;
        for(int k=b;k<=c;++k){
          vs2[k]-=1;
        }
        int d=(M-1)-b;
        int e=(M-1)-c;
        for(int k=e;k<=d;++k){
          if(vs2[k]){
            cnt+=1;
            break;
          }
        }
      }
      if(cnt==2) ans="NO";
    }
  }
  cout<<ans<<endl;
}
0