Solution:
Suppose you have selected all the points.
If you delete a point from it, the score for all other points can only be reduced or unchanged.
If you want to make the smallest score larger after several steps have been removed, then the point set that is deleted must contain the point with the lowest current score.
So each time a point is deleted, the maximum value is recorded once. It is good to take the maximum output of the case.
#include <bits/stdc++.h>using namespacestd;Const intN =100009; Vector<int> E[n], out;Set<pair<Double,int>>s;intDeg[n], vis[n], dg[n];intN, M, K;intMain () {Ios::sync_with_stdio (0 ); CIN>> n >> M >>K; for(inti =1, X; I <= K; ++i) {cin>>x; VIS[X]=1; } for(inti =1, u, v; I <= m; ++i) {cin>> u >>v; E[u].push_back (v),++Deg[u]; if(!vis[v]) + +Dg[u]; E[v].push_back (u),++Deg[v]; if(!vis[u]) + +Dg[v]; } for(inti =1; I <= N; ++i) {if(!Vis[i]) S.insert (Make_pair (1. *dg[i]/Deg[i], i)); } DoubleAns =-1; while(!S.empty ()) {Auto It= *S.begin (); if(It.first >ans) {ans=It.first; out. Clear (); for(Auto &i:s) { out. push_back (I.second); }} s.erase (S.begin ()); Vis[it.second]=1; for(Auto &I:e[it.second]) { if(!Vis[i]) {S.erase (Make_pair (1. *dg[i]/Deg[i], i)); --Dg[i]; S.insert (Make_pair (1. *dg[i]/Deg[i], i)); } }} cout<< out. Size () <<Endl; for(Auto &i: out) {cout<< I <<" "; }}
View Code
Codeforces 553D nudist Beach (graph theory, greed)