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 <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, M = 1e9+7, LOG = 16;
const ll LINF = 1e18;
int len, N;
string res;
unordered_map<string, bool> vis;
void dfs(string node) {
if(res.size() > N) return;
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) {
N = n;
vector<int> labels(n);
len = min(10, n);
deBruijn();
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) {
N = n;
vector<int> labels(n);
len = min(10, n);
deBruijn();
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;
}
Compilation message (stderr)
squares.cpp: In function 'void dfs(std::string)':
squares.cpp:18:16: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
18 | if(res.size() > N) return;
| ~~~~~~~~~~~^~~
# | 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... |