제출 #1207804

#제출 시각아이디문제언어결과실행 시간메모리
1207804Adeeb_obedo자동 인형 (IOI18_doll)C++20
53 / 100
117 ms51264 KiB
#include<bits/stdc++.h> #define ll long long #define ld double #define _1 first #define _2 second #define yes cout<<"Yes\n" #define nah cout<<"No\n" #define FFF ios_base::sync_with_stdio(0);cin.tie(0); #define ipr pair<int,int> #define ret return #define intt int32_t #define mid ((l+r)/2) #define pb push_back #define lll __int128 using namespace std; ll tst, ts; intt mo = 1e9+7, dx[] = {0, 1, 0, -1}, dy[] = {-1, 0, 1, 0}; ll mul( ll x, ll y ) { ret ( ( x % mo ) * ( y % mo ) ) % mo; ret x*y; } ll pwo( ll x, ll y ) { ll res = 1; for( ll i = 63; i + 1; i-- ) res = mul( res, res * ( ( 1ll << i )&y ? x : 1 ) ); ret res; } ll dvii( ll x, ll y ) { ret mul( x, pwo( y, mo - 2 ) ); } ll oo( char x ) { ret ( ll )x - '0'; } ll lgg( ll x, ll y ) { ll u = 0; while( x ) { u++; x /= y; } ret u; } ll mun( ll x, ll y ) { while( x < y )x += mo; ret ( x - y ) % mo; } ll add( ll x, ll y ) { ret x + y - ( mo * ( x + y >= mo ) ); ret x + y; } ll lcm( ll x, ll y ) { ret ( x * y ) / __gcd( x, y ); } #include "doll.h" #define endl '\n'; const ll M =1007, N = 2e5+ 7, N2 = 5e3 + 7, inf = 1e9+7 ; ll n,m,t,r,b[N*20]; vector<int>g[N],c; vector<int>e[2]; void dfs(ll i){ if(g[r].size()==0) ret; i--; if(e[b[i]][i]!=inf){ b[i]=!b[i]; dfs(-e[!b[i]][i]); ret; } e[b[i]][i]=g[r].back(); g[r].pop_back(); b[i]=!b[i]; dfs(-c[r]); } void create_circuit(intt Mm, vector<intt>a){ m=Mm,n=a.size(),t=1; c.resize(m+1); e[0].resize(N*20+7); e[1].resize(N*20+7); for(auto&i:e[0])i=inf; for(auto&i:e[1])i=inf; a.pb(0); for(ll i=0;i<n;i++) g[a[i]].pb(a[i+1]); c[0]=a[0]; for(ll i=1;i<=m;i++){ if(g[i].size()==0){ c[i]=0; continue; } if(g[i].size()==1){ c[i]=g[i][0]; continue; } reverse(g[i].begin(),g[i].end()); c[i]=-t;r=i; ll o=2,p=0; vector<ll>v[2]; v[0].pb(t); t++; while(o<g[i].size()){ v[!p].clear(); for(auto i:v[p]){ e[0][i-1]=-t; v[!p].pb(t); t++; e[1][i-1]=-t; v[!p].pb(t); t++; } o*=2,p=!p; } while(g[i].size()<o) g[i].pb(c[r]); dfs(-c[r]); for(ll j=0;j<2;j++) for(auto u:v[p]) if(e[j][u-1]==inf) e[j][u-1]=c[r]; } for(ll j=0;j<2;j++) while(e[j].size()>=t) e[j].pop_back();/* for(int i=0;i<=m;i++) cout<<c[i]<<" "; cout<<endl; for(auto i:e[0]) cout<<i<<" "; cout<<endl; for(auto i:e[1]) cout<<i<<" "; cout<<endl;*/ // cout<<e[0].size()<<endl; answer(c,e[0],e[1]); } /* void solve(){ } intt main() { FFF //freopen("fcolor.in", "r", stdin); //freopen("fcolor.out", "w", stdout); tst = 1; cin >> tst; for ( ts = 1; ts <= tst; ts++ ){ solve(); } } */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...