Submission #55827681
Source Code Expand
#include <bits/stdc++.h>
using i64 = long long;
using pii = std::pair<int, int>;
using tuu = std::tuple<int, int, int>;
#define pb push
using std::cin, std::cout, std::string, std::vector;
int read(int x = 0, int f = 0, char ch = getchar())
{
while (ch < 48 or 57 < ch) f = ch == 45, ch = getchar();
while(48 <= ch and ch <= 57) x = x * 10 + ch - 48, ch = getchar();
return f ? -x : x;
}
const int N = 1e3 + 5;
int n, m, Y;
int a[N][N];
bool vis[N][N];
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};
struct Node
{
int x, y;
bool friend operator < (Node a, Node b)
{
return ::a[a.x][a.y] > ::a[b.x][b.y];
}
};
std::priority_queue<Node> S;
void put(int x, int y)
{
if (x < 1 or x > n or y < 1 or y > m) return;
if (vis[x][y]) return;
S.push({x, y}), vis[x][y] = 1;
}
void solve()
{
n = read(), m = read(), Y = read();
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++)
a[i][j] = read();
for (int i = 1; i <= n; i++) put(i, 1), put(i, m);
for (int j = 1; j <= m; j++) put(1, j), put(n, j);
int ans = n * m;
for (int i = 1; i <= Y; i++)
{
while (!S.empty() and a[S.top().x][S.top().y] <= i)
{
auto [x, y] = S.top(); S.pop();
ans--;
for (int j = 0; j < 4; j++) put(x + dx[j], y + dy[j]);
}
printf("%d\n", ans);
}
}
signed main()
{
#ifndef ONLINE_JUDGE
freopen("x.in", "r", stdin);
#endif
// for (int T = read(); T--; solve());
solve();
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | E - Sinking Land |
| User | TosakaUCW |
| Language | C++ 20 (gcc 12.2) |
| Score | 450 |
| Code Size | 1633 Byte |
| Status | AC |
| Exec Time | 284 ms |
| Memory | 12592 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 450 / 450 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | example_00.txt, example_01.txt |
| All | example_00.txt, example_01.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, hand_07.txt, hand_08.txt, hand_09.txt, hand_10.txt, hand_11.txt, hand_12.txt, hand_13.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_27.txt, random_28.txt, random_29.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| example_00.txt | AC | 1 ms | 3680 KiB |
| example_01.txt | AC | 1 ms | 3668 KiB |
| hand_00.txt | AC | 170 ms | 12400 KiB |
| hand_01.txt | AC | 170 ms | 12488 KiB |
| hand_02.txt | AC | 159 ms | 9252 KiB |
| hand_03.txt | AC | 8 ms | 8476 KiB |
| hand_04.txt | AC | 6 ms | 3672 KiB |
| hand_05.txt | AC | 5 ms | 3864 KiB |
| hand_06.txt | AC | 279 ms | 12348 KiB |
| hand_07.txt | AC | 152 ms | 12136 KiB |
| hand_08.txt | AC | 25 ms | 8788 KiB |
| hand_09.txt | AC | 247 ms | 10308 KiB |
| hand_10.txt | AC | 145 ms | 12256 KiB |
| hand_11.txt | AC | 1 ms | 3612 KiB |
| hand_12.txt | AC | 16 ms | 8832 KiB |
| hand_13.txt | AC | 1 ms | 3684 KiB |
| random_00.txt | AC | 284 ms | 12352 KiB |
| random_01.txt | AC | 280 ms | 12472 KiB |
| random_02.txt | AC | 284 ms | 12480 KiB |
| random_03.txt | AC | 278 ms | 12592 KiB |
| random_04.txt | AC | 277 ms | 12448 KiB |
| random_05.txt | AC | 254 ms | 10456 KiB |
| random_06.txt | AC | 255 ms | 10220 KiB |
| random_07.txt | AC | 250 ms | 10284 KiB |
| random_08.txt | AC | 249 ms | 10280 KiB |
| random_09.txt | AC | 252 ms | 10372 KiB |
| random_10.txt | AC | 219 ms | 9332 KiB |
| random_11.txt | AC | 223 ms | 9192 KiB |
| random_12.txt | AC | 220 ms | 9152 KiB |
| random_13.txt | AC | 219 ms | 9336 KiB |
| random_14.txt | AC | 218 ms | 9172 KiB |
| random_15.txt | AC | 170 ms | 8664 KiB |
| random_16.txt | AC | 170 ms | 8628 KiB |
| random_17.txt | AC | 172 ms | 8788 KiB |
| random_18.txt | AC | 170 ms | 8860 KiB |
| random_19.txt | AC | 170 ms | 8624 KiB |
| random_20.txt | AC | 250 ms | 10180 KiB |
| random_21.txt | AC | 248 ms | 10192 KiB |
| random_22.txt | AC | 249 ms | 10384 KiB |
| random_23.txt | AC | 250 ms | 10196 KiB |
| random_24.txt | AC | 251 ms | 10180 KiB |
| random_25.txt | AC | 215 ms | 12464 KiB |
| random_26.txt | AC | 213 ms | 12352 KiB |
| random_27.txt | AC | 216 ms | 12560 KiB |
| random_28.txt | AC | 215 ms | 12592 KiB |
| random_29.txt | AC | 214 ms | 12484 KiB |