# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1077873 | veehj | Broken Device (JOI17_broken_device) | C++17 | 40 ms | 2876 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>
using namespace std;
typedef long long ll;
typedef long double ld;
#define F first
#define S second
#define pb push_back
#define sz(a) (ll) a.size()
#define all(x) (x).begin(), (x).end()
void set3(int id, int a, int b, int c){
Set(id, a);
Set(id+1, b);
Set(id+2, c);
}
void Anna( int N, long long X, int K, int P[] ){
ll curr=X;
set<int> er;
for(int i=0; i<K; i++) er.insert(P[i]);
for(int i=0; i<N; i+=3){
if(er.count(i)+er.count(i+1)+er.count(i+2)>=2 || curr==0){
set3(i, 0, 0, 0); //0->
continue;
}
if(!(er.count(i) || er.count(i+1) || er.count(i+2))){
if(curr%4==0) set3(i, 1, 0, 0); //4->00
if(curr%4==1) set3(i, 1, 1, 0); //5->10
if(curr%4==2) set3(i, 1, 0, 1); //6->01
if(curr%4==3) set3(i, 1, 1, 1); //7->11
curr/=4;
continue;
}
if(curr%2){
if(er.count(i+2)) set3(i, 0, 1, 1); //3->1
else set3(i, 0, 0, 1); //1->1
curr/=2;
} else {
if(er.count(i+1)){
if(curr%4==0) set3(i, 1, 0, 0); //4->00
if(curr%4==2) set3(i, 1, 0, 1); //5->10
curr/=4;
} else {
set3(i, 0, 1, 0); //2->0
curr/=2;
}
}
}
}
#include "Brunolib.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define F first
#define S second
#define pb push_back
#define sz(a) (ll) a.size()
#define all(x) (x).begin(), (x).end()
long long Bruno( int N, int A[] ){
stack<int> st;
ll ans=0;
for(int i=0; i<N; i+=3){
int nw=A[i]*4+A[i+1]*2+A[i+2];
if(nw==0) continue;
if(nw==1) st.push(1);
if(nw==2) st.push(0);
if(nw==3) st.push(1);
if(nw==4){
st.push(0);
st.push(0);
}
if(nw==5){
st.push(0);
st.push(1);
}
if(nw==6){
st.push(1);
st.push(0);
}
if(nw==7){
st.push(1);
st.push(1);
}
}
while(!st.empty()){
ans*=2;
ans+=st.top();
st.pop();
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |