답안 #105513

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
105513 2019-04-13T07:03:47 Z polyfish Shortcut (IOI16_shortcut) C++14
컴파일 오류
0 ms 0 KB
//Pantyhose(black) + glasses = infinity

#include <bits/stdc++.h>
using namespace std;
 
#define debug(x) cerr << #x << " = " << x << '\n';
#define BP() cerr << "OK!\n";
#define PR(A, n) {cerr << #A << " = "; for (int _=1; _<=n; ++_) cerr << A[_] << ' '; cerr << '\n';}
#define PR0(A, n) {cerr << #A << " = "; for (int _=0; _<n; ++_) cerr << A[_] << ' '; cerr << '\n';}
#define FILE_NAME "data"

const int64_t INF = 1e18;

int n;
int64_t c;
vector<int64_t> d, v;

bool check(int64_t x) {
	int64_t l1, r1, l2, r2;
	l1 = l2 = -INF;
	r1 = r2 = INF;

	for (int i=0; i<n; ++i) {
		for (int j=i+1; j<n; ++j) {
			if (d[j]-d[i]+v[i]+v[j]>x) {
				l1 = max(l1, d[i]+d[j]-x+c+v[i]+v[j]);
				r1 = min(r1, d[i]+d[j]+x-c-v[i]-v[j]);
				l2 = max(l2, d[i]-d[j]-x+c+v[i]+v[j]);
				r2 = min(r2, d[i]-d[j]+x-c-v[i]-v[j]);
			}
		}
	}
	// cerr << l1 << ' ' << r1 << ' ' << l2 << ' ' << r2 << '\n';

	for (int i=0; i<n; ++i) {
		for (int j=0; j<n; ++j) {
			int64_t tmp1 = d[i] + d[j], tmp2 = d[i] - d[j];
			if (l1<=tmp1 && tmp1<=r1 && l2<=tmp2 && tmp2<=r2) {
				// cerr << i << ' ' << j << '\n';
				return true;
			}
		}
	}

	return false;
}

int64_t find_shortcut(int _n, vector<int> _l, vector<int> _d, int _c) {
	c = _c;
	n = _n;

	for (auto x : _d)
		v.push_back(x);

	for (auto x : _l)
		d.push_back(x);

	d.insert(d.begin(), 0);
	for (int i=1; i<d.size(); ++i)
		d[i] += d[i-1];
	// PR0(v, n);

	// debug(check(80));

	int64_t l = 1, r = INF;
	for (int64_t mid=(l+r)/2; mid!=l && r!=mid; mid=(l+r)/2) {
		if (check(mid))
			r = mid;
		else
			l = mid;
	}

	for (int64_t i=l; i<=r; ++i) {
		if (check(i))
			return i;
	}

	return 0;
}

int main() {
	#ifdef GLASSES_GIRL
		freopen(FILE_NAME".in", "r", stdin);
		freopen(FILE_NAME".out", "w", stdout);
	#endif
	ios::sync_with_stdio(0); cin.tie(0);

	int n, c;
	cin >> n >> c;

	vector<int> l(n-1), d(n);

	for (int i=0; i+1<n; ++i)
		cin >> l[i];
	for (int i=0; i<n; ++i)
		cin >> d[i];

	cout << find_shortcut(n, l, d, c);
}

Compilation message

shortcut.cpp: In function 'int64_t find_shortcut(int, std::vector<int>, std::vector<int>, int)':
shortcut.cpp:59:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i=1; i<d.size(); ++i)
                ~^~~~~~~~~
/tmp/cc1wQHkA.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/cckSHOFK.o:shortcut.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status