# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
371611 | hoaphat1 | Painting Squares (IOI20_squares) | C++17 | 0 ms | 0 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<bits/stdc++.h>
using namespace std;
vector<int> fpm;
vector<int> value;
void recall() {
int k = 10;
for (int i = 0; i < 10; i++) fpm.push_back(1);
int v = (1 << k) - 1;
vector<bool> kt(1 << k);
while ((int)fpm.size() < 1000) {
v = (v << 1) % (1 << k);
int sign = 0;
if (kt[v]) {
v++;
sign = 1;
}
assert(!kt[v]);
kt[v] = true;
value.push_back(v);
fpm.push_back(sign);
}
}
int* paint(int n) {
if (fpm.empty()) recall();
int *a = new int[n + 1];
a[n] = 10;
for (int i = 0; i < n; i++) a[i] = fpm[i];
return a;
}
vector<int> now;
int find_location(int n, int c[]) {
vector<int> need(c, c + 10);
/*for (int i = 0; i < 10; i++) cout << c[i] <<" ";cout << endl;
for (int i = 0; i < 10; i++) cout << need[i] <<" ";cout << endl;*/
for (int i = 0; i < n; i++) {
now.clear();
for (int j = 0; j < 10; j++) {
if (i + j >= n) now.push_back(-1);
else now.push_back(fpm[i + j]);
}
if (now == need) return i;
}
assert(false);
}
/*int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n = 100;
int* a = paint(n);
//for (int i = 0; i <= n; i++) cout << a[i] <<" ";cout << endl;
mt19937 rgn(chrono::steady_clock::now().time_since_epoch().count());
for (int i = 0; i < 7; i++) {
int pos = rgn() % n;
int c[a[n]];
for (int j = 0; j < a[n]; j++) {
c[j] = (pos + j >= n ? -1 : a[pos + j]);
}
cout << pos << endl;
cout << find_location(n, c) << endl;
}
}*/