Submission #559439

# Submission time Handle Problem Language Result Execution time Memory
559439 2022-05-09T19:22:49 Z ahmet34 Painting Squares (IOI20_squares) C++14
0 / 100
1000 ms 1260 KB
#include "squares.h"
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using pii = pair<int, int>;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

const int INF = 2e9, N = 1005, M = 1e9+7, LOG = 16;
const ll LINF = 1e18;

int len;
string res;
map<string, bool> vis;

void dfs(string node) {
    for(int i = 0; i < 2; i++) {
        string to = node + char('0' + i);
        if(!vis[to]) {
            vis[to] = true;
            dfs(to.substr(1));
            res += to.back();
        }
    }
}

void deBruijn () {
	vis.clear();
	res.clear();
	string s = string(len-1, '0');
    dfs(s);
    res += s;
}

vector<int> paint(int n) {
	len = min(10, n);
	deBruijn();

	vector<int> labels(n);
	for(int i = 0; i < n; ++i)
		labels[i] = res[i]-'0';

	labels.push_back(len);
	return labels;
}

int find_location(int n, vector<int> c) {
	len = min(10, n);
	deBruijn();

	vector<int> labels(n);
	for(int i = 0; i < n; ++i)
		labels[i] = res[i]-'0';

	for(int i = 0; i < len; i++) labels.push_back(-1);

	for(int i = 0; i < n; i++) {
		if(equal(all(c), labels.begin()+i, labels.begin()+i+len))
			return i;
	}
	return -1;
}
# Verdict Execution time Memory Grader output
1 Execution timed out 3084 ms 1260 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3088 ms 1252 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3013 ms 1244 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3074 ms 1200 KB Time limit exceeded
2 Halted 0 ms 0 KB -