#include <bits/stdc++.h>
#include "monster.h"
using namespace std;
const long long d=11;
long long pst[1069],tmp[1069],sq[1069],zs=0;
void rk(long long lh,long long rh)
{
if(lh==rh)
{
pst[lh]=lh;
}
else
{
long long i,md=(lh+rh)/2,p[2];
rk(lh,md);
rk(md+1,rh);
p[0]=lh;
p[1]=md+1;
for(i=lh;i<=rh;i++)
{
if(p[1]>rh||(p[0]<=md&&Query(pst[p[1]],pst[p[0]])))
{
tmp[i]=pst[p[0]];
p[0]++;
}
else
{
tmp[i]=pst[p[1]];
p[1]++;
}
}
for(i=lh;i<=rh;i++)
{
pst[i]=tmp[i];
}
}
}
vector<int> Solve(int n)
{
long long i,j,c=0,l=1,p;
vector<int> v;
rk(0,n-1);
for(i=2;i<=min(min(d*2-1,l+d),(long long)n-1);i++)
{
if(Query(pst[0],pst[i]))
{
c++;
l=i;
}
}
if(c>1)
{
p=c;
}
else
{
if(l>2)
{
if(Query(pst[1],pst[3]))
{
p=0;
}
else
{
p=1;
}
}
else
{
for(i=l+1;i<=min(l+d,(long long)n-1);i++)
{
if(Query(pst[l],pst[i]))
{
break;
}
}
if(i>min(l+d,(long long)n-1))
{
p=0;
}
else
{
p=1;
}
}
}
l=-1;
for(i=p;i<n;i++)
{
if(i>p)
{
if(Query(pst[l+1],pst[i]))
{
l=p;
p=i;
}
}
if(i==p)
{
for(j=p;j>l;j--)
{
sq[pst[j]]=zs;
zs++;
}
}
}
for(i=0;i<n;i++)
{
v.push_back(sq[i]);
}
return v;
}
# |
결과 |
실행 시간 |
메모리 |
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 |
0 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 |
252 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 |
1 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 |
304 KB |
Output is correct |
17 |
Correct |
21 ms |
320 KB |
Output is correct |
18 |
Correct |
14 ms |
356 KB |
Output is correct |
19 |
Correct |
21 ms |
256 KB |
Output is correct |
20 |
Correct |
21 ms |
300 KB |
Output is correct |
21 |
Correct |
1 ms |
200 KB |
Output is correct |
22 |
Correct |
1 ms |
200 KB |
Output is correct |
23 |
Correct |
1 ms |
200 KB |
Output is correct |
24 |
Correct |
1 ms |
200 KB |
Output is correct |
25 |
Correct |
1 ms |
200 KB |
Output is correct |
26 |
Correct |
15 ms |
200 KB |
Output is correct |
27 |
Correct |
1 ms |
200 KB |
Output is correct |
28 |
Correct |
1 ms |
200 KB |
Output is correct |
29 |
Correct |
1 ms |
200 KB |
Output is correct |
30 |
Correct |
1 ms |
200 KB |
Output is correct |
31 |
Correct |
1 ms |
200 KB |
Output is correct |
32 |
Correct |
14 ms |
200 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
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 |
0 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 |
252 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 |
1 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 |
304 KB |
Output is correct |
17 |
Correct |
21 ms |
320 KB |
Output is correct |
18 |
Correct |
14 ms |
356 KB |
Output is correct |
19 |
Correct |
21 ms |
256 KB |
Output is correct |
20 |
Correct |
21 ms |
300 KB |
Output is correct |
21 |
Correct |
1 ms |
200 KB |
Output is correct |
22 |
Correct |
1 ms |
200 KB |
Output is correct |
23 |
Correct |
1 ms |
200 KB |
Output is correct |
24 |
Correct |
1 ms |
200 KB |
Output is correct |
25 |
Correct |
1 ms |
200 KB |
Output is correct |
26 |
Correct |
15 ms |
200 KB |
Output is correct |
27 |
Correct |
1 ms |
200 KB |
Output is correct |
28 |
Correct |
1 ms |
200 KB |
Output is correct |
29 |
Correct |
1 ms |
200 KB |
Output is correct |
30 |
Correct |
1 ms |
200 KB |
Output is correct |
31 |
Correct |
1 ms |
200 KB |
Output is correct |
32 |
Correct |
14 ms |
200 KB |
Output is correct |
33 |
Correct |
91 ms |
300 KB |
Output is correct |
34 |
Correct |
147 ms |
292 KB |
Output is correct |
35 |
Correct |
142 ms |
296 KB |
Output is correct |
36 |
Correct |
153 ms |
324 KB |
Output is correct |
37 |
Correct |
139 ms |
292 KB |
Output is correct |
38 |
Correct |
80 ms |
296 KB |
Output is correct |
39 |
Correct |
79 ms |
304 KB |
Output is correct |
40 |
Correct |
72 ms |
200 KB |
Output is correct |
41 |
Correct |
90 ms |
296 KB |
Output is correct |
42 |
Correct |
138 ms |
300 KB |
Output is correct |
43 |
Correct |
66 ms |
292 KB |
Output is correct |
44 |
Correct |
31 ms |
300 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
105 ms |
288 KB |
Output is correct |
2 |
Correct |
127 ms |
304 KB |
Output is correct |
3 |
Correct |
72 ms |
300 KB |
Output is correct |
4 |
Correct |
96 ms |
444 KB |
Output is correct |
5 |
Correct |
92 ms |
292 KB |
Output is correct |
6 |
Correct |
43 ms |
428 KB |
Output is correct |
7 |
Correct |
97 ms |
308 KB |
Output is correct |
8 |
Correct |
52 ms |
296 KB |
Output is correct |
9 |
Correct |
122 ms |
300 KB |
Output is correct |
10 |
Correct |
124 ms |
368 KB |
Output is correct |
11 |
Correct |
101 ms |
300 KB |
Output is correct |
12 |
Correct |
107 ms |
296 KB |
Output is correct |
13 |
Correct |
101 ms |
292 KB |
Output is correct |
14 |
Correct |
72 ms |
300 KB |
Output is correct |
15 |
Correct |
89 ms |
296 KB |
Output is correct |
16 |
Correct |
79 ms |
296 KB |
Output is correct |
17 |
Correct |
94 ms |
292 KB |
Output is correct |
18 |
Correct |
85 ms |
292 KB |
Output is correct |