There is a planet more than thousand light years away from earth. They have a big
problem, because they still don’t have a police force and laws, and people are fighting
for land.
There are N (2 <= N <= 1000) people living in this planet. Every person has an
ID number from 1 to N and no two persons will have the same ID number. When they
fight the stronger one wins and the weaker loses. There are M (1 <= M <=
1000) fights going on.
You
are given the strength of each person and the fighting pairs and you have to
determine the winner of each fight.
Input (fight.in)
1. First line contains N and M.
2. Each of the next N Lines contains one integer Pi (1
<= Pi
<= 2000) which is the strength the ith
person.
3. Next M lines contains two integers x and y (1 <= x, y <= N), the ID
numbers of the fighting pair.
Output (fight.out)
Example Input
4 4
1
3
5
2
1 2
2 3
3 4
1 4
Example Output
2
3
3
4
2,296 Views |
#include
#include
#include
using namespace std;
int main(int argc, char* argv[]) {
ifstream file(argv[1]);
int n, m;
vector strength;
file >> n >> m;
for (int i = 0; i > s;
strength.push_back(s);
}
for (int i = 0; i > id0 >> id1;
int st[] = {strength[id0 - 1], strength[id1 - 1]};
cout st[1])?id0:id1)
Leave an Answer/Comment