Submission #715927

#TimeUsernameProblemLanguageResultExecution timeMemory
715927ismayilArt Collections (BOI22_art)C++17
100 / 100
1780 ms784 KiB
#include "art.h" #include<bits/stdc++.h> using namespace std; // g++ -std=c++17 art_sample.cpp sample_grader.cpp int n; int f(){ vector<int> order; for (int i = 1; i <= n; i++) { order.push_back(i); } return publish(order); } int f_inv(int a){ vector<int> order; for (int i = 1; i <= n; i++) { if(i == a) continue; order.push_back(i); } order.push_back(a); return publish(order); } int cell[4001]; void solve(int N) { n = N; vector<int> ans(n, 0); int inv = f(); for (int i = 1; i < n; i++) { int ninv = f_inv(i); /* inv = x + y + pos(i); ninv = n - i - pos(i) + x + y; inv - ninv = pos(i) - n + i + pos(i) 2 * pos(i) = inv - ninv + n - i */ int pos = (inv - ninv + n - i) / 2; //cout << i << " " << pos << endl; for(int j = 0; j < n; j++){ if(cell[j] == 0 && pos == 0){ ans[j] = i; cell[j] = 1; break; } if(cell[j] == 0) pos--; } } for(int j = 0; j < n; j++){ if(cell[j] == 0){ ans[j] = n; cell[j] = 1; 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...