Submission #380876

#TimeUsernameProblemLanguageResultExecution timeMemory
380876BlancaHMPainting Squares (IOI20_squares)C++14
0 / 100
2 ms292 KiB
#include <iostream>
#include <vector>
using namespace std;

vector<int> squares;

vector<int> paint(int n) {
	squares = vector<int>(n+1);
	// rellenar squares con los números en binario (8 bits) del 00000001 a 00111111
	int numero = 1;
	for (int i = 0; i < n; i += 8) {
		for (int j = 0; j < 8; j++) {
			if (i + j == n)
				break;
			squares[i+j] = numero & (1<<(7-j));
		}
		numero++;
	}
	squares[n] = 10;
	return squares;
}

int find_location(int n, vector<int> c) {
	if (c[9] == -1) {
		int last = 10;
		while(last && c[last-1] == -1)
			last--;
		return n - (10-last);
	}
	bool found;
	int pos = 0;
	for (int i = 0; i <= n-10; i++) {
		found = true;
		for (int j = 0; j < 10; j++) {
			if (squares[i+j] != c[j]) {
				found = false;
				break;
			}
		}
		if (found) {
			pos = i;
			break;
		}
	}
	return pos;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...