# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
238894 | 2020-06-13T12:03:04 Z | Sorting | Secret Permutation (RMI19_permutation) | C++14 | 5 ms | 384 KB |
#include <bits/stdc++.h> #include "permutationc.h" using namespace std; int query(int v[]); int query(vector<int> v); void answer(int v[]); void answer(vector<int> v); void solve(int n){ vector<int> v; for(int i = 1; i <= n; ++i) v.push_back(i); int best_diff = 0, best_idx = 1; for(int i = 2; i < n; ++i){ swap(v[i], v[n - 1]); int curr = query(v); swap(v[1], v[n - 1]); int after = query(v); swap(v[1], v[n - 1]); swap(v[i], v[n - 1]); int curr_diff = after - curr; if(curr_diff > best_diff){ best_diff = curr_diff; best_idx = i; } } int best_val = best_idx + 1; //cout << best_idx << " best_idx" << endl; swap(v[best_idx], v[0]); vector<int> diff(n); diff[1] = 0; for(int i = 2; i < n; ++i){ swap(v[i], v[n - 1]); int curr = query(v); swap(v[1], v[n - 1]); int after = query(v); swap(v[1], v[n - 1]); swap(v[i], v[n - 1]); diff[i] = after - curr; } int min_diff = 100000; for(int i = 1; i < n; ++i) min_diff = min(diff[i], min_diff); for(int i = 1; i < n; ++i){ diff[i] -= min_diff; diff[i] += 2; } diff[0] = 1; swap(diff[best_idx], diff[0]); answer(diff); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 384 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 384 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 384 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |