이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "doll.h"
#include <bits/stdc++.h>
using namespace std;
int n;
int a[200010];
int sta=0;
int cur=-1;
int seg[800040];
int ord[200010];
int cou=0;
vector<int> ss;
int sw(int k)
{
int ans=0;
for(int i=0;i<sta;i++)
{
if((k>>i)&1) ans+=1<<(sta-1-i);
}
return ans;
}
vector<int> toadd;
void build(int v,int st,int ed)
{
if(ed<(1<<sta)-n)
{
seg[v]=-1;
return;
}
if(st==ed)
{
seg[v]=a[ord[st]];
return;
}
int mid=(st+ed)>>1;
seg[v]=cur;
cur--;
toadd.push_back(v);
build(2*v,st,mid);
build(2*v+1,mid+1,ed);
}
void create_circuit(int M, std::vector<int> A) {
n=A.size()+1;
for(int i=0;i<A.size();i++)
{
a[i]=A[i];
}
a[n-1]=0;
if(n==2)
{
vector<int> c(M+1,0),x,y;
c[0]=A[0];
answer(c,x,y);
return;
}
while((1<<sta)<n) sta++;
for(int i=0;i<(1<<sta);i++) ss.push_back(sw(i));
for(int i=0;i<ss.size();i++)
{
if(ss[i]>=(1<<sta)-n)
{
ord[ss[i]]=cou;cou++;
}
}
build(1,0,(1<<sta)-1);
vector<int> c(M+1,-1),x(-cur-1),y(-cur-1);
for(int i=0;i<toadd.size();i++)
{
x[-1-seg[toadd[i]]]=seg[2*toadd[i]];
y[-1-seg[toadd[i]]]=seg[2*toadd[i]+1];
}
answer(c,x,y);
}
컴파일 시 표준 에러 (stderr) 메시지
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:46:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
46 | for(int i=0;i<A.size();i++)
| ~^~~~~~~~~
doll.cpp:60:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
60 | for(int i=0;i<ss.size();i++)
| ~^~~~~~~~~~
doll.cpp:69:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
69 | for(int i=0;i<toadd.size();i++)
| ~^~~~~~~~~~~~~
# | 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... |