Submission #1244879

#TimeUsernameProblemLanguageResultExecution timeMemory
1244879j_vdd16Mechanical Doll (IOI18_doll)C++20
Compilation error
0 ms0 KiB
#include <iostream> #include <vector> #include <queue> #include <algorithm> #include "doll.h" using namespace std; #define loop(X, N) for (int X = 0; X < (N); X++) typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int, int> ii; typedef vector<ii> vii; typedef vector<vii> vvii; int numBits = 0; int rev(int n) { int out = 0; for (int i = 0; i < numBits; i++) { if (n & (1 << i)) out |= 1 << (numBits - 1 - i); } return out; } bool cmp(int a, int b) { return rev(a) < rev(b); } void create_circuit(int m, vi a) { vi c; //exits vi x, y; int n = a.size(); c.push_back(a[0]); int pow = 1; while (pow < n) { numBits++; pow *= 2; } vi order(pow); for (int i = 0; i < pow; i++) { order[i] = i; } sort(order.begin(), order.end(), cmp); if (pow == 1) { c.push_back(0); } else { vi exits(pow * 2); for (int j = 0; j < n - 1; j++) { exits[order[j] + pow] = a[j + 1]; } for (int j = n - 1; j < pow - 1; j++) { exits[order[j] + pow] = INT_MAX; } exits[order[pow - 1] + pow] = 0; int nodes = 1; for (int j = pow - 1; j >= 1; j--) { if (exits[j * 2] == INT_MAX && exits[j * 2 + 1] == INT_MAX) { exits[j] = INT_MAX; } else { x.push_back(exits[j * 2]); y.push_back(exits[j * 2 + 1]); exits[j] = -(nodes++); } } for (int& idx : c) if (idx == INT_MAX) idx = -(nodes - 1); for (int& idx : x) if (idx == INT_MAX) idx = -(nodes - 1); for (int& idx : y) if (idx == INT_MAX) idx = -(nodes - 1); for (int i = 0; i < m; i++) c.push_back(-(nodes - 1)); } answer(c, x, y); }

Compilation message (stderr)

doll.cpp: In function 'void create_circuit(int, vi)':
doll.cpp:62:37: error: 'INT_MAX' was not declared in this scope
   62 |             exits[order[j] + pow] = INT_MAX;
      |                                     ^~~~~~~
doll.cpp:7:1: note: 'INT_MAX' is defined in header '<climits>'; did you forget to '#include <climits>'?
    6 | #include "doll.h"
  +++ |+#include <climits>
    7 | 
doll.cpp:68:33: error: 'INT_MAX' was not declared in this scope
   68 |             if (exits[j * 2] == INT_MAX && exits[j * 2 + 1] == INT_MAX) {
      |                                 ^~~~~~~
doll.cpp:68:33: note: 'INT_MAX' is defined in header '<climits>'; did you forget to '#include <climits>'?
doll.cpp:78:39: error: 'INT_MAX' was not declared in this scope
   78 |         for (int& idx : c) if (idx == INT_MAX) idx = -(nodes - 1);
      |                                       ^~~~~~~
doll.cpp:78:39: note: 'INT_MAX' is defined in header '<climits>'; did you forget to '#include <climits>'?
doll.cpp:79:39: error: 'INT_MAX' was not declared in this scope
   79 |         for (int& idx : x) if (idx == INT_MAX) idx = -(nodes - 1);
      |                                       ^~~~~~~
doll.cpp:79:39: note: 'INT_MAX' is defined in header '<climits>'; did you forget to '#include <climits>'?
doll.cpp:80:39: error: 'INT_MAX' was not declared in this scope
   80 |         for (int& idx : y) if (idx == INT_MAX) idx = -(nodes - 1);
      |                                       ^~~~~~~
doll.cpp:80:39: note: 'INT_MAX' is defined in header '<climits>'; did you forget to '#include <climits>'?