답안 #758946

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
758946 2023-06-15T15:01:34 Z alexander707070 자동 인형 (IOI18_doll) C++14
0 / 100
0 ms 212 KB
#include<bits/stdc++.h>
#include "doll.h"
#define MAXN 200007
using namespace std;
 
int m,power,n;
int a[MAXN],s;
vector< pair<int,int> > edges;
vector<int> from,to,c;

int rev(int x){
    int res=0;
    for(int i=1;i<power;i*=2){
        res*=2; res+=x%2; x/=2;
    }
    return res;
}

void build(int v,int l,int r,int num){
    if(l+1==r){
        num*=2;

        if(rev(num)<n)edges.push_back({-v,a[rev(num)]});
        else if(rev(num)==power-1)edges.push_back({-v,0});
        else edges.push_back({v,-1});

        num++;
        if(rev(num)<n)edges.push_back({-v,a[rev(num)]});
        else if(rev(num)==power-1)edges.push_back({-v,0});
        else edges.push_back({v,-1});
    }else{
        int tt=(l+r)/2;
        build(2*v,l,tt,2*num);
        build(2*v+1,tt+1,r,2*num+1);

        edges.push_back({-v,-2*v});
        edges.push_back({-v,-2*v-1});
    }
}

void create_circuit(int M, vector<int> A){
    m=M; n=int(A.size());

    for(int i=0;i<n;i++){
        a[i]=A[i];
    }
    
    power=1;
    while(power<n+1)power*=2;
    build(1,0,power-1,0);

    for(int i=0;i<=m;i++)c.push_back(-1);
    for(int i=0;i<edges.size();i++){
        from.push_back(edges[i].first);
        to.push_back(edges[i].second);
    }

    answer(c,from,to);
}
/*
int main(){
 
}
*/

Compilation message

doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:53:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |     for(int i=0;i<edges.size();i++){
      |                 ~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB wrong serial number
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB wrong serial number
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB wrong serial number
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB wrong serial number
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB wrong serial number
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB wrong serial number
2 Halted 0 ms 0 KB -