# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
28582 | 볼빨간 승관이 (#68) | Oriental P.A.D.A.K (FXCUP2_padak) | C++11 | 49 ms | 65536 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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<bool> 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;
visit[here.x][here.y] = true;
que.push(here);
}
while(que.empty() == false) {
Node here = que.front();
//cout << here.x << " " << here.y << endl;
que.pop();
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);
visit[there.x][there.y] = true;
}
}
}
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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |