Submission #990770

#TimeUsernameProblemLanguageResultExecution timeMemory
990770abczzBroken Device (JOI17_broken_device)C++14
57 / 100
146 ms2960 KiB
#include "Annalib.h"
#include <iostream>
#include <random>
#define ll long long

using namespace std;

void Anna( int N, long long X, int K, int P[] ){
  srand(7318371);
  ll x = 805215019090496300, L[60][150];
  bool B[150], F[150];
  for (int i=0; i<N; ++i) B[i] = F[i] = 0;
  for (int i=0; i<K; ++i) B[P[i]] = 1;
  x ^= X;
  for (int i=0; i<60; ++i) {
    L[i][0] = rand() & 1;
    L[i][1] = L[i][0] ^ 1;
    for (int j=2; j<N; ++j) {
      L[i][j] = rand() & 1;
    }
  }
  ll p = 0;
  for (int i=59; i>=0; --i) {
    ll bit = (bool)(x & (1LL<<i));
    for (int j=0; j<N; ++j) {
      if (L[i][j] == bit && !B[p+j]) {
        //cout << i << " " << j << endl;
        F[p+j] = 1;
        p += j+1;
        break;
      }
    }
  }
  for (int i=0; i<N; ++i) {
    Set(i, F[i]);
  }
}
#include "Brunolib.h"
#include <iostream>
#include <vector>
#include <random>
#define ll long long

using namespace std;

long long Bruno( int N, int A[] ){
  srand(7318371);
  ll x = 805215019090496300, L[60][150];
  vector <ll> V;
  for (int i=0; i<60; ++i) {
    L[i][0] = rand() & 1;
    L[i][1] = L[i][0] ^ 1;
    for (int j=2; j<N; ++j) {
      L[i][j] = rand() & 1;
    }
  }
  ll p = 0;
  for (int i=0; i<N; ++i) {
    if (A[i]) {
      V.push_back(i);
    }
  }
  int j = 0;
  for (int i=59; i>=0; --i) {
    //cout << V[j]-p << " ";
    if (L[i][V[j]-p]) x ^= (1LL<<i);
    p = V[j++]+1;
  }
  //cout << endl;
  //cout << x << endl;
  return x;
}
#Verdict Execution timeMemoryGrader output
Fetching results...