이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#include "doll.h"
#define F first
#define S second
#define PB push_back
#define sz(s) (int(s.size()))
#define bit(n, k) (((n)>>(k)) & 1)
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
const int maxn = 3e5 + 10, mod = 1e9 + 7, inf = 1e9 + 10;
vector<pii> vec;
int solve(vector<int> v){
if(sz(v) == 1){
return v[0];
}
vector<int> v1, v2;
for(int i = 0; i < sz(v); i++){
if(i & 1)
v2.PB(v[i]);
else
v1.PB(v[i]);
}
if(sz(v1) == sz(v2)){
vec.PB({solve(v1), solve(v2)});
return -sz(vec);
}
else{
swap(v1[sz(v1)-1], v2[sz(v2)-1]);
vec.PB({-1, -1});
int root = sz(vec);
int A = solve(v1);
int &x = v2[sz(v2)-1];
vec.PB({-root, x});
x = -sz(vec);
int B = solve(v2);
vec[root-1] = {A, B};
return root;
}
assert(0);
}
void create_circuit(int M, vector<int> A) {
A.PB(0);
int st = solve(A);
vector<int> C, X, Y;
for(int i = 0; i <= M; i++){
C.PB(st);
}
for(pii p : vec){
X.PB(p.F);
Y.PB(p.S);
}
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... |