답안 #987075

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
987075 2024-05-21T19:30:44 Z VMaksimoski008 커다란 상품 (IOI17_prize) C++17
컴파일 오류
0 ms 0 KB
#include "prize.h"
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;

pii memo[200005];

pii query(int p) {
	if(memo[p] != pii{ -1, -1 }) return memo[p];
	vector<int> res = ask(p);
	return memo[p] = { res[0], res[1] };
}

int sum(int p) { return query(p).first + query(p).second; }
int L(int p) { return query(p).first; }
int R(int p) { return query(p).second; }

int find_best(int n) {
	//da se iskoristat 2ki?????
	for(int i=0; i<n; i++) memo[i] = { -1, -1 };

	int curr = -1, mx = 0;
	set<int> s;
	for(int i=0; i<min(480, n); i++) {
		mx = max(mx, sum(i));
		if(sum(i) == 0) return i;
	}

	int R = n-1, cnt = 1;
	for(int i=0; i<min(480, n); i++) {
		if(sum(i) == 1) {
			if(L(i) == 1) {
				R = i;
				break;
			}
		}

		if(sum(i) != mx) {
			curr = i;
			cnt++;
		}
	}

	int L = 0;
	for(int i=cnt; i<=mx; i++) {
		int l=max(L, curr+1), r=R, pos=n-1;

		while(l <= r) {
			int mid = (l + r) / 2;
			if(sum(mid) == 0) return mid;

			if(sum(mid) == mx) {
				if(L(mid) >= i) pos = mid, r = mid - 1;
				else l = mid + 1;
			} else {
				if(sum(mid) == 1 && L(mid) == 1)
					R = min(R, mid - 1);
				if(sum(mid) == 1 && R(mid) = 1)
					L = max(L, mid + 1);
				if(sum(mid) == 1) {
					s.insert(mid);
				}
				pos = mid;
				r = mid - 1;
			}
		}
		
		curr = pos;
	}

	return 0;
}

Compilation message

prize.cpp: In function 'int find_best(int)':
prize.cpp:53:13: error: 'L' cannot be used as a function
   53 |     if(L(mid) >= i) pos = mid, r = mid - 1;
      |             ^
prize.cpp:56:30: error: 'L' cannot be used as a function
   56 |     if(sum(mid) == 1 && L(mid) == 1)
      |                              ^
prize.cpp:58:30: error: 'R' cannot be used as a function
   58 |     if(sum(mid) == 1 && R(mid) = 1)
      |                              ^