제출 #784162

#제출 시각아이디문제언어결과실행 시간메모리
784162BoasCave (IOI13_cave)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
#include "cave.h"
#include "grader.c"
using namespace std;
#define ALL(x) (x).begin(), (x).end()
#define set(x, v) fill(ALL(x), v)
typedef vector<int> vi;

void exploreCave(int N)
{
    vi switches(N, 0);
    vi revS(N, 0);  // the correct position of each switch corresponding to door i
    vi D(N, -1);    // element D[i] should contain the door number that switch i is connected to
    vi revD(N, -1); // element revD[i] should contain the switch number that door i is connected to
    bool done = false;
    for (int i = 0; i < N; i++)
    {
        if (i > 0)
            set(switches, 0);
        for (int j = 0; j < N; j++)
        {
            if (revD[j] == -1)
                break;
            switches[revD[j]] = revS[j];
        }
        revS[i] = tryCombination(switches.data()) == i;
        int min = 0, max = N - 1;
        while (max - min > 0)
        {
            int s = (max + min) / 2;
            set(switches, !revS[i]);
            fill(switches.begin() + min, switches.begin() + s + 1, revS[i]);
            for (int j = 0; j < N; j++)
            {
                if (revD[j] == -1)
                    break;
                switches[revD[j]] = revS[j];
            }
            int d = tryCombination(switches.data());
            if (d == -1)
            {
                done = true;
                break;
            }
            if (d > i)
            {
                if (s == max)
                    throw;
                max = s;
            }
            else
            {
                min = s + 1;
            }
        }
        if (done)
            break;
        revD[i] = min;
        D[min] = i;
    }
    for (int i = 0; i < N; i++)
    {
        if (D[i] != -1)
            continue;
        switches[i] = !switches[i];
        int d = tryCombination(switches.data());
        D[i] = d;
        switches[i] = !switches[i];
    }
    answer(switches.data(), D.data());
}

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

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