結果
問題 | No.655 E869120 and Good Triangles |
ユーザー | FF256grhy |
提出日時 | 2019-11-23 12:11:18 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 1,511 ms / 2,500 ms |
コード長 | 3,448 bytes |
コンパイル時間 | 1,646 ms |
コンパイル使用メモリ | 175,016 KB |
実行使用メモリ | 224,968 KB |
最終ジャッジ日時 | 2024-10-11 06:55:00 |
合計ジャッジ時間 | 27,977 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
7,628 KB |
testcase_01 | AC | 3 ms
9,680 KB |
testcase_02 | AC | 2 ms
7,628 KB |
testcase_03 | AC | 3 ms
7,760 KB |
testcase_04 | AC | 3 ms
9,564 KB |
testcase_05 | AC | 3 ms
7,624 KB |
testcase_06 | AC | 3 ms
7,624 KB |
testcase_07 | AC | 2 ms
7,500 KB |
testcase_08 | AC | 3 ms
7,628 KB |
testcase_09 | AC | 2 ms
7,628 KB |
testcase_10 | AC | 1,440 ms
223,944 KB |
testcase_11 | AC | 1,418 ms
223,236 KB |
testcase_12 | AC | 1,421 ms
223,424 KB |
testcase_13 | AC | 1,421 ms
223,688 KB |
testcase_14 | AC | 1,414 ms
223,436 KB |
testcase_15 | AC | 1,449 ms
223,128 KB |
testcase_16 | AC | 1,511 ms
224,840 KB |
testcase_17 | AC | 1,477 ms
223,564 KB |
testcase_18 | AC | 1,474 ms
223,796 KB |
testcase_19 | AC | 1,430 ms
224,968 KB |
testcase_20 | AC | 1,481 ms
224,204 KB |
testcase_21 | AC | 1,495 ms
224,328 KB |
testcase_22 | AC | 1,393 ms
224,324 KB |
testcase_23 | AC | 1,375 ms
223,304 KB |
testcase_24 | AC | 848 ms
222,664 KB |
testcase_25 | AC | 827 ms
222,280 KB |
testcase_26 | AC | 822 ms
221,636 KB |
testcase_27 | AC | 953 ms
222,024 KB |
testcase_28 | AC | 800 ms
221,640 KB |
testcase_29 | AC | 863 ms
221,768 KB |
testcase_30 | AC | 3 ms
7,496 KB |
testcase_31 | AC | 3 ms
7,500 KB |
testcase_32 | AC | 3 ms
7,632 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long signed int LL; typedef long long unsigned int LU; #define incID(i, l, r) for(LL i = (l) ; i < (r); ++i) #define incII(i, l, r) for(LL i = (l) ; i <= (r); ++i) #define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i) #define decII(i, l, r) for(LL i = (r) ; i >= (l); --i) #define inc(i, n) incID(i, 0, n) #define inc1(i, n) incII(i, 1, n) #define dec(i, n) decID(i, 0, n) #define dec1(i, n) decII(i, 1, n) #define inID(v, l, r) ((l) <= (v) && (v) < (r)) #define inII(v, l, r) ((l) <= (v) && (v) <= (r)) #define PB push_back #define EB emplace_back #define MP make_pair #define FI first #define SE second #define ALL(v) v.begin(), v.end() #define RALL(v) v.rbegin(), v.rend() template<typename T> bool setmin (T & a, T b) { if(b < a) { a = b; return true; } else { return false; } } template<typename T> bool setmax (T & a, T b) { if(b > a) { a = b; return true; } else { return false; } } template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } } template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } } LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; } LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); } LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); } template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); } template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; } #define bit(b, i) (((b) >> (i)) & 1) #define BC __builtin_popcountll #define SC static_cast #define SI(v) SC<int>(v.size()) #define SL(v) SC<LL >(v.size()) #define RF(e, v) for(auto & e: v) #define ef else if #define UR assert(false) // ---- ---- const int N = 4000; int d[N][N]; LL s1[N + 1][N + 1]; LL s2[N + 1][N + 1]; int main() { LL n, k, p; cin >> n >> k >> p; // auto d = V2(n, int, n, n); inc(i, n) { inc(j, n) { d[i][j] = n; } } queue<pair<int, int>> q; auto update = [&](int i, int j, int v) { if(setmin(d[i][j], v)) { q.push({ i, j }); } }; inc(l, k) { int i, j; cin >> i >> j; i--; j--; i = n - 1 - i; update(i, j, 0); } while(! q.empty()) { auto e = q.front(); q.pop(); int i = e.FI; int j = e.SE; inc(l, 6) { int di[6] = { +1, 0, -1, 0, +1, -1 }; int dj[6] = { 0, +1, 0, -1, -1, +1 }; int ii = i + di[l]; int jj = j + dj[l]; if(! (0 <= ii && 0 <= jj && ii + jj < n)) { continue; } update(ii, jj, d[i][j] + 1); } } // auto s1 = V2(0, LL, n + 1, n + 1); // auto s2 = V2(0, LL, n + 1, n + 1); inc(i, n) { inc(j, n) { if(i + j >= n) { continue; } s1[i][j + 1] = d[i][j]; s2[i + 1][j] = d[i][j]; } } incII(i, 0, n) { incII(j, 0, n) { if(i + j > n) { continue; } if(j > 0) { s1[i][j] += s1[i][j - 1]; } if(i > 0) { s2[i][j] += s2[i - 1][j]; } } } inc1(c, n) { inc1(j, c) { int i = c - j; s1[i][j] += s1[i + 1][j - 1]; } inc1(i, c) { int j = c - i; s2[i][j] += s2[i - 1][j + 1]; } } auto sum = [&](int c, int i, int j) -> LL { // assert(s1[0][c ] == s2[c ][0]); // assert(s1[0][i + j] == s2[i + j][0]); return s1[i][c - i] + s2[c - j][j] - s1[i][j] - s2[i][j] + s1[0][i + j] - s1[0][c]; }; LL ans = 0; inc1(c, n) { int j = c; incII(i, 0, c) { while(j >= 0 && sum(c, i, j) < p) { j--; } ans += j + 1; } } cout << ans << endl; return 0; }