답안 #644248

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
644248 2022-09-24T08:11:16 Z Karuk Secret Permutation (RMI19_permutation) C++14
0 / 100
0 ms 208 KB
#include<bits/stdc++.h>
#include "permutationc.h"
using namespace std;
void solve(int n) {
    int a[n];
    for(int i=1;i<=n;i++) {
        a[i-1]=i;
    }
    int maxres=0,maxind=-1;
    for(int i=1;i<n;i++) {
        reverse(a,a+i);
        int c=query(a);
        reverse(a,a+i);
        if(c>maxres){maxres=c;maxind=i;}
    }
    swap(a[0],a[maxind]);
    maxres=0;
    maxind=-1;
    vector<pair<int,int> >v;
    for(int i=1;i<n;i++) {
        reverse(a,a+i);
        int c=query(a);
        reverse(a,a+i);
        v.push_back({c,a[i]});
    }
    int ans[n];
    sort(v.begin(),v.end());
    ans[a[0]]=1;
    for(int i=2;i<=n;i++) {
        ans[v[i-2].second]=i;
    }
    answer(ans);
}

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 Incorrect 0 ms 208 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 208 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 208 KB Output isn't correct
2 Halted 0 ms 0 KB -