Submission #1151434

#TimeUsernameProblemLanguageResultExecution timeMemory
1151434gustavo_dBroken Device (JOI17_broken_device)C++20
41 / 100
23 ms1592 KiB
#include "Annalib.h"
#include <bits/stdc++.h>
using namespace std;

void Anna(int n, long long X, int K, int P[]){
  bool blocked[n];
  for (int i=0; i<n; i++) blocked[i] = false;
  for (int i=0; i<K; i++) {
    blocked[P[i]] = true;
  }

  bool hsb = false;
  vector<bool> bits;
  for (int b=62; b>=0; b--) {
    if (((1LL << b) & X) != 0) {
      hsb = true;
    }
    if (hsb) bits.push_back(((1LL << b) & X) != 0);
  }

  int pt_mask = 0;
  // cout << "n=" <<  n << endl;
  for (int i = 0; i+1 < n; i+=2){
    if (
      !blocked[i] and !blocked[i+1]
      and pt_mask < (int)bits.size()
    ) {
      Set(i, bits[pt_mask++]);
      Set(i+1, 1);
    } else {
      Set(i, 0); Set(i+1, 0);
    }
    // cout << i << ' ' << i +1 << ' ' << n << endl;
  }
  if (n&1) Set(n-1, 0);
  // cout << "enviei " << bitset<60>(X) << endl;
}
#include "Brunolib.h"
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

long long Bruno(int n, int a[]){
  vector<bool> bits;
  // for (int i=0; i<n; i++) cout << a[i] << ' ';
  // cout << endl;
  for (int i=0; i+1<n; i+=2) {
    if (a[i+1] == 1) bits.push_back(a[i]);
  }
  
  ll x = 0;
  reverse(bits.begin(), bits.end());
  for (int b=0; b<(int)bits.size(); b++) {
    if (bits[b]) {
      x += (1LL << b);
      // cout << x << endl;
    }
  }
  // cout << "Recebi " << bitset<60>(x) << endl;
  return x;
}
#Verdict Execution timeMemoryGrader output
Fetching results...