제출 #1286221

#제출 시각아이디문제언어결과실행 시간메모리
1286221SmuggingSpunArt Collections (BOI22_art)C++20
100 / 100
674 ms484 KiB
#include "art.h" #include<bits/stdc++.h> using namespace std; void solve(int n){ if(n <= 6){ vector<int>p(n); iota(p.begin(), p.end(), 1); do{ if(publish(p) == 0){ answer(p); return; } } while(next_permutation(p.begin(), p.end())); } if(n <= 444){ vector<int>p(n), ans(1, 1); iota(p.begin(), p.end(), 1); for(int i = 2, init = publish(p); i <= n; i++){ int low = 0, high = i - 2, pos = 0; while(low <= high){ int mid = (low + high) >> 1; swap(p[i - 1], p[ans[mid] - 1]); if(publish(p) > init){ low = pos = mid + 1; } else{ high = mid - 1; } swap(p[i - 1], p[ans[mid] - 1]); } ans.insert(ans.begin() + pos, i); } answer(ans); return; } vector<int>ans(n, -1), p(n); iota(p.begin(), p.end(), 1); for(int i = 1, init = publish(p); i < n; i++){ p.insert(p.begin(), p.back()); p.pop_back(); int d = publish(p) - init; ans[(d + n - 1) >> 1] = p[0]; init += d; } ans[find(ans.begin(), ans.end(), -1) - ans.begin()] = 1; answer(ans); }
#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...