結果
問題 |
No.274 The Wall
|
ユーザー |
![]() |
提出日時 | 2015-08-28 22:57:45 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
MLE
|
実行時間 | - |
コード長 | 1,218 bytes |
コンパイル時間 | 651 ms |
コンパイル使用メモリ | 83,124 KB |
実行使用メモリ | 823,100 KB |
最終ジャッジ日時 | 2024-07-18 15:21:47 |
合計ジャッジ時間 | 4,469 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 7 MLE * 2 -- * 13 |
ソースコード
#include <iostream> #include <vector> #include <cstdio> #include <sstream> #include <map> #include <string> #include <algorithm> #include <queue> #include <cmath> #include <set> using namespace std; bool comp(const pair<int,int>& x, const pair<int,int>& y){ if(x.first != y.first) return x.second < y.second; else return x.first < y.first; } int main(){ int n,m; cin >> n >> m; vector<int> L(n),R(n); for(int i=0; i<n; i++){ cin >> L[i] >> R[i]; } vector<pair<int,int>> v(n); for(int i=0; i<n; i++){ if(L[i] >= m/2){ swap(L[i], R[i]); L[i] = m-1 - L[i]; R[i] = m-1 - R[i]; } v[i] = {L[i], R[i]}; } sort(v.begin(), v.end(), comp); vector<pair<int,int>> next; next.push_back({-1,m}); for(int i=0; i<n; i++){ vector<pair<int,int>> next_; for(int j=0; j<next.size(); j++){ int l = v[i].first; int r = v[i].second; if(next[j].first < l && r < next[j].second){ next_.push_back({r, next[j].second}); } swap(l,r); l = m-1 - l; r = m-1 - r; if(next[j].first < l && r < next[j].second){ next_.push_back({next[j].first, l}); } } swap(next, next_); } if(next.size() == 0){ cout << "NO" << endl; }else{ cout << "YES" << endl; } return 0; }