Submission #27807

# Submission time Handle Problem Language Result Execution time Memory
27807 2017-07-14T06:49:03 Z 상수조아(#1181) Cultivation (JOI17_cultivation) C++
Compilation error
0 ms 0 KB
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <set>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
#define pb(x) push_back(x)
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define Fi first
#define Se second

int R, C, N;
pii P[320];

int Do(ll L) {
	for(int i=0;i<R&&i<=L;i++) {
		for(int j=0;i+j<R&&i+j<=L;j++) {
			int left = 0, right = 0;
			int g = 0;
			int ok = 1;
			for(int r=1;r<=R;r++){
				vector <int> v;
				for(int k=1;k<=N;k++) {
					int x = P[k].Fi, y = P[k].Se;
					if(x-j <= r && r <= x+i) {
						v.pb(y);
					}
				}
				if(sz(v) == 0) { ok = 0; break; }
				left = max(left, v[0] - 1);
				right = max(right, C - v.back());
				for(int i=1;i<sz(v);i++) g = max(g, v[i] - v[i-1] - 1);
			}
			if(ok) {
				ll f = max(g, left + right);
				if(f + i + j <= L) return 1;
			}
		}
	}
	return 0;
}

int main(){
	scanf("%d%d%d", &R, &C, &N);
	if(R > 40) return 0;
	for(int i=1;i<=N;i++) scanf("%d%d", &P[i].Fi, &P[i].Se);
	sort(P+1, P+1+N, [](pii a, pii b) { return a.Se < b.Se; });
	ll low = 0, high = R + C - 2, res = 0;
	while(low <= high) {
		ll mid = (low + high) >> 1;
		if(Do(mid)) res = mid, high = mid - 1;
		else low = mid + 1;
	}
	printf("%lld\n", res);
	return 0;
};

Compilation message

cultivation.cpp: In function 'int main()':
cultivation.cpp:52:58: warning: lambda expressions only available with -std=c++11 or -std=gnu++11
  sort(P+1, P+1+N, [](pii a, pii b) { return a.Se < b.Se; });
                                                          ^
cultivation.cpp:52:59: error: no matching function for call to 'sort(pii*, pii*, main()::<lambda(pii, pii)>)'
  sort(P+1, P+1+N, [](pii a, pii b) { return a.Se < b.Se; });
                                                           ^
In file included from /usr/include/c++/5/algorithm:62:0,
                 from cultivation.cpp:3:
/usr/include/c++/5/bits/stl_algo.h:4689:5: note: candidate: template<class _RAIter> void std::sort(_RAIter, _RAIter)
     sort(_RandomAccessIterator __first, _RandomAccessIterator __last)
     ^
/usr/include/c++/5/bits/stl_algo.h:4689:5: note:   template argument deduction/substitution failed:
cultivation.cpp:52:59: note:   candidate expects 2 arguments, 3 provided
  sort(P+1, P+1+N, [](pii a, pii b) { return a.Se < b.Se; });
                                                           ^
In file included from /usr/include/c++/5/algorithm:62:0,
                 from cultivation.cpp:3:
/usr/include/c++/5/bits/stl_algo.h:4718:5: note: candidate: template<class _RAIter, class _Compare> void std::sort(_RAIter, _RAIter, _Compare)
     sort(_RandomAccessIterator __first, _RandomAccessIterator __last,
     ^
/usr/include/c++/5/bits/stl_algo.h:4718:5: note:   template argument deduction/substitution failed:
cultivation.cpp: In substitution of 'template<class _RAIter, class _Compare> void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = std::pair<int, int>*; _Compare = main()::<lambda(pii, pii)>]':
cultivation.cpp:52:59:   required from here
cultivation.cpp:52:59: error: template argument for 'template<class _RAIter, class _Compare> void std::sort(_RAIter, _RAIter, _Compare)' uses local type 'main()::<lambda(pii, pii)>'
  sort(P+1, P+1+N, [](pii a, pii b) { return a.Se < b.Se; });
                                                           ^
cultivation.cpp:52:59: error:   trying to instantiate 'template<class _RAIter, class _Compare> void std::sort(_RAIter, _RAIter, _Compare)'
cultivation.cpp:49:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d", &R, &C, &N);
                             ^
cultivation.cpp:51:57: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=1;i<=N;i++) scanf("%d%d", &P[i].Fi, &P[i].Se);
                                                         ^