#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
#include <set>
#include <unordered_map>
#include <list>
#include <unordered_set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#define INFI 987654321
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
struct Node{
int x, y, dist;
};
int N, M, K, B, Z;
vector<int> visit[1000001];
vector<int> data;
int dx[] = {1, 0, 0, -1};
int dy[] = {0, 1, -1, 0};
int main() {
ios_base::sync_with_stdio(false);
cin >> N >> M >> K >> B >> Z;
for(int i = 1; i <= N; ++i)
visit[i].resize(M + 1, 0);
queue<Node> que;
for(int i = 0; i < K; ++i) {
Node here;
cin >> here.x >> here.y;
here.dist = 0;
que.push(here);
}
while(que.empty() == false) {
Node here = que.front();
//cout << here.x << " " << here.y << endl;
que.pop();
if(visit[here.x][here.y])
continue;
visit[here.x][here.y] = 1;
data.push_back(here.dist);
for(int i = 0; i < 4; ++i) {
Node there = here;
there.x += dx[i];
there.y += dy[i];
there.dist++;
if(there.x < 1 || there.y < 1 || there.x > N || there.y > M)
continue;
if(visit[there.x][there.y] == 0)
que.push(there);
}
}
reverse(data.begin(), data.end());
vector<int> data2 = data;
int mini = 0, maxi = 0, t = 0, cur = 0;
while(data.empty() == false) {
while(data.empty() == false && data.back() <= t)
data.pop_back();
for(int i = 0; i < Z; ++i) {
if(cur >= data.size())
break;
mini++;
cur++;
}
t++;
}
t = 0;
while(data2.empty() == false) {
while(data2.empty() == false && data2.back() <= t)
data2.pop_back();
for(int i = 0; i < Z; ++i) {
if(data2.empty())
break;
data2.pop_back();
maxi++;
}
t++;
}
cout << mini << " " << maxi;
return 0;
}
Compilation message
padak.cpp: In function 'int main()':
padak.cpp:67:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(cur >= data.size())
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
25620 KB |
Output is correct |
2 |
Correct |
6 ms |
25620 KB |
Output is correct |
3 |
Correct |
66 ms |
37588 KB |
Output is correct |
4 |
Correct |
63 ms |
37588 KB |
Output is correct |
5 |
Correct |
59 ms |
37572 KB |
Output is correct |
6 |
Correct |
56 ms |
39912 KB |
Output is correct |
7 |
Correct |
53 ms |
37568 KB |
Output is correct |
8 |
Correct |
43 ms |
37568 KB |
Output is correct |
9 |
Correct |
83 ms |
64912 KB |
Output is correct |
10 |
Correct |
56 ms |
37588 KB |
Output is correct |
11 |
Correct |
63 ms |
37852 KB |
Output is correct |
12 |
Correct |
66 ms |
37644 KB |
Output is correct |
13 |
Correct |
66 ms |
39956 KB |
Output is correct |
14 |
Correct |
53 ms |
37612 KB |
Output is correct |
15 |
Correct |
39 ms |
37572 KB |
Output is correct |
16 |
Correct |
143 ms |
64912 KB |
Output is correct |
17 |
Correct |
73 ms |
38528 KB |
Output is correct |
18 |
Correct |
86 ms |
39640 KB |
Output is correct |
19 |
Correct |
69 ms |
38516 KB |
Output is correct |
20 |
Correct |
63 ms |
40360 KB |
Output is correct |
21 |
Correct |
116 ms |
40644 KB |
Output is correct |
22 |
Correct |
43 ms |
37596 KB |
Output is correct |
23 |
Correct |
246 ms |
65004 KB |
Output is correct |
24 |
Correct |
369 ms |
61040 KB |
Output is correct |
25 |
Correct |
333 ms |
61036 KB |
Output is correct |
26 |
Correct |
279 ms |
61028 KB |
Output is correct |
27 |
Correct |
463 ms |
62404 KB |
Output is correct |
28 |
Correct |
309 ms |
60752 KB |
Output is correct |
29 |
Correct |
276 ms |
50916 KB |
Output is correct |
30 |
Memory limit exceeded |
159 ms |
65536 KB |
Memory limit exceeded |
31 |
Halted |
0 ms |
0 KB |
- |