Submission #28604

# Submission time Handle Problem Language Result Execution time Memory
28604 2017-07-16T07:55:37 Z 맞왜틀 맞왜틀 신나는노래~ 헤이! 나도한번 불러보자(#1216, skdudn321, choiking10) Oriental P.A.D.A.K (FXCUP2_padak) C++
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>

using lint = long long int;
using pii = std::pair<int, int>;

using std::vector;
using std::queue;

int xx[4] = { 0, 0, 1, -1 };
int yy[4] = { 1, -1, 0, 0 };
vector<int> graph[1001000];
int cou[1001000];
int temp_cou[1001000];
queue<pii> qu;

int main(void) {
	int N, M, K, B, Z;
	scanf("%d %d %d %d %d", &N, &M, &K, &B, &Z);
	
	for (int i = 1; i <= N; i++) {
		graph[i].resize(M + 1, 1001000);
	}

	for (int i = 1; i <= K; i++) {
		int t1, t2;
		scanf("%d %d", &t1, &t2);
		graph[t1][t2] = 0;
		qu.push(pii(t1, t2));
	}

	int val = 1;
	while (!qu.empty()) {
		int cou = qu.size();
		for(int asdf = 1; asdf <= cou; asdf++){
			int x = qu.front().first;
			int y = qu.front().second;
			qu.pop();

			for (int i = 0; i < 4; i++) {
				if (0 < x + xx[i] && x + xx[i] <= N && 0 < y + yy[i] && y + yy[i] <= M) {
					if (graph[x + xx[i]][y + yy[i]] > val) {
						graph[x + xx[i]][y + yy[i]] = val;
						qu.push(pii(x + xx[i], y + yy[i]));
					}
				}
			}
		}
		val++;
	}

	int maxi = 0;
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= M; j++) {
			maxi = std::max(maxi, graph[i][j]);
			cou[graph[i][j]]++;
		}
	}

	int ans1 = 0, ans2 = 0;
	for (int i = 1; i <= maxi; i++) {
		temp_cou[i] = cou[i];
	}
	int rest = 0;
	for (int i = 1; i <= maxi; i++) {
		if (Z <= temp_cou[i]) {
			ans1 += Z;
			if (temp_cou[i] - Z >= rest) {
				ans1 += rest;
				rest = 0;
			}
			else {
				ans1 += temp_cou[i] - Z;
				rest -= temp_cou[i] - Z;
			}
		}
		else {
			ans1 += temp_cou[i];
			rest += Z - temp_cou[i];
		}
	}
	int ind = maxi;
	for (int i = 1; i <= maxi; i++) {
		if (i > ind) {
			break;
		}
		int cur = 0;
		while (cur < Z) {
			if (temp_cou[ind] >= Z - cur) {
				temp_cou[ind] -= Z - cur;
				cur = Z;
			}
			else {
				cur += temp_cou[ind];
				ind--;
			}
			if (i > ind) {
				break;
			}
		}
		ans2 += cur;
		if (i > ind) {
			break;
		}
	}

	printf("%d %d", ans2, ans1);

	return 0;
}

Compilation message

padak.cpp:3:7: error: expected nested-name-specifier before 'lint'
 using lint = long long int;
       ^
padak.cpp:4:7: error: expected nested-name-specifier before 'pii'
 using pii = std::pair<int, int>;
       ^
padak.cpp:14:7: error: 'pii' was not declared in this scope
 queue<pii> qu;
       ^
padak.cpp:14:10: error: template argument 1 is invalid
 queue<pii> qu;
          ^
padak.cpp:14:10: error: template argument 2 is invalid
padak.cpp: In function 'int main()':
padak.cpp:28:6: error: request for member 'push' in 'qu', which is of non-class type 'int'
   qu.push(pii(t1, t2));
      ^
padak.cpp:28:21: error: 'pii' was not declared in this scope
   qu.push(pii(t1, t2));
                     ^
padak.cpp:32:13: error: request for member 'empty' in 'qu', which is of non-class type 'int'
  while (!qu.empty()) {
             ^
padak.cpp:33:16: error: request for member 'size' in 'qu', which is of non-class type 'int'
   int cou = qu.size();
                ^
padak.cpp:35:15: error: request for member 'front' in 'qu', which is of non-class type 'int'
    int x = qu.front().first;
               ^
padak.cpp:36:15: error: request for member 'front' in 'qu', which is of non-class type 'int'
    int y = qu.front().second;
               ^
padak.cpp:37:7: error: request for member 'pop' in 'qu', which is of non-class type 'int'
    qu.pop();
       ^
padak.cpp:43:10: error: request for member 'push' in 'qu', which is of non-class type 'int'
       qu.push(pii(x + xx[i], y + yy[i]));
          ^
padak.cpp:43:39: error: 'pii' was not declared in this scope
       qu.push(pii(x + xx[i], y + yy[i]));
                                       ^
padak.cpp:18: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:26:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &t1, &t2);
                           ^