이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "doll.h"
#include<bits/stdc++.h>
using namespace std;
vector<int> X, Y, A, FLG;
int h, v, n;
const int UNDEF = 7e6+5;
int cn = 0;
int cnt = 0;
void fin(int x, int p, int am, int val, bool ok){
//cout << "x: " << x << " p: " << p << " am: " << am << " val: " << val << " ok: " << ok << endl;
if(!am){
// cout << "Hey" << endl;
cnt--;
if(ok){
Y[p] = -1;
}
else X[p] = -1;
fin(0,0,n,v,0);
return;
}
if(!val){
// cout << "HeY" << endl;
cnt--;
if(ok){
Y[p] = A[cn++];
}
else X[p] = A[cn++];
if(cn == n)return;
fin(0,0,n,v,0);
return;
}
if((int)X.size() <= x){
X.push_back(UNDEF);
Y.push_back(UNDEF);
FLG.push_back(0);
X.back() = -(++cnt)-1;
fin(cnt,x,max(0,am-val),val>>1,0);
return;
}
FLG[x]^=1;
if(FLG[x]){
if(Y[x] == UNDEF){
Y[x] = -(++cnt)-1;
fin(cnt,x,min(am,val),val>>1,1);
}
else{
fin(-Y[x]-1,x,min(am,val),val>>1,1);
}
return;
}
else{
fin(-X[x]-1,x,max(0,am-val),val>>1,0);
}
}
void create_circuit(int m, vector<int> _A) {
_A.push_back(0);
n = _A.size();
A = _A;
vector<int> C(m+1,-1);
h = ceil(log2(n));
v = (1<<(h-1));
fin(0,0,n,v,0);
//for(int i : C)cout << i << ' ';cout << endl;
//for(int i : X)cout << i << ' ';cout << endl;
//for(int i : Y)cout << i << ' ';cout << endl;
answer(C, X, Y);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |