답안 #1094309

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1094309 2024-09-29T10:30:17 Z alexdd Secret Permutation (RMI19_permutation) C++17
0 / 100
1 ms 600 KB
#include "permutation.h"
#include <bits/stdc++.h>
using namespace std;
map<vector<int>,int> mp;
int intreaba(vector<int> aux)
{
    if(mp[aux]==0)
    {
        mp[aux] = query(aux);
    }
    return mp[aux];
}
void solve(int N)
{
    mp.clear();
    vector<int> v(N);
    for(int i=0;i<N;i++)
        v[i]=i+1;
    while(intreaba(v) > N-1)
    {
        bool schimbat=0;
        for(int i=0;i+1<N;i++)
        {
            int init = intreaba(v);
            swap(v[i],v[i+1]);
            if(intreaba(v) >= init)
                swap(v[i],v[i+1]);
            else
                schimbat=1;
        }
        assert(schimbat);
    }
    vector<int> rez(N);
    for(int i=0;i<N;i++)
        rez[v[i]-1]=i+1;
    answer(rez);
}
/*
7
2 1 3 7 4 6 5
*/

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);
      |   ~~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -