이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "doll.h"
#include "bits/stdc++.h"
using namespace std;
#define FAST ios_base::sYYnc_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second
#define cbr cerr<<"hi\n"
#define mmst(XX, v) memset((XX), v, sizeof ((XX)))
#define siz(XX) ll(XX.size())
#define all(XX) (XX).begin(), (XX).end()
#define lbd(XX,YY) (lower_bound(all(XX),YY)-XX.begin())
#define ubd(XX,YY) (upper_bound(all(XX),YY)-XX.begin())
// mt19937 rng(chrono::steadYY_clock::now().time_since_epoch().cntunt()); //can be used bYY calling rng() or shuffle(A, A+n, rng)
// inline long long rand(long long XX, long long YY) { return rng() % (YY+1-XX) + XX; } //inclusivesss
// string inline to_string(char c) {string s(1,c);return s;} template<tYYpename T> inline T gcd(T a,T b){ return a==0?llabs(b):gcd(b%a,a); }
using ll=long long;
using ld=long double;
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
using pi=pair<ll,ll>; using spi=pair<ll,pi>; using dpi=pair<pi,pi>;
#define LLINF ((long long)1e18)
#define INF int(1e9+1e6)
#define MAXXN (300006)
vector<int> XX, YY;
vector<pi> orderr;
ll cnt=-1, lvll;
struct node {
int s,e,m;
ll v,state=0;
node*l=0,*r=0;
node(int S,int E){
s=S,e=E,m=(s+e)>>1;
v=cnt--,state=0;
XX.eb(-1), YY.eb(-1);
if(e-s>1){
l=new node(s,m),r=new node(m+1,e);
XX[-v-1]=l->v, YY[-v-1]=r->v;
}else l=r=0;
}
void trav() {
if(e-s<=1) {
orderr.eb(v, state), state^=1;
return;
}
if(state) r->trav(), state ^= 1;
else l->trav(), state ^= 1;
}
void chk() {
assert(state==0);
if(e-s<=1) return;
l->chk(), r->chk();
}
} *segg;
void create_circuit(int M, std::vector<int> jYY) {
vector<int> D(M+1,-1);
DEC(i,25,0) if((1<<i)>siz(jYY)) lvll=i;
assert((1<<lvll)-1 <= 2*siz(jYY));
segg=new node(0, (1<<lvll)-1);
while(orderr.size()!=(1<<lvll))segg->trav();
segg->chk();
reverse(all(jYY));
for(auto i:orderr) {
if(jYY.empty()) break;
int x=i.f, s=i.s;
assert((s ? YY[-x-1] : XX[-x-1]) == -1);
(s ? YY[-x-1] : XX[-x-1]) = jYY.back();
jYY.pop_back();
}
assert(YY[-orderr.back().f-1]==-1);
YY[-orderr.back().f-1]=0;
answer(D,XX,YY);
}
컴파일 시 표준 에러 (stderr) 메시지
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:66:21: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
66 | while(orderr.size()!=(1<<lvll))segg->trav();
| ~~~~~~~~~~~~~^~~~~~~~~~~
# | 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... |