답안 #937842

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
937842 2024-03-04T15:17:02 Z Macker 커다란 상품 (IOI17_prize) C++14
컴파일 오류
0 ms 0 KB
#include "prize.h"
#include <bits/stdc++.h>

typedef long long ll;
#define all(v) v.begin(), v.end()
#define FOR(i, n) for (int i = 0; i < n; i++)


int find_best(int n) {
	int mn = 0;
	FOR(i, min(500, n)){
		auto res = ask(i);
		mn = max(mn, res[0] + res[1]);
	}
	vector<int> pos;
	int l = 0, r = 1;
	FOR(i, mn){
		while(1){
			auto ret = ask(r);
			if(ret[0] + ret[1] != mn) break;
			if(ret[0] > i) break;
			r += (r - l); 
		}
		while(l < r){
			int mid = (l + r) / 2;
			auto ret = ask(mid);
			if(ret[0] + ret[1] != mn) r = mid;
			else if(ret[0] > i) r = mid - 1;
			else l = mid + 1;
		}
		pos.push_back(l);
		r++;
	}
	for (auto i : pos) {
		auto ret = ask(i);
		if(ret[0] + ret[1] == 0) return i;
	}
	return 0;
}

Compilation message

prize.cpp: In function 'int find_best(int)':
prize.cpp:11:9: error: 'min' was not declared in this scope; did you mean 'std::min'?
   11 |  FOR(i, min(500, n)){
      |         ^~~
prize.cpp:6:39: note: in definition of macro 'FOR'
    6 | #define FOR(i, n) for (int i = 0; i < n; i++)
      |                                       ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from prize.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: 'std::min' declared here
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
prize.cpp:13:8: error: 'max' was not declared in this scope; did you mean 'std::max'?
   13 |   mn = max(mn, res[0] + res[1]);
      |        ^~~
      |        std::max
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from prize.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: 'std::max' declared here
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
prize.cpp:15:2: error: 'vector' was not declared in this scope; did you mean 'std::vector'?
   15 |  vector<int> pos;
      |  ^~~~~~
      |  std::vector
In file included from /usr/include/c++/10/vector:67,
                 from prize.h:1,
                 from prize.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:389:11: note: 'std::vector' declared here
  389 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
prize.cpp:15:9: error: expected primary-expression before 'int'
   15 |  vector<int> pos;
      |         ^~~
prize.cpp:31:3: error: 'pos' was not declared in this scope; did you mean 'pow'?
   31 |   pos.push_back(l);
      |   ^~~
      |   pow
prize.cpp:34:16: error: 'pos' was not declared in this scope; did you mean 'pow'?
   34 |  for (auto i : pos) {
      |                ^~~
      |                pow