結果
問題 | No.1997 X Lighting |
ユーザー | SSRS |
提出日時 | 2022-07-01 21:44:24 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 195 ms / 2,000 ms |
コード長 | 1,546 bytes |
コンパイル時間 | 1,725 ms |
コンパイル使用メモリ | 178,952 KB |
実行使用メモリ | 15,456 KB |
最終ジャッジ日時 | 2023-08-17 09:11:35 |
合計ジャッジ時間 | 5,704 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,380 KB |
testcase_01 | AC | 2 ms
4,380 KB |
testcase_02 | AC | 2 ms
4,380 KB |
testcase_03 | AC | 1 ms
4,380 KB |
testcase_04 | AC | 1 ms
4,380 KB |
testcase_05 | AC | 4 ms
4,376 KB |
testcase_06 | AC | 29 ms
4,380 KB |
testcase_07 | AC | 1 ms
4,380 KB |
testcase_08 | AC | 4 ms
4,380 KB |
testcase_09 | AC | 2 ms
4,380 KB |
testcase_10 | AC | 2 ms
4,380 KB |
testcase_11 | AC | 2 ms
4,376 KB |
testcase_12 | AC | 2 ms
4,376 KB |
testcase_13 | AC | 50 ms
4,804 KB |
testcase_14 | AC | 173 ms
15,212 KB |
testcase_15 | AC | 38 ms
6,528 KB |
testcase_16 | AC | 54 ms
7,492 KB |
testcase_17 | AC | 133 ms
12,996 KB |
testcase_18 | AC | 71 ms
8,892 KB |
testcase_19 | AC | 152 ms
14,688 KB |
testcase_20 | AC | 190 ms
15,456 KB |
testcase_21 | AC | 191 ms
15,100 KB |
testcase_22 | AC | 168 ms
14,824 KB |
testcase_23 | AC | 95 ms
9,356 KB |
testcase_24 | AC | 5 ms
4,376 KB |
testcase_25 | AC | 195 ms
15,020 KB |
testcase_26 | AC | 156 ms
13,124 KB |
testcase_27 | AC | 163 ms
13,392 KB |
testcase_28 | AC | 50 ms
6,488 KB |
testcase_29 | AC | 48 ms
6,468 KB |
testcase_30 | AC | 183 ms
14,636 KB |
testcase_31 | AC | 118 ms
10,736 KB |
testcase_32 | AC | 29 ms
5,308 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(){ long long L, N; cin >> L >> N; vector<pair<long long, long long>> A, B; for (int i = 0; i < N; i++){ long long y, x; cin >> y >> x; y--; x--; if ((x + y) % 2 == 0){ A.push_back(make_pair(y, x)); } else { B.push_back(make_pair(y, x)); } } int Acnt = A.size(); set<long long> Ax, Ay; for (int i = 0; i < Acnt; i++){ Ay.insert(A[i].first - A[i].second); Ax.insert(A[i].first + A[i].second); } vector<long long> Ay2; for (long long y : Ay){ Ay2.push_back(y); } long long Aans = 0; for (long long x : Ax){ Aans += min(x + 1, L * 2 - x - 1); } for (long long y : Ay){ Aans += L - abs(y); } for (long long x : Ax){ long long ub = min(x, L * 2 - 2 - x); long long lb = -ub; Aans -= upper_bound(Ay2.begin(), Ay2.end(), ub) - lower_bound(Ay2.begin(), Ay2.end(), lb); } long long Bcnt = B.size(); set<long long> Bx, By; for (int i = 0; i < Bcnt; i++){ By.insert(B[i].first - B[i].second); Bx.insert(B[i].first + B[i].second); } vector<long long> By2; for (long long y : By){ By2.push_back(y); } long long Bans = 0; for (long long x : Bx){ Bans += min(x + 1, L * 2 - x - 1); } for (long long y : By){ Bans += L - abs(y); } for (long long x : Bx){ long long ub = min(x, L * 2 - 2 - x); long long lb = -ub; Bans -= upper_bound(By2.begin(), By2.end(), ub) - lower_bound(By2.begin(), By2.end(), lb); } cout << Aans + Bans << endl; }