結果
| 問題 |
No.655 E869120 and Good Triangles
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-07-28 18:05:15 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,253 bytes |
| コンパイル時間 | 2,008 ms |
| コンパイル使用メモリ | 201,484 KB |
| 実行使用メモリ | 259,260 KB |
| 最終ジャッジ日時 | 2025-07-28 18:05:32 |
| 合計ジャッジ時間 | 13,433 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 WA * 3 |
ソースコード
#include<bits/stdc++.h>
#define ls(k) k << 1
#define rs(k) k << 1 | 1
#define fi first
#define se second
#define popcnt(x) __builtin_popcount(x)
#define open(s1, s2) freopen(s1, "r", stdin), freopen(s2, "w", stdout);
#define id(i, j) i * (i - 1) / 2 + j
using namespace std;
typedef __int128 __;
typedef long double lb;
typedef double db;
typedef unsigned long long ull;
typedef long long ll;
bool Begin;
const int N = 4040;
inline ll read(){
ll x = 0, f = 1;
char c = getchar();
while(c < '0' || c > '9'){
if(c == '-')
f = -1;
c = getchar();
}
while(c >= '0' && c <= '9'){
x = (x << 1) + (x << 3) + (c ^ 48);
c = getchar();
}
return x * f;
}
inline void write(ll x){
if(x < 0){
putchar('-');
x = -x;
}
if(x > 9)
write(x / 10);
putchar(x % 10 + '0');
}
ll ans, p;
int n, x, y, k;
int a[N][N], b[N][N], c[N][N], dp[N][N];
int dx[6] = {-1, -1, 0, 0, 1, 1}, dy[6] = {-1, 0, -1, 1, 0, 1};
ll get(int x, int y, int r){
return c[x][y] - c[x + r][y + r] - (b[x + r][y + r - 1] - b[x + r][y - 1]);
}
bool End;
int main(){
queue<pair<int, int>> q;
memset(a, 0x3f, sizeof(a));
n = read(), k = read(), p = read();
while(k--){
x = read(), y = read();
q.push({x, y});
a[x][y] = 0;
}
while(!q.empty()){
auto t = q.front();
q.pop();
int x = t.fi, y = t.se;
for(int k = 0; k < 6; ++k){
int zx = x + dx[k], zy = y + dy[k];
if(zy < 0 || zx > n || zy > zx)
continue;
if(a[zx][zy] > a[x][y] + 1){
a[zx][zy] = a[x][y] + 1;
q.push({zx, zy});
}
}
}
for(int i = n; i >= 1; --i){
for(int j = 1; j <= i; ++j){
b[i][j] = a[i][j] + b[i + 1][j];
c[i][j] = b[i][j] + c[i + 1][j + 1];
}
}
for(int i = n; i >= 1; --i){
for(int j = 1; j <= i; ++j)
b[i][j] = a[i][j] + b[i][j - 1];
for(int j = 1; j <= i; ++j)
b[i][j] += b[i + 1][j];
}
for (int i = 1; i <= n + 1; i++)
dp[n + 1][i] = 1;
for(int i = n; i >= 1; i--){
for(int j = i; j >= 1; j--){
int r = min(dp[i + 1][j], dp[i + 1][j + 1]);
while(1){
if(get(i, j, r) < p){
dp[i][j] = r + 1;
break;
}
r--;
}
ans += (n - i + 1) - dp[i][j] + 1;
}
}
write(ans);
cerr << '\n' << abs(&Begin - &End) / 1048576 << "MB";
return 0;
}