Covid Cure

5

1 votes
Graphs, Algorithms, Graph Representation, C++
Problem

Note: This is an approximate problem. There is no exact solution. You must find the most optimal solution. Please, take a look at the sample explanation to ensure that you understand the problem correctly.

In the Disneyland which consists of N cities and M connecting roads, you being the Mayor is planning to build new Hospitals to cure COVID - 19.

Every hospital which will be built in different cities, has two parameters associated with them.

  • Patient capacity : Represented by array B .
  • Establishment cost : Represented by array C.

So, C[i] and B[i], denotes the capacity and establisment cost of hospital which will be built in the ith city.

Due to spreading nature of virus we have following constraints on the establishment of hospitals.

  • No two hospitals should be directly connected via a road. 
  • At-most one hospital can be built in a city.

You have to choose K cities to establish hospitals say represented by array A, such that the value of Z is maximized.

Z=Ki=1B[A[i]]Ki=1C[A[i]]

Input

  • First line contains two space-separated integers N M.
  • Next M lines contains two space-separated integers u v denoting a direct road between city u and v.
  • Next line contains N space-separated integers denoting array B
  • Next line contains N space-separated integers denoting array C

Output

  • Print an integer K ( >= 1) denoting the number of cities you choose to build hospitals.
  • In next line print K space-separated integers denoting the index of selected cities.

Constraints

1N1041M2×1051u,vN1B[i],C[i]105C[i]B[i]

Verdict and scoring 

Your score is equal to the sum of the values of all test files. The value of each test file is equal to the value of Z that you found.

Note, K integers must be less than or equal to N and distinct. If the output format if wrong or K citites selected does not follow condition in problem statement Wrong Answer verdict will be recieved.

Sample Input
5 4
1 2
2 3
3 4
1 4
10 11 25 40 36
2 8 20 15 31
Sample Output
2
1 3
Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation
  • Z=(B[1]+B[3])(C[1]+C[3])
  • Z=(10+25)(2+20)
  • Z=3522=13

Note : There are other possible answers also. Sample Input / Output is for explanation test cases follow input constraints.

Editor Image

?