Submission #862366

#TimeUsernameProblemLanguageResultExecution timeMemory
862366The_SamuraiArt Collections (BOI22_art)C++17
100 / 100
1220 ms1772 KiB
#include "art.h" #include "bits/stdc++.h" using namespace std; /* A = publish({x+1, x+2, ..., n, 1, 2, ..., x}) B = publish({x, x+1, x+2, ..., n, 1, 2, ..., x-1}) sol[x] = uni asl orderi B = A + (sol[x] - 1) - (n - sol[x]) B = A - 1 - n + 2*sol[x] sol[x] = (B-A+1+n)/2 */ void solve(int n) { vector<int> sol(n + 1), p(n); iota(p.begin(), p.end(), 1); int A = publish(p); for (int i = n; i > 1; i--) { p.insert(p.begin(), i); p.pop_back(); int B = publish(p); assert((B - A + 1 + n) % 2 == 0); sol[i] = (B - A + 1 + n) / 2; A = B; } for (int i = 1; i <= n; i++) { if (!count(sol.begin(), sol.end(), i)) { sol[1] = i; break; } } vector<int> ans(n); for (int i = 1; i <= n; i++) ans[sol[i] - 1] = i; answer(ans); }

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...