답안 #1055317

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1055317 2024-08-12T17:12:14 Z Ahmed57 자동 인형 (IOI18_doll) C++17
컴파일 오류
0 ms 0 KB
#include "bits/stdc++.h"
//#include "doll.h"

using namespace std;
int seg[400001];
int ad;
int swp[400001];
int S = -1;
vector<int> X,Y,C;
void add(int p,int l,int r,int val){
    if(r<=ad)return ;
    if(l==r){
        seg[p] = val;
        return ;
    }
    int md = (l+r)/2;
    if(swp[p]==0){
        add(p*2,l,md,val);
    }else{
        add(p*2+1,md+1,r,val);
    }
    swp[p] = !swp[p];
}
int build(int p,int l,int r){
    if(r<=ad)return -1e9;
    if(l==r)return seg[p];
    int md = (l+r)/2;
    int x = build(p*2,l,md);
    int y = build(p*2+1,md+1,r);
    if(x==-1e9)X.push_back(-1e9);
    else X.push_back(x);
    Y.push_back(y);
    return S--;
}

vector<int> dc(vector<int> lol){
    if(lol.size()==1)return lol;
    int sz = lol.size();
    int add = sz/2;
    vector<int> ret;
    for(auto i:lol){
        cout<<i<<" ";
    }
    cout<<endl;
    for(int j = 0;j+add<sz;j++){
        if(lol[j]==-1e9&&lol[j+add]==-1e9){
            ret.push_back(-1e9);
            continue;
        }
        if(lol[j]==-1e9)X.push_back(S);
        else X.push_back(lol[j]);
        Y.push_back(lol[j+add]);
        ret.push_back(S--);
    }
    return dc(ret);
}

void create_circuit(int M, vector<int> A){
    S = -1;
    X.clear();
    Y.clear();
    C.clear();
    vector<int> adj[M+1];
    int N = A.size();
    vector<int> lo;
    for(int i = 1;i<N;i++){
        lo.push_back(A[i]);
    }
    lo.push_back(0);
    int rem = 1;
    while(rem<lo.size())rem*=2;
    ad = rem - (long long)(lo.size());
    for(int i = 0;i<ad;i++){
        add(1,1,rem,0);
    }
    for(auto i:lo)add(1,1,rem,i);
    int v = build(1,1,rem);
    for(int i = 0;i<X.size();i++){
        if(X[i]==-1e9)X[i] = v;
        if(Y[i]==-1e9)Y[i] = v;
    }
    C.push_back(A[0]);
    for(int i = 1;i<=M;i++){
        if(rem!=1)C.push_back(-1);
        else C.push_back(0);
    }
    answer(C,X,Y);
}

Compilation message

doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:71:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   71 |     while(rem<lo.size())rem*=2;
      |           ~~~^~~~~~~~~~
doll.cpp:78:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   78 |     for(int i = 0;i<X.size();i++){
      |                   ~^~~~~~~~~
doll.cpp:87:5: error: 'answer' was not declared in this scope
   87 |     answer(C,X,Y);
      |     ^~~~~~