#include "monster.h"
#include <bits/stdc++.h>
using namespace std;
#define sf scanf
#define pf printf
#define fi first
#define se second
#define pb emplace_back
#define sz(x) (int)x.size()
#define mnto(x,y) x=min(x,(__typeof__(x))y)
#define mxto(x,y) x=max(x,(__typeof__(x))y)
#define INF 1023456789
#define LINF 1023456789123456789
#define all(x) x.begin(), x.end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef tuple<int, int, int> iii;
typedef tuple<int, int, int, int> iiii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<pll> vll;
namespace{
vector<int> a,t,ans;
vector<ii> p;
void mergesort(int l,int r){
if(l==r)return;
int m=(l+r)/2;
mergesort(l,m);
mergesort(m+1,r);
t.clear();
int cl=l,cr=m+1;
while(cl<=m||cr<=r){
if(cl>m||(cr<=r&&Query(a[cl],a[cr])))t.pb(a[cr++]);
else t.pb(a[cl++]);
}
for(int i=l;i<=r;++i)a[i]=t[i-l];
t.clear();
}
void small(int n){//brute force the first n elements
for(int i=0;i<n;++i){
int cnt=0;
for(int j=0;j<n;++j){
if(j==i)continue;
cnt+=Query(a[i],a[j]);
}
p.pb(cnt,a[i]);
}
sort(all(p));
if(Query(p[1].se,p[0].se))swap(p[1],p[0]);
if(Query(p[n-1].se,p[n-2].se))swap(p[n-2],p[n-1]);
for(int i=0;i<n;++i)a[i]=p[i].se;
}
}
vector<int> Solve(int n){
for(int i=0;i<n;++i)a.pb(i);
mergesort(0,n-1);
small(min(n,10));
ans.resize(n);
int cur=0;
for(int i=cur+1;i<n;++i){
if(Query(a[cur],a[i])){
reverse(a.begin()+cur+1,a.begin()+i+1);
cur=i;
}
}
for(int i=0;i<n;++i)ans[a[i]]=i;
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
200 KB |
Output is correct |
3 |
Correct |
1 ms |
200 KB |
Output is correct |
4 |
Correct |
1 ms |
200 KB |
Output is correct |
5 |
Correct |
1 ms |
200 KB |
Output is correct |
6 |
Correct |
1 ms |
200 KB |
Output is correct |
7 |
Correct |
1 ms |
200 KB |
Output is correct |
8 |
Correct |
1 ms |
200 KB |
Output is correct |
9 |
Correct |
1 ms |
200 KB |
Output is correct |
10 |
Correct |
1 ms |
200 KB |
Output is correct |
11 |
Correct |
1 ms |
200 KB |
Output is correct |
12 |
Correct |
1 ms |
200 KB |
Output is correct |
13 |
Correct |
2 ms |
200 KB |
Output is correct |
14 |
Correct |
1 ms |
200 KB |
Output is correct |
15 |
Correct |
1 ms |
200 KB |
Output is correct |
16 |
Correct |
20 ms |
200 KB |
Output is correct |
17 |
Correct |
13 ms |
200 KB |
Output is correct |
18 |
Correct |
16 ms |
200 KB |
Output is correct |
19 |
Correct |
19 ms |
200 KB |
Output is correct |
20 |
Incorrect |
21 ms |
200 KB |
Wrong Answer [3] |
21 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
200 KB |
Output is correct |
3 |
Correct |
1 ms |
200 KB |
Output is correct |
4 |
Correct |
1 ms |
200 KB |
Output is correct |
5 |
Correct |
1 ms |
200 KB |
Output is correct |
6 |
Correct |
1 ms |
200 KB |
Output is correct |
7 |
Correct |
1 ms |
200 KB |
Output is correct |
8 |
Correct |
1 ms |
200 KB |
Output is correct |
9 |
Correct |
1 ms |
200 KB |
Output is correct |
10 |
Correct |
1 ms |
200 KB |
Output is correct |
11 |
Correct |
1 ms |
200 KB |
Output is correct |
12 |
Correct |
1 ms |
200 KB |
Output is correct |
13 |
Correct |
2 ms |
200 KB |
Output is correct |
14 |
Correct |
1 ms |
200 KB |
Output is correct |
15 |
Correct |
1 ms |
200 KB |
Output is correct |
16 |
Correct |
20 ms |
200 KB |
Output is correct |
17 |
Correct |
13 ms |
200 KB |
Output is correct |
18 |
Correct |
16 ms |
200 KB |
Output is correct |
19 |
Correct |
19 ms |
200 KB |
Output is correct |
20 |
Incorrect |
21 ms |
200 KB |
Wrong Answer [3] |
21 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
77 ms |
280 KB |
Wrong Answer [3] |
2 |
Halted |
0 ms |
0 KB |
- |