結果
問題 | No.655 E869120 and Good Triangles |
ユーザー | FF256grhy |
提出日時 | 2019-11-23 12:06:36 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 1,918 ms / 2,500 ms |
コード長 | 3,530 bytes |
コンパイル時間 | 2,111 ms |
コンパイル使用メモリ | 181,312 KB |
実行使用メモリ | 316,568 KB |
最終ジャッジ日時 | 2024-10-11 06:54:17 |
合計ジャッジ時間 | 35,240 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,248 KB |
testcase_02 | AC | 2 ms
5,248 KB |
testcase_03 | AC | 2 ms
5,248 KB |
testcase_04 | AC | 2 ms
5,248 KB |
testcase_05 | AC | 2 ms
5,248 KB |
testcase_06 | AC | 2 ms
5,248 KB |
testcase_07 | AC | 2 ms
5,248 KB |
testcase_08 | AC | 2 ms
5,248 KB |
testcase_09 | AC | 2 ms
5,248 KB |
testcase_10 | AC | 1,852 ms
316,416 KB |
testcase_11 | AC | 1,764 ms
316,556 KB |
testcase_12 | AC | 1,778 ms
316,448 KB |
testcase_13 | AC | 1,778 ms
316,544 KB |
testcase_14 | AC | 1,857 ms
316,416 KB |
testcase_15 | AC | 1,823 ms
316,568 KB |
testcase_16 | AC | 1,918 ms
316,544 KB |
testcase_17 | AC | 1,874 ms
316,544 KB |
testcase_18 | AC | 1,877 ms
316,456 KB |
testcase_19 | AC | 1,856 ms
316,544 KB |
testcase_20 | AC | 1,883 ms
316,416 KB |
testcase_21 | AC | 1,873 ms
316,544 KB |
testcase_22 | AC | 1,762 ms
316,544 KB |
testcase_23 | AC | 1,817 ms
316,544 KB |
testcase_24 | AC | 1,085 ms
316,288 KB |
testcase_25 | AC | 1,092 ms
316,288 KB |
testcase_26 | AC | 1,080 ms
316,288 KB |
testcase_27 | AC | 1,199 ms
316,416 KB |
testcase_28 | AC | 1,035 ms
316,416 KB |
testcase_29 | AC | 1,146 ms
316,288 KB |
testcase_30 | AC | 2 ms
5,248 KB |
testcase_31 | AC | 1 ms
5,248 KB |
testcase_32 | AC | 2 ms
5,248 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) // ---- ---- #define T0(T) T #define T1(T) vector<T0(T)> #define T2(T) vector<T1(T)> #define V0(v, T, ...) v #define V1(v, T, n, ...) T1(T)(n, V0(v, T, __VA_ARGS__)) #define V2(v, T, n, ...) T2(T)(n, V1(v, T, __VA_ARGS__)) int main() { LL n, k, p; cin >> n >> k >> p; auto d = V2(n, int, n, 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; }