This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "doll.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long double ld;
typedef vector<vector<ll>> vll;
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define ROF(i, a, b) for(int i = a; i >= b; i--)
#define pb push_back
#define ms memset
#define fi first
#define se second
const int mxN = 1e6+1;
int cur = 1; vi X(mxN),Y(mxN),C;
void build(int i, vi nxt){
if (nxt.size()==2){
X[i-1] = nxt[0];
Y[i-1] = nxt[1];
return;
}
int len = nxt.size();
if (len % 2 == 0){
X[i-1] = -cur; cur++;
vi Nxt;
for (int j = 0; j < len; j+=2) Nxt.pb(nxt[j]);
build(cur-1,Nxt); Nxt.clear();
for (int j = 1; j < len; j+=2) Nxt.pb(nxt[j]);
Y[i-1] = -cur; cur++;
build(cur-1,Nxt);
}else{
X[i-1] = -cur; cur++;
vi Nxt;
for (int j = 0; j < len-1; j+=2) Nxt.pb(nxt[j]);
Nxt.pb(-i);
build(cur-1,Nxt); Nxt.clear();
for (int j = 1; j < len; j+=2) Nxt.pb(nxt[j]);
Y[i-1] = -cur; cur++;
Nxt.pb(nxt[len-1]);
build(cur-1,Nxt);
}
}
void create_circuit(int M, vi A) {
int N = A.size();
C.resize(M+1);
C[0] = A[0];
vi nxt[M+1];
FOR(i,0,N-1){
nxt[A[i]].pb(A[i+1]);
}
nxt[A[N-1]].pb(0);
FOR(i,1,M+1){
if (nxt[i].empty()) continue;
if (nxt[i].size()==1){
C[i] = nxt[i][0]; continue;
}
C[i] = -cur; cur++;
build(cur-1,nxt[i]);
}
vi x(cur-1), y(cur-1);
FOR(i,0,cur-1){
x[i]=X[i]; y[i]=Y[i];
}
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... |