This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//
// ~oisín~ C++ Template
//
#include <bits/stdc++.h>
#define MX_N 5001
#define mp make_pair
#define mod7 1000000007
#define modpi 314159
#define PI 3.141592653589793238
#define pb push_back
#define FastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define All(a) a.begin(),a.end()
#define fi first
#define se second
#define ll long long int
#define ull unsigned long long int
int kx[8] = {+2, +2, -2, -2, +1, +1, -1, -1};
int ky[8] = {+1, -1, +1, -1, +2, -2, +2, -2};
int d9x[9] = {+1, +1, +1, +0, +0, +0, -1, -1, -1};
int d9y[9] = {+1, +0, -1, +1, +0, -1, +1, +0, -1};
int dx4[4] = {+0, +0, +1, -1};
int dy4[4] = {+1, -1, +0, +0};
ll gcd(ull a, ull b){
return (a==0)?b:gcd(b%a,a);
}
ll lcm(ull a, ull b){
return a*(b/gcd(a,b));
}
const long long INF = 1e18;
using namespace std;
vector<int> res(991);
bitset<1024> in_res;
map<int, int> pos;
bool augment(int at){
if(at == 991){
return true;
}
int cand = (res[at-1] << 1)%1024;
if(in_res[cand] == false){
in_res[cand] = true;
res[at] = cand;
if(augment(at+1)){
return true;
}
in_res[cand] = false;
}
++cand;
if(in_res[cand] == false){
in_res[cand] = true;
res[at] = cand;
if(augment(at+1)){
return true;
}
in_res[cand] = false;
}
return false;
}
vector<int> paint(int n){
in_res.set();
in_res.flip();
in_res[0] = 1;
res[0] = 0;
augment(1);
for(int i=0;i<991;++i){
pos[res[i]] = i;
}
vector<int> ans(n);
for(int i=0;i<n;++i){
if(i < 10){
ans[i] = 0;
}else{
ans[i] = res[i-9]&1;
}
}
ans.pb(min(n, 10));
return ans;
}
int find_location(int n, vector<int> c){
int edge_case = 0;
int k = min(n, 10);
for(int x : c){
edge_case += (x == -1);
}
if(edge_case){
return n - k + edge_case;
}
int x = 0;
reverse(All(c));
for(int i=0;i<k;++i){
if(c[i]){
x += (1 << i);
}
}
return pos[x];
}
# | 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... |