結果
問題 | No.2687 所により大雨 |
ユーザー |
|
提出日時 | 2024-03-20 22:59:17 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 125 ms / 2,000 ms |
コード長 | 2,102 bytes |
コンパイル時間 | 2,719 ms |
コンパイル使用メモリ | 222,628 KB |
最終ジャッジ日時 | 2025-02-20 09:55:52 |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 25 |
ソースコード
#pragma GCC optimize("Ofast") #include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef unsigned long long int ull; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); ll myRand(ll B) { return (ull)rng() % B; } inline double time() { return static_cast<long double>(chrono::duration_cast<chrono::nanoseconds>(chrono::steady_clock::now().time_since_epoch()).count()) * 1e-9; } int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); int n,m; cin >> n >> m; vector<pair<ll,ll>> v(n), u(m); for (int i = 0; i < n; ++i) { cin >> v[i].first >> v[i].second; } for (int i = 0; i < m; ++i) { cin >> u[i].first >> u[i].second; } int k; cin >> k; vector<ll> pos(k); for (int i = 0; i < k; ++i) { cin >> pos[i]; } sort(v.begin(), v.end()); sort(u.begin(), u.end()); bool ok = false; ll mx = v[0].second; for (int i = 1; i < n; ++i) { if (v[i].first <= mx) ok = true; mx = max(mx, v[i].second); } mx = u[0].second; for (int i = 1; i < m; ++i) { if (u[i].first <= mx) ok = true; mx = max(mx, u[i].second); } if (ok) { for (int i = 0; i < k; ++i) { cout << 1 << " "; } cout << "\n"; return 0; } for (int i = 0; i < k; ++i) { ok = false; for (int j = 0; j < m and !ok; ++j) { ll l = u[j].first-pos[i]; ll r = u[j].second-pos[i]; if (l > r) swap(l, r); ll lx = pos[i]-r, rx = pos[i]-l; if (lx > rx) swap(lx, rx); // if (pos[i] == 2) { // cout << l << " " << r << " " << lx << " " << rx << endl; // } auto it = lower_bound(v.begin(), v.end(), pair<ll,ll>{rx+1, -2e9}); if (it != v.begin()) { it--; auto p = *it; if (max(p.first, lx) <= min(p.second, rx)) { ok = true; } } } cout << ok << " "; } cout << endl; }