제출 #1262070

#제출 시각아이디문제언어결과실행 시간메모리
1262070M_W_13Broken Device (JOI17_broken_device)C++20
85 / 100
31 ms1552 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 = {60, 116, 11, 106, 131, 17, 61, 4, 47, 22, 107, 78, 93, 41, 79, 111, 139, 1, 33, 15, 86, 141, 147, 148, 65, 149, 104, 14, 35, 29, 68, 34, 74, 43, 134, 101, 87, 3, 63, 25, 8, 31, 24, 81, 54, 50, 75, 49, 135, 57, 100, 9, 105, 145, 84, 40, 95, 53, 13, 138, 5, 21, 27, 76, 97, 73, 28, 123, 133, 38, 44, 32, 55, 119, 96, 2, 18, 26, 20, 19, 120, 142, 42, 52, 94, 77, 67, 90, 137, 103, 62, 127, 45, 117, 109, 46, 16, 129, 10, 48, 82, 92, 143, 99, 102, 146, 30, 56, 69, 128, 140, 126, 59, 98, 66, 23, 85, 6, 64, 108, 7, 36, 115, 125, 71, 136, 51, 124, 114, 122, 89, 83, 80, 130, 112, 12, 144, 37, 88, 132, 72, 121, 70, 110, 39, 91, 118, 113, 0, 58};
  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 {
      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 = {60, 116, 11, 106, 131, 17, 61, 4, 47, 22, 107, 78, 93, 41, 79, 111, 139, 1, 33, 15, 86, 141, 147, 148, 65, 149, 104, 14, 35, 29, 68, 34, 74, 43, 134, 101, 87, 3, 63, 25, 8, 31, 24, 81, 54, 50, 75, 49, 135, 57, 100, 9, 105, 145, 84, 40, 95, 53, 13, 138, 5, 21, 27, 76, 97, 73, 28, 123, 133, 38, 44, 32, 55, 119, 96, 2, 18, 26, 20, 19, 120, 142, 42, 52, 94, 77, 67, 90, 137, 103, 62, 127, 45, 117, 109, 46, 16, 129, 10, 48, 82, 92, 143, 99, 102, 146, 30, 56, 69, 128, 140, 126, 59, 98, 66, 23, 85, 6, 64, 108, 7, 36, 115, 125, 71, 136, 51, 124, 114, 122, 89, 83, 80, 130, 112, 12, 144, 37, 88, 132, 72, 121, 70, 110, 39, 91, 118, 113, 0, 58};
  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...