제출 #102074

#제출 시각아이디문제언어결과실행 시간메모리
102074bert30702자동 인형 (IOI18_doll)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #ifdef ONLINE_JUDGE #include "doll.h" #endif using namespace std; const int MX = 4e5 + 1000; int ptr = 0; int x[MX], y[MX], c[MX]; #ifndef ONLINE_JUDGE void answer(vector<int> c, vector<int> x, vector<int> y) { cout << x.size() << endl; for(auto it: c) cout << it << ' '; cout << endl; for(auto it: x) cout << it << ' '; cout << endl; for(auto it: y) cout << it << ' '; cout << endl; } #endif int build(vector<int> v) { if(ptr != 0 and *max_element(v.begin(), v.end()) == *min_element(v.begin(), v.end())) return v[0]; int d = --ptr; vector<int> a, b; for(int i = 0; i < v.size(); i ++) { if(i & 1) b.push_back(v[i]); else a.push_back(v[i]); } x[-d] = build(a); y[-d] = build(b); return d; } void create_circuit(int n, vector<int> v) { vector<int> a(v.begin() + 1, v.end()); a.push_back(0); int k = max(2, 1 << __lg(a.size() * 2 - 1)); vector<int> tmp(k), GG(k, 0); int need = k - a.size(); for(int i = k / 2; i >= 1; i >>= 1) { for(int j = 0; j < k; j += i) { if(!GG[j] and need) { GG[j] = true, tmp[j] = -1, need --; } } } for(int i = k - 1; i >= 0; i --) { if(!GG[i]) tmp[i] = a.back(), a.pop_back(); } exit(0); build(tmp); c[0] = v[0]; for(int i = 1; i <= n; i ++) c[i] = -1; answer( vector<int>(c, c + n + 1), vector<int>(x + 1, x + 1 - ptr), vector<int>(y + 1, y + 1 - ptr) ); } #ifndef ONLINE_JUDGE main () { create_circuit(1, {1, 1}); } #endif

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

doll.cpp: In function 'void answer(std::vector<int>, std::vector<int>, std::vector<int>)':
doll.cpp:12:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   12 |  for(auto it: c) cout << it << ' '; cout << endl;
      |  ^~~
doll.cpp:12:37: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   12 |  for(auto it: c) cout << it << ' '; cout << endl;
      |                                     ^~~~
doll.cpp:13:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   13 |  for(auto it: x) cout << it << ' '; cout << endl;
      |  ^~~
doll.cpp:13:37: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   13 |  for(auto it: x) cout << it << ' '; cout << endl;
      |                                     ^~~~
doll.cpp:14:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   14 |  for(auto it: y) cout << it << ' '; cout << endl;
      |  ^~~
doll.cpp:14:37: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   14 |  for(auto it: y) cout << it << ' '; cout << endl;
      |                                     ^~~~
doll.cpp: In function 'int build(std::vector<int>)':
doll.cpp:21:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |  for(int i = 0; i < v.size(); i ++) {
      |                 ~~^~~~~~~~~~
doll.cpp: At global scope:
doll.cpp:54:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   54 | main () {
      | ^~~~
/usr/bin/ld: /tmp/ccGCoEq0.o: in function `answer(std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)':
grader.cpp:(.text+0x1f0): multiple definition of `answer(std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'; /tmp/ccIlTPe1.o:doll.cpp:(.text+0x0): first defined here
/usr/bin/ld: /tmp/ccGCoEq0.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccIlTPe1.o:doll.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status