Submission #735170

#TimeUsernameProblemLanguageResultExecution timeMemory
735170DAleksaArt Collections (BOI22_art)C++17
0 / 100
0 ms208 KiB
#include <bits/stdc++.h> #include "art.h" using namespace std; void solve(int n) { vector<int> inv(n); vector<int> ask(n); iota(ask.begin(), ask.end(), 1); inv[0] = publish(ask); for(int i = 1; i < n; i++) { ask[n - 1] = i; for(int j = 0; j < n - 1; j++) ask[j] = (j + 1 < i ? j + 1 : j + 2); inv[i] = publish(ask); } //for(int i = 0; i < n; i++) cout << inv[i] << " "; //cout << "\n"; for(int i = 1; i < n; i++) inv[i] = (inv[0] - inv[i] + n - i) / 2; vector<int> res(n); vector<bool> mark(n + 1, false); for(int i = 1; i < n; i++) { int cnt = 0; for(int j = 1; j <= n; j++) { if(mark[j]) continue; cnt++; if(cnt == inv[i] + 1) { res[i - 1] = i; mark[i] = true; } } } for(int i = 1; i <= n; i++) { if(!mark[i]) { res[n - 1] = i; break; } } answer(res); } // inv[0] - inv[1] = < - > // < + > = n - 1 // inv[0] - inv[1] + n - 1 = 2 * < //

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