Submission #754048

#TimeUsernameProblemLanguageResultExecution timeMemory
754048jakobrsArt Collections (BOI22_art)C++17
100 / 100
1568 ms680 KiB
#include <iostream> #include <vector> #include <algorithm> int publish(std::vector<int> R); void answer(std::vector<int> R); void solve(int N) { // Used for comparisons std::vector<int> R; std::vector<int> ans(N, -1); for (int i = 1; i <= N; i++) { R.push_back(i); } int prev = publish(R); for (int i = N; i >= 2; i--) { R.pop_back(); R.insert(R.begin(), i); int measured = publish(R); // measured = prev - ob + nb // ob = N - nb - 1 // nb = intended position i think ??? // measured - prev = nb - ob = nb - N + nb + 1 // measured - prev + N - 1 = 2 nb int pos = ((measured - prev) + N - 1)/2; ans[pos] = i; prev = measured; } for (int i = 0; i < N; i++) { if (ans[i] == -1) { ans[i] = 1; } } 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...