# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1077335 | LCJLY | Broken Device (JOI17_broken_device) | C++14 | 214 ms | 2692 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 "Annalib.h"
#include <bits/stdc++.h>
//#include "grader.cpp"
using namespace std;
#define show(x,y) cout << y << " " << #x << endl;
#define show2(x,y,i,j) cout << y << " " << #x << " " << j << " " << #i << endl;
#define show3(x,y,i,j,p,q) cout << y << " " << #x << " " << j << " " << i << " " << q << " " << #p << endl;
#define show4(x,y) for(auto it:y) cout << it << " "; cout << #x << endl;
typedef pair<int,int>pii;
void Anna(int n, long long val, int k, int p[]){
bool amos[155];
memset(amos,0,sizeof(amos));
for(int x=0;x<k;x++){
amos[p[x]]=true;
}
deque<int>v;
for(int x=0;x<60;x++){
if(val&(1LL<<x)) v.push_back(1);
else v.push_back(0);
}
int ptr=0;
int st=0;
for(;st<n;st++){
if(ptr==8) break;
if(ptr<(int)8&&st+1<n&&!amos[st]&&!amos[st+1]){
ptr++;
st+=1;
}
}
ptr=0;
pii maxi={-1,-1};
for(int x=1;x<n;x++){
//if(60%x!=0) continue;
int bit=0;
for(int y=st;y<n;y++){
if(ptr<(int)v.size()&&y+x<n){
bool ok=true;
for(int i=0;i<=x;i++){
if(amos[y+i]) ok=false;
}
if(ok){
bit+=x;
y+=x;
}
}
}
maxi=max(maxi,{bit,x});
}
for(int i=7;i>=0;i--){
if(maxi.second&(1<<i)){
v.push_front(1);
}
else v.push_front(0);
}
int x=0;
vector<int>done;
for(;x<n;x++){
if(ptr==8) break;
if(ptr<(int)8&&x+1<n&&!amos[x]&&!amos[x+1]){
Set(x,1);
Set(x+1,v[ptr]);
ptr++;
x+=1;
}
else Set(x,0);
}
for(;x<n;x++){
if(ptr<(int)v.size()&&x+maxi.second<n){
bool ok=true;
for(int i=0;i<=maxi.second;i++){
if(amos[x+i]) ok=false;
}
if(ok){
Set(x,1);
for(int i=0;i<maxi.second;i++){
if(ptr==(int)v.size()) Set(x+i+1,0);
else{
Set(x+i+1,v[ptr]);
ptr++;
}
}
x+=maxi.second;
}
else Set(x,0);
}
else Set(x,0);
}
}
#include "Brunolib.h"
#include <bits/stdc++.h>
//#include "grader.cpp"
using namespace std;
#define show(x,y) cout << y << " " << #x << endl;
#define show2(x,y,i,j) cout << y << " " << #x << " " << j << " " << #i << endl;
#define show3(x,y,i,j,p,q) cout << y << " " << #x << " " << j << " " << i << " " << q << " " << #p << endl;
#define show4(x,y) for(auto it:y) cout << it << " "; cout << #x << endl;
typedef pair<int,int>pii;
long long Bruno(int n, int a[]){
long long val=0;
int cur=0;
//for(int x=0;x<n;x++) cout << a[x] << " ";
//cout << endl;
//for(int x=0;x<n;x++){
//if(a[x]==1){
//if(a[x+1]==1){
//val+=1LL<<cur;
//}
//cur++;
//if(a[x+2]==1){
//val+=1LL<<cur;
//}
//cur++;
//if(a[x+3]==1){
//val+=1LL<<cur;
//}
//cur++;
//x+=3;
//}
//}
int x=0;
int base=0;
//int cnt=0;
for(;x<n;x++){
if(cur==8) break;
if(a[x]==1){
if(a[x+1]==1){
base+=1LL<<cur;
}
cur++;
x++;
}
}
//show(base,base);
cur=0;
for(;x<n;x++){
if(a[x]==1){
for(int y=0;y<base;y++){
if(x+y+1>=n) break;
if(a[x+y+1]==1){
val+=1LL<<cur;
}
cur++;
}
x+=base;
}
}
//for(int x=0;x<n;x++){
//cout << a[x] << " ";
//}
//cout << " a\n";
//cout << "check" << endl;
return val;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |