結果

問題 No.1997 X Lighting
ユーザー 沙耶花沙耶花
提出日時 2022-07-01 21:41:29
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 245 ms / 2,000 ms
コード長 626 bytes
コンパイル時間 2,062 ms
コンパイル使用メモリ 207,300 KB
実行使用メモリ 13,536 KB
最終ジャッジ日時 2023-08-17 09:07:38
合計ジャッジ時間 8,255 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,388 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 4 ms
4,380 KB
testcase_06 AC 29 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 4 ms
4,380 KB
testcase_09 AC 3 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 49 ms
4,376 KB
testcase_14 AC 174 ms
13,536 KB
testcase_15 AC 40 ms
6,028 KB
testcase_16 AC 55 ms
7,016 KB
testcase_17 AC 159 ms
11,668 KB
testcase_18 AC 75 ms
8,012 KB
testcase_19 AC 197 ms
13,008 KB
testcase_20 AC 245 ms
13,456 KB
testcase_21 AC 242 ms
13,380 KB
testcase_22 AC 201 ms
12,936 KB
testcase_23 AC 102 ms
8,660 KB
testcase_24 AC 5 ms
4,376 KB
testcase_25 AC 227 ms
13,100 KB
testcase_26 AC 191 ms
11,812 KB
testcase_27 AC 195 ms
11,956 KB
testcase_28 AC 51 ms
6,296 KB
testcase_29 AC 48 ms
6,312 KB
testcase_30 AC 221 ms
12,944 KB
testcase_31 AC 137 ms
9,596 KB
testcase_32 AC 31 ms
5,244 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main(){
	
	long long L,N;
	cin>>L>>N;

	set<long long> S1[2];
	set<long long> S2[2];
	long long x,y;
	for(long long i=0;i<N;i++){
		cin>>x>>y;
		x--,y--;
		S1[abs((y-x))%2].insert(y-x);
		S2[(x+y)%2].insert(x+y);
	}
	vector<long long> V[2];
	long long ans = 0;
	for(long long i=0;i<2;i++){
		for(auto a:S1[i]){
			ans+=(long long)L-abs(a);
			V[i].push_back(a);
		}
		for(auto a:S2[i]){
			long long x = L-abs((L-1)-a);
			ans+=(long long)x;
			ans-=upper_bound(V[i].begin(),V[i].end(),x-1)-lower_bound(V[i].begin(),V[i].end(),-(x-1));
		}
	}
	cout<<ans<<endl;
	
	return 0;
}
0