Question: use cuda c + + language, please give the working code not what i have to do 1 Problem Statement There is a battlefield which

use cuda c++ language, please give the working code not what i have to do
1 Problem Statement
There is a battlefield which can be represented as a grid of size MN.
There are 'T' no. of tanks placed randomly on the grid with ids (0 to T-1)
at integer coordinates (x,y). Consider the tanks to be point sized objects.
Your task is to simulate a game between tanks with following rules and re-
turn the score of each tank at the end of the game.
The rules are as follows:
Each tank has Health Points (HP) allotted to them given in an array. A
tank is considered destroyed at the end of a round if its HP dropped to
0.
The game consists of multiple rounds, in each round the tanks which are
not yet destroyed in the previous rounds fire in the direction of other
tanks.
In kth round the Tank i will fire in the direction of Tank (i+k)%T. Since
a tank cannot fire at its own direction you can consider every round which
is a multiple of T to be a null round i.e the tanks do not fire at each other.
Each hit taken by a tank reduces its HP by 1 and increase the score of
the tank which fired that shot by 1.
The way hit detection works is that if in a round Tank i fires in the
direction of Tank j the shot will hit the first tank it encounters in that
direction which is not yet destroyed. So depending on the layout of the
grid there can be following scenarios and their logical variations:
-The simplest case in which there are no tanks between Tanks i and j
and Tank j is not destroyed, so the shot hits Tank j.Tank i fires at Tank j and hits Tank j
-There was a tank Tank k between Tank i and j which was not yet
destroyed in which case the shot will hit Tank k.Tank i fires at Tank j and hits Tank k
-There were Tanks k and l between Tanks i and j in that order, Tank k
was destroyed in some previous round but Tank 1 is not yet destroyed
in which case the shot hits Tank 1.
-There are Tanks i, j & k in the i-j direction and Tank j was destroyed in some previous round but Tank k is still not destroyed in which case the shot will hit Tank k Tank i fires at Tank j and hits Tank k
-The game finishes when there is only one or no tanks left (i.e not destroyed)
on the battlefield.
-A tank is considered destroyed only at the end of round in which its HP
drops to 0, it will still fire its shot in that round and it will still take
hits from all the shots which encounter it in that round and the scores of
each of the tanks which fired those shots will increase by 1.
Hint: A line can be represented using equation y=mx+ c. i.e. every unique
combination of m & c represents a unique line. If you are taking this approach
try to think of how you can avoid the use of c in the equation.All the Tanks in the i-j direction except Tank i were destroyed in previous rounds in which case the shot will not hit any tank.
3 Input and Output Format
3.1 Input Format
The first line contains integers M N T H where, M&N are grid sizes, T
is the no. of tanks on the battlefield and H is the starting health points
of each tank (all tanks have same starting HP).
T lines follow with each line containing Tank coordinates, specifically line
i contains 2 integers representing x& y coordinates respectively of Tank
(i-1).
3.2 Output Format
The final score of each Tank should be updated on the 'score' array in the host
which will get written to output file such that Line i represents final score of
Tank i.
3.3 Constraints
0xM*0yN1HP10002
1HP1000
No two tanks lie on the same point in the grid.
3.4 Sample Input
4435
11
22
33
3.5 Sample Output
6
3
62
0xM
*0yN
2
1HP1000
No two tanks lie on the same point in the grid.
3.4 Sample Input
4435
11
22
33
3.5 Sample Output
6
3
6
input testcase1:
10
10
10
15
88
64
310
12
79
96
58
1010
107
34
output testcase1:
15
15
15
the explanation of the problem is given in the image :
use cuda c + + language, please give the working

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!