제출 #414592

#제출 시각아이디문제언어결과실행 시간메모리
414592schse자동 인형 (IOI18_doll)C++17
컴파일 에러
0 ms0 KiB
#include "doll.h" #ifndef EVAL #include "grader.cpp" #endif #include <bits/stdc++.h> using namespace std; vector<int> C, X, Y; struct node { unordered_set<int> options; vector<int> folowing; int visited = 0; }; vector<node> g; void rec(int index, int value, vector<bool> &tree, vector<int> &X, vector<int> &Y) { if (index > (tree.size() - 1) / 2) { if (tree[index]) X[index - 1] = value; else Y[index - 1] = value; } else if (tree[index]) rec(index * 2, value, tree, X, Y); else rec(index * 2 + 1, value, tree, X, Y); tree[index] = !tree[index]; } pair<vector<int>, vector<int>> maketree(int offset, vector<int> const &folows) { int ends = 2; while (ends < folows.size()) ends *= 2; vector<int> X(ends - 1), Y(ends - 1); vector<bool> tree(ends, true); for (int i = 1; i < ends / 2; i++) { X[i - 1] = i * -2 + offset; Y[i - 1] = i * -2 - 1 + offset; } while (ends-- != folows.size()) // lose ends rec(1, -1, tree, X, Y); for (int i : folows) rec(1, i, tree, X, Y); return {X, Y}; } void create_circuit(int M, std::vector<int> A) { g.resize(M + 1); C.resize(M + 1, 0); g[0].folowing.push_back(A[0]); g[0].options.insert(A[0]); for (int i = 1; i < N; i++) { g[A[i - 1]].folowing.push_back(A[i]); g[A[i - 1]].options.insert(A[i]); } g[A[N - 1]].folowing.push_back(0); g[A[N - 1]].options.insert(0); for (int i = 0; i < M + 1; i++) { if (g[i].options.size() == 1) C[i] = g[i].folowing[0]; else if (g[i].options.size() == 0) C[i] = 0; else { C[i] = -X.size() - 1; auto tmp = maketree(X.size(), g[i].folowing); X.insert(X.end(), tmp.first.begin(), tmp.first.end()); Y.insert(Y.end(), tmp.second.begin(), tmp.second.end()); } } answer(C, X, Y); }

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

doll.cpp: In function 'void rec(int, int, std::vector<bool>&, std::vector<int>&, std::vector<int>&)':
doll.cpp:20:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<bool>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |   if (index > (tree.size() - 1) / 2)
      |       ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
doll.cpp: In function 'std::pair<std::vector<int>, std::vector<int> > maketree(int, const std::vector<int>&)':
doll.cpp:37:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |   while (ends < folows.size())
      |          ~~~~~^~~~~~~~~~~~~~~
doll.cpp:49:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |   while (ends-- != folows.size()) // lose ends
      |          ~~~~~~~^~~~~~~~~~~~~~~~
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:64:23: error: 'N' was not declared in this scope
   64 |   for (int i = 1; i < N; i++)
      |                       ^
doll.cpp:69:7: error: 'N' was not declared in this scope
   69 |   g[A[N - 1]].folowing.push_back(0);
      |       ^