版本比较
P14121 题解
正文
增加 4 行删除 4 行
6 行未改动789101111121314153 行未改动19202122232324252626272829308 行未改动394041424343444546472 行未改动6 行未改动考虑直接找到最靠后的 $\max_i\gt x$ 点判断其是否与 $x+1$ 相邻即可。
```cpp#pragma target("avx512f,sse2,sse3,sse4,sse4.2")#include<bits/stdc++.h> #include<bits/stdc++.h>using namespace std;#define ll long longconst ll N=1e6+5,inf=1e6;int t,n,m;3 行未改动 stk[top=1]=1; ans=0; for(int now=2;now<=n;now++){ for(int to:v[now]) vis[to]=1; while((top>=2)&&(maxx[stk[top]]<=now-1)) top--;
if(!vis[stk[top]]) ans++; stk[++top]=now;
for(int to:v[now]) vis[to]=0; } printf("%d\n",ans);}8 行未改动 maxx[x]=max(maxx[x],y); maxx[y]=max(maxx[y],x);} work(); for(int i=1;i<=n;i++) v[i].clear(),maxx[i]=0; } } return 0;}
2 行未改动