結果
問題 | No.1997 X Lighting |
ユーザー | SSRS |
提出日時 | 2022-07-01 21:44:24 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 223 ms / 2,000 ms |
コード長 | 1,546 bytes |
コンパイル時間 | 1,868 ms |
コンパイル使用メモリ | 180,176 KB |
実行使用メモリ | 15,524 KB |
最終ジャッジ日時 | 2024-05-04 16:03:06 |
合計ジャッジ時間 | 5,864 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | AC | 2 ms
5,376 KB |
testcase_05 | AC | 5 ms
5,376 KB |
testcase_06 | AC | 31 ms
5,376 KB |
testcase_07 | AC | 2 ms
5,376 KB |
testcase_08 | AC | 5 ms
5,376 KB |
testcase_09 | AC | 3 ms
5,376 KB |
testcase_10 | AC | 2 ms
5,376 KB |
testcase_11 | AC | 2 ms
5,376 KB |
testcase_12 | AC | 2 ms
5,376 KB |
testcase_13 | AC | 53 ms
5,376 KB |
testcase_14 | AC | 177 ms
15,272 KB |
testcase_15 | AC | 39 ms
6,616 KB |
testcase_16 | AC | 55 ms
7,716 KB |
testcase_17 | AC | 132 ms
13,268 KB |
testcase_18 | AC | 71 ms
8,916 KB |
testcase_19 | AC | 176 ms
14,868 KB |
testcase_20 | AC | 223 ms
15,524 KB |
testcase_21 | AC | 204 ms
15,320 KB |
testcase_22 | AC | 168 ms
14,932 KB |
testcase_23 | AC | 99 ms
9,752 KB |
testcase_24 | AC | 5 ms
5,376 KB |
testcase_25 | AC | 201 ms
15,000 KB |
testcase_26 | AC | 172 ms
13,352 KB |
testcase_27 | AC | 170 ms
13,584 KB |
testcase_28 | AC | 52 ms
6,656 KB |
testcase_29 | AC | 48 ms
6,656 KB |
testcase_30 | AC | 187 ms
14,756 KB |
testcase_31 | AC | 121 ms
10,784 KB |
testcase_32 | AC | 31 ms
5,504 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; }