#include<bits/stdc++.h>
#include "doll.h"
#define MAXN 800007
using namespace std;
int m,power,n,num;
int a[MAXN],s,ind[MAXN],temp[MAXN];
int lt[MAXN],rt[MAXN];
vector<int> from,to,c;
int rev(int x){
int res=0;
for(int i=1;i<power;i*=2){
res*=2; res+=x%2;
x/=2;
}
return res;
}
void build(int v,int l,int r){
if(l+1==r){
if(l<n)lt[v]=a[l];
else lt[v]=-1;
if(r<n)rt[v]=a[r];
else if(r==power-1)rt[v]=0;
else rt[v]=-1;
}else{
int tt=(l+r)/2;
if(l>=n and tt<power-1){
lt[v]=-1;
}else{
num++; lt[v]=-num;
build(num,l,tt);
}
if(tt+1>=n and r<power-1){
rt[v]=-1;
}else{
num++; rt[v]=-num;
build(num,tt+1,r);
}
}
}
bool cmp(int x,int y){
return rev(x)<rev(y);
}
void create_circuit(int M, vector<int> A){
m=M; n=int(A.size());
for(int i=0;i<n;i++){
a[i]=A[i]; ind[i]=i;
}
power=1; num=1;
while(power<n+1)power*=2;
sort(ind,ind+n,cmp);
for(int i=0;i<n;i++)temp[ind[i]]=a[i];
for(int i=0;i<n;i++)a[i]=temp[i];
build(1,0,power-1);
for(int i=0;i<=m;i++)c.push_back(-1);
for(int i=1;i<=num;i++){
from.push_back(lt[i]);
to.push_back(rt[i]);
}
answer(c,from,to);
}
/*
int main(){
create_circuit(4, {1, 2, 1,3,2,4,3,1,2});
}
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
316 KB |
Output is correct |
7 |
Correct |
1 ms |
308 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
1 ms |
340 KB |
Output is partially correct |
2 |
Correct |
169 ms |
7608 KB |
Output is correct |
3 |
Partially correct |
150 ms |
7600 KB |
Output is partially correct |
4 |
Partially correct |
215 ms |
10736 KB |
Output is partially correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
1 ms |
340 KB |
Output is partially correct |
2 |
Correct |
169 ms |
7608 KB |
Output is correct |
3 |
Partially correct |
150 ms |
7600 KB |
Output is partially correct |
4 |
Partially correct |
215 ms |
10736 KB |
Output is partially correct |
5 |
Partially correct |
219 ms |
11356 KB |
Output is partially correct |
6 |
Partially correct |
208 ms |
11144 KB |
Output is partially correct |
7 |
Partially correct |
215 ms |
11184 KB |
Output is partially correct |
8 |
Partially correct |
207 ms |
10896 KB |
Output is partially correct |
9 |
Partially correct |
160 ms |
7596 KB |
Output is partially correct |
10 |
Partially correct |
237 ms |
10932 KB |
Output is partially correct |
11 |
Partially correct |
207 ms |
10640 KB |
Output is partially correct |
12 |
Partially correct |
148 ms |
7904 KB |
Output is partially correct |
13 |
Correct |
175 ms |
8328 KB |
Output is correct |
14 |
Partially correct |
152 ms |
8372 KB |
Output is partially correct |
15 |
Partially correct |
164 ms |
8496 KB |
Output is partially correct |
16 |
Partially correct |
3 ms |
596 KB |
Output is partially correct |
17 |
Correct |
172 ms |
7156 KB |
Output is correct |
18 |
Correct |
170 ms |
7900 KB |
Output is correct |
19 |
Partially correct |
148 ms |
7900 KB |
Output is partially correct |
20 |
Partially correct |
209 ms |
10692 KB |
Output is partially correct |
21 |
Partially correct |
212 ms |
10640 KB |
Output is partially correct |
22 |
Partially correct |
227 ms |
10600 KB |
Output is partially correct |