#include <bits/stdc++.h>
#include "monster.h"
using namespace std;
#define endl '\n'
#define st first
#define nd second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define ll long long
ll mod=1000000007;
int inf=1000000007;
ll infl=1000000000000000007;
/*
const int N=1007;
int p[N];
bool Query(int a, int b)
{
if(abs(p[a]-p[b])==1) return p[a]<p[b];
else return p[a]>p[b];
}*/
bool is[1007][1007];
vector<int>Solve(int n)
{
vector<int>V(n);
for(int i=0;i<n;i++) V[i]=i;
stable_sort(all(V),Query);
reverse(all(V));
/* for(int b=0;b<4;b++)
{
if(b+3<n&&Query(V[b],V[b+2])&&Query(V[b+1],V[b+3]))
{
int l=b+4;
for(int j=b+2;j+2<n;j++) if(!Query(V[j],V[j+2])) l++;
reverse(V.begin()+b,V.begin()+l);
}
}*/
for(int i=0;i<n;i++)
{
for(int j=0;j<i;j++)
{
is[i][j]=Query(V[i],V[j]);
is[j][i]=!is[i][j];
}
}
int A=-1,B=-1;
for(int i=0;i<n;i++)
{
int c=0;
for(int j=0;j<n;j++) if(i!=j) c+=is[i][j];
if(c==1)
{
if(A==-1) A=i;
else B=i;
}
}
if(Query(V[A],V[B])) reverse(V.begin(),V.begin()+A+1);
else reverse(V.begin(),V.begin()+B+1);
for(int i=1;i<n;i++)
{
for(int j=i;j<n;j++)
{
if(Query(V[i-1],V[j]))
{
reverse(V.begin()+i,V.begin()+j+1);
break;
}
}
}
vector<int>ans(n,0);
for(int i=0;i<n;i++) ans[V[i]]=i;
return ans;
}
/*
int main()
{
int n;
cin>>n;
for(int i=0;i<n;i++) cin>>p[i];
vector<int>V=Solve(n);
for(auto x:V) cout<<x<<" ";
cout<<endl;
return 0;
}*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
0 ms |
208 KB |
Output is correct |
6 |
Correct |
0 ms |
208 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
8 |
Correct |
1 ms |
208 KB |
Output is correct |
9 |
Correct |
1 ms |
208 KB |
Output is correct |
10 |
Correct |
1 ms |
208 KB |
Output is correct |
11 |
Correct |
1 ms |
208 KB |
Output is correct |
12 |
Correct |
1 ms |
208 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
208 KB |
Output is correct |
15 |
Correct |
1 ms |
208 KB |
Output is correct |
16 |
Correct |
127 ms |
416 KB |
Output is correct |
17 |
Correct |
134 ms |
436 KB |
Output is correct |
18 |
Correct |
113 ms |
796 KB |
Output is correct |
19 |
Correct |
125 ms |
480 KB |
Output is correct |
20 |
Correct |
141 ms |
440 KB |
Output is correct |
21 |
Correct |
0 ms |
208 KB |
Output is correct |
22 |
Correct |
0 ms |
208 KB |
Output is correct |
23 |
Correct |
1 ms |
208 KB |
Output is correct |
24 |
Correct |
1 ms |
208 KB |
Output is correct |
25 |
Correct |
1 ms |
208 KB |
Output is correct |
26 |
Correct |
68 ms |
480 KB |
Output is correct |
27 |
Correct |
1 ms |
208 KB |
Output is correct |
28 |
Correct |
0 ms |
208 KB |
Output is correct |
29 |
Correct |
0 ms |
208 KB |
Output is correct |
30 |
Correct |
0 ms |
208 KB |
Output is correct |
31 |
Correct |
1 ms |
208 KB |
Output is correct |
32 |
Correct |
125 ms |
472 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
0 ms |
208 KB |
Output is correct |
6 |
Correct |
0 ms |
208 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
8 |
Correct |
1 ms |
208 KB |
Output is correct |
9 |
Correct |
1 ms |
208 KB |
Output is correct |
10 |
Correct |
1 ms |
208 KB |
Output is correct |
11 |
Correct |
1 ms |
208 KB |
Output is correct |
12 |
Correct |
1 ms |
208 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
208 KB |
Output is correct |
15 |
Correct |
1 ms |
208 KB |
Output is correct |
16 |
Correct |
127 ms |
416 KB |
Output is correct |
17 |
Correct |
134 ms |
436 KB |
Output is correct |
18 |
Correct |
113 ms |
796 KB |
Output is correct |
19 |
Correct |
125 ms |
480 KB |
Output is correct |
20 |
Correct |
141 ms |
440 KB |
Output is correct |
21 |
Correct |
0 ms |
208 KB |
Output is correct |
22 |
Correct |
0 ms |
208 KB |
Output is correct |
23 |
Correct |
1 ms |
208 KB |
Output is correct |
24 |
Correct |
1 ms |
208 KB |
Output is correct |
25 |
Correct |
1 ms |
208 KB |
Output is correct |
26 |
Correct |
68 ms |
480 KB |
Output is correct |
27 |
Correct |
1 ms |
208 KB |
Output is correct |
28 |
Correct |
0 ms |
208 KB |
Output is correct |
29 |
Correct |
0 ms |
208 KB |
Output is correct |
30 |
Correct |
0 ms |
208 KB |
Output is correct |
31 |
Correct |
1 ms |
208 KB |
Output is correct |
32 |
Correct |
125 ms |
472 KB |
Output is correct |
33 |
Incorrect |
144 ms |
456 KB |
Wrong Answer [6] |
34 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
158 ms |
440 KB |
Wrong Answer [6] |
2 |
Halted |
0 ms |
0 KB |
- |