Submission #28468

# Submission time Handle Problem Language Result Execution time Memory
28468 2017-07-16T06:16:43 Z 점수판에 아이디와 팀명이 같이 표기되니, 신중하게 적어주세요.(#1186, kajebiii, secsegy, woqja125) Oriental P.A.D.A.K (FXCUP2_padak) C++14
0 / 1
0 ms 2160 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;
	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 Incorrect 0 ms 2160 KB Output isn't correct
3 Halted 0 ms 0 KB -