제출 #1351963

#제출 시각아이디문제언어결과실행 시간메모리
1351963Andrey커다란 상품 (IOI17_prize)C++20
컴파일 에러
0 ms0 KiB
#include "prize.h"
#include<bits/stdc++.h>
using namespace std;

int lol = 0;
int ans = 0;

bool dude(int l, int r, int brl, int brr, int br) {
    if(br == 0 || l > r) {
        return false;
    }
    if(l == r) {
        vector<int> wut = ask(l);
        if(wut[0]+wut[1] == 0) {
            ans = l;
            return true;
        }
        return false;
    }
    vector<int> wut(0);
    int midl = (l+r)/2+1;
    int midr = midl-1;
    int p;
    for(int i = 0; i < r-l+1; i++) {
        if(i%2 == 0) {
            midl--;
            wut = ask(midl);
            p = midl;
        }
        else {
            midr++;
            wut = ask(midr);
            p = midr;
        }
        if(wut[0]+wut[1] == 0) {
            ans = p;
            return true;
        }
        if(wut[0]+wut[1] == lol) {
            if(i%2 == 0) {
                if(dude(l,midl-1,brl,brr+i,wut[0]-brl)) {
                    return true;
                }
                if(dude(midr+1,r,brl+i,brr,wut[1]-brr-i)) {
                    return true;
                }
            }
            else {
                if(dude(l,midl-1,brl,brr+i,wut[0]-i-brl)) {
                    return true;
                }
                if(dude(midr+1,r,brl+i,brr,wut[1])) {
                    return true;
                }
            }
            break;
        }
    }
    return false;
}

int find_best(int n) {
    for(int i = 0; i < min(n,2*sqrt(n)); i++) {
        vector<int> wut = ask(i);
        lol = max(lol,wut[0]+wut[1]);
    }
    dude(0,n-1,0,0,lol);
	return ans;
}

컴파일 시 표준 에러 (stderr) 메시지

prize.cpp: In function 'int find_best(int)':
prize.cpp:63:27: error: no matching function for call to 'min(int&, __gnu_cxx::__enable_if<true, double>::__type)'
   63 |     for(int i = 0; i < min(n,2*sqrt(n)); i++) {
      |                        ~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/13/vector:62,
                 from prize.h:1,
                 from prize.cpp:1:
/usr/include/c++/13/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
prize.cpp:63:27: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__enable_if<true, double>::__type' {aka 'double'})
   63 |     for(int i = 0; i < min(n,2*sqrt(n)); i++) {
      |                        ~~~^~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:281:5: note:   template argument deduction/substitution failed:
prize.cpp:63:27: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__enable_if<true, double>::__type' {aka 'double'})
   63 |     for(int i = 0; i < min(n,2*sqrt(n)); i++) {
      |                        ~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from prize.cpp:2:
/usr/include/c++/13/bits/stl_algo.h:5775:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5775 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5775:5: note:   template argument deduction/substitution failed:
prize.cpp:63:27: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   63 |     for(int i = 0; i < min(n,2*sqrt(n)); i++) {
      |                        ~~~^~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:5785:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5785 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5785:5: note:   template argument deduction/substitution failed:
prize.cpp:63:27: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   63 |     for(int i = 0; i < min(n,2*sqrt(n)); i++) {
      |                        ~~~^~~~~~~~~~~~~