离奇MLE

P2731 [USACO3.3] 骑马修栅栏 Riding the Fences

jomy @ 2023-11-14 22:13:35

``` #include<bits/stdc++.h> using namespace std; const int N=2023; int a[N][N]; int d[N],l[N],ans=1; void dfs(int h){ for(int i=1;i<=150;i++){ if(a[h][i]){ a[h][i]--; a[i][h]--; dfs(i); } } l[ans++]=h; } int main(){ int m,p=0,x,j=10086,y,n=-114514; cin>>m; while(m--){ int o,k; cin>>o>>k; d[o]++; d[k]++; a[o][k]++; a[k][o]++; j=min({j,o,k}); n=max({n,o,k}); } for(int i=j;i<=n;i++){ if(d[i]%2==1){ if(!p) x=i; else y=i; p++; } } for(int i=j;i<=n;i++){ sort(a[i]+0,a[i]+26); } if(p==2) dfs(x); else dfs(j); for(int i=ans-1;i>0;i--){ cout<<l[i]; } return 0; } ```

by carp_oier @ 2023-11-14 23:45:49

可能是栈递归炸了


|