제출 #99267

#제출 시각아이디문제언어결과실행 시간메모리
99267long10024070Cave (IOI13_cave)C++11
컴파일 에러
0 ms0 KiB
#define Link "https://oj.uz/problem/view/IOI13_cave?fbclid=IwAR2HAQQWHxbplVnmFGboqMw4yr-N9sR3mRA2usvk6rTocr7u5QYaZIyHqxw"

#include <iostream>
#include <cstdio>
#include <set>

#define TASK "Cave"

using namespace std;

const int maxn = 5e3 + 10;
int n,Val[maxn],realval[maxn];
bool s[maxn],True[maxn],reals[maxn];

#ifdef LHL
int tryCombination(bool s[])
{
    int res = n;
    for (int i=0;i<n;++i)
        if (s[i] != reals[i])
            res = min(res,realval[i]);
    return res == n ? -1 : res;
}

void answer(bool True[], int Val[])
{
    for (int i=0;i<n;++i)
        cout << True[i] << ' ';
    cout << '\n';
    for (int i=0;i<n;++i)
        cout << Val[i] << ' ';
}
#else
#include "cave.h"
#endif // LHL

void Fill(int l, int r, bool d)
{
    for (int i=l;i<=r;++i)
        if (Val[i] != -1)
            s[i] = True[i];
        else
            s[i] = d;
}

void exploreCave(int n)
{
    fill(Val,Val+n,-1);
    for (int i=0;i<n;++i) {
        Fill(0,n-1,0);
        bool fl = (i == tryCombination(s));
//        cout << "    ";
//        for (int i=0;i<n;++i)
//            cout << s[i] << ' ';
//        cout << '\n';
//        cout << i <<  ' ' << fl << ' ' << tryCombination(s) << '\n';
        int l = 0;
        int r = n - 1;
        while (l <= r) {
            int m = (l + r) / 2;
            Fill(1,n-1,fl^1);
            Fill(l,m,fl);
            Fill(m+1,r,fl^1);
//            cout << "    ";
//            for (int i=0;i<n;++i)
//                cout << s[i] << ' ';
//            cout << '\n';
//            cout << i << ' ' << l << ' ' << r << ' ' << m << ' ' << tryCombination(s) << '\n';
            if (tryCombination(s) == i)
                l = m + 1;
            else
                r = m - 1;
        }
//        cout << l << ' ' << fl << '\n';
        True[l] = fl;
        Val[l] = i;
    }
    answer(True,Val);
}

#ifdef LHL
void Enter()
{
    cin >> n;
    for (int i=0;i<n;++i)
        cin >> reals[i];
    for (int i=0;i<n;++i)
        cin >> realval[i];
}

void Init()
{

}

void Solve()
{
    exploreCave(n);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    freopen(".INP","r",stdin);
    freopen(".OUT","w",stdout);

    Enter();
    Init();
    Solve();
}
#else
#endif //LHL

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

cave.cpp: In function 'void exploreCave(int)':
cave.cpp:51:41: error: cannot convert 'bool*' to 'int*' for argument '1' to 'int tryCombination(int*)'
         bool fl = (i == tryCombination(s));
                                         ^
cave.cpp:69:33: error: cannot convert 'bool*' to 'int*' for argument '1' to 'int tryCombination(int*)'
             if (tryCombination(s) == i)
                                 ^
cave.cpp:78:20: error: cannot convert 'bool*' to 'int*' for argument '1' to 'void answer(int*, int*)'
     answer(True,Val);
                    ^