답안 #1055261

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

using namespace std;
int S = -1;
vector<int> X,Y,C;
vector<int> dc(vector<int> lol){
    if(lol.size()==1)return lol;
    int sz = (lol.size()+1)/2;
    vector<int> ret;
    for(int j = 0;j+sz<lol.size();j++){
        ret.push_back(S--);
        X.push_back(lol[j]);
        Y.push_back(lol[j+sz]);
    }
    if(lol.size()%2){
        int x = lol.size()-sz;
        X.push_back(S);
        Y.push_back(lol[x]);
        ret.push_back(S--);
    }
    return ret;
}
vector<int> create_circuit(int M, vector<int> A){
    vector<int> adj[M+1];
    adj[0].push_back(A[0]);
    for(int i = 1;i<M;i++){
        adj[A[i-1]].push_back(A[i]);
    }
    adj[A[M-1]].push_back(0);
    for(int i = 0;i<=M;i++){
        if(adj[i].empty())adj[i].push_back(0);
        vector<int> x = dc(adj[i]);
        C.push_back(x[0]);
    }
    answer(C,X,Y);
}

Compilation message

doll.cpp: In function 'std::vector<int> dc(std::vector<int>)':
doll.cpp:11:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |     for(int j = 0;j+sz<lol.size();j++){
      |                   ~~~~^~~~~~~~~~~
doll.cpp: At global scope:
doll.cpp:24:13: error: ambiguating new declaration of 'std::vector<int> create_circuit(int, std::vector<int>)'
   24 | vector<int> create_circuit(int M, vector<int> A){
      |             ^~~~~~~~~~~~~~
In file included from doll.cpp:2:
doll.h:5:6: note: old declaration 'void create_circuit(int, std::vector<int>)'
    5 | void create_circuit(int M, std::vector<int> A);
      |      ^~~~~~~~~~~~~~
doll.cpp: In function 'std::vector<int> create_circuit(int, std::vector<int>)':
doll.cpp:37:1: warning: no return statement in function returning non-void [-Wreturn-type]
   37 | }
      | ^