Submission #573629

#TimeUsernameProblemLanguageResultExecution timeMemory
573629pavementArt Collections (BOI22_art)C++17
100 / 100
1716 ms580 KiB
#include "art.h" #include <bits/stdc++.h> using namespace std; #define pb push_back void solve(int N) { int _ord[2 * N + 1], *ord = _ord + N; memset(_ord, -1, sizeof _ord); ord[0] = 1; vector<int> order, out; for (int i = 1; i <= N; i++) order.pb(i); int E = publish(order); for (int i = 2, pos = 0; i <= N; i++) { int tmp = -1; if (i & 1) { swap(order[pos], order[(i - 1) / 2]); tmp = order[pos]; pos = (i - 1) / 2; } else { swap(order[pos], order[order.size() - i / 2]); tmp = order[pos]; pos = order.size() - i / 2; } int E2 = publish(order), D = E2 - E; if (i & 1) D = -D; int dist = (D > 0 ? (D + 1) / 2 : -(-D + 1) / 2); if (dist > 0) { int pos = 0; while (dist) { if (ord[pos] == -1) dist--; pos++; } ord[pos - 1] = tmp; } else { int pos = 0; while (dist) { if (ord[pos] == -1) dist++; pos--; } ord[pos + 1] = tmp; } E = E2; } for (int i = -N; i <= N; i++) if (ord[i] != -1) out.pb(ord[i]); answer(out); }

Compilation message (stderr)

interface.cpp: In function 'int publish(std::vector<int>)':
interface.cpp:20:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   20 |     if(v.size() != N) {
      |        ~~~~~~~~~^~~~
interface.cpp: In function 'void answer(std::vector<int>)':
interface.cpp:36:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   36 |     if(v.size() != N) {
      |        ~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...