Cody

Solution 1721946

Submitted on 6 Feb 2019 by James
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

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/mss.system.ftjeKD/analysis_in.txt' Elapsed time is 0.524802 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; % } % % %

A = 0 0 1 1 0 0 0 0 0 0 0 1 1 0 1 0 0 0 0 0 0 0 1 0 sa = 2 A = 1 0 0 0 sa = 1 A = 1 0 0 1 0 1 0 1 1 1 0 1 sa = 3 A = 1 1 0 0 0 0 1 0 sa = 2 A = 1 0 1 0 0 1 1 0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