이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "doll.h"
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3e5 + 10;
int cnt , ans[MAXN];
vector<int> vec , C , X , Y;
int reverse(int x){
int ans = 0;
for(int i = 0 ; i < cnt ; i++){
ans = ans * 2 + ((x & (1 << i)) != 0);
}
return ans;
}
int solve(int ql , int qr , int l , int r){
if(r <= ql || qr <= l) return -1;
if(r - l == 1) return ans[l];
int id = X.size();
X.push_back(-1); Y.push_back(-1);
int mid = l + r >> 1;
int a = solve(ql , qr , l , mid);
int b = solve(ql , qr , mid , r);
X[id] = a; Y[id] = b;
return -(id + 1);
}
void create_circuit(int M, vector<int> A) {
fill(ans , ans + MAXN , -1);
int k = 1 , n = A.size();
while(k < n) k *= 2 , cnt++;
for(int i = k - n ; i < k ; i++){
vec.push_back(reverse(i));
}
sort(vec.begin() , vec.end());
C.push_back(A[0]);
for(int i = 0 ; i < n ; i++){
ans[reverse(vec[i])] = (i + 1 < n ? A[i + 1] : 0);
}
for(int i = 0 ; i < M ; i++) C.push_back(-1);
/* for(int i = 0 ; i < k ; i++){
cout << ans[i] << endl;
}
*/ solve(k - n , k , 0 , k);
/* 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);
}
컴파일 시 표준 에러 (stderr) 메시지
doll.cpp: In function 'int solve(int, int, int, int)':
doll.cpp:23:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
23 | int mid = l + r >> 1;
| ~~^~~
# | 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... |