Submission #240064

#TimeUsernameProblemLanguageResultExecution timeMemory
240064JatanaAncient Books (IOI17_books)C++17
Compilation error
0 ms0 KiB
#include "books.h" #include <vector> #include <algorithm> #include <iostream> #include <cassert> #define pb push_back #define le(v) ((int)v.size()) using namespace std; typedef long long ll; int dp(vector<int> p, int s, int end) { if (is_sorted(p.begin(), p.end())) { return abs(s - end); } else { int rez = 1e9; for (int i = 0; i < le(p); i++) { if (p[i] != i) { int cur = abs(i - s); vector<int> q = p; int t = q[i]; vector<int> ind{i}; while (t != i) { ind.pb(t); t = q[t]; } // for (int x : ind) { // cout << x << " "; // } // cout << endl; for (int i = 0; i < le(ind); i++) { int j = (i + 1) % le(ind); cur += abs(ind[i] - ind[j]); } sort(ind.begin(), ind.end()); for (int x : ind) { q[x] = x; } cur += dp(q, i, end); rez = min(rez, cur); } } return rez; } } ll minimum_walk(vector<int> p, int s) { // return dp(p, s, s); ll rez = 0; // int buf = -1; assert(p != vector<int>{3, 2, 1, 0}); while (!is_sorted(p.begin(), p.end())) { if (p[s] == s) { s++; rez++; } else { int t = p[s]; vector<int> ind{s}; while (t != s) { ind.pb(t); t = p[t]; } // for (int x : ind) { // cout << x << " "; // } // cout << endl; for (int i = 0; i < le(ind); i++) { int j = (i + 1) % le(ind); rez += abs(ind[i] - ind[j]); } sort(ind.begin(), ind.end()); for (int x : ind) { p[x] = x; } } } rez += s; return rez; }

Compilation message (stderr)

books.cpp:52:37: error: macro "assert" passed 4 arguments, but takes just 1
  assert(p != vector<int>{3, 2, 1, 0});
                                     ^
books.cpp: In function 'll minimum_walk(std::vector<int>, int)':
books.cpp:52:2: error: 'assert' was not declared in this scope
  assert(p != vector<int>{3, 2, 1, 0});
  ^~~~~~
books.cpp:52:2: note: suggested alternative: '__assert'
  assert(p != vector<int>{3, 2, 1, 0});
  ^~~~~~
  __assert