Submission #1262074

#TimeUsernameProblemLanguageResultExecution timeMemory
1262074M_W_13Broken Device (JOI17_broken_device)C++20
0 / 100
1 ms320 KiB
#include "Annalib.h"
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define st first
#define nd second
#define pb push_back

void Anna(int N, long long X, int K, int P[] ){
  vector<int> pom = {97, 98, 73, 1, 84, 62, 131, 96, 41, 55, 112, 37, 26, 48, 119, 59, 80, 81, 49, 66, 114, 38, 93, 27, 139, 117, 70, 47, 108, 86, 85, 61, 121, 99, 143, 32, 104, 56, 133, 11, 122, 71, 16, 5, 109, 136, 60, 40, 92, 101, 113, 128, 138, 10, 89, 21, 137, 12, 53, 103, 149, 102, 31, 69, 76, 140, 130, 24, 19, 43, 14, 36, 126, 141, 145, 39, 7, 67, 79, 4, 57, 72, 35, 34, 91, 20, 78, 125, 116, 95, 64, 135, 100, 68, 74, 18, 3, 111, 82, 105, 123, 0, 65, 54, 42, 124, 52, 144, 8, 120, 118, 15, 132, 87, 51, 45, 46, 30, 33, 9, 22, 115, 58, 13, 127, 83, 129, 110, 28, 75, 2, 106, 94, 77, 44, 50, 17, 29, 23, 63, 107, 148, 6, 142, 134, 147, 88, 90, 25, 146};
  queue<ll> vec;
  rep(i, 38) {
    vec.push(X % 3ll);
    X /= 3ll;
  }
  int pol = N/2;
  bool czy[N];
  rep(i, N) {
    czy[i] = true;
  }
  rep(i, K) {
    int x = P[i];
    czy[x] = false;
  }
  for (int i = 0; i < N; i += 2) {
    int a = pom[i];
    int b = pom[i + 1];
    if (czy[a] && czy[b]) {
      if (vec.empty()) {
        Set(a, 0);
        Set(b, 0);
      }
      else {
        ll p = vec.front();
        vec.pop();
        if (p == 0) {
          Set(a, 0);
          Set(b, 1);
        }
        else if (p == 1) {
          Set(a, 1);
          Set(b, 0);
        }
        else {
          Set(a, 1);
          Set(b, 1);
        }
      }
    }
    else {
      if (czy[a]) {
        if (vec.front() == 1) {
          Set(a, 1);
          Set(b, 0);
          vec.pop();
          continue;
        }
      }
      else if (czy[b]) {
        if (vec.front() == 0) {
          Set(a, 1);
          Set(b, 0);
          vec.pop();
          continue;
        }
      }
      Set(a, 0);
      Set(b, 0);
    }
  }
}
#include "Brunolib.h"
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define st first
#define nd second
#define pb push_back

long long Bruno( int N, int A[] ){
  vector<int> pom = {97, 98, 73, 1, 84, 62, 131, 96, 41, 55, 112, 37, 26, 48, 119, 59, 80, 81, 49, 66, 114, 38, 93, 27, 139, 117, 70, 47, 108, 86, 85, 61, 121, 99, 143, 32, 104, 56, 133, 11, 122, 71, 16, 5, 109, 136, 60, 40, 92, 101, 113, 128, 138, 10, 89, 21, 137, 12, 53, 103, 149, 102, 31, 69, 76, 140, 130, 24, 19, 43, 14, 36, 126, 141, 145, 39, 7, 67, 79, 4, 57, 72, 35, 34, 91, 20, 78, 125, 116, 95, 64, 135, 100, 68, 74, 18, 3, 111, 82, 105, 123, 0, 65, 54, 42, 124, 52, 144, 8, 120, 118, 15, 132, 87, 51, 45, 46, 30, 33, 9, 22, 115, 58, 13, 127, 83, 129, 110, 28, 75, 2, 106, 94, 77, 44, 50, 17, 29, 23, 63, 107, 148, 6, 142, 134, 147, 88, 90, 25, 146};
  ll x = 0;
  ll pot = 1;
  for (int i = 0; i < N; i += 2) {
    int a = pom[i];
    int b = pom[i + 1];
    if (A[a] == 1 && A[b] == 0) {
      x += pot;
    }
    else if (A[a] == 1 && A[b] == 1) {
      x += (2ll * pot);
    }
    if (A[a] == 0 && A[b] == 0) {
      continue;
    }
    pot *= 3ll;
  }
  // cout << "x = " << x << '\n';
  return x;
}
#Verdict Execution timeMemoryGrader output
Fetching results...