結果

問題 No.1997 X Lighting
ユーザー kabipoyokabipoyo
提出日時 2022-07-01 23:00:04
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 322 ms / 2,000 ms
コード長 2,016 bytes
コンパイル時間 3,823 ms
コンパイル使用メモリ 271,388 KB
実行使用メモリ 24,092 KB
最終ジャッジ日時 2024-05-04 17:24:59
合計ジャッジ時間 8,390 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 1 ms
5,248 KB
testcase_03 AC 1 ms
5,248 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 5 ms
5,376 KB
testcase_06 AC 32 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 5 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 56 ms
5,376 KB
testcase_14 AC 217 ms
24,092 KB
testcase_15 AC 53 ms
8,960 KB
testcase_16 AC 75 ms
10,880 KB
testcase_17 AC 201 ms
20,060 KB
testcase_18 AC 102 ms
12,928 KB
testcase_19 AC 263 ms
22,884 KB
testcase_20 AC 299 ms
23,964 KB
testcase_21 AC 288 ms
23,968 KB
testcase_22 AC 293 ms
22,992 KB
testcase_23 AC 144 ms
14,080 KB
testcase_24 AC 6 ms
5,376 KB
testcase_25 AC 322 ms
23,252 KB
testcase_26 AC 218 ms
20,308 KB
testcase_27 AC 226 ms
20,820 KB
testcase_28 AC 64 ms
9,344 KB
testcase_29 AC 61 ms
8,980 KB
testcase_30 AC 261 ms
22,828 KB
testcase_31 AC 162 ms
16,256 KB
testcase_32 AC 39 ms
7,168 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef int64_t lint;
#define rep(i, n) for(int i=0; i<n; i++)
#define repx(i, l, n) for(int i=l; i<n; i++)
#define all(v) v.begin(), v.end()
#define show(x) cout << #x << ": " << x << endl;
#define list(x) cout << #x << ": " << x << "  ";
#define pb push_back
using vi = vector<lint>;
using vvi = vector<vector<lint>>;
template<class T> inline void vin(vector<T>& v) { rep(i, v.size()) cin >> v.at(i); }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline void drop(T x) { cout << x << endl; exit(0); }
template<class T> void vout(vector<T> v) { rep(i, v.size()) { cout << v.at(i) << ' '; } cout << endl; }
constexpr lint LINF = LLONG_MAX/2;

int main() {
	lint N, M;
	cin >> N >> M;

	lint a=0, b=0, c=0, x, y, z;
	set<lint> s, t, so, se, to, te;
	rep(i, M) {
		cin >> x >> y;
		s.insert(y-x);
		t.insert(x+y-2);
		if ((y-x)%2) so.insert(y-x);
		else se.insert(y-x);
		if ((x+y)%2) to.insert(x+y-2);
		else te.insert(x+y-2);
	}
	vi vo, ve, wo, we;
	for (auto l : so) vo.pb(l);
	for (auto l : se) ve.pb(l);
	for (auto l : to) wo.pb(l);
	for (auto l : te) we.pb(l);
	// vout(vo);
	// vout(ve);
	for (auto l : s) {
		c += N-abs(l);
		// x = N-1-abs(l);
		// y = N-1+abs(l);
		// if (l%2) {
		// 	auto o = lower_bound(all(wo), x);
		// 	auto u = upper_bound(all(wo), y);
		// 	c -= u-o;
		// } else {
		// 	auto o = lower_bound(all(we), x);
		// 	auto u = upper_bound(all(we), y);
		// 	c -= u-o;
		// }
	}
	for (auto l : t) {
		c += N-abs(N-1-l);
		x = abs(N-1-l)-(N-1);
		y = N-1-abs(N-1-l);
		// list(l)
		// list(x)
		// show(y)
		if (l%2) {
			auto o = lower_bound(all(vo), x);
			auto u = upper_bound(all(vo), y);
			c -= u-o;
		} else {
			auto o = lower_bound(all(ve), x);
			auto u = upper_bound(all(ve), y);
			c -= u-o;
		}
	}
	std::cout << c << '\n';
}
0