# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
649856 | boris_mihov | Secret Permutation (RMI19_permutation) | C++17 | 3393 ms | 208 KiB |
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 "permutation.h"
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <cassert>
#include <vector>
#include <cmath>
#include <set>
const int MAXN = 256 + 10;
const int INF = 1e9;
// int p[MAXN];
// int query(std::vector <int> v)
// {
// int sum = 0;
// for (int i = 0 ; i < v.size() - 1 ; ++i)
// {
// sum += abs(p[v[i + 1]] - p[v[i]]);
// }
// return sum;
// }
// void answer(std::vector <int> v)
// {
// int cnt = 1;
// bool res = true;
// for (const int &i : v)
// {
// std::cout << i << ' ';
// res &= (i == p[cnt++]);
// }
// std::cout << '\n';
// if (res) std::cout << "OK\n";
// else std::cout << "WA\n";
// exit(0);
// }
std::vector <int> perm;
std::vector <int> ans;
void solve(int n)
{
perm.resize(n);
ans.resize(n);
std::iota(perm.begin(), perm.end(), 1);
do
{
if (query(perm) == n-1)
{
int cnt = 1;
for (int i : perm) ans[i-1] = cnt++;
answer(ans);
return;
}
} while(std::next_permutation(perm.begin(), perm.end()));
}
// int n;
// int main()
// {
// std::cin >> n;
// for (int i = 1 ; i <= n ; ++i)
// {
// std::cin >> p[i];
// }
// solve(n);
// return 0;
// }
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |