結果
問題 | No.2687 所により大雨 |
ユーザー | shobonvip |
提出日時 | 2024-03-20 23:37:27 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 354 ms / 2,000 ms |
コード長 | 3,424 bytes |
コンパイル時間 | 4,638 ms |
コンパイル使用メモリ | 274,016 KB |
実行使用メモリ | 8,740 KB |
最終ジャッジ日時 | 2024-09-30 09:37:26 |
合計ジャッジ時間 | 11,252 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 354 ms
8,600 KB |
testcase_01 | AC | 353 ms
8,476 KB |
testcase_02 | AC | 354 ms
8,604 KB |
testcase_03 | AC | 353 ms
8,732 KB |
testcase_04 | AC | 352 ms
8,472 KB |
testcase_05 | AC | 2 ms
6,816 KB |
testcase_06 | AC | 2 ms
6,820 KB |
testcase_07 | AC | 2 ms
6,820 KB |
testcase_08 | AC | 2 ms
6,816 KB |
testcase_09 | AC | 2 ms
6,816 KB |
testcase_10 | AC | 332 ms
8,528 KB |
testcase_11 | AC | 328 ms
8,612 KB |
testcase_12 | AC | 330 ms
8,608 KB |
testcase_13 | AC | 333 ms
8,608 KB |
testcase_14 | AC | 329 ms
8,608 KB |
testcase_15 | AC | 329 ms
8,740 KB |
testcase_16 | AC | 333 ms
8,484 KB |
testcase_17 | AC | 333 ms
8,476 KB |
testcase_18 | AC | 329 ms
8,612 KB |
testcase_19 | AC | 333 ms
8,604 KB |
testcase_20 | AC | 2 ms
6,816 KB |
testcase_21 | AC | 2 ms
6,820 KB |
testcase_22 | AC | 2 ms
6,820 KB |
testcase_23 | AC | 1 ms
6,816 KB |
testcase_24 | AC | 3 ms
6,820 KB |
testcase_25 | AC | 3 ms
6,820 KB |
testcase_26 | AC | 3 ms
6,820 KB |
testcase_27 | AC | 3 ms
6,820 KB |
testcase_28 | AC | 3 ms
6,820 KB |
ソースコード
#include<bits/stdc++.h> using namespace std; //* ATCODER #include<atcoder/all> using namespace atcoder; typedef modint998244353 mint; //*/ /* BOOST MULTIPRECISION #include<boost/multiprecision/cpp_int.hpp> using namespace boost::multiprecision; //*/ typedef long long ll; #define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++) #define rrep(i, s, n) for (int i = (int)(n)-1; i >= (int)(s); i--) template <typename T> bool chmin(T &a, const T &b) { if (a <= b) return false; a = b; return true; } template <typename T> bool chmax(T &a, const T &b) { if (a >= b) return false; a = b; return true; } template <typename T> T max(vector<T> &a){ assert(!a.empty()); T ret = a[0]; for (int i=0; i<(int)a.size(); i++) chmax(ret, a[i]); return ret; } template <typename T> T min(vector<T> &a){ assert(!a.empty()); T ret = a[0]; for (int i=0; i<(int)a.size(); i++) chmin(ret, a[i]); return ret; } template <typename T> T sum(vector<T> &a){ T ret = 0; for (int i=0; i<(int)a.size(); i++) ret += a[i]; return ret; } // importbisect template <typename T> int bisect_left(vector<T> &X, T v){ return lower_bound(X.begin(), X.end(), v) - X.begin(); } template <typename T> int bisect_right(vector<T> &X, T v){ return upper_bound(X.begin(), X.end(), v) - X.begin(); } // ----- // defcomp template <typename T> vector<T> compress(vector<T> &X) { vector<T> vals = X; sort(vals.begin(), vals.end()); vals.erase(unique(vals.begin(), vals.end()), vals.end()); return vals; } // ----- int main(){ int n, m; cin >> n >> m; vector<ll> l(n+m), r(n+m); rep(i,0,n+m){ cin >> l[i] >> r[i]; r[i]++; } int k; cin >> k; vector<ll> p(k); rep(i,0,k) cin >> p[i]; vector<bool> ans(k); // CHECK THE CHOFUKU { vector<ll> pt; rep(i,0,n){ pt.push_back(l[i]); pt.push_back(r[i]); } pt = compress(pt); int g = pt.size(); vector<ll> imos(g+1); rep(i,0,n){ int lx = bisect_left(pt, l[i]); int rx = bisect_left(pt, r[i]); imos[lx]++; imos[rx]--; } rep(i,0,g){ imos[i+1] += imos[i]; } bool mode = 0; rep(i,0,g){ if (imos[i] >= 2){ mode = 1; break; } } if (mode){ rep(i,0,k){ ans[i] = 1; } } } { vector<ll> pt; rep(i,n,n+m){ pt.push_back(l[i]); pt.push_back(r[i]); } pt = compress(pt); int g = pt.size(); vector<ll> imos(g+1); rep(i,n,n+m){ int lx = bisect_left(pt, l[i]); int rx = bisect_left(pt, r[i]); imos[lx]++; imos[rx]--; } rep(i,0,g){ imos[i+1] += imos[i]; } bool mode = 0; rep(i,0,g){ if (imos[i] >= 2){ mode = 1; break; } } if (mode){ rep(i,0,k){ ans[i] = 1; } } } vector<pair<ll,ll>> normal; vector<pair<ll,ll>> special; rep(i,0,n){ normal.push_back(pair(l[i], r[i]-1)); } rep(i,n,n+m){ special.push_back(pair(l[i], r[i]-1)); } sort(normal.begin(), normal.end()); sort(special.begin(), special.end()); rep(i,0,k){ ll tr = p[i]; int piv = 0; rrep(j,0,m){ while (piv < n){ ll lt1 = p[i] - normal[piv].second; ll rt1 = p[i] - normal[piv].first; ll lt2 = special[j].first - p[i]; ll rt2 = special[j].second - p[i]; //cout << lt1 << ' ' << rt1 << ' ' << lt2 << ' ' << rt2 << endl; if (max(lt2, lt1) - min(rt2, rt1) <= 0){ ans[i] = 1; break; } if (rt2 < lt1){ piv++; continue; } break; } } } rep(i,0,k){ cout << ans[i] << ' '; } cout << '\n'; }