Submission #716705

#TimeUsernameProblemLanguageResultExecution timeMemory
716705aykhnCave (IOI13_cave)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#include "cave.h"

using namespace std;

typedef long long ll;

#define OPT ios_base::sync_with_stdio(0); \
            cin.tie(0); \
            cout.tie(0)

#define pii pair<int,int>
#define pll pair<ll,ll>
#define endl "\n"
#define all(v) v.begin(), v.end()
#define mpr make_pair
#define pb push_back
#define ts to_string
#define fi first
#define se second
#define inf 0x3F3F3F3F
#define bpc __builtin_popcount
#define print(v) for(int i = 0; i < v.size(); i++) cout << v[i] << " "; cout<<endl;

int a[4], b[4];

void answer(int ans[], int used[])
{
    for (int i = 0; i < 4; i++)
    {
        cout << ans[i] << " ";
    }
    cout << endl;
    for (int i = 0; i < 4; i++)
    {
        cout << used[i] << " ";
    }
}

int tryCombination(int open[])
{
    int mn = inf;
    for (int i = 0; i < 4; i++)
    {
        if (open[i] != a[i]) mn = min(mn, b[i]);
    }
    if (mn == inf) return -1;
    return mn;
}
void exploreCave(int N)
{
    int open[N];
    int ans[N];
    int used[N];

    for (int i = 0; i < N; i++)
    {
        open[i] = 0;
        used[i] = -1;
    }

    for (int i = 0; i < N; i++)
    {
        int l = 0;
        int r = N - 1;
        int pans = tryCombination(open);

        while (l < r)
        {
            int mid = (l + r) >> 1;

            for (int j = l; j <= mid; j++)
            {
                if (used[j] != -1) continue;

                open[j] = 1 - open[j];
            }
            int ans = tryCombination(open);
            for (int j = l; j <= mid; j++)
            {
                if (used[j] != -1) continue;

                open[j] = 1 - open[j];
            }

            if (pans == -1)
            {
                if (ans != i) l = mid + 1;
            }
            else if (pans == i)
            {
                if (ans != pans || ans == -1) r = mid;
                else l = mid + 1;
            }
            else
            {
                if (ans == i) r = mid;
                else l = mid + 1;
            }
        }
        used[l] = i;

        if (pans == i) open[l] = 1;
        else open[l] = 0;
    }

    answer(open, used);
}

Compilation message (stderr)

cave.cpp: In function 'void exploreCave(int)':
cave.cpp:53:9: warning: unused variable 'ans' [-Wunused-variable]
   53 |     int ans[N];
      |         ^~~
/usr/bin/ld: /tmp/ccbGzLsl.o: in function `answer':
cave.cpp:(.text+0x0): multiple definition of `answer'; /tmp/ccTcaVKn.o:grader.c:(.text+0x0): first defined here
/usr/bin/ld: /tmp/ccbGzLsl.o: in function `tryCombination':
cave.cpp:(.text+0xa0): multiple definition of `tryCombination'; /tmp/ccTcaVKn.o:grader.c:(.text+0x80): first defined here
collect2: error: ld returned 1 exit status