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>
#include "squares.h"
using namespace std;
vector<int>paint(int n) {
if(n == 2)
return {1,0,1};
int sz = 0, c = 0;
vector<int>v(n+1);
for(int i = 0 ; i < n ; i++) {
if(c)
v[i] = 0, c--;
else
v[i] = 1, c = ++sz;
}
int f = -1, s = -1;
for(int i = n-1 ; i >= 0 ; i--) {
if(v[i] == 1) {
if(f == -1)
f = i;
else if(s == -1)
s = i;
}
}
v[n] = 2*(f - s -1)+3;
return v;
}
int find_location(int n, vector<int>v) {
if(n == 2)
return (v[0] == 1 ? 0 : 1);
for(int i = 0 ; i < n ; i++) {
if(v[i] == -1) {
return n - i;
}
}
int f = -1, s = -1;
for(int i = 0 ; i < n ; i++) {
if(v[i] == 1) {
if(f == -1)
f = i;
else if(s == -1)
s = i;
}
}
assert(f != -1 && s != -1);
int len = s - f - 1;
return (len * (len-1))/2 + (len-1) - f;
}
# | 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... |