Test | Status | Code Input and Output |
---|---|---|
1 | Pass |
%%
tic
urlwrite('http://contest.usc.edu/index.php/Fall12/Home?action=download&upname=analysis.in.txt','analysis_in.txt')
toc
ans =
/users/msssystem6/analysis_in.txt
Elapsed time is 0.258417 seconds.
|
2 | Pass |
%%
fid=fopen('analysis_in.txt','r');
min_elements_expected=[2 0 1 2 0 3 4];
qty=fscanf(fid,'%i',1);
for q=1:qty
n = fscanf(fid,'%i %i\n',2)'; % cols / rows
A=zeros(n)'; % Format is colmns, rows
for i=1:n(2)
strv = fgetl(fid);
A(i,:) = strv - '0';
end
strv=fgetl(fid);
Sample=strv - '0';
min_elements=Chem_analysis(A,Sample);
assert(isequal(min_elements,min_elements_expected(q)));
end % for q
fclose(fid);
% The C Winning Solution
% #include <iostream>
% #include <fstream>
% #include <string>
% using namespace std;
% int testcases;
% int n, m;
% int now;
% int best;
% string goal;
% string s[1000];
% void search(int i, string status)
% {
% if (i == n)
% {
% if (status == goal)
% {
% if ((best < 0) || (now < best)) best = now;
% }
% return;
% }
% search(i + 1, status);
% string tmp = status;
% for (int j = 0; j < m; j ++)
% {
% if (s[i][j] == '1') tmp[j] = '1';
% }
% now ++;
% search(i + 1, tmp);
% now --;
% }
% int main()
% {
% ifstream inf("analysis.in");
% inf >> testcases;
% for (int testcase = 1; testcase <= testcases; testcase ++)
% {
% cout << "Data Set " << testcase << ":" << endl;
% inf >> m >> n;
% for (int i = 0; i < n; i ++)
% inf >> s[i];
% inf >> goal;
% best = -1;
% string ini = "";
% for (int i = 0; i < m; i ++)
% ini = ini + "0";
% now = 0;
% search(0, ini);
% if (best < 0) cout << "Impossible" << endl; else cout << best << endl;
% cout << endl;
% }
% inf.close();
% return 0;
% }
%
%
%
|
3892 Solvers
29 Solvers
81 Solvers
380 Solvers
Find the elements of a matrix according to a defined property.
72 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!