#include "squares.h"
#include <vector>
#include<bits/stdc++.h>
using namespace std;
std::vector<int> paint(int n) {
std::vector<int> labels(n + 1);
int p=1;
for(int i=0;i<n;i+=p){
labels[i]=1;
p++;
}
labels[n]=70;
return labels;
}
int find_location(int n, std::vector<int> c) {
// x ees hooishoo n
int cnt=0;
for(int i=0;i<n;i++){
if(c[i]==-1)cnt++;
}
if(cnt){
return n-(70-cnt);
}
int p=0;
int l=0;
int L=0;
int R=0;
while(1){
if(c.back()==1){
if(p==0){
// hoino heden l baiga
L=l; // hoid taliin 0 uudiin too
}
if(p==1){
R=l;
// dundiin 0 uud iin too
}
p++;
l=0;
}
else{
l++;
}
c.pop_back();
}
int h= (R+1)*(R+2)/2;
h+=L-1;
return h;
// 1 2 3 4 5
// 1 3 6 10 15 21
// 1 . . . . . 0000 1
}
| # | 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... |