Question: Could you explain what each part of this code does in depth ? Simplify it as much as you can. Also, could you help me
Could you explain what each part of this code does in depth Simplify itas much as you can. Also, could you help me write another version of this code by splitting it into two classes one with the logic one to run the code that does the exact same thing and returns the same results?
Sample input:
Sample output:
#
##
# # #
# # #
# #
#
#
# #
# # #
# # #
# #
#
Sample input :
Sample output :
# #
# #
#
# # #
# # # #
# # #
# # #
# # #Crystal Crosswind
Time Limit: seconds
You are part of a scientific team developing a new technique to image crystal structures at the molecular level. The technique involves blowing a very fine wind over the surface of the crystal at various angles to detect boundaries indicated by molecules that are exposed to the wind This is repeated with different wind directions and the boundaries observed for each direction are recorded. Your team has already collected the data, but as is often the case with applied science now the real work, analysis, must begin.
For a given crystal, you will receive the directions in which wind blew over the surface, and the location of all boundaries encountered by each of these winds. For a wind blowing in direction wx wy a boundary is defined by location x y such that a molecule exists at x y and no molecule exists at x wx y wy Note that for technical reasons wx and wy are not necessarily prime.
The data might not uniquely determine the structure of the crystal. You must find two unique structures with the minimal and maximal number of molecules consistent with the observations.
For example, in the first sample input, nine different molecules are directly encountered by the given winds. There must be a molecule at location because otherwise would be a boundary for the third wind. For similar reasons, there must be molecules at and There cannot be any further molecules as they would result in additional observations for some of the winds.
Input:
The first line of input contains three integers dx dy and k where dx and dy dx dy are the maximum dimensions of the crystal structure, and k is the number of times wind was blown over the crystal.
Each of the remaining k lines specifies the data for one wind. These lines each start with two integers wx and wy dx wx dx and dy wy dy but not both zero denoting the direction of the wind. Then comes an integer b b giving the number of boundaries encountered by this wind. The line finishes with b distinct pairs of integers x y x dx and y dy listing each observed boundary.
You may assume the input is consistent with at least one crystal and that no molecules exist outside the specified dimensions.
Output:
Output two textual representations of the crystal structure separated by an empty line. Each structure has dy rows of dx characters, with the topleft corner representing the location The first is the structure with the minimal number of molecules consistent with the observations, the second is the maximal one. Use # for a location where a molecule exists and for a location where no molecule exists.
import jaxarutid,ArbayList;
import jaxarutilutisit;
import java,utiScandeE;
public class Main
static int X Y N;
static char g;
static List skM wx;
static void doitint x int y
char chx && x X && y && y Y gyx : ;
if ch return;
for int i; i && xX&& y && y Y&& gyx
gyx ch;
doitx y;
public static void mainString angs
Scanner scandex new ScannerSystemin;
while scaddebhasNext
X scadretudaxtInt;
Y scadnew,daxtInt;
N scandex,dsxtInt;
g new char YX;
wk new AxxaxListN;
WR new AxxaList N;
for int ij ; i && xX && y && y Y gyx;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
