Submission #28470

# Submission time Handle Problem Language Result Execution time Memory
28470 2017-07-16T06:17:45 Z 점수판에 아이디와 팀명이 같이 표기되니, 신중하게 적어주세요.(#1186, kajebiii, secsegy, woqja125) Oriental P.A.D.A.K (FXCUP2_padak) C++14
0 / 1
59 ms 65536 KB
#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<pair<pi, int> > Q;
	for(int k=0; k<K; k++) {
		int x, y; scanf("%d%d", &x, &y); x--; y--;
		Q.push(make_pair(pi(x, y), 0));
		When[x][y] = 0;
	}
	vector<pair<pi, int>> list;
	int maxK = -1;
	while(!Q.empty()) {
		pi p; int v; tie(p, v) = Q.front(); Q.pop(); int x, y; tie(x, y) = p;
		list.push_back(make_pair(p, v));
//		printf("%d %d [%d]\n", x, y, 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(make_pair(pi(nx, ny), v+1));
		}
	}
	int ix = 0, maxAns = 0;
	for(int k=1; k<=maxK+1; k++) {
		while(ix < SZ(list) && list[ix].second < 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].second < k) break;
			minAns++; ix--;
		}
		if(ix < 0 || list[ix].second < 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--;
                                  ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2024 KB Output is correct
2 Correct 0 ms 2160 KB Output is correct
3 Correct 49 ms 24492 KB Output is correct
4 Correct 56 ms 24484 KB Output is correct
5 Correct 56 ms 24472 KB Output is correct
6 Correct 53 ms 27572 KB Output is correct
7 Correct 59 ms 24552 KB Output is correct
8 Correct 43 ms 30592 KB Output is correct
9 Memory limit exceeded 56 ms 65536 KB Memory limit exceeded
10 Halted 0 ms 0 KB -