#include "permutation.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define fi first
#define se second
#define endl '\n'
#define debug(x) cout << #x << " is " << x << endl;
#define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
int val[100005];
void solve(int n) {
vector<int> v;
int lo=1,hi=2;
rep(x,3,n+1){
//lets try to see if x is lowest or highest
int v1,v2;
v={lo,x,hi};
rep(y,1,n+1) if (y!=lo && y!=x && y!=hi) v.push_back(y);
v1=query(v);
swap(v[0],v[1]);
v2=query(v);
if (v2<v1){
lo=x;
continue;
}
v={hi,x,lo};
rep(y,1,n+1) if (y!=lo && y!=x && y!=hi) v.push_back(y);
v1=query(v);
swap(v[0],v[1]);
v2=query(v);
if (v2<v1){
hi=x;
continue;
}
}
//cout<<lo<<" "<<hi<<endl;
val[lo]=-1e9;
val[hi]=1e9;
rep(x,1,n+1) if (x!=lo && x!=hi){
v={lo,hi,x};
rep(y,1,n+1) if (y!=lo && y!=x && y!=hi) v.push_back(y);
int v1,v2;
v1=query(v);
swap(v[0],v[1]);
v2=query(v);
val[x]=v2-v1;
}
vector<int> perm,ans(n);
rep(x,1,n+1) perm.push_back(x);
sort(all(perm),[](int i,int j){
return val[i]<val[j];
});
rep(x,0,n) ans[perm[x]-1]=x+1;
//for (auto &it:perm) cout<<it<<" "; cout<<endl;
for (auto &it:ans) cout<<it<<" "; cout<<endl;
answer(ans);
}
Compilation message
permutation.cpp: In function 'void solve(int)':
permutation.cpp:80:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
for (auto &it:ans) cout<<it<<" "; cout<<endl;
^~~
permutation.cpp:80:36: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
for (auto &it:ans) cout<<it<<" "; cout<<endl;
^~~~
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]
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]
fscanf(stdin, "%d", &N);
~~~~~~^~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Wrong query format! |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Wrong query format! |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Wrong query format! |
2 |
Halted |
0 ms |
0 KB |
- |