Submission #783975

#TimeUsernameProblemLanguageResultExecution timeMemory
783975BoasCave (IOI13_cave)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#include "cave.h"
#include "grader.c"
using namespace std;

constexpr bool debug = false;

typedef vector<int> vi;

// map<vi, int> tryCombi;

int ownTryCombination(vi &switches)
{
    if (debug)
    {
        cerr << endl
             << "TryCombination: ";
        for (int t : switches)
        {
            cerr << t << " ";
        }

        cerr << endl;
    }
    int res;
    // if (tryCombi.find(switches) != tryCombi.end())
    //{
    // res = tryCombi[switches];
    //}
    // else
    {
        res = tryCombination(switches.data());
        // tryCombi[switches] = res;
    }
    if (debug)
        cerr << "Result: " << res << endl;
    return res;
}

void exploreCave(int N)
{
    vi switches(N, 0);
    vi minDist(N);
    vi maxDist(N, N);
    int d = ownTryCombination(switches);
    int nd = 0;
    while (d != -1)
    {
        if (nd == -1)
            break;
        for (int i = 0; i < N; i++)
        {
            if (minDist[i] == maxDist[i])
                continue;
            switches[i] = !switches[i];
            nd = ownTryCombination(switches);
            if (nd == -1)
                break;
            if (nd == d)
            {
                if (debug)
                    cerr << "minDist[" << i << "] = " << d + 1 << endl;
                minDist[i] = d + 1;
                switches[i] = !switches[i];
                d = nd;
            }
            else if (nd > d)
            {
                if (debug)
                    cerr << "min&maxDist[" << i << "] = " << d << endl;
                minDist[i] = d;
                maxDist[i] = d;
                d = nd;
            }
            else
            {
                if (debug)
                    cerr << "min&maxDist[" << i << "] = " << nd << endl;
                minDist[i] = nd;
                maxDist[i] = nd;
                switches[i] = !switches[i];
                // i--;
            }
        }
        if (nd == -1)
            break;
    }
    for (int i = 0; i < N; i++)
    {
        if (minDist[i] == maxDist[i])
            continue;
        switches[i] = !switches[i];
        int d = ownTryCombination(switches);
        minDist[i] = d;
        maxDist[i] = d;
        switches[i] = !switches[i];
    }
    answer(switches.data(), minDist.data());
    cerr << endl;
}

Compilation message (stderr)

/usr/bin/ld: /tmp/ccQ4pKDK.o: in function `answer':
cave.cpp:(.text+0x0): multiple definition of `answer'; /tmp/cctj3SUM.o:grader.c:(.text+0x0): first defined here
/usr/bin/ld: /tmp/ccQ4pKDK.o: in function `tryCombination':
cave.cpp:(.text+0x80): multiple definition of `tryCombination'; /tmp/cctj3SUM.o:grader.c:(.text+0x80): first defined here
/usr/bin/ld: /tmp/ccQ4pKDK.o: in function `init()':
cave.cpp:(.text+0x110): multiple definition of `init()'; /tmp/cctj3SUM.o:grader.c:(.text+0x110): first defined here
/usr/bin/ld: /tmp/ccQ4pKDK.o: in function `main':
cave.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cctj3SUM.o:grader.c:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status