이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "encoder.h"
#include "encoderlib.h"
using namespace std;
#define ll unsigned long long
static const int maxx = 31;
static ll idx, dp[40][32] = {0};
ll raw_to_hash(vector<int> &v){
ll re = 0;
for (int i = 0; i < v.size(); i++){
int rem_length = v.size() - i - 1;
ll bruh = v[i] * pow(256, rem_length);
re += bruh;
}
return re;
}
ll cnt_encoded(int i, int x){
if (dp[i][x] != -1) return dp[i][x];
if (i == 0) return 1ll;
ll re = 0;
for (int y = x; y <= maxx; y++) re += cnt_encoded(i - 1, y);
dp[i][x] = re;
return re;
}
void dp_encode(){
for (int x = 0; x < 32; x++) dp[0][x] = 1;
for (int i = 1; i < 40; i++){
for (int x = 0; x < 32; x++){
ll re = 0;
for (int y = x; y <= maxx; y++) re += dp[i - 1][y];
dp[i][x] = re;
}
}
}
void actually_encode(int i, ll rem, int last){
if (i == 0) return;
for (int y = last; y <= maxx; y++){
ll cnt = dp[i - 1][y];
if (rem >= cnt) rem -= cnt;
else{
send(idx + y);
actually_encode(i - 1, rem, y);
return;
}
}
}
void bruh_encode(int i, ll rem, int last){
while (i){
for (int y = last; y <= maxx; y++){
ll cnt = dp[i - 1][y];
if (rem >= cnt) rem -= cnt;
else{
send(idx + y);
last = y; i--;
break;
}
}
}
}
void encode(int N, int M[]){
dp_encode();
int angie = 0;
for (int i = 0; i < N; i += 8){
idx = angie<<5; angie++;
vector<int> v;
for (int j = i; j < min(N, i + 8); j++){
v.push_back(M[j]);
}
ll hash = raw_to_hash(v);
// actually_encode(min((int)v.size() * 5, (int)38), hash, 0);
bruh_encode(min((int)v.size() * 5, (int)38), hash, 0);
}
}
#include <bits/stdc++.h>
#include "decoder.h"
#include "decoderlib.h"
using namespace std;
#define ll unsigned long long
static const int maxx = 31;
static ll dp[40][32] = {0};
ll cnt_decode(int i, int x){
if (dp[i][x] != -1) return dp[i][x];
if (i == 0) return 1ll;
ll re = 0;
for (int y = x; y <= maxx; y++) re += dp[i - 1][y];
dp[i][x] = re;
return re;
}
void dp_decode(){
for (int x = 0; x < 32; x++) dp[0][x] = 1;
for (int i = 1; i < 40; i++){
for (int x = 0; x < 32; x++){
ll re = 0;
for (int y = x; y <= maxx; y++) re += dp[i - 1][y];
dp[i][x] = re;
}
}
}
void actually_decode(int i, ll rem){
ll angie = 0, og_rem = rem;
for (int j = 0; j < i; j++){
int rem_length = i - j - 1;
ll bruh = pow(256, rem_length);
ll y = rem / bruh;
output(y);
rem %= bruh;
angie += y * bruh;
}
}
void decode(int N, int L, int X[]){
dp_decode();
sort(X, X + L);
for (int i = 0; i < L; i += 38){
vector<int> v;
for (int j = i; j < min(L, i + 38); j++){
v.push_back(X[j] % 32);
}
ll hash = 0;
ll angie = 0;
for (int j = 0; j < v.size(); j++){
int sz = v.size() - j - 1;
for (int x = (j == 0 ? 0 : v[j - 1]); x < v[j]; x++){
hash += dp[sz][x];
}
}
actually_decode((v.size() + 4) / 5, hash);
}
}
컴파일 시 표준 에러 (stderr) 메시지
encoder.cpp: In function 'long long unsigned int raw_to_hash(std::vector<int>&)':
encoder.cpp:13:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
13 | for (int i = 0; i < v.size(); i++){
| ~~^~~~~~~~~~
encoder.cpp: In function 'long long unsigned int cnt_encoded(int, int)':
encoder.cpp:22:18: warning: comparison of integer expressions of different signedness: 'long long unsigned int' and 'int' [-Wsign-compare]
22 | if (dp[i][x] != -1) return dp[i][x];
| ~~~~~~~~~^~~~~
decoder.cpp: In function 'long long unsigned int cnt_decode(int, int)':
decoder.cpp:12:18: warning: comparison of integer expressions of different signedness: 'long long unsigned int' and 'int' [-Wsign-compare]
12 | if (dp[i][x] != -1) return dp[i][x];
| ~~~~~~~~~^~~~~
decoder.cpp: In function 'void actually_decode(int, long long unsigned int)':
decoder.cpp:32:19: warning: unused variable 'og_rem' [-Wunused-variable]
32 | ll angie = 0, og_rem = rem;
| ^~~~~~
decoder.cpp: In function 'void decode(int, int, int*)':
decoder.cpp:53:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
53 | for (int j = 0; j < v.size(); j++){
| ~~^~~~~~~~~~
decoder.cpp:52:12: warning: unused variable 'angie' [-Wunused-variable]
52 | ll angie = 0;
| ^~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |