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>
#include <cstdio>
#include <algorithm>
using namespace std;
vector<int> paint(int n) {
vector<int> labels(n + 1, 1);
return labels;
}
int find_location(int n, vector<int> c) {
if(c.back() == -1){
for(int i = 0;i < (int)c.size();i++){
if(c[i] == -1){
return n - ((int)c.size() - i) - 1;
}
}
}
vector<int> labels = paint(n);
int k = labels.back();
int curr = 0,target = 0;
for(auto it:c){
target = target * 2 + it;
}
for(int i = 0;i < k;i++){
curr = curr * 2 + labels[i];
}
for (int i = 0;i < n - k + 1;i++){
if(curr == target){
return i;
}
curr = (curr * 2 + labels[i + k]) - (labels[i] << (k + 1));
}
return 0;
}
# | 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... |