이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "doll.h"
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
#define SZ(x) int((x).size())
#define X first
#define Y second
#define sep ' '
int curInd = 1;
vector<pii> res;
int solve(vector<int> vec , int n){
int flag = 1;
for(int i = 0 ; i < SZ(vec) ; i++){
if(vec[i] != vec[0]){
flag = 0;
}
}
if(flag && (SZ(vec) == n || SZ(vec) == 0)){
return (SZ(vec) == 0 ? -1 : vec[0]);
}
int root = curInd++ , ptr = 0 , ind = SZ(res);
res.push_back({-1 , -1});
vector<int> left , right;
int szleft = SZ(vec) - n / 2;
for(int i = 0 ; i < min(SZ(vec) , n - SZ(vec)) ; i++){
right.push_back(vec[ptr++]);
}
while(ptr < SZ(vec)){
left.push_back(vec[ptr++]);
right.push_back(vec[ptr++]);
}
int lc = solve(left , n / 2);
int rc = solve(right , n / 2);
res[ind] = {lc , rc};
return -root;
}
void create_circuit(int M, vector<int> A) {
A.push_back(0);
int n = 1;
while(n < SZ(A)) n *= 2;
int root = solve(A , n);
vector<int> C , x , y;
for(int i = 0 ; i <= M ; i++){
C.push_back(-1);
//cout << i << sep << -1 << endl;
}
for(int i = 0 ; i < SZ(res) ; i++){
x.push_back(res[i].X);
y.push_back(res[i].Y);
//cout << -(i + 1) << sep << res[i].X << sep << res[i].Y << endl;
}
answer(C , x , y);
}
컴파일 시 표준 에러 (stderr) 메시지
doll.cpp: In function 'int solve(std::vector<int>, int)':
doll.cpp:28:9: warning: unused variable 'szleft' [-Wunused-variable]
28 | int szleft = SZ(vec) - n / 2;
| ^~~~~~
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:46:9: warning: unused variable 'root' [-Wunused-variable]
46 | int root = solve(A , n);
| ^~~~
# | 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... |