Submission #649920

#TimeUsernameProblemLanguageResultExecution timeMemory
649920Pablo_NoCave (IOI13_cave)C++17
0 / 100
379 ms384 KiB
#include "cave.h"

#include <vector>

void exploreCave(int N) {
	int B = 13;
	
	std::vector<int> q(N), cpos(N), ord(N);
	
	for(int i = 0; i < N; i++)
	{
		cpos[i] = -1;
	}
	
    for(int i = 0; i < N; i++)
    {
		for(int j = 0; j < N; j++)
		{
			q[j] = 0;
			if(cpos[j] != -1)
				q[j] = cpos[j];
		}
		
		int an = tryCombination(&q[0]);
		cpos[i] = 1;
		if(an > i)
			cpos[i] = 0;
		int cp = cpos[i];
		
		int idx = 0;
		
		for(int k = 0; k < B; k++)
		{
			for(int j = 0; j < N; j++)
			{
				q[j] = 1-cp;
				if(cpos[j] != -1)
					q[j] = cpos[j];
				else if((j & (1 << k)) && ((j | ((1 << k)-1)) == idx))
					q[i] = cp;
			}
			int anx = tryCombination(&q[0]);
			if(anx > i)
				idx += (1 << k);
		}
		ord[i] = idx;
	}
	
	answer(&cpos[0], &ord[0]);
}
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...