This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "doll.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=(a);i<(b);i++)
#define fore(i,a,b) for(int i=(a);i<=(b);i++)
#define pb push_back
#define F first
#define S second
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
void amin(ll &a, ll b){ a=min(a,b); }
void amax(ll &a, ll b){ a=max(a,b); }
void YES(){cout<<"YES\n";} void NO(){cout<<"NO\n";}
void SD(int t=0){ cout<<"PASSED "<<t<<endl; }
const ll INF = ll(1e18);
const int MOD = 998244353;
const bool DEBUG = 0;
const int MAXN = 200005;
vector<int> c,x,y;
int dfs(const vector<int>& nxt, int l, int r)
{
if(r-l==1)
{
x.pb(-(x.size()+1));
y.pb(nxt[l]);
return -x.size();
}
if(r-l==2)
{
x.pb(nxt[l]);
y.pb(nxt[l+1]);
return -x.size();
}
int mid=1;
while(mid<(r-l+1)/2) mid<<=1;
x.pb(dfs(nxt, l, mid));
y.pb(dfs(nxt, mid, r));
return -x.size();
}
void create_circuit(int m, vector<int> a)
{
int n = a.size();
c.resize(m+1);
vector<int> nxt[m+1];
forn(i,0,n-1){
nxt[a[i]].pb(a[i+1]);
}
nxt[a[n-1]].pb(0);
/*fore(i,1,m){
cout<<"nxt["<<i<<"]=";
for(int x: nxt[i]) cout<<x<<" ";
cout<<'\n';
}*/
c[0]=a[0];
fore(i,1,m){
if(nxt[i].empty()){
c[i]=i;
continue;
}
c[i]=dfs(nxt[i],0,nxt[i].size());
}
answer(c,x,y);
}
# | 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... |