이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "doll.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> adj[100001], tree[100001], num[100001];
void create_circuit(int M, vector<int> A)
{
int N=A.size()+2, c=0;
vector<int> C(M+1), X, Y, temp;
A.push_back(0);
reverse(A.begin(),A.end());
A.push_back(0);
reverse(A.begin(),A.end());
for(int i=1;i<N;i++) adj[A[i-1]].push_back(A[i]);
for(int i=0;i<=M;i++) if(adj[i].size()) {
int sz=1, k, osz=adj[i].size();
for(;sz<adj[i].size();sz<<=1);
tree[i].resize(2*sz);
for(int j=0;j<sz;j++) tree[i][sz+j]=0x7fffffff;
temp.clear();
for(int j=0;j<osz;j++) {
k=0;
for(int b=1;b<sz;b<<=1) {
k<<=1;
if((sz-1-j)&b) k|=1;
}
temp.push_back(k);
}
sort(temp.begin(),temp.end());
for(int j=0;j<osz;j++) {
k=0;
for(int b=1;b<sz;b<<=1) {
k<<=1;
if(temp[j]&b) k|=1;
}
tree[i][sz+k]=adj[i][j];
}
for(int j=sz;--j;) if(tree[i][2*j]==tree[i][2*j+1]) {
tree[i][j]=tree[i][2*j];
tree[i][2*j]=tree[i][2*j+1]=0x7fffffff;
}
for(int j=1;j<sz;j++) if(tree[i][j]!=0x7fffffff) {
tree[i][j]=--c;
X.push_back(0);
Y.push_back(0);
}
for(int j=1;j<sz;j++) if(tree[i][j]!=0x7fffffff) {
X[-tree[i][j]-1]=tree[i][2*j]==0x7fffffff ? tree[i][1]:tree[i][2*j];
Y[-tree[i][j]-1]=tree[i][2*j+1]==0x7fffffff ? tree[i][1]:tree[i][2*j+1];
}
adj[i].clear();
C[i]=tree[i][1];
}
answer(C,X,Y);
}
컴파일 시 표준 에러 (stderr) 메시지
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:19:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
19 | for(;sz<adj[i].size();sz<<=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... |