Submission #962143

#TimeUsernameProblemLanguageResultExecution timeMemory
962143lotusblumeArt Collections (BOI22_art)C++17
100 / 100
1212 ms1788 KiB
#include <iostream> #include <vector> #include "art.h" void solve(int n) { std::vector<int> p(n); for (int i = 0; i < n; ++i) { p[i] = i + 1; } int orig = publish(p); std::vector<int> ans(n, 0); for (int i = 0; i < n - 1; ++i) { for (int j = 0; j < i; ++j) { p[j] = j + 1; } for (int j = i; j < n - 1; ++j) { p[j] = j + 2; } p[n - 1] = i + 1; int dif = orig - publish(p); int x = ((n - i - 1) + dif) / 2; for (int j = 0; j < n; ++j) { if (ans[j] == 0) { if (x == 0) { ans[j] = i + 1; break; } else { --x; } } } } for (int j = 0; j < n; ++j) { if (ans[j] == 0) { ans[j] = n; break; } } 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...