#include "monster.h"
#include <bits/stdc++.h>
using namespace std;
const int N=1005;
int n;
map<pair<int,int>,int> m;
inline int ask(int a,int b){
if(m.find({a,b})!=m.end()){
return m[{a,b}];
}
if(m.find({b,a})!=m.end()){
return m[{b,a}]^1;
}
return m[{a,b}]=Query(a,b);
}
vector<int> dc(int l,int r){\
if(r-l==1){
return vector<int>(1,l);
}
int m=(l+r)>>1;
vector<int> a = dc(l,m);
vector<int> b = dc(m,r);
vector<int> c;
int j=0;
int sz=b.size();
for(int i:a){
while(j<sz&&ask(i,b[j])){
c.push_back(b[j]);
j++;
}
c.push_back(i);
}
while(j<sz){
c.push_back(b[j]);
j++;
}
return c;
}
vector<int> Solve(int n1) {
n=n1;
vector<int> v = dc(0,n);
vector<int> ans(n),t(n);
int cnt=0;
for(int i=0;i<n-1;i++){
cnt+=ask(v[n-1],v[i]);
}
int i=n-1;
for(;cnt<n;cnt++,i--){
t[i]=cnt;
}
int last=n-1;
while(i>=0){
int rec=i;
while(!ask(v[i],v[last])){
i--;
}
last=rec;
cnt=rec;
for(int j=i;j<=rec;j++){
t[j]=cnt;
cnt--;
}
i--;
}
for(int i=0;i<n;i++){
ans[v[i]]=t[i];
}
return ans;
}
/*
6
1 3 5 0 4 2
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Incorrect |
0 ms |
344 KB |
Wrong Answer [5] |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Incorrect |
0 ms |
344 KB |
Wrong Answer [5] |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
53 ms |
2200 KB |
Partially correct |
2 |
Partially correct |
55 ms |
1804 KB |
Partially correct |
3 |
Partially correct |
50 ms |
2160 KB |
Partially correct |
4 |
Partially correct |
63 ms |
2380 KB |
Partially correct |
5 |
Partially correct |
69 ms |
1884 KB |
Partially correct |
6 |
Correct |
41 ms |
1588 KB |
Output is correct |
7 |
Correct |
45 ms |
1600 KB |
Output is correct |
8 |
Partially correct |
54 ms |
1096 KB |
Partially correct |
9 |
Partially correct |
52 ms |
2128 KB |
Partially correct |
10 |
Partially correct |
51 ms |
2404 KB |
Partially correct |
11 |
Partially correct |
48 ms |
1868 KB |
Partially correct |
12 |
Partially correct |
58 ms |
1760 KB |
Partially correct |
13 |
Correct |
42 ms |
2016 KB |
Output is correct |
14 |
Correct |
46 ms |
1920 KB |
Output is correct |
15 |
Correct |
31 ms |
1352 KB |
Output is correct |
16 |
Correct |
30 ms |
1576 KB |
Output is correct |
17 |
Correct |
44 ms |
1872 KB |
Output is correct |
18 |
Correct |
27 ms |
1368 KB |
Output is correct |