Submission #838511

#TimeUsernameProblemLanguageResultExecution timeMemory
838511skittles1412Art Collections (BOI22_art)C++17
100 / 100
1410 ms588 KiB
#include "bits/extc++.h" using namespace std; template <typename T, typename... U> void dbgh(const T& t, const U&... u) { cerr << t; ((cerr << " | " << u), ...); cerr << endl; } #ifdef DEBUG #define dbg(...) \ cerr << "L" << __LINE__ << " [" << #__VA_ARGS__ << "]: "; \ dbgh(__VA_ARGS__) #else #define dbg(...) #define cerr \ if (false) \ cerr #endif #define endl "\n" #define long int64_t #define sz(x) int(std::size(x)) /** * returns how many complaints you will receive for this ordering of the art collections */ int publish(vector<int>); /** * use this function when you have found the correct order of the art collections * You must call answer exactly once; your program will be automatically * terminated afterwards. */ void answer(vector<int>); /** * implement this function */ void solve(int n) { int arr[n]; vector<int> perm(n); for (int i = 0; i < n; i++) { perm[i] = n - i; } for (int i = 0; i < n; i++) { arr[i] = publish(perm); rotate(perm.begin(), perm.end() - 1, perm.end()); } int q_arr[n]; for (int i = 0; i < n; i++) { int me = arr[i], nxt = arr[(i + 1) % n]; dbg(me, nxt); q_arr[i] = (me - nxt + (n - 1)) / 2; } vector<int> ans(n); for (int i = 0; i < n; i++) { ans[q_arr[i]] = i + 1; } reverse(begin(ans), end(ans)); 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...