답안 #1096394

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1096394 2024-10-04T11:34:51 Z guagua0407 자동 인형 (IOI18_doll) C++17
컴파일 오류
0 ms 0 KB
#include "doll.h"
#include "grader.cpp"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int inf=1e9;

void create_circuit(int m, std::vector<int> a) {
    int n=a.size();
    int lg=__lg(n-1)+1;
    vector<int> state(1<<lg);
    vector<vector<int>> to(1<<lg,vector<int>(2,inf));
    for(int i=1;i<(1<<lg);i++){
        if(i*2<(1<<lg)) to[i][0]=-(i*2);
        if(i*2+1<(1<<lg)) to[i][1]=-(i*2+1);
    }
    for(int i=0;i<n-1;i++){
        int nxt=a[i+1];
        int cur=1;
        while(to[cur][state[cur]]!=inf){
            state[cur]^=1;
            cur=-to[cur][state[cur]^1];
        }
        to[cur][state[cur]]=nxt;
        state[cur]^=1;
    }
    for(int i=n-1;i<(1<<lg);i++){
        int nxt=(i==(1<<lg)-1?0:inf);
        int cur=1;
        while(to[cur][state[cur]]!=inf){
            state[cur]^=1;
            cur=-to[cur][state[cur]^1];
        }
        to[cur][state[cur]]=nxt;
        state[cur]^=1;
    }
    vector<int> vec;
    for(int i=1;i<(1<<lg);i++){
        if(to[i][0]!=inf and to[i][1]!=inf){
            vec.push_back(i);
        }
    }
    vector<int> c(m+1,-1);
    c[0]=a[0];
    vector<int> x(vec.size()),y(vec.size());
    vector<int> id(1<<lg,inf);
    for(int i=0;i<(int)vec.size();i++){
        id[vec[i]]=i;
    }
    for(int i=1;i<(1<<lg);i++){
        if(id[i]==inf){
            to[i/2][i-(i/2)*2]=(to[i][0]==inf?to[i][1]:to[i][0]);
            if(to[i/2][i-(i/2)*2]==inf) to[i/2][i-(i/2)*2]=-(i/2);
        }
    }
    for(int i=0;i<(int)vec.size();i++){
        x[i]=to[vec[i]][0];
        y[i]=to[vec[i]][1];
    }
    answer(c,x,y);
}

Compilation message

/usr/bin/ld: /tmp/ccvbsTp3.o: in function `answer(std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)':
grader.cpp:(.text+0x1f0): multiple definition of `answer(std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'; /tmp/cc06vji3.o:doll.cpp:(.text+0x1f0): first defined here
/usr/bin/ld: /tmp/ccvbsTp3.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cc06vji3.o:doll.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status