제출 #712450

#제출 시각아이디문제언어결과실행 시간메모리
712450BackNoob앵무새 (IOI11_parrots)C++14
컴파일 에러
0 ms0 KiB
#include "encoder.h" #include "encoderlib.h" #include <bits/stdc++.h> #define ll long long #define fi first #define se second #define endl '\n' #define MASK(i) (1LL << (i)) #define ull unsigned long long #define ld long double #define pb push_back #define all(x) (x).begin() , (x).end() #define BIT(x , i) ((x >> (i)) & 1) #define TASK "task" #define sz(s) (int) (s).size() using namespace std; struct bigint{ int arr[23]; bigint(){ memset(arr, 0, sizeof(arr)); } } choose[607][306]; bigint add(bigint a, bigint b) { bigint res; for(int i = 0; i < 21; i++) { int tmp = a.arr[i] + b.arr[i]; res.arr[i + 1] += tmp / BASE; res.arr[i] += tmp % BASE; } return res; } bigint sub(bigint a, bigint b) { bigint res; for(int i = 0; i < 21; i++) { while(a.arr[i] < b.arr[i]) { a.arr[i] += BASE; a.arr[i + 1]--; } res.arr[i] = a.arr[i] - b.arr[i]; } return res; } bigint Div(bigint a, int b) { bigint res; ll rem = 0; for(int i = 20; i >= 0; i--) { res.arr[i] = (ll) (1LL * BASE * rem + a.arr[i]) / b; rem = (rem * BASE + a.arr[i]) % b; } return res; } int Mod(bigint a, int b) { ll res = 0; for(int i = 20; i >= 0; i--) { res = 1LL * res * BASE + a.arr[i]; res %= b; } return res; } int cmp(bigint a, bigint b) { for(int i = 20; i >= 0; i--) { if(a.arr[i] == b.arr[i]) continue; if(a.arr[i] < b.arr[i]) return -1; return 1; } return 0; } void encode(int n, int a[]) { bigint x; for(int i = 0; i < n; i++) { bigint tmp; tmp.arr[0] = a[i]; bigint t = x; for(int j = 1; j < 256; j++) x = add(x, t); x = add(x, tmp); } bigint t; t.arr[0] = 1; x = add(x, t); for(int i = 0; i <= 530; i++) { choose[i][0].arr[0] = 1; for(int j = 1; j <= min(256, i); j++) { choose[i][j] = add(choose[i - 1][j], choose[i - 1][j - 1]); } } bigint lim; lim.arr[0] = 1; for(int i = 1; i <= n * 8; i++) { lim = add(lim, lim); } int k = 1; while(cmp(choose[256 + k - 1][256], lim) == -1) ++k; int sta = 0; for(int i = 1; i <= k; i++) { for(int j = sta; j <= 255; j++) { bigint way = choose[255 - j + (k - i)][255 - j]; int tmp = cmp(x, way); if(tmp <= 0) { send(j); sta = j; break; } else { x = sub(x, way); } } } }
#include "decoder.h" #include "decoderlib.h" #include <bits/stdc++.h> #define ll long long #define fi first #define se second #define endl '\n' #define MASK(i) (1LL << (i)) #define ull unsigned long long #define ld long double #define pb push_back #define all(x) (x).begin() , (x).end() #define BIT(x , i) ((x >> (i)) & 1) #define TASK "task" #define sz(s) (int) (s).size() using namespace std; struct bigint{ int arr[23]; bigint(){ memset(arr, 0, sizeof(arr)); } } choose[607][306]; bigint add(bigint a, bigint b) { bigint res; for(int i = 0; i < 21; i++) { int tmp = a.arr[i] + b.arr[i]; res.arr[i + 1] += tmp / BASE; res.arr[i] += tmp % BASE; } return res; } bigint sub(bigint a, bigint b) { bigint res; for(int i = 0; i < 21; i++) { while(a.arr[i] < b.arr[i]) { a.arr[i] += BASE; a.arr[i + 1]--; } res.arr[i] = a.arr[i] - b.arr[i]; } return res; } bigint Div(bigint a, int b) { bigint res; ll rem = 0; for(int i = 20; i >= 0; i--) { res.arr[i] = (ll) (1LL * BASE * rem + a.arr[i]) / b; rem = (rem * BASE + a.arr[i]) % b; } return res; } int Mod(bigint a, int b) { ll res = 0; for(int i = 20; i >= 0; i--) { res = 1LL * res * BASE + a.arr[i]; res %= b; } return res; } int cmp(bigint a, bigint b) { for(int i = 20; i >= 0; i--) { if(a.arr[i] == b.arr[i]) continue; if(a.arr[i] < b.arr[i]) return -1; return 1; } return 0; } void encode(int n, int a[]) { bigint x; for(int i = 0; i < n; i++) { bigint tmp; tmp.arr[0] = a[i]; bigint t = x; for(int j = 1; j < 256; j++) x = add(x, t); x = add(x, tmp); } bigint t; t.arr[0] = 1; x = add(x, t); for(int i = 0; i <= 530; i++) { choose[i][0].arr[0] = 1; for(int j = 1; j <= min(256, i); j++) { choose[i][j] = add(choose[i - 1][j], choose[i - 1][j - 1]); } } bigint lim; lim.arr[0] = 1; for(int i = 1; i <= n * 8; i++) { lim = add(lim, lim); } int k = 1; while(cmp(choose[256 + k - 1][256], lim) == -1) ++k; int sta = 0; for(int i = 1; i <= k; i++) { for(int j = sta; j <= 255; j++) { bigint way = choose[255 - j + (k - i)][255 - j]; int tmp = cmp(x, way); if(tmp <= 0) { send(j); sta = j; break; } else { x = sub(x, way); } } } } void decode(int n, int l, int a[]) { vector<int> v; for(int i = 0; i < l; i++) v.pb(a[i]); sort(all(v)); for(int i = 0; i <= 530; i++) { choose[i][0].arr[0] = 1; for(int j = 1; j <= min(256, i); j++) { choose[i][j] = add(choose[i - 1][j], choose[i - 1][j - 1]); } } bigint res; int sta = 0; for(int i = 1; i <= sz(v); i++) { int x = v[i - 1]; for(int j = sta; j < x; j++) { res = add(res, choose[(255 - j) + (sz(v) - i)][(255 - j)]); } sta = x; } vector<int> ans; for(int i = 1; i <= n; i++) { ans.pb(Mod(res, 256)); res = Div(res, 256); } reverse(all(ans)); for(auto it : ans) output(it); }

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

