#include "dungeon2.h"
#pragma GCC optimize("Ofast,unroll-loops")
#include<bits/stdc++.h>
//#define int long long
#define ll long long
#define down cout<<'\n';
#define debug cout<<" cucuucucuuu",down
#define modwwe int t;cin>>t; while(t--)
#define bit(i,j) (i>>j&1)
#define sobit(a) __builtin_popcountll(a)
#define task2 "ftree"
#define task "test"
#define fin(x) freopen(x".inp","r",stdin)
#define fou(x) freopen(x".out","w",stdout)
#define pb push_back
#define mask(k) (1<<k)
#define checktime cerr << (double)clock() / CLOCKS_PER_SEC * 1000 << " ms";
using namespace std;
#define getchar_unlocked getchar
mt19937 rd(chrono::steady_clock::now().time_since_epoch().count());
int rand(int l,int r)
{
return uniform_int_distribution<int>(l,r)(rd);
}
void phongbeo();
const int inf = 1e9;
const ll mod2 = 1e9+7;
const ll base=67;
int n, m, s1, s2, s4, s3, sf, k, s5, s6, mx, s7, s8, s9, mx2, res, dem2 = 0, dem = 0, s33, dem3, dem4, mid, l2, r2, center;
int i, s10, s12,k1,k2,k3,s11,lim,w,l,r,dem5,dem6,dem7,dem9;
int kk;
int t;
int el = 19;/*
main()
{
if(fopen(task2".inp","r"))
{
fin(task2);
fou(task2);
}
if(fopen(task".inp","r"))
{
fin(task);
fou(task);
}
ios_base::sync_with_stdio(0);
cout.tie(0);
cin.tie(0);
/// cin>>s1;
//int t;cin>>t; while(t--)
phongbeo();
checktime
}*/
int dist[201][201];
int dp[201][201];
int cnt[201];
int f[201][201];
int par[201];
int g[201];
int col[201];
bool go[201][201];
struct ib
{
int a,b;
};
vector<ib> v[201];
vector<int> son[201];/*
int LastRoad()
{
int s=-1;
dem=0;
for(auto x:son[s2])
{
dem++;
if(s3==x)
{
s=dem;
break;
}
}
return s;
}
int NumberOfRoads()
{
return son[s2].size();
}
int color()
{
return col[s2];
}
void Move(int x,int y)
{
s3=s2;
s2=son[s2][x-1];
col[s3]=y;
}*/
void pre_dfs(int x)
{
par[x]=LastRoad();
int xx=NumberOfRoads();
for(int i=1; i<=xx; i++)
{
Move(i,2);
if(Color()==2)
{
go[x][i]=1;
Move(LastRoad(),2);
}
else
{
lim++;
v[x].pb({lim,i});
pre_dfs(lim);
}
}
if(x!=1)
Move(par[x],2);
}
void dfs(int x)
{
int xx=NumberOfRoads();
for(auto [u,v]:v[x])
{
Move(v,(x/s9)%3+1);
dfs(u);
}
for(int i=1; i<=xx; i++)
if(go[x][i])
{
Move(i,1);
int cc=Color();
f[x][i]=f[x][i]*3+cc-1;
if(s9==1)dp[f[x][i]][x]=dp[x][f[x][i]]=1;
Move(LastRoad(),cc);
}
if(x!=1)
Move(par[x],1);
}
void Inspect(int x)
{
for(int i=1; i<=200; i++)
col[i]=1;
s9=81;
for(int i=1; i<=200; i++)
for(int j=1; j<=200; j++)
dp[i][j]=inf;
s2=1;
s3=0;
lim=1;
pre_dfs(1);
for(int i=0; i<5; i++)
{
dfs(1);
s9/=3;
}
for(int k=1; k<=lim; k++)
for(int i=1; i<=lim; i++)
for(int j=1; j<=lim; j++)
dp[i][j]=min(dp[i][k]+dp[k][j],dp[i][j]);
for(int i=1; i<=n; i++)
for(int j=i+1; j<=n; j++)
g[dp[i][j]]++;
for(int i=1; i<=x; i++)
Answer(i,g[i]);
}/*
void phongbeo()
{
cin>>n>>m>>r;
for(int i=1; i<=n; i++)
for(int j=1; j<=n; j++)
dist[i][j]=inf;
for(int i=1; i<=n; i++)
{
cin>>k;
while(k--)
{
cin>>s2;
son[i].pb(s2);
dist[i][s2]=dist[s2][i]=1;
}
}
for(int k=1; k<=n; k++)
for(int i=1; i<=n; i++)
for(int j=1; j<=n; j++)
dist[i][j]=min(dist[i][k]+dist[k][j],dist[i][j]);
for(int i=1; i<=n; i++)
for(int j=i+1; j<=n; j++)
cnt[dist[i][j]]++;
for(int i=1; i<=r; i++)
cout<<cnt[i],down
Inspect(r);
}
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |