版本比较
题解:AT_kupc2021_g Two Step Sort
正文
增加 4 行删除 4 行
91 行未改动929394959696979899991001011011021031041059 行未改动1151161171181191191201211221233 行未改动91 行未改动 for(int i=1;i<=n;i++){ if(vis[i])continue; int cnt=1; t.xg(cnt,x[i],y[i]); int hjy=0; int tot=0; int j=p[i]; vis[i]=1; hjy+=y[i]; tot+=y[i]; while(j!=i){ hjy+=y[j]; tot+=y[j]; vis[j]=1; t.xg(++cnt,x[j],y[j]); j=p[j]; }9 行未改动 for(int j=1;j<=cnt;j++){ INFO xx=t.query(j,j+cnt-1); P=min(P,min({xx.l[0][0],xx.l[1][0]})); } ans+=min(P,hjy);//不要忘记特判 ans+=min(P,tot);//不要忘记特判 } cout<<ans<<endl;// while(1); return 0;3 行未改动