# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
307486 | urd05 | Painting Squares (IOI20_squares) | C++14 | 131 ms | 572 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 <bits/stdc++.h>
using namespace std;
vector<int> paint(int n) {
vector<int> ret(n+1,1);
int now=1;
int ind=0;
while (1) {
int save=ind;
while (ind<n&&ind<save+now) {
ret[ind++]=0;
}
while (ind<n&&ind<save+now*2) {
ret[ind++]=1;
}
if (ind==n) {
break;
}
now++;
}
ret[n]=2*now+1;
return ret;
}
int find_location(int n,vector<int> c) {
int val0[50];
int val1[50];
for(int i=1;i<50;i++) {
val0[i]=i*i-i;
val1[i]=i*i;
}
int k=c.size();
if (c.back()==-1) {
int ret=n-k;
for(int i=k-1;i>=0;i--) {
if (c[i]!=-1) {
break;
}
ret++;
}
return ret;
}
int f=c[0];
for(int i=1;i<k;i++) {
if (c[i]!=f) {
int len;
for(int j=i+1;j<k;j++) {
if (c[j]==f) {
len=j-i;
break;
}
}
int pos=(f==0?val1[len]:val0[len]);
return pos-i;
}
}
}
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... |