이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "doll.h"
using namespace std;
const int c=270002;
int n, po=1, db, sw, el[c], pos, cnt;
vector<int> s, x, y, sz;
bool v[c], akt[c];
void dfs(int a, int x) {
if (a>=po) return;
if (db-n>=x) {db-=x, sw-=x-1, v[a]=1; return;}
dfs(2*a, x/2), dfs(2*a+1, x/2);
}
void dfs2(int a) {
if (a>=po) return;
if (v[a]) {el[a]=1; return;}
cnt++, el[a]=cnt;
if (a<po/2) {
dfs2(2*a), x[el[a]-1]=-el[2*a];
dfs2(2*a+1), y[el[a]-1]=-el[2*a+1];
}
}
void dfs3(int a) {
if (v[a]) return;
if (a<po/2) {
dfs3(2*a+akt[a]);
akt[a]=!akt[a];
} else {
//cout << a << " " << el[a]-1 << " " << cnt << " " << sz[cnt] << endl;
if (!akt[a]) x[el[a]-1]=sz[cnt];
else y[el[a]-1]=sz[cnt];
cnt++, akt[a]=!akt[a];
}
}
void create_circuit(int m, vector<int> p) {
for (int i=0; i<m+1; i++) s.push_back(-1);
sz=p, n=sz.size();
if (n%2==0) sz.push_back(-1);
sz.push_back(0), n=sz.size();
while(po<n) po*=2; db=po, sw=po-1;
dfs(1, po);
x.resize(sw), y.resize(sw);
dfs2(1), cnt=0;
for (int i=0; i<po; i++) dfs3(1);
/*for (int i=0; i<sw; i++) {
cout << x[i] << " " << y[i] << "\n";
}*/
answer(s, x, y);
}
컴파일 시 표준 에러 (stderr) 메시지
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:39:5: warning: this 'while' clause does not guard... [-Wmisleading-indentation]
39 | while(po<n) po*=2; db=po, sw=po-1;
| ^~~~~
doll.cpp:39:24: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'while'
39 | while(po<n) po*=2; db=po, sw=po-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... |