제출 #230637

#제출 시각아이디문제언어결과실행 시간메모리
230637DrSwad자동 인형 (IOI18_doll)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; const int N = int(4e5) + 10; int c[N]; int x[N], y[N]; int switches_used; void handle(int from, int L, int R, vector<int> &a) { if (R - L + 1 <= 0) return; if (R - L + 1 == 1) { c[from] = a[0]; return; } int at_switch = ++switches_used; if (R - L + 1 == a.size()) c[from] = -at_switch; int mid = (L + R) >> 1; if (mid - L + 1 == 1) x[at_switch] = a[L]; else { x[at_switch] = -(switches_used + 1); handle(from, L, mid, a); } if (R - mid == 1) y[at_switch] = a[R]; else { y[at_switch] = -(switches_used + 1); handle(from, mid + 1, R, a); } } void create_circuit(int m, vector<int> a) { a.push_back(0); c[0] = a[0]; int n = a.size(); vector<vector<int>> v(m + 1); for (int i = 0; i < n - 1; i++) v[a[i]].push_back(a[i + 1]); for (int i = 1; i <= m; i++) handle(i, 0, (int)v[i].size() - 1, v[i]); answer(vector<int>(c + 0, c + m + 1), vector<int>(x + 1, x + switches_used + 1), vector<int>(y + 1, y + switches_used + 1)); }

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

doll.cpp: In function 'void handle(int, int, int, std::vector<int>&)':
doll.cpp:19:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |  if (R - L + 1 == a.size()) c[from] = -at_switch;
      |      ~~~~~~~~~~^~~~~~~~~~~
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:46:2: error: 'answer' was not declared in this scope
   46 |  answer(vector<int>(c + 0, c + m + 1), vector<int>(x + 1, x + switches_used + 1), vector<int>(y + 1, y + switches_used + 1));
      |  ^~~~~~