# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
430422 | schse | Painting Squares (IOI20_squares) | C++17 | 106 ms | 600 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "squares.h"
#include <vector>
#ifndef EVAL
#include "grader.cpp"
#endif
#include <bits/stdc++.h>
using namespace std;
bool seen[1024 + 10];
vector<int> edges;
int pos[1024];
vector<int> debj;
void dfs(int node)
{
for (int i = 0; i < 2; i++)
{
int cn = node * 2 + i;
if (!seen[cn])
{
seen[cn] = true;
dfs(cn & 511);
edges.push_back(i);
}
}
}
vector<int> deBruijn(int n)
{
fill(seen, seen + 1024, 0);
edges.clear();
dfs(0);
for (int i = 0; i < 10; i++)
edges.push_back(0);
vector<int> v;
for (int i = 0; i < edges.size() - 10; i++)
{
int c = 0;
for (int e = 0; e < 10; e++)
{
c = c * 2 + edges[i + e];
}
pos[c] = i;
}
for (int i = 0; i < n; i++)
v.push_back(edges[i]);
v.push_back(10);
return v;
}
std::vector<int> paint(int n)
{
return deBruijn(n);
}
int find_location(int n, std::vector<int> c)
{
if (c.back() == -1)
{
int p = n - c.size();
while (c.back() == -1)
{
p++;
c.pop_back();
}
return p;
}
int b = 0;
for (int i = 0; i < c.size(); i++)
{
b = b * 2 + c[i];
}
return pos[b];
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |