版本比较
题解 P6305 【[eJOI2018]循环排序】
正文
增加 3 行删除 3 行
97 行未改动989910010110210210310410410510610710810911011111211311311411511611735 行未改动97 行未改动 for(int i =0; i < n; ++i) if(a[i] != b[i]) addedge(a[i], b[i], i+1); // init done. //
int sum =0;
for(int i =1; i <= col; ++i) if(!vis[i]){ dfs(i); if(ans[tot].size() != 0){ sum +=ans[tot].size(); ++tot; } }
if(sum > s) putchar('-'), putchar('1'), putchar('\n'); else if(s-sum <= 1 || tot <= 1){ write(tot), putchar('\n');35 行未改动