Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Correct

80Size
Leading solution size is 78.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test
Code Input and Output
1
Pass
 
%%
%http://contest.usc.edu/index.php/Fall12/Home?action=download&upname=water.in.txt
tic
urlwrite('http://contest.usc.edu/index.php/Fall12/Home?action=download&upname=water.in.txt','water_in.txt');
toc
Elapsed time is 0.808433 seconds.
2
Pass
 
%%
 fid=fopen('water_in.txt','r');
 w_area_expect=[8 16;100 100;0 1;1 1;5 9;186 675;23 110; 480 2500;102 2500;61 400; ...
     73 930;160 441; 678 800; 55 361; 53 195;216 1296;199 1110;81 576;232 552;12 30;9 25;15 25;25 143; ...
     66 120;2500 2500;270 1680;264 900;292 1365;748 2401;244 609;315 1296;214 1188];
 qty=fscanf(fid,'%i',1);
 for q=1:qty
  n = fscanf(fid,'%i %i %i\n',3)'; % rows / cols / min rect
  s=n(3);
  n=n(1:2);
  strv=fgetl(fid);
  iswater=strv;
  A=zeros(n); % Format is rows, columns
  for i=1:n(1)
   strv = fgetl(fid);
   A(i,:) = strv;
  end
  A=char(A);
  [w,w_area]=Water_analysis(A,iswater,s);
  assert(isequal([w w_area],w_area_expect(q,:)));
 end
 fprintf('Processing Complete\n\n')
 fclose(fid);
toc
Processing Complete
Elapsed time is 14.535714 seconds.