Submission #28427

# Submission time Handle Problem Language Result Execution time Memory
28427 2017-07-16T05:41:29 Z AcornCkiGuiziTeam(#1202, dotorya, cki86201, zigui) Oriental P.A.D.A.K (FXCUP2_padak) C++14
1 / 1
473 ms 27780 KB
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:1048576")  
using namespace std;

#define mp make_pair  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;
typedef tuple <int, int, int> t3;

int IT_MAX = 1 << 17;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<(n);i++)

int dis[1000050];
vector <int> Vu;

int cnt[2000050];
int ocnt[2000050];
int main() {
	int N, M, K, B, Z, i, j;
	scanf("%d %d %d %d %d", &N, &M, &K, &B, &Z);
	for (i = 0; i < N*M; i++) dis[i] = INF;

	while (K--) {
		scanf("%d %d", &i, &j);
		i--, j--;
		dis[i*M + j] = 0;
		Vu.emplace_back(i*M + j);
	}
	for (i = 0; i < Vu.size(); i++) {
		int x = Vu[i] / M, y = Vu[i] % M;
		int d = dis[Vu[i]];
		for (j = 0; j < 4; j++) {
			int x2 = x + "1102"[j] - '1';
			int y2 = y + "0211"[j] - '1';
			if (x2 < 0 || x2 >= N || y2 < 0 || y2 >= M || dis[x2*M+y2] != INF) continue;
			dis[x2*M+y2] = d + 1;
			Vu.push_back(x2*M + y2);
		}
	}
	Vu.clear();

	for (i = 0; i < 2000050; i++) ocnt[i] = cnt[i] = 0;
	for (i = 0; i < N*M; i++) ocnt[dis[i]]++;

	int a1 = 0, a2 = 0;

	int p = 1;
	for (i = 0; i <= 2000000; i++) cnt[i] = ocnt[i];
	for (i = 1; i <= 2000000; i++) {
		if (p < i) p = i;
		int t = Z;
		while (p <= 2000000 && t) {
			int x = min(t, cnt[p]);
			a2 += x;
			cnt[p] -= x;
			t -= x;
			if (cnt[p] == 0) p++;
		}
	}

	p = 2000000;
	for (i = 0; i <= 2000000; i++) cnt[i] = ocnt[i];
	for (i = 1; i <= 2000000; i++) {
		int t = Z;
		while (p >= i && t) {
			int x = min(t, cnt[p]);
			a1 += x;
			cnt[p] -= x;
			t -= x;
			if (cnt[p] == 0) p--;
		}
	}
	return !printf("%d %d\n", a1, a2);
}

Compilation message

padak.cpp:23:0: warning: ignoring #pragma warning  [-Wunknown-pragmas]
 #pragma warning(disable:4996)  
 ^
padak.cpp:24:0: warning: ignoring #pragma comment  [-Wunknown-pragmas]
 #pragma comment(linker, "/STACK:1048576")  
 ^
padak.cpp: In function 'int main()':
padak.cpp:66:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (i = 0; i < Vu.size(); i++) {
                ^
padak.cpp:57: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:61:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &i, &j);
                         ^
# Verdict Execution time Memory Grader output
1 Correct 36 ms 21552 KB Output is correct
2 Correct 29 ms 21552 KB Output is correct
3 Correct 79 ms 27780 KB Output is correct
4 Correct 69 ms 27780 KB Output is correct
5 Correct 66 ms 27780 KB Output is correct
6 Correct 59 ms 27780 KB Output is correct
7 Correct 69 ms 27780 KB Output is correct
8 Correct 59 ms 27780 KB Output is correct
9 Correct 56 ms 27780 KB Output is correct
10 Correct 69 ms 27780 KB Output is correct
11 Correct 73 ms 27780 KB Output is correct
12 Correct 83 ms 27780 KB Output is correct
13 Correct 56 ms 27780 KB Output is correct
14 Correct 66 ms 27780 KB Output is correct
15 Correct 56 ms 27780 KB Output is correct
16 Correct 83 ms 27780 KB Output is correct
17 Correct 79 ms 27780 KB Output is correct
18 Correct 96 ms 27780 KB Output is correct
19 Correct 86 ms 27780 KB Output is correct
20 Correct 69 ms 27780 KB Output is correct
21 Correct 113 ms 27780 KB Output is correct
22 Correct 66 ms 27780 KB Output is correct
23 Correct 66 ms 27780 KB Output is correct
24 Correct 466 ms 27780 KB Output is correct
25 Correct 386 ms 27780 KB Output is correct
26 Correct 443 ms 27780 KB Output is correct
27 Correct 443 ms 27780 KB Output is correct
28 Correct 429 ms 27780 KB Output is correct
29 Correct 443 ms 27780 KB Output is correct
30 Correct 473 ms 27780 KB Output is correct
31 Correct 66 ms 27780 KB Output is correct
32 Correct 59 ms 27780 KB Output is correct