제출 #118309

#제출 시각아이디문제언어결과실행 시간메모리
118309MAMBA앵무새 (IOI11_parrots)C++17
컴파일 에러
0 ms0 KiB
#include "encoder.h"
#include <bits/stdc++.h>
#include "encoderlib.h"


using namespace std;

#define rep(i, j, k) for (int i = j; i < (int)k; i++)
#define pb push_back
#define mt make_tuple
#define all(x) x.begin(), x.end()

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

template <class T, class S>
inline bool smin(T &a, S b) {
  return (T)b < a ? a = b, 1 : 0;
}
template <class T, class S>
inline bool smax(T &a, S b) {
  return a < (T)b ? a = b, 1 : 0;
}

constexpr int N = 150 * 1000 + 10;

const int LEN = (1 << 9);

typedef int[LEN] sagy;

sagy operator+(sagy l, sagy r) {
  sagy res;
  bool cary = false;
  rep(i, 0, LEN) {
    ll tmp = 1ll * l[i] + r[i] + (cary ? 1: 0);
    res[i] = tmp & ((1l << 32) - 1);
    cary = tmp >> 32;
  }
  assert(!cary);
  return res;
}

bool operator<(sagy l, sagy r) {
	for (int i = LEN - 1; ~i; i--) {
      int tmp = l[i] ^ r[i];
      if (tmp) {
        for (int j = 31; ; j--) {
          if ((tmp >> j) & 1) 
            return (r >> j) & 1;
        }
      }
    }
  return false;
}

const int L = 257;
const int R = L + 64 * 5;
sagy c[L][R];

inline void init() {
  rep(i, 0, R) {
    c[0][i][0] = true;
    if (i < L) c[i][i][0] = true;
    rep(j, 1, min(i, L)) c[j][i] = c[j - 1][i - 1] + c[j][i - 1];
  }
}

int cnt[L];

void encode(int N, int M[]) {
  init();
  return;
  sagy code;
  rep(i, 0, N) rep(j, 0, 8) code[(i << 3) + j] = (M[i] >> j) & 1;
  sagy ta_hala;
  int have = 5 * N;
  for (int i = 255; ~i; i--) {
    while (true) {
      sagy ta_alan = ta_hala;
      have--;
      cnt[i]++;
      ta_alan = ta_alan + c[i][have + i];
      if (code < ta_alan) {
        have++;
        cnt[i]--;
        break;
      }
      ta_hala = ta_alan;
    }
  }
  rep(i, 0, 256) rep(j, 0, cnt[i]) send(i);
}
#include "decoder.h"
#include <bits/stdc++.h>
#include "decoderlib.h"

using namespace std;

#define rep(i, j, k) for (int i = j; i < (int)k; i++)
#define pb push_back
#define mt make_tuple
#define all(x) x.begin(), x.end()

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

template <class T, class S>
inline bool smin(T &a, S b) {
  return (T)b < a ? a = b, 1 : 0;
}
template <class T, class S>
inline bool smax(T &a, S b) {
  return a < (T)b ? a = b, 1 : 0;
}

constexpr int N = 150 * 1000 + 10;


const int LEN = (1 << 9);

typedef int[LEN] sagy;

sagy operator+(sagy l, sagy r) {
  sagy res;
  bool cary = false;
  rep(i, 0, LEN) {
    ll tmp = 1ll * l[i] + r[i] + (cary ? 1: 0);
    res[i] = tmp & ((1l << 32) - 1);
    cary = tmp >> 32;
  }
  assert(!cary);
  return res;
}

bool operator<(sagy l, sagy r) {
	for (int i = LEN - 1; ~i; i--) {
      int tmp = l[i] ^ r[i];
      if (tmp) {
        for (int j = 31; ; j--) {
          if ((tmp >> j) & 1) 
            return (r >> j) & 1;
        }
      }
    }
  return false;
}

const int L = 257;
const int R = L + 64 * 5;
sagy c[L][R];

inline void init() {
  rep(i, 0, R) {
    c[0][i][0] = true;
    if (i < L) c[i][i][0] = true;
    rep(j, 1, min(i, L)) c[j][i] = c[j - 1][i - 1] + c[j][i - 1];
  }
}

int cnt[L];

void decode(int N, int L, int X[]) {
  return;
  init();
  rep(i, 0, L) cnt[X[i]]++;
  sagy code;
  int have = 5 * N;
  for (int i = 255; ~i; i--) {
    while (cnt[i] > 1) {
      code = code + c[i][have + i];
      have--;
      cnt[i]--;
    }
    have--;
  }
  code = code + c[0][0];
  rep(i, 0, N) {
    int res = 0;
    rep(j, 0, 8) if (code[(i << 3) + j]) res += (1 << j);
    output(res);
  }
}

컴파일 시 표준 에러 (stderr) 메시지

encoder.cpp:31:1: error: decomposition declaration cannot be declared 'typedef'
 typedef int[LEN] sagy;
 ^~~~~~~
encoder.cpp:31:12: error: decomposition declaration cannot be declared with type 'int'
 typedef int[LEN] sagy;
            ^~~~~
encoder.cpp:31:12: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
encoder.cpp:31:16: error: conflicting declaration 'auto LEN'
 typedef int[LEN] sagy;
                ^
