#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]=100;
return labels;
}
int find_location(int n, std::vector<int> c) {
int cnt=0;
for(int i=0;i<n;i++){
if(c[i]==-1)cnt++;
}
if(cnt){
return n-(100-cnt)+2;
}
int p=0;
int l=0;
int L=0;
int R=0;
while(!c.empty()){
if(c.back()==1){
if(p==0){
L=l;
}
if(p==1){
R=l;
}
p++;
l=0;
}
else{
l++;
}
c.pop_back();
}
if(p==1)R=100-L-1;
// cout<<R<<" "<<L<<endl;
int h= (R+1)*(R+2)/2;
h+=L-100;
return h;
// 1 2 3 4 5
// 1 3 6 10 15 21
// 1 0 1 0 0 1
// 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... |