# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1094511 | Math4Life2020 | 자동 인형 (IOI18_doll) | C++17 | 113 ms | 9600 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "doll.h"
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int,int>;
const int INF = 1e9;
int v2(int x) {
return __builtin_ctz(x);
}
int l2(int x) {
return (31-__builtin_clz(x));
}
void print(vector<int> A) {
cout << "printing\n";
for (int x: A) {
cout << x<<" ";
}
cout << "\n";
exit(0);
}
void create_circuit(int M, vector<int> A) {
int N = A.size();
vector<int> C;
C.push_back(A[0]);
for (int i=0;i<M;i++) {
C.push_back(-1);
}
vector<int> X,Y;
int CIND = 0;
int D = l2(2*N-1);
stack<pii> bd;
bd.push({N,D});
while (!bd.empty()) {
pii p0 = bd.top(); bd.pop();
int k = p0.first; int d = p0.second;
if (d<=1) {
if (k==1) {
X.push_back(0);
Y.push_back(-INF);
} else if (k==2) {
X.push_back(-INF);
Y.push_back(-INF);
} else {
cout << "reporting error #1\n";
}
} else {
if (k>(1<<(d-1))) {
Y.push_back(CIND+1);
X.push_back(CIND+(1<<(d-1)));
bd.push({k-(1<<(d-1)),d-1});
bd.push({(1<<(d-1)),d-1});
} else {
X.push_back(0);
Y.push_back(CIND+1);
bd.push({k,d-1});
}
}
CIND++;
}
/*cout << "INIT: print C:\n";
for (int c: C) {
cout << c <<" ";
}
cout << "\nprint X: \n";
for (int x: X) {
cout << x << " ";
}
cout << "\nprint Y: \n";
for (int y: Y) {
cout << y << " ";
}*/
bool st[X.size()];
bool stn[X.size()];
for (int t=0;t<N;t++) {
st[t]=0;
stn[t]=0;
}
for (int t=0;t<N;t++) {
int cx = 0;
int locp = -1;
bool stp = 0;
while (cx >= 0) {
if (st[cx]==0) {
st[cx]=1;
locp = cx;
stp = 0;
cx = X[cx];
} else {
st[cx]=0;
locp = cx;
stp = 1;
cx = Y[cx];
}
}
if (cx != -INF) {
cout << "invalid value\n";
} else {
int nval;
if (t<(N-1)) {
nval = A[t+1];
} else {
nval = 0;
}
nval++;
if (stp==0) {
X[locp]=-INF+nval;
} else {
Y[locp]=-INF+nval;
}
}
}
for (int d=0;d<X.size();d++) {
if (X[d]>=0) {
X[d]=-1-X[d];
} else {
X[d]=X[d]-(-INF+1);
}
if (Y[d]>=0) {
Y[d]=-1-Y[d];
} else {
Y[d]=Y[d]-(-INF+1);
}
}
/*cout << "print C:\n";
for (int c: C) {
cout << c <<" ";
}
cout << "\nprint X: \n";
for (int x: X) {
cout << x << " ";
}
cout << "\nprint Y: \n";
for (int y: Y) {
cout << y << " ";
}
cout << "\n";*/
//simulate:
int cpos = 0;
vector<int> ans;
int time = 0;
do {
time++;
if (cpos >= 0) {
if (cpos>0) {
ans.push_back(cpos);
}
cpos = C[cpos];
} else {
if (st[-1-cpos]==0) {
st[-1-cpos]=1;
cpos = X[-1-cpos];
} else {
st[-1-cpos]=0;
cpos = Y[-1-cpos];
}
}
} while (cpos != 0);
if (ans.size()!=N) {
cout << "wrong size!\n";
print(A);
} else {
for (int i=0;i<N;i++) {
if (ans[i]!=A[i]) {
cout << "mismatch!\n";
print(A);
}
}
}
answer(C,X,Y);
}
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |