This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "art.h"
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
// int publish(vector<int> B) {
// answer(B);
// int ans;cin>>ans;
// return ans;
// }
// void answer(vector<int> B) {
// for (auto el : B) cout << el << " ";
// cout << endl;
// }
// A = [5, 2, 3, 1, 4], inv = 4 + 1 + 1 = 6
// A = [2, 3, 1, 4, 5], inv = 1 + 1 = 2
// A = [3, 1, 4, 5, 2], inv = 2 + 1 + 1 = 4
// A = [1, 4, 5, 2, 3], inv = 2+2 = 4
// A = [4, 5, 2, 3, 1], inv = 3+3+2 = 8
void solve(int n) {
vector<int> a(n);
iota(all(a),1);
vector<int> rec(n);
vector<int> ans;
for (int i = 0; i < n; i++) {
int x = publish(a);
a.push_back(*a.begin());
a.erase(a.begin());
ans.push_back(x);
}
vector<pair<int, int>> delt(n);
for (int i = 0; i < n; i++) {
delt[i] = {ans[(i+1)%n] - ans[i], i};
}
sort(all(delt));
reverse(all(delt));
for (int i = 0; i < n; i++) rec[i] = delt[i].second+1;
answer(rec);
}
// int main() {
// int n;cin>>n;
// solve(n);
// }
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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |