Submission #649858

# Submission time Handle Problem Language Result Execution time Memory
649858 2022-10-11T13:05:13 Z boris_mihov Secret Permutation (RMI19_permutation) C++17
0 / 100
24 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 (perm[0] < perm[1]) continue;
        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 Incorrect 24 ms 208 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 24 ms 208 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 24 ms 208 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -