結果

問題 No.2687 所により大雨
ユーザー shobonvipshobonvip
提出日時 2024-03-20 23:37:27
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 410 ms / 2,000 ms
コード長 3,424 bytes
コンパイル時間 5,036 ms
コンパイル使用メモリ 274,164 KB
実行使用メモリ 8,604 KB
最終ジャッジ日時 2024-03-20 23:37:40
合計ジャッジ時間 12,451 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 409 ms
8,600 KB
testcase_01 AC 410 ms
8,600 KB
testcase_02 AC 409 ms
8,600 KB
testcase_03 AC 410 ms
8,600 KB
testcase_04 AC 409 ms
8,600 KB
testcase_05 AC 1 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 381 ms
8,604 KB
testcase_11 AC 384 ms
8,604 KB
testcase_12 AC 381 ms
8,604 KB
testcase_13 AC 381 ms
8,604 KB
testcase_14 AC 381 ms
8,604 KB
testcase_15 AC 381 ms
8,604 KB
testcase_16 AC 382 ms
8,604 KB
testcase_17 AC 390 ms
8,604 KB
testcase_18 AC 381 ms
8,604 KB
testcase_19 AC 381 ms
8,604 KB
testcase_20 AC 2 ms
6,676 KB
testcase_21 AC 2 ms
6,676 KB
testcase_22 AC 2 ms
6,676 KB
testcase_23 AC 2 ms
6,676 KB
testcase_24 AC 3 ms
6,676 KB
testcase_25 AC 3 ms
6,676 KB
testcase_26 AC 3 ms
6,676 KB
testcase_27 AC 3 ms
6,676 KB
testcase_28 AC 3 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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';

}

0