이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "doll.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define db long double
#define ii pair<int,int>
#define vi vector<int>
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define FN(i, n) for (int i = 0; i < (int)(n); ++i)
#define FEN(i,n) for (int i = 1;i <= (int)(n); ++i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(i,a,b) for(int i=b-1;i>=a;i--)
#define SET(A, val) memset(A, val, sizeof(A))
typedef tree<int ,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set ;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
const int N=200005;
vi v[N],X,Y;
int cnt=0;
int getind(vi &curr)
{
assert(!curr.empty());
int mx=*max_element(all(curr));
int mn=*min_element(all(curr));
if(mx==mn)
return mx;
vi tmp1,tmp2;
rep(i,0,sz(curr))
{
if(i%2==0) tmp1.pb(curr[i]);
else tmp2.pb(curr[i]);
}
//make a switch
int ans=++cnt;
X.pb(0); Y.pb(0);
int x=getind(tmp1);
X[ans-1]=x;
x=getind(tmp2);
Y[ans-1]=x;
return -ans;
}
void create_circuit(int m,vi A)
{
int n=sz(A);
vi C(m+1);
rep(i,0,n-1)
v[A[i]].pb(A[i+1]);
v[A[n-1]].pb(0);
C[0]=A[0];
rep(i,1,m+1)
{
if(v[i].empty())
{
C[i]=0;
continue;
}
C[i]=getind(v[i]);
}
answer(C,X,Y);
int x=n+(int)log2(n);
assert(cnt<=x);
}
# | 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... |