版本比较
题解:P12748 [POI 2017 R2] 体育比赛 Sports competition
正文
增加 16 行删除 5 行
25 行未改动2627282930313031323334354 行未改动40414243444546474849505152535455565758596053616263646566676869617071727374757666777879808131 行未改动25 行未改动
constexpr int N = 1e6 + 5;constexpr int mod = 1e9 + 7;
std::bitset<N> vis;int n,x,y,ans = 1,res[N],have[N];std::bitset<N> vis,vis_color;int n,x,y,ans = 1,res[N],have[N],cnt[N];std::vector<std::pair<int,int>> g[N];
signed main(){ std::ios::sync_with_stdio(false);4 行未改动 std::cin >> op; if(op == 'T'){ std::cin >> x; have[i] = x; ++ cnt[x]; vis_color[x] = 1; continue; }else{ std::cin >> x >> y; vis_color[x] = 1; vis_color[y] = 1; g[x].push_back(std::make_pair(y,i)); g[y].push_back(std::make_pair(x,i)); } } if((int)vis_color.count() != n){ std::cout << "NIE\n" << 0 << '\n'; return 0; } for(int i = 1; i <= n; ++ i){ if(!vis[i]){ int point_cnt = 0,point_edge = 0; int point_cnt = 0,point_edge = 0,have_sure = 0; std::function<void(int)> dfs; dfs = [&](int x){ vis[x] = 1; have_sure += (cnt[x] != 0); point_edge += g[x].size(); ++ point_cnt; for(auto & it : g[x]){ int v = it.first; if(!vis[v]) dfs(v); if(!vis[v]){ dfs(v); } } }; dfs(i); point_edge /= 2; if(point_edge > point_cnt){ if(point_edge + have_sure > point_cnt){ std::cout << "NIE\n" << 0 << '\n'; return 0; } if(point_edge == point_cnt){31 行未改动