Submission #1204567

#TimeUsernameProblemLanguageResultExecution timeMemory
1204567jer033Cave (IOI13_cave)C++20
Compilation error
0 ms0 KiB
//2013 IOI P4
#include "cave.h"
#include <bits/stdc++.h>
using namespace std;

int query(int N, vector<int> (&S))
{
    int x = tryCombination(S);
    if (x==-1)
        return N;
    return x;
}

int flip_switches(vector<int> (&s), vector<int> (&assignment), int l, int r, int N)
{
    vector<int> changes;
    for (int i=l; i<=r; i++)
    {
        if (assignment[i] == -1)
        {
            changes.push_back(i);
            s[i] = 1;
        }
    }
    int ans = query(N, s);
    for (int i: changes)
        s[i] = 0;
    return ans;
}

void exploreCave(int N)
{
    vector<int> switches(N, 0);
    vector<int> assignment(N, -1);
    for (int i=0; i<N; i++)
    {
        switches[i] = 0;
        assignment[i] = -1;
    }
    for (int door = 0; door<N; door++)
    {
        int lo = 0;
        int hi = N-1;
        int curr = query(N, switches);
        while (lo!=hi)
        {
            int mid = (lo+hi)/2;
            if (flip_switches(switches, assignment, lo, mid, N) == curr)
                lo = mid+1;
            else
                hi = mid;
        }
        if (curr > door)
            switches[lo] = 0;
        else
            switches[lo] = 1;
        assignment[lo] = door;
    }
    answer(switches, assignment);
}

Compilation message (stderr)

cave.cpp: In function 'int query(int, std::vector<int>&)':
cave.cpp:8:28: error: cannot convert 'std::vector<int>' to 'int*'
    8 |     int x = tryCombination(S);
      |                            ^
      |                            |
      |                            std::vector<int>
In file included from cave.cpp:2:
cave.h:8:24: note:   initializing argument 1 of 'int tryCombination(int*)'
    8 | int tryCombination(int S[]);
      |                    ~~~~^~~
cave.cpp: In function 'void exploreCave(int)':
cave.cpp:59:12: error: cannot convert 'std::vector<int>' to 'int*'
   59 |     answer(switches, assignment);
      |            ^~~~~~~~
      |            |
      |            std::vector<int>
In file included from cave.cpp:2:
cave.h:9:17: note:   initializing argument 1 of 'void answer(int*, int*)'
    9 | void answer(int S[], int D[]);
      |             ~~~~^~~