# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
907420 | andrey27_sm | Broken Device (JOI17_broken_device) | C++17 | 47 ms | 3012 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 <bits/stdc++.h>
#include <Annalib.h>
using namespace std;
void Anna( int N, long long X, int K, int P[] ){
vector<int> L(N,-2);
stack<int> B;
while(X) B.push(X&1), X>>=1;
set<int> used;
for(int i = 0;i < K;i++) Set(P[i],0),L[P[i]] = -1, used.insert(P[i]);
for(int i = 0;i < N;i++){
if(L[i] == -1) continue;
int cnt = 0;
while(i+cnt < N and L[i+cnt] == -2) cnt++;
// cout << i << "-" << i+cnt-1 << "\n";
int Pcnt = 0;
if(cnt >= 68 and B.size() >= 60) {
cnt-=68;
for(int j = 0;j < 7;j++) {
used.insert(i+j);
Set(i+j,1);
}
used.insert(i+7);
Set(i+7,0);
for(int j = 0;j < 60;j++) {
used.insert(i+8+j);
Set(i+8+j,B.top());
B.pop();
}
Pcnt++;
i += 68;
}
if(cnt >= 39 and B.size() >= 32) {
cnt-=39;
for(int j = 0;j < 6;j++) {
used.insert(i+j);
Set(i+j,1);
}
used.insert(i+6);
Set(i+6,0);
for(int j = 0;j < 32;j++) {
used.insert(i+7+j);
Set(i+7+j,B.top());
B.pop();
}
Pcnt++;
i += 39;
}
if(cnt >= 22 and B.size() >= 16) {
cnt-=22;
for(int j = 0;j < 5;j++) {
used.insert(i+j);
Set(i+j,1);
}
used.insert(i+5);
Set(i+5,0);
for(int j = 0;j < 16;j++) {
used.insert(i+6+j);
Set(i+6+j,B.top());
B.pop();
}
Pcnt++;
i += 22;
}
if(cnt >= 13 and B.size() >= 8) {
cnt-=13;
for(int j = 0;j < 4;j++) {
used.insert(i+j);
Set(i+j,1);
}
used.insert(i+4);
Set(i+4,0);
for(int j = 0;j < 8;j++) {
used.insert(i+5+j);
Set(i+5+j,B.top());
B.pop();
}
Pcnt++;
i += 13;
}
if(cnt >= 8 and B.size() >= 4) {
cnt-=8;
for(int j = 0;j < 3;j++) {
used.insert(i+j);
Set(i+j,1);
}
used.insert(i+3);
Set(i+3,0);
for(int j = 0;j < 4;j++) {
used.insert(i+4+j);
Set(i+4+j,B.top());
B.pop();
}
Pcnt++;
i += 8;
}
if(cnt >= 5 and B.size() >= 2) {
cnt-=5;
for(int j = 0;j < 2;j++) {
used.insert(i+j);
Set(i+j,1);
}
used.insert(i+2);
Set(i+2,0);
for(int j = 0;j < 2;j++) {
used.insert(i+3+j);
Set(i+3+j,B.top());
B.pop();
}
Pcnt++;
i += 5;
}
if(cnt >= 3 and B.size() >= 1) {
cnt-=3;
used.insert(i);
used.insert(i+1);
used.insert(i+2);
Set(i,1);
Set(i+1,0);
Set(i+2,B.top());
B.pop();
Pcnt++;
i += 3;
}
if(Pcnt) i--;
}
for(int i = 0;i < N;i++) {
if(used.count(i)) continue;
Set(i,0);
}
}
#include <bits/stdc++.h>
#include <Brunolib.h>
using namespace std;
long long Bruno( int N, int A[] ){
long long X = 0;
for(int i = 0;i < N-1;i++){
if(A[i] == 0) continue;
int cnt = 0;
while(A[i] == 1) cnt++,i++;
i++;
for(int j = 0; j < (1<<(cnt-1));j++) {
X<<=1;
X|=A[i+j];
}
i+=(1<<(cnt-1))-1;
}
return X;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |