# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1227140 | emptypringlescan | Broken Device (JOI17_broken_device) | C++17 | 39 ms | 1536 KiB |
#include "Annalib.h"
#include <bits/stdc++.h>
using namespace std;
/*
* 001: 0
* 010: 10
* 011: 11
* 100: 1
* 101: 01
* 110: 0
* 111: 00
*/
void Anna( int n, long long x, int k, int p[] ){
int ans[n];
memset(ans,-1,sizeof(ans));
for(int i=0; i<k; i++) ans[p[i]]=0;
int msg[65];
memset(msg,0,sizeof(msg));
for(long long i=0; i<60; i++) msg[i]=(!!(x&(1ll<<i)));
int cur=0;
for(int i=0; i<n; i+=3){
if(cur>60) break;
int bad=0;
for(int j=0; j<3; j++) bad+=(ans[i+j]==0);
if(bad>1) continue;
if(bad==1){
if(msg[cur]==0&&ans[i+2]!=0) ans[i+2]=1;
else if(msg[cur]==0) ans[i]=ans[i+1]=1;
else if(ans[i]!=0) ans[i]=1;
else if(msg[cur+1]==0) ans[i+1]=1,cur++;
else ans[i+1]=ans[i+2]=1,cur++;
cur++;
}
else{
if(msg[cur]==0&&msg[cur+1]==0) ans[i]=ans[i+1]=ans[i+2]=1;
else if(msg[cur]==0&&msg[cur+1]==1) ans[i]=ans[i+2]=1;
else if(msg[cur]==1&&msg[cur+1]==0) ans[i+1]=1;
else ans[i+1]=ans[i+2]=1;
cur+=2;
}
}
for(int i=0; i<n; i++) ans[i]=max(ans[i],0);
for(int i=0; i<n; i++) Set(i,max(ans[i],0));
}
#include "Brunolib.h"
#include <bits/stdc++.h>
using namespace std;
/*
* 001: 0
* 010: 10
* 011: 11
* 100: 1
* 101: 01
* 110: 0
* 111: 00
*/
long long Bruno( int n, int a[] ){
vector<int> bts;
vector<vector<int> > ref={{},{0},{1,0},{1,1},{1},{0,1},{0},{0,0}};
for(int i=0; i<n; i+=3){
int bm=0;
for(int j=0; j<3; j++){
bm*=2;
bm+=a[i+j];
}
if(bm==0) continue;
for(int j:ref[bm]) bts.push_back(j);
}
long long ret=0;
for(long long i=0; i<60; i++) if(bts[i]) ret^=(1ll<<i);
return ret;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |