Submission #28299

# Submission time Handle Problem Language Result Execution time Memory
28299 2017-07-16T04:31:17 Z 뚜룹뚜룹뚜룹뚜스~><(#1151, chan492811) Oriental P.A.D.A.K (FXCUP2_padak) C++11
0 / 1
3 ms 13648 KB
#include <cstdio>
#include <cstring>
#include <deque>
using namespace std;

int n, m, k, b, z, r1, r2;
int direct[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
int darr[1000010], rarr1[1000010], rarr2[1000010];
deque <int> dq;

int main(){
	int i, a, s, x, y, now, nz, tmp;
	scanf("%d %d %d %d %d", &n, &m, &k, &b, &z);
	memset(darr, -1, sizeof(darr));
	for(i = 0; i < k; i++){
		scanf("%d %d", &a, &s); a--; s--;
		dq.push_back(a * m + s);
		darr[a * m + s] = 0; rarr1[0]++;
	}
	while(!dq.empty()){
		a = dq[0] / m; s = dq[0] % m; dq.pop_front();
		for(i = 0; i < 4; i++){
			x = a + direct[i][0];
			y = s + direct[i][1];
			if(x < 0 || x >= n || y < 0 || y >= m) continue;
			if(darr[x * m + y] != -1) continue;
			darr[x * m + y] = darr[a * m + s] + 1; rarr1[darr[x * m + y]]++;
			dq.push_back(x * m + y);
		}
	}
	for(i = 1; i <= n * m; i++) rarr2[i] = rarr1[i];
	now = 1;
	for(i = 1; i <= n * m; i++){
		now = max(now, i);
		if(now > n * m) break;
		nz = z;
		while(nz){
			if(now > n * m) break;
			if(rarr1[now] >= nz) rarr1[now] -= nz, r1 += nz, nz = 0;
			else r1 += rarr1[now], nz -= rarr1[now++];
		}
	}
	now = n * m;
	while(rarr2[now] == 0) now--;
	for(i = 1; i <= n * m; i++){
		if(now < i) break;
		nz = z;
		while(nz){
			if(now < i) break;
			if(rarr2[now] >= nz) rarr2[now] -= nz, r2 += nz, nz = 0;
			else r2 += rarr2[now], nz -= rarr2[now--];
		}
	}
	printf("%d %d", r1, r2);
	return 0;
}

Compilation message

padak.cpp: In function 'int main()':
padak.cpp:12:30: warning: unused variable 'tmp' [-Wunused-variable]
  int i, a, s, x, y, now, nz, tmp;
                              ^
padak.cpp:13:45: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %d %d %d", &n, &m, &k, &b, &z);
                                             ^
padak.cpp:16:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &a, &s); a--; s--;
                         ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 13648 KB Output is correct
2 Incorrect 3 ms 13648 KB Output isn't correct
3 Halted 0 ms 0 KB -