제출 #418221

#제출 시각아이디문제언어결과실행 시간메모리
418221FlippenFazMechanical Doll (IOI18_doll)C++11
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; vector<int> c; vector<int> x; vector<int> y; vector<vector<int>> cons; void connect(int start, int end) { if (c[start] == 0) { c[start] = end; } else if (c[start] > 0) { x.push_back( c[start] ); y.push_back( end ); c[start] = -x.size(); } else { } } void create_circuit(int m, vector<int> a) { cons.resize(m+1); c.resize(m+1); int prev = 0; for (int i = 0; i < a.size(); i++) { cons[prev].push_back(a[i]); } for (int i = 0; i < cons.size(); i++) { if (cons[i].size() == 0) { c[i] = 0; } else if (cons[i].size() == 1) { c[i] == cons[i][0]; } else { int offset = -x.size(); int added = pow(2,ceil(log2(cons[i].size()))) - 1; for (int i = 1; i < added+1; i++) { x.push_back( offset -i*2 ); y.push_back( offset -i*2 - 1); } int last = added/2+1; int start = x.size()-1-last; int cnt = 0; for (int i = start; i < x.size(); i++) { x[i] = -i-1; y[i] = cons[i][cnt++]; } for (int i = start; cnt < cons[i].size(); i++) { x[i] = y[i]; y[i] = cons[i][cnt++]; } } } answer(c, x, y); }

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

doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:30:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |     for (int i = 0; i < a.size(); i++) {
      |                     ~~^~~~~~~~~~
doll.cpp:34:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |     for (int i = 0; i < cons.size(); i++) {
      |                     ~~^~~~~~~~~~~~~
doll.cpp:38:18: warning: value computed is not used [-Wunused-value]
   38 |             c[i] == cons[i][0];
doll.cpp:49:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |             for (int i = start; i < x.size(); i++) {
      |                                 ~~^~~~~~~~~~
doll.cpp:53:37: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |             for (int i = start; cnt < cons[i].size(); i++) {
      |                                 ~~~~^~~~~~~~~~~~~~~~
doll.cpp:61:5: error: 'answer' was not declared in this scope
   61 |     answer(c, x, y);
      |     ^~~~~~