Submission #725007

#TimeUsernameProblemLanguageResultExecution timeMemory
725007FatihSolakArt Collections (BOI22_art)C++17
100 / 100
1572 ms692 KiB
#include "art.h" #include <bits/stdc++.h> using namespace std; int n; bool cmp(int a,int b){ vector<int> ask1 = {a,b}; vector<int> ask2 = {b,a}; for(int i = 1;i<=n;i++){ if(i != a && i != b){ ask1.push_back(i); ask2.push_back(i); } } if(publish(ask1) > publish(ask2)){ return 1; } return 0; } vector<int> srt(vector<int> v){ if(v.size() == 1){ return v; } vector<int> a; vector<int> b; int asz = v.size()/2; int bsz = v.size()-asz; for(int i = 0;i<asz;i++){ a.push_back(v[i]); } for(int i = asz;i<asz+bsz;i++){ b.push_back(v[i]); } a = srt(a); b = srt(b); vector<int> ret; int pt1 = 0; for(int i = 0;i<asz;){ if(pt1 < bsz && cmp(a[i],b[pt1])){ ret.push_back(b[pt1]); pt1++; } else{ ret.push_back(a[i]); i++; } } while(pt1 <bsz){ ret.push_back(b[pt1]); pt1++; } return ret; } void solve(int N) { n = N; vector<int> order; vector<int> pos(N+1); for(int i = 1;i<=N;i++){ order.push_back(i); } //order = srt(order); int last = publish(order); for(int i = 1;i<n;i++){ vector<int> nw; for(int i = 1;i<n;i++) nw.push_back(order[i]); nw.push_back(order[0]); order = nw; int now = publish(order); int delta = now - last; //cout << last << " " << now << endl; pos[i] = (delta - n - 1)/-2; last = now; } vector<int> ans(N+1,N); for(int i = 1;i<n;i++){ ans[pos[i]] = i; } order.clear(); for(int i = 1;i<=N;i++){ order.push_back(ans[i]); } answer(order); }

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