encoder.cpp:29:11: note: previous declaration as 'const int LEN'
 const int LEN = (1 << 9);
           ^~~
encoder.cpp:31:18: error: expected initializer before 'sagy'
 typedef int[LEN] sagy;
                  ^~~~
encoder.cpp:33:1: error: 'sagy' does not name a type
 sagy operator+(sagy l, sagy r) {
 ^~~~
encoder.cpp:45:16: error: declaration of 'operator<' as non-function
 bool operator<(sagy l, sagy r) {
                ^~~~
encoder.cpp:45:16: error: 'sagy' was not declared in this scope
encoder.cpp:45:24: error: 'sagy' was not declared in this scope
 bool operator<(sagy l, sagy r) {
                        ^~~~
encoder.cpp:60:1: error: 'sagy' does not name a type
 sagy c[L][R];
 ^~~~
encoder.cpp: In function 'void init()':
encoder.cpp:64:5: error: 'c' was not declared in this scope
     c[0][i][0] = true;
     ^
encoder.cpp: In function 'void encode(int, int*)':
encoder.cpp:75:3: error: 'sagy' was not declared in this scope
   sagy code;
   ^~~~
encoder.cpp:76:29: error: 'code' was not declared in this scope
   rep(i, 0, N) rep(j, 0, 8) code[(i << 3) + j] = (M[i] >> j) & 1;
                             ^~~~
encoder.cpp:76:29: note: suggested alternative: 'clone'
   rep(i, 0, N) rep(j, 0, 8) code[(i << 3) + j] = (M[i] >> j) & 1;
                             ^~~~
                             clone
encoder.cpp:77:8: error: expected ';' before 'ta_hala'
   sagy ta_hala;
        ^~~~~~~
encoder.cpp:81:12: error: expected ';' before 'ta_alan'
       sagy ta_alan = ta_hala;
            ^~~~~~~
encoder.cpp:84:7: error: 'ta_alan' was not declared in this scope
       ta_alan = ta_alan + c[i][have + i];
       ^~~~~~~
encoder.cpp:84:7: note: suggested alternative: '__atan'
       ta_alan = ta_alan + c[i][have + i];
       ^~~~~~~
       __atan
encoder.cpp:84:27: error: 'c' was not declared in this scope
       ta_alan = ta_alan + c[i][have + i];
                           ^
encoder.cpp:85:11: error: 'code' was not declared in this scope
       if (code < ta_alan) {
           ^~~~
encoder.cpp:85:11: note: suggested alternative: 'clone'
       if (code < ta_alan) {
           ^~~~
           clone
encoder.cpp:90:7: error: 'ta_hala' was not declared in this scope
       ta_hala = ta_alan;
       ^~~~~~~
encoder.cpp:90:7: note: suggested alternative: 'tanhl'
       ta_hala = ta_alan;
       ^~~~~~~
       tanhl

decoder.cpp:31:1: error: decomposition declaration cannot be declared 'typedef'
 typedef int[LEN] sagy;
 ^~~~~~~
decoder.cpp:31:12: error: decomposition declaration cannot be declared with type 'int'
 typedef int[LEN] sagy;
            ^~~~~
decoder.cpp:31:12: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
decoder.cpp:31:16: error: conflicting declaration 'auto LEN'
 typedef int[LEN] sagy;
                ^
decoder.cpp:29:11: note: previous declaration as 'const int LEN'
 const int LEN = (1 << 9);
           ^~~
decoder.cpp:31:18: error: expected initializer before 'sagy'
 typedef int[LEN] sagy;
                  ^~~~
decoder.cpp:33:1: error: 'sagy' does not name a type
 sagy operator+(sagy l, sagy r) {
 ^~~~
decoder.cpp:45:16: error: declaration of 'operator<' as non-function
 bool operator<(sagy l, sagy r) {
                ^~~~
decoder.cpp:45:16: error: 'sagy' was not declared in this scope
decoder.cpp:45:24: error: 'sagy' was not declared in this scope
 bool operator<(sagy l, sagy r) {
                        ^~~~
decoder.cpp:60:1: error: 'sagy' does not name a type
 sagy c[L][R];
 ^~~~
decoder.cpp: In function 'void init()':
decoder.cpp:64:5: error: 'c' was not declared in this scope
     c[0][i][0] = true;
     ^
decoder.cpp: In function 'void decode(int, int, int*)':
decoder.cpp:76:3: error: 'sagy' was not declared in this scope
   sagy code;
   ^~~~
decoder.cpp:80:7: error: 'code' was not declared in this scope
       code = code + c[i][have + i];
       ^~~~
decoder.cpp:80:7: note: suggested alternative: 'clone'
       code = code + c[i][have + i];
       ^~~~
       clone
decoder.cpp:80:21: error: 'c' was not declared in this scope
       code = code + c[i][have + i];
                     ^
decoder.cpp:86:3: error: 'code' was not declared in this scope
   code = code + c[0][0];
   ^~~~
decoder.cpp:86:3: note: suggested alternative: 'clone'
   code = code + c[0][0];
   ^~~~
   clone
decoder.cpp:86:17: error: 'c' was not declared in this scope
   code = code + c[0][0];
                 ^