Submission #128660

#TimeUsernameProblemLanguageResultExecution timeMemory
128660Just_Solve_The_ProblemMechanical Doll (IOI18_doll)C++11
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "doll.h" #include "grader.cpp" using namespace std; const int maxn = (int)1e5 + 7; int sz; void solve5(int M, vector<int> A) { int N = A.size(); vector<int> C(M + 1); vector<int> X, Y; C[0] = A[0]; int tmp = N - 1; while (tmp > 0) { sz++; tmp >>= 1; } if (sz) C[1] = -1; else C[1] = 0; X.resize(sz); Y.resize(sz); tmp = N - 1; for (int i = 1; i <= sz; i++) { if ((tmp >> (sz - i)) & 1) { X[i - 1] = A[0]; } else { X[i - 1] = -1; } Y[i - 1] = ((i == sz) ? 0 : -(i + 1)); } answer(C, X, Y); } int cnt[maxn]; void add(int val, int v, int l, int r, vector<int> &X, vector <int> &Y) { if (l == r) { cnt[v]++; return ; } int mid = (l + r) >> 1; if (cnt[v + v] != cnt[v + v + 1]) { if (l == mid) X[v - 1] = val; add(val, v + v, l, mid, X, Y); } else { if (mid + 1 == r) Y[v - 1] = val; add(val, v + v + 1, mid + 1, r, X, Y); } cnt[v]++; } void solve123(int M, vector<int> A) { int N = A.size(); vector <int> C(M + 1); vector <int> X, Y; C[0] = A[0]; int asd = 0; while ((1 << asd) < N) { asd++; } for (int i = 1; i < (1 << asd); i++) { X.push_back(-(i + i)); if (i + i >= (1 << asd)) X.back() = -1; Y.push_back(-(i + i + 1)); if (i + i + 1 >= (1 << asd)) Y.back() = -1; } for (int i = 1; i <= M; i++) { C[i] = -1; } add(0, 1, 0, (1 << asd) - 1, X, Y); for (int i = N - 1; i > 0; i--) { add(A[i], 1, 0, (1 << asd) - 1, X, Y); } answer(C, X, Y); } void solve4(int M, vector <int> A) { int N = A.size(); vector <int> C(M + 1); vector <int> X, Y; C[0] = A[0]; for (int i = 1; i < 16; i++) { X.push_back(-(i + i)); Y.push_back(-(i + i + 1)); } for (int i = 1; i <= M; i++) { C[i] = -1; } for (int i = 1; i < N; i++) { add(A[i], 1, 0, 15, X, Y); } add(0, 1, 0, 15, X, Y); answer(C, X, Y); } void create_circuit(int M, vector<int> A) { if (M == 1) { solve5(M, A); } else { solve123(M, A); } } /* 2 16 1 1 1 1 2 2 2 2 1 1 1 1 2 2 2 2 */

Compilation message (stderr)

/usr/bin/ld: /tmp/cciBczE2.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+0x1e0): multiple definition of `answer(std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'; /tmp/cc1LPeh6.o:doll.cpp:(.text+0x1e0): first defined here
/usr/bin/ld: /tmp/cciBczE2.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cc1LPeh6.o:doll.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status