Submission #406539

#TimeUsernameProblemLanguageResultExecution timeMemory
406539snasibov05Comparing Plants (IOI20_plants)C++14
Compilation error
0 ms0 KiB
#include "plants.h" #include <queue> #define pb push_back using namespace std; vector<int> h; void init(int k, vector<int> r) { int n = r.size(); int x = n; h.resize(n); for (int i = 0; i < n; ++i) { r.pb(r[i]); } for (int i = 0; i < n; ++i) { queue<int> q; for (int j = 0; j < n; ++j) { if (!q.empty() && j - q.front() > k - 1) q.pop(); if (r[j] == 0) q.push(r[j]); } int cur = 0; for (int j = n; j < 2*n; ++j) { if (!q.empty() && j - q.front() > k - 1) q.pop(); if (r[j] == 0 && q.empty()){ cur = j; break; } if (r[j] == 0) q.push(r[j]); } assert(cur >= n); h[cur%n] = x--; for (int j = cur; j > cur - k ; --j) { r[j]--; if (j >= n) r[j-n]--; else r[j+n]--; } } } int compare_plants(int x, int y) { if (h[x] > h[y]) return 1; else return -1; }

Compilation message (stderr)

plants.cpp: In function 'void init(int, std::vector<int>)':
plants.cpp:39:9: error: 'assert' was not declared in this scope
   39 |         assert(cur >= n);
      |         ^~~~~~
plants.cpp:3:1: note: 'assert' is defined in header '<cassert>'; did you forget to '#include <cassert>'?
    2 | #include <queue>
  +++ |+#include <cassert>
    3 |