Submission #649856

# Submission time Handle Problem Language Result Execution time Memory
649856 2022-10-11T13:04:05 Z boris_mihov Secret Permutation (RMI19_permutation) C++17
3 / 100
3393 ms 208 KB
#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

stub.cpp: In function 'int query(int*)':
stub.cpp:15:9: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |   fscanf(stdin, "%d", &x);
      |   ~~~~~~^~~~~~~~~~~~~~~~~
stub.cpp: In function 'int main(int, char**)':
stub.cpp:48:9: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   48 |   fscanf(stdin, "%d", &N);
      |   ~~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Partially correct 12 ms 208 KB Partially correct
2 Partially correct 1 ms 208 KB Partially correct
3 Partially correct 6 ms 208 KB Partially correct
4 Partially correct 9 ms 208 KB Partially correct
5 Partially correct 3 ms 208 KB Partially correct
6 Partially correct 2 ms 208 KB Partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 12 ms 208 KB Partially correct
2 Partially correct 1 ms 208 KB Partially correct
3 Partially correct 6 ms 208 KB Partially correct
4 Partially correct 9 ms 208 KB Partially correct
5 Partially correct 3 ms 208 KB Partially correct
6 Partially correct 2 ms 208 KB Partially correct
7 Execution timed out 3393 ms 208 KB Time limit exceeded (wall clock)
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 12 ms 208 KB Partially correct
2 Partially correct 1 ms 208 KB Partially correct
3 Partially correct 6 ms 208 KB Partially correct
4 Partially correct 9 ms 208 KB Partially correct
5 Partially correct 3 ms 208 KB Partially correct
6 Partially correct 2 ms 208 KB Partially correct
7 Execution timed out 3393 ms 208 KB Time limit exceeded (wall clock)
8 Halted 0 ms 0 KB -