답안 #728979

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
728979 2023-04-23T10:46:12 Z cig32 Broken Device (JOI17_broken_device) C++17
컴파일 오류
0 ms 0 KB
#include "bits/stdc++.h"
using namespace std;

static mt19937_64 rng((long long) std::chrono::steady_clock::now().time_since_epoch().count());

static long long rnd(long long x, long long y) {
  return uniform_int_distribution<long long>(x, y)(rng);
}

const static long long R = 487846703374293674ll;
const static int S[150] = {
  111, 107, 40, 99, 11, 30, 35, 87, 58, 71, 64, 93, 70, 
  54, 55, 106, 117, 12, 133, 26, 7, 120, 60, 103, 138, 130, 
  9, 116, 89, 122, 37, 43, 23, 125, 105, 98, 46, 42, 145, 
  27, 59, 15, 92, 96, 10, 5, 121, 38, 18, 95, 143, 140, 
  72, 129, 101, 22, 16, 61, 109, 88, 63, 85, 66, 135, 36, 
  68, 81, 83, 132, 51, 65, 78, 73, 2, 32, 74, 86, 50, 69, 
  6, 14, 100, 52, 114, 53, 136, 102, 3, 84, 21, 149, 113, 
  127, 76, 134, 77, 94, 48, 128, 0, 67, 75, 80, 104, 33, 112, 
  39, 124, 131, 1, 90, 123, 8, 82, 119, 126, 139, 29, 34, 
  144, 57, 49, 115, 146, 28, 4, 62, 24, 19, 45, 118, 141, 
  79, 44, 47, 20, 137, 41, 147, 25, 56, 17, 91, 13, 108, 
  142, 31, 97, 148, 110
};

void Anna( int N, long long X, int K, int P[] ){
  X ^= R;
  bool bad[N];
  for(int i=0; i<N; i++) bad[i] = 0;
  for(int i=0; i<K; i++) bad[P[i]] = 1;
  
  int bit = 59;
  for(int i=0; i<N; i++) {
    int cur = S[i];
    if(i+1 == N) { // can't do anything
      Set(cur, 0); break;
    }
    int nxt = S[i+1];
    if(bad[cur] == 1) {
      Set(cur, 0); continue;
    }
    if(bit == -1) {
      Set(cur, 0); continue;
    }
    // Current can transmit info
    if(bad[nxt] == 0 || (X & (1ll << bit)) == 0) {
      Set(cur, 1); 
      //cout << cur << " is set to 1, " << nxt << "\n";
      long long res = X & (1ll << bit);
      if(res > 0) res = 1;
      Set(nxt, res);
      i++;
      bit--;
    }
    else {
      Set(cur, 0);
    }
  }
  //cout << bit << "\n";
}
#include "bits/stdc++.h"
using namespace std;

static mt19937_64 rng((long long) std::chrono::steady_clock::now().time_since_epoch().count());

static long long rnd(long long x, long long y) {
  return uniform_int_distribution<long long>(x, y)(rng);
}

const static long long R = 487846703374293674ll;
const static int S[150] = {
  111, 107, 40, 99, 11, 30, 35, 87, 58, 71, 64, 93, 70, 
  54, 55, 106, 117, 12, 133, 26, 7, 120, 60, 103, 138, 130, 
  9, 116, 89, 122, 37, 43, 23, 125, 105, 98, 46, 42, 145, 
  27, 59, 15, 92, 96, 10, 5, 121, 38, 18, 95, 143, 140, 
  72, 129, 101, 22, 16, 61, 109, 88, 63, 85, 66, 135, 36, 
  68, 81, 83, 132, 51, 65, 78, 73, 2, 32, 74, 86, 50, 69, 
  6, 14, 100, 52, 114, 53, 136, 102, 3, 84, 21, 149, 113, 
  127, 76, 134, 77, 94, 48, 128, 0, 67, 75, 80, 104, 33, 112, 
  39, 124, 131, 1, 90, 123, 8, 82, 119, 126, 139, 29, 34, 
  144, 57, 49, 115, 146, 28, 4, 62, 24, 19, 45, 118, 141, 
  79, 44, 47, 20, 137, 41, 147, 25, 56, 17, 91, 13, 108, 
  142, 31, 97, 148, 110
};

long long Bruno( int N, int A[] ){
  long long X = 0;
  int bit = 59;
  for(int i=0; i<N; i++) {
   // cout << "checking " << S[i] << ": A["<<S[i]<<"] = " << A[S[i]] << "\n";
    if(A[S[i]] == 1) {
     // cout << "A[" << S[i]<<"] = 1\n";
      if(A[S[i+1]]) X ^= (1ll << bit);
      i++;
      bit--;
      if(bit == -1) break;
    }
  }
  return X ^ R;
}

Compilation message

Anna.cpp: In function 'void Anna(int, long long int, int, int*)':
Anna.cpp:36:7: error: 'Set' was not declared in this scope
   36 |       Set(cur, 0); break;
      |       ^~~
Anna.cpp:40:7: error: 'Set' was not declared in this scope
   40 |       Set(cur, 0); continue;
      |       ^~~
Anna.cpp:43:7: error: 'Set' was not declared in this scope
   43 |       Set(cur, 0); continue;
      |       ^~~
Anna.cpp:47:7: error: 'Set' was not declared in this scope
   47 |       Set(cur, 1);
      |       ^~~
Anna.cpp:56:7: error: 'Set' was not declared in this scope
   56 |       Set(cur, 0);
      |       ^~~
Anna.cpp: At global scope:
Anna.cpp:6:18: warning: 'long long int rnd(long long int, long long int)' defined but not used [-Wunused-function]
    6 | static long long rnd(long long x, long long y) {
      |                  ^~~

Bruno.cpp:6:18: warning: 'long long int rnd(long long int, long long int)' defined but not used [-Wunused-function]
    6 | static long long rnd(long long x, long long y) {
      |                  ^~~