# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
28350 | 2017-07-16T04:55:45 Z | 三( ε:)(#1146, xdoju, veckal, unused) | Oriental P.A.D.A.K (FXCUP2_padak) | C++14 | 823 ms | 65072 KB |
#include <bits/stdc++.h> using namespace std; vector<vector<int>> dist; constexpr int dr[4][2] = { 1,0, 0,1, -1,0, 0,-1 }; int main() { int n, m, k, b, z; scanf("%d%d%d%d%d",&n,&m,&k,&b,&z); dist.resize(n, vector<int>(m)); queue<pair<int, int>> que; for (int i = 0; i < k; i++) { int x, y; scanf("%d%d",&x,&y); x--; y--; if (dist[x][y] == 0) { dist[x][y] = 1; que.emplace(x, y); } } while (que.empty() == false) { int x, y; tie(x, y) = que.front(); que.pop(); for (int d = 0; d < 4; d++) { int nx = x + dr[d][0]; int ny = y + dr[d][1]; if (nx < 0 || nx >= n || ny < 0 || ny >= m || dist[nx][ny]) continue; dist[nx][ny] = dist[x][y] + 1; que.emplace(nx, ny); } } vector<int> vt; for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) if (dist[i][j] > 1) vt.push_back(dist[i][j] - 1); sort(vt.begin(), vt.end()); int ans1 = 0; for (int i = 1, p = (int)vt.size() - 1; p >= 0; i++) { bool yes = false; for (int j = 0; j < z && p >= 0 && vt[p] >= i; j++, ans1++, p--, yes = true) ; if (yes == false) break; } printf("%d ", ans1); int ans2 = 0; for (int i = 1, p = 0; p < vt.size(); i++) { while (p < vt.size() && vt[p] < i) ++p; for (int j = 0; j < z && p < vt.size(); j++, ans2++, p++) ; } printf("%d\n", ans2); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2028 KB | Output is correct |
2 | Correct | 0 ms | 2028 KB | Output is correct |
3 | Correct | 69 ms | 12212 KB | Output is correct |
4 | Correct | 66 ms | 12204 KB | Output is correct |
5 | Correct | 69 ms | 12188 KB | Output is correct |
6 | Correct | 79 ms | 15288 KB | Output is correct |
7 | Correct | 73 ms | 12268 KB | Output is correct |
8 | Correct | 63 ms | 14208 KB | Output is correct |
9 | Correct | 176 ms | 62948 KB | Output is correct |
10 | Correct | 79 ms | 12224 KB | Output is correct |
11 | Correct | 93 ms | 12284 KB | Output is correct |
12 | Correct | 73 ms | 12216 KB | Output is correct |
13 | Correct | 76 ms | 15300 KB | Output is correct |
14 | Correct | 63 ms | 12268 KB | Output is correct |
15 | Correct | 73 ms | 14208 KB | Output is correct |
16 | Correct | 199 ms | 62948 KB | Output is correct |
17 | Correct | 83 ms | 12388 KB | Output is correct |
18 | Correct | 89 ms | 12824 KB | Output is correct |
19 | Correct | 83 ms | 12360 KB | Output is correct |
20 | Correct | 89 ms | 15388 KB | Output is correct |
21 | Correct | 96 ms | 12948 KB | Output is correct |
22 | Correct | 63 ms | 14212 KB | Output is correct |
23 | Correct | 256 ms | 62992 KB | Output is correct |
24 | Correct | 413 ms | 14368 KB | Output is correct |
25 | Correct | 453 ms | 14320 KB | Output is correct |
26 | Correct | 423 ms | 14348 KB | Output is correct |
27 | Correct | 619 ms | 17412 KB | Output is correct |
28 | Correct | 426 ms | 14292 KB | Output is correct |
29 | Correct | 439 ms | 14196 KB | Output is correct |
30 | Correct | 823 ms | 65072 KB | Output is correct |
31 | Correct | 66 ms | 12208 KB | Output is correct |
32 | Correct | 96 ms | 62948 KB | Output is correct |