(为防止抄袭,仅展示部分代码)
代码1:
#define int __int128
void add(int from,int to)
{
static int sum=0;
e[++sum].to=to;
e[sum].next=head[from];
head[from]=sum;
}
void dfs(int now,int fath)
{
...
}
inline int work_high(int x,int l,int r)
{
...
}
int num[100010],val[100010];
bool vis[100010];
bool check(int x,int n)
{
...
}
...
代码2:
void add(int from,int to)
{
static int sum=0;
e[++sum].to=to;
e[sum].next=head[from];
head[from]=sum;
}
void dfs(int now,int fath)
{
...
}
__int128 work_high(int x,__int128 l,__int128 r)
{
...
}
int num[100010],val[100010];
bool vis[100010];
bool check(int x,int n)
{
...
return 1;
}
...
在代码1中:使用了#define int __int128导致一些只需要 int 便能解决的数据花了 4 倍的时间,导致TLE
为避免问题,仅在求高度等会爆 long long 函数中使用 __int128 可以减小代码常数,防止 TLE