fork download
  1. vector<pi> q;
  2. for(int i=0; i<n; i++) {
  3. q.pb({adj[i].size(), i});
  4. }
  5.  
  6. sort(all(q));
  7. vector<bool> chosen(n, false);
  8. vector<int> ans;
  9. target = k%2==0?k/2:k/2+1;
  10. for(auto x:q){
  11. if(chosen[x.second])
  12. continue;
  13. ans.pb(x.second);
  14. for(auto y:adj[x.second])
  15. chosen[y] = true;
  16.  
  17. if(ans.size()==target)
  18. break;
  19. }
  20.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:1:1: error: ‘vector’ does not name a type
 vector<pi> q;
 ^~~~~~
prog.cpp:2:3: error: expected unqualified-id before ‘for’
   for(int i=0; i<n; i++) {
   ^~~
prog.cpp:2:16: error: ‘i’ does not name a type
   for(int i=0; i<n; i++) {
                ^
prog.cpp:2:21: error: ‘i’ does not name a type
   for(int i=0; i<n; i++) {
                     ^
prog.cpp:6:7: error: expected constructor, destructor, or type conversion before ‘(’ token
   sort(all(q));
       ^
prog.cpp:7:3: error: ‘vector’ does not name a type
   vector<bool> chosen(n, false);
   ^~~~~~
prog.cpp:8:3: error: ‘vector’ does not name a type
   vector<int> ans;
   ^~~~~~
prog.cpp:9:3: error: ‘target’ does not name a type
   target = k%2==0?k/2:k/2+1;
   ^~~~~~
prog.cpp:10:3: error: expected unqualified-id before ‘for’
   for(auto x:q){
   ^~~
stdout
Standard output is empty