# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
100078 | dwsc | Broken Device (JOI17_broken_device) | C++14 | 69 ms | 3120 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;
void Anna( int N, long long X, int K, int P[] ){
int broke[N] = {0};
for (int i = 0; i < K; i++) broke[P[i]] = 1;
long long pow = 1;
for (int i = 0; i < 59; i++) pow*= 2;
//cout << pow;
for (int i = 0; i < N; i+= 3){
int countbroke = 0;
for (int j = i; j < i+3; j++){
countbroke += broke[j];
}
//cout << i << " " << countbroke << " " << pow<< "\n";
if (pow == 0) countbroke = 3;
if (countbroke >= 1){
for (int j = i; j < i+3; j++) Set(j,0);
}
/* else if (countbroke == 1){
int before = 0;
if (X >= pow){
X -= pow;
before = 1;
}
pow /= 2;
if (broke[i]){
Set(i,0);
Set(i+1,before);
Set(i+2,!before);
}
if (broke[i+1]){
Set(i,before);
Set(i+1,0);
Set(i+2,!before);
}
if (broke[i+2]){
Set(i,before);
Set(i+1,!before);
Set(i+2,0);
}
}*/
else{
//cout << "hi\n";
int num1 = 0,num2 = 0;
if (X >= pow){
X -= pow;
num1 = 1;
}
pow /= 2;
if (X >= pow){
X -= pow;
num2 = 1;
}
pow /= 2;
//cout << num1 << " " << num2 << "\n";
if (num1 && num2){
Set(i,1);
Set(i+1,1);
Set(i+2,1);
}
else if (num1){
Set(i,1);
Set(i+1,1);
Set(i+2,0);
}
else if (num2){
Set(i,1);
Set(i+1,0);
Set(i+2,1);
}
else{
Set(i,0);
Set(i+1,1);
Set(i+2,1);
}
}
}
}
#include "Brunolib.h"
long long Bruno( int N, int A[] ){
long long pow = 1;
for (int i = 0; i < 59; i++) pow*= 2;
long long ans = 0;
for (int i = 0; i < N; i+= 3){
int temp = A[i]+A[i+1]+A[i+2];
if (temp == 0) continue;
if (A[i] && A[i+1] && A[i+2]){
ans += pow;
pow/=2;
ans += pow;
pow/=2;
}
else if (A[i] && A[i+1]){
ans += pow;
pow/=4;
}
else if (A[i] && A[i+2]){
pow/=2;
ans += pow;
pow/=2;
}
else{
pow/=4;
}
// cout << ans << "\n";
}
// cout << "hi\n";
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |