Submission #418292

#TimeUsernameProblemLanguageResultExecution timeMemory
418292JediMaster11Mechanical Doll (IOI18_doll)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define fo(a, b, c) for (int a = b; a < c; a++) #define ll long long #define print(x) cout << x << "\n"; ll recur(int l, int r, int *h) { // r is non-inclsuive if (r - l <=1) { return h[l]; } int maxH = -1; fo(i, l, r) { maxH = max(maxH, h[i]); } vector<pair<pair<int, int>, ll>> aves; // stores the left and right, and then the sum of the middle int leftH = l; fo(i, l, r) { if (h[i] == maxH) { ll tmp = recur(leftH, i, h); aves.push_back({{leftH, i}, tmp}); leftH = i + 1; } } if (leftH != r) { ll tmp = recur(leftH, r, h); aves.push_back({{leftH, r}, tmp}); } int index=-1; double minAve = maxH + 1; fo(i,0,aves.size()){ double maxtmp = 0.0 + aves[i].second / (aves[i].first.second - aves[i].first.first+1); if(maxtmp < minAve){ minAve=maxtmp; index=i; } } ll numMax = (r - aves[index].first.second) + (aves[index].first.first-l); return 1ll * numMax * maxH + aves[index].second; } //looking for smallest ave // h - heights // l, r - left and right bounds of each meeting ll minCosts[750000]; ll *minimum_costs(int *h, int *l, int *r) { int numMeetings = sizeof(l) / sizeof(l[0]); // ll minCosts[numMeetings]; fo(i, 0, numMeetings) { minCosts[i] = recur(l[i], r[i] + 1, h); } return minCosts; } // int main() // { // ios::sync_with_stdio(0); // cin.tie(0); // int h[] = {2, 4, 3, 5}; // int l[] = {0, 1}; // int r[] = {2, 3}; // ll* tm = minimum_costs(h, l, r); // fo(i,0,sizeof(l)/sizeof(l[0])){ // print(tm[i]); // } // }

Compilation message (stderr)

doll.cpp: In function 'long long int recur(int, int, int*)':
doll.cpp:4:39: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<std::pair<int, int>, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    4 | #define fo(a, b, c) for (int a = b; a < c; a++)
......
   50 |     fo(i,0,aves.size()){
      |        ~~~~~~~~~~~~~~~                 
doll.cpp:50:5: note: in expansion of macro 'fo'
   50 |     fo(i,0,aves.size()){
      |     ^~
doll.cpp: In function 'long long int* minimum_costs(int*, int*, int*)':
doll.cpp:74:33: warning: division 'sizeof (int*) / sizeof (int)' does not compute the number of array elements [-Wsizeof-pointer-div]
   74 |     int numMeetings = sizeof(l) / sizeof(l[0]);
      |                       ~~~~~~~~~~^~~~~~~~~~~~~~
doll.cpp:71:32: note: first 'sizeof' operand was declared here
   71 | ll *minimum_costs(int *h, int *l, int *r)
      |                           ~~~~~^
/usr/bin/ld: /tmp/ccDHSDgl.o: in function `main':
grader.cpp:(.text.startup+0x168): undefined reference to `create_circuit(int, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status