疑似 HACK?

P5018 [NOIP2018 普及组] 对称二叉树

@[bs_commander](/user/1000166) 我说的是卡掉暴力检测的代码了?
by _H17_ @ 2024-09-16 22:32:23


那就不知道了
by bs_commander @ 2024-09-16 22:33:01


@[_H17_](/user/743014) 有道理,但好像我是暴力却 $1 s$ 跑完
by dongzirui0817 @ 2024-09-16 22:39:06


@[_H17_](/user/743014) 好像真能卡掉,我洛谷上这组数据原地 MLE
by dongzirui0817 @ 2024-09-16 22:42:43


附个记录:[this](https://www.luogu.com.cn/record/177270847)
by dongzirui0817 @ 2024-09-16 22:44:18


@[_H17_](/user/743014) 当我没说,我忘关 `freopen` 了,暴力照样过
by dongzirui0817 @ 2024-09-16 22:46:58


@[_H17_](/user/743014) https://www.luogu.com.cn/record/177271353 ```cpp #include<bits/stdc++.h> using namespace std; int n,ansm=0; struct node{ int l,r,w; }tree[1000001]; bool check(long long z,int y){ if(z==-1&&y==-1) return 1; else if(y==-1||z==-1||tree[z].w!=tree[y].w) return false; return check(tree[z].l,tree[y].r)&&check(tree[z].r,tree[y].l); } int tr(int k){ if(k==-1) return 0; return tr(tree[k].l)+tr(tree[k].r)+1; } int main(){ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin>>n; for(int i=1;i<=n;i++) cin>>tree[i].w; for(int i=1;i<=n;i++) cin>>tree[i].l>>tree[i].r; for(int i=1;i<=n;i++) if(check(i,i)) ansm=max(ansm,tr(i)); cout<<ansm; return 0; } ``` 这算暴力检测吗
by shoot_down @ 2024-09-16 22:48:20


@[dongzirui0817](/user/905593) 如果是完全二叉树呢?卡到 $10^6$ 个点 或者对称的 $10^6$ 个点?
by _H17_ @ 2024-09-16 22:56:25


@[_kenma_](/user/750163) 来来来,质疑我暴力的大佬快来卡,我是不会卡了
by _H17_ @ 2024-09-16 22:59:38


|