#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef pair<int, int> pi; typedef pair<ll, int> pli; typedef pair<ll, pi> plp;
typedef tuple<int, int, int> ti; typedef tuple<ll, int, int> tli;
const int INF = 0x3f2f1f0f;
const ll LINF = 1ll * INF * INF;
int N, M, K, B, Z;
vector<vector<int>> When;
int main() {
cin >> N >> M >> K >> B >> Z;
When = vector<vector<int>>(N, vector<int>(M, -1));
queue<pi> Q;
for(int k=0; k<K; k++) {
int x, y; scanf("%d%d", &x, &y); x--; y--;
Q.push(pi(x, y));
When[x][y] = 0;
}
int maxK = -1;
vector<int> list;
while(!Q.empty()) {
int x, y; tie(x, y) = Q.front(); Q.pop();
int v = When[x][y];
list.push_back(v);
maxK = v;
for(int k=0; k<4; k++) {
int nx = x + "1012"[k] - '1', ny = y + "0121"[k] - '1';
if(nx < 0 || ny < 0 || nx >= N || ny >= M) continue;
if(When[nx][ny] != -1) continue;
When[nx][ny] = v+1;
Q.push(pi(nx, ny));
}
}
int ix = 0, maxAns = 0;
for(int k=1; k<=maxK+1; k++) {
while(ix < SZ(list) && list[ix] < k) ix++;
int now = min(Z, SZ(list) - ix);
maxAns += now;
ix += now;
}
int minAns = 0;
ix = SZ(list) - 1;
for(int k=1; k<=maxK+1; k++) {
for(int i=0; i<Z; i++) {
if(ix < 0 || list[ix] < k) break;
minAns++; ix--;
}
if(ix < 0 || list[ix] < k) break;
}
printf("%d %d\n", minAns, maxAns);
return 0;
}
Compilation message
padak.cpp: In function 'int main()':
padak.cpp:23:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
int x, y; scanf("%d%d", &x, &y); x--; y--;
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2024 KB |
Output is correct |
2 |
Correct |
0 ms |
2024 KB |
Output is correct |
3 |
Correct |
33 ms |
12204 KB |
Output is correct |
4 |
Correct |
36 ms |
12196 KB |
Output is correct |
5 |
Correct |
39 ms |
12184 KB |
Output is correct |
6 |
Correct |
43 ms |
15284 KB |
Output is correct |
7 |
Correct |
29 ms |
12264 KB |
Output is correct |
8 |
Correct |
33 ms |
14204 KB |
Output is correct |
9 |
Correct |
99 ms |
62944 KB |
Output is correct |
10 |
Correct |
49 ms |
12212 KB |
Output is correct |
11 |
Correct |
39 ms |
12240 KB |
Output is correct |
12 |
Correct |
43 ms |
12196 KB |
Output is correct |
13 |
Correct |
39 ms |
15300 KB |
Output is correct |
14 |
Correct |
46 ms |
12264 KB |
Output is correct |
15 |
Correct |
36 ms |
14208 KB |
Output is correct |
16 |
Correct |
139 ms |
62944 KB |
Output is correct |
17 |
Correct |
53 ms |
12400 KB |
Output is correct |
18 |
Correct |
83 ms |
12820 KB |
Output is correct |
19 |
Correct |
56 ms |
12412 KB |
Output is correct |
20 |
Correct |
56 ms |
15388 KB |
Output is correct |
21 |
Correct |
113 ms |
13084 KB |
Output is correct |
22 |
Correct |
46 ms |
14220 KB |
Output is correct |
23 |
Correct |
236 ms |
63008 KB |
Output is correct |
24 |
Correct |
466 ms |
17632 KB |
Output is correct |
25 |
Correct |
489 ms |
17500 KB |
Output is correct |
26 |
Correct |
419 ms |
17592 KB |
Output is correct |
27 |
Correct |
646 ms |
20596 KB |
Output is correct |
28 |
Correct |
439 ms |
17472 KB |
Output is correct |
29 |
Correct |
383 ms |
22404 KB |
Output is correct |
30 |
Memory limit exceeded |
633 ms |
65536 KB |
Memory limit exceeded |
31 |
Halted |
0 ms |
0 KB |
- |