encoder.cpp: In function 'bigint add(bigint, bigint)':
encoder.cpp:32:33: error: 'BASE' was not declared in this scope
   32 |         res.arr[i + 1] += tmp / BASE;
      |                                 ^~~~
encoder.cpp: In function 'bigint sub(bigint, bigint)':
encoder.cpp:43:25: error: 'BASE' was not declared in this scope
   43 |             a.arr[i] += BASE;
      |                         ^~~~
encoder.cpp: In function 'bigint Div(bigint, int)':
encoder.cpp:57:34: error: 'BASE' was not declared in this scope
   57 |         res.arr[i] = (ll) (1LL * BASE * rem + a.arr[i]) / b;
      |                                  ^~~~
encoder.cpp: In function 'int Mod(bigint, int)':
encoder.cpp:67:27: error: 'BASE' was not declared in this scope
   67 |         res = 1LL * res * BASE + a.arr[i];
      |                           ^~~~

decoder.cpp: In function 'bigint add(bigint, bigint)':
decoder.cpp:32:33: error: 'BASE' was not declared in this scope
   32 |         res.arr[i + 1] += tmp / BASE;
      |                                 ^~~~
decoder.cpp: In function 'bigint sub(bigint, bigint)':
decoder.cpp:43:25: error: 'BASE' was not declared in this scope
   43 |             a.arr[i] += BASE;
      |                         ^~~~
decoder.cpp: In function 'bigint Div(bigint, int)':
decoder.cpp:57:34: error: 'BASE' was not declared in this scope
   57 |         res.arr[i] = (ll) (1LL * BASE * rem + a.arr[i]) / b;
      |                                  ^~~~
decoder.cpp: In function 'int Mod(bigint, int)':
decoder.cpp:67:27: error: 'BASE' was not declared in this scope
   67 |         res = 1LL * res * BASE + a.arr[i];
      |                           ^~~~
decoder.cpp: In function 'void encode(int, int*)':
decoder.cpp:120:17: error: 'send' was not declared in this scope
  120 |                 send(j);
      |                 ^~~~