이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "doll.h"
#include <bits/stdc++.h>
using namespace std;
const int MAXN = (int)2e6 + 5;
int cur = -1;
vector<int> X, Y, C;
int do_it(vector<int> & sm){
int ad = cur--;
int nxPw = sm.size();
while(nxPw == 1 || __builtin_popcount(nxPw) != 1)
nxPw++;
int kal = nxPw - sm.size();
vector<int> nw(nxPw, 313131313);
if(ad == -1){
vector<int> pws;
int mxP;
for(int j = 20; j >= 0; j--){
if((1<<j) & nxPw) mxP = j;
if((1<<j) & kal){
pws.push_back(j);
}
}
int kt = 0;
for(int j: pws){
int cur = (1<<(mxP - j));
for(int i = kt; i < nw.size(); i += cur) nw[i] = -1;
kt++;
kt *= 2;
}
int curB = 0;
for(int l: sm){
while(nw[curB] != 313131313)
curB++;
nw[curB] = l;
}
}else{
for(int i = 0; i < nw.size(); i++)
nw[i] = sm[i];
}
int deg = 0;
for(int i = 1; i < nw.size(); i++){
deg += (nw[i] != nw[i - 1]);
}
if(!deg){
cur++;
return nw[0];
}
if(nw.size() == 2){
X[-ad - 1] = nw[0];
Y[-ad - 1] = nw[1];
return ad;
}
vector<int> ot1, ot2;
for(int i = 0; i < nw.size(); i+=2)
ot1.push_back(nw[i]);
for(int i = 1; i < nw.size(); i+=2)
ot2.push_back(nw[i]);
int a = do_it(ot1), b = do_it(ot2);
X[-ad - 1] = a;
Y[-ad - 1] = b;
return ad;
}
void create_circuit(int M, vector<int> A){
A.push_back(0);
int N = A.size();
X.resize(MAXN, 0);
Y.resize(MAXN, 0);
C.resize(M + 1, 0);
C[0] = do_it(A);
for(int i = 1; i <= M; i++) C[i] = C[0];
X.resize(-cur - 1);
Y.resize(-cur - 1);
/*for(int i = 0; i < X.size(); i++){
cerr<<X[i]<<" "<<Y[i]<<endl;
}*/
answer(C, X, Y);
}
컴파일 시 표준 에러 (stderr) 메시지
doll.cpp: In function 'int do_it(std::vector<int>&)':
doll.cpp:28:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
28 | for(int i = kt; i < nw.size(); i += cur) nw[i] = -1;
| ~~^~~~~~~~~~~
doll.cpp:39:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
39 | for(int i = 0; i < nw.size(); i++)
| ~~^~~~~~~~~~~
doll.cpp:48:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
48 | for(int i = 1; i < nw.size(); i++){
| ~~^~~~~~~~~~~
doll.cpp:61:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
61 | for(int i = 0; i < nw.size(); i+=2)
| ~~^~~~~~~~~~~
doll.cpp:63:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
63 | for(int i = 1; i < nw.size(); i+=2)
| ~~^~~~~~~~~~~
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:74:9: warning: unused variable 'N' [-Wunused-variable]
74 | int N = A.size();
| ^
doll.cpp: In function 'int do_it(std::vector<int>&)':
doll.cpp:27:32: warning: 'mxP' may be used uninitialized in this function [-Wmaybe-uninitialized]
27 | int cur = (1<<(mxP - j));
| ~~~~~^~~~
# | 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... |