Submission #529304

#TimeUsernameProblemLanguageResultExecution timeMemory
529304EqualTurtleCounting Mushrooms (IOI20_mushrooms)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; constexpr int maxk = 100; vector <int> sure[2]; int res = 0; int use_machine(int arr[]); void first_two() { int* arr = new int[2]; arr[0] = 0, arr[1] = 1; int curr = use_machine(arr); delete[] arr; if (curr == 0){ sure[0].push_back(1); return; } sure[1].push_back(1); arr = new int[2]; arr[0] = 0, arr[1] = 2; curr = use_machine(arr); delete[] arr; sure[curr].push_back(2); } void phase1(int k) { int* arr = new int[4]; int counter = (int)sure[0].size() + (int)sure[1].size(); int which = (sure[0].size() >= 2 ? 0 : 1); while ((int)sure[0].size() < k && (int)sure[1].size() < k) { arr[0] = sure[which][0], arr[1] = counter, arr[2] = sure[which][1], arr[3] = counter + 1; int curr = use_machine(arr); sure[(which ^ (curr % 2))].push_back(counter + 1); curr /= 2; sure[(which ^ curr)].push_back(counter + 1); counter += 2; } delete[] arr; } void phase2(int n) { int counter = (int)sure[0].size() + (int)sure[1].size(); int which = (sure[0].size() >= sure[1].size() ? 0 : 1); while (counter < n) { int siz = min(n - counter, (int)sure[which].size()); int* arr = new int[2 * siz]; for (int i = 0; i < siz; i++){ arr[i * 2] = sure[which][i]; arr[i * 2 + 1] = counter + i; } int curr = use_machine(arr); sure[(which ^ (curr % 2))].push_back(counter + 1); res += (which == 0 ? curr / 2 : siz - curr/2); which = (sure[0].size() >= sure[1].size() ? 0 : 1); delete[] arr; counter += siz; } res += (int)sure[0].size(); } int count_mushooms(int n) { // very small n corner sure[0].push_back(0); first_two(); // already know at least 2 of same kind phase1(min(n/2 - 1, maxk)); // already know at leat k of same kind phase2(n); return res; }

Compilation message (stderr)

/usr/bin/ld: /tmp/cci4doCO.o: in function `phase1(int)':
mushrooms.cpp:(.text+0x1b6): undefined reference to `use_machine(int*)'
/usr/bin/ld: /tmp/cci4doCO.o: in function `phase2(int)':
mushrooms.cpp:(.text+0x34d): undefined reference to `use_machine(int*)'
/usr/bin/ld: /tmp/cci4doCO.o: in function `first_two()':
mushrooms.cpp:(.text+0x49b): undefined reference to `use_machine(int*)'
/usr/bin/ld: mushrooms.cpp:(.text+0x4fd): undefined reference to `use_machine(int*)'
/usr/bin/ld: /tmp/ccGhgewQ.o: in function `main':
stub.cpp:(.text.startup+0x86): undefined reference to `count_mushrooms(int)'
collect2: error: ld returned 1 exit status