제출 #944114

#제출 시각아이디문제언어결과실행 시간메모리
944114shoryu386자동 인형 (IOI18_doll)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; int ptr = -1; vector<int> xLead, yLead; int construct(vector<int> item){ if (item.size() == 1){ return item[0]; } vector<int> itemLeft, itemRight; for (int x = 0; x < item.size(); x+=2){ itemLeft.push_back(item[x]); } for (int x = 1; x < item.size(); x+=2){ itemRight.push_back(item[x]); } int curNode = ptr; //cerr << "Construct " << curNode << '\n'; //for (auto y : item) cerr << y << ' '; //cerr << '\n'; ptr--; xLead[curNode] = ( construct(itemLeft) ); yLead[curNode] = ( construct(itemRight) ); return curNode; } void create_circuit(int m, std::vector<int> A) { int n = A.size(); xLead.clear(); yLead.clear(); xLead.resize(2*n + 100); yLead.resize(2*n + 100); ptr = -1; vector<int> leads[m+1]; leads[0].push_back(A[0]); for (int x = 0; x < n-1; x++){ leads[A[x]].push_back(A[x+1]); } leads[A[n-1]].push_back(0); vector<int> connection(m+1); for (int x = 0; x <= m; x++){ if (leads[x].size() == 0){ connection[x] = x; } else if (leads[x].size() == 1){ connection[x] = leads[x][0]; } else{ //construct binary tree connection[x] = construct(leads[x]); } //cerr << "leads " << x << '\n'; //for (auto y : leads[x]){ // cerr << y << ' '; //} //cerr << '\n'; } xLead.resize(-ptr - 1); yLead.resize(-ptr - 1); answer(connection, xLead, yLead); }

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

doll.cpp: In function 'int construct(std::vector<int>)':
doll.cpp:12:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |  for (int x = 0; x < item.size(); x+=2){
      |                  ~~^~~~~~~~~~~~~
doll.cpp:15:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |  for (int x = 1; x < item.size(); x+=2){
      |                  ~~^~~~~~~~~~~~~
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:68:2: error: 'answer' was not declared in this scope
   68 |  answer(connection, xLead, yLead);
      |  ^~~~~~