이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "encoder.h"
#include "encoderlib.h"
using namespace std;
typedef long long ll;
ll dp[22][20], i, j;
ll cmp(ll len,ll lst){
if(len==0) return 1LL;
else if(dp[len][lst]) return dp[len][lst];
for(int i=lst;i<=16;i++)
dp[len][lst]+=cmp(len-1,i);
return dp[len][lst];
}
void enc(ll idx,ll wtf,ll len,ll lst){
if(!len) return;
for(ll i=lst;i<=16;i++){
if(cmp(len,i+1)<=wtf){
if(i<16) send((idx<<4)+i);
wtf -= cmp(len,i+1);
enc(idx, wtf, len-1, i);
return;
}
}
}
void encode(int N,int *M){
for(i=0;i<N;i+=4){
ll heh = 0;
for(j=0;j<4&&i+j<N;j++)
heh += (1LL<<(j*8))*M[i+j];
enc(i>>2,heh,5*j,0);
}
}
#include <bits/stdc++.h>
#include "decoder.h"
#include "decoderlib.h"
using namespace std;
typedef long long ll;
ll dp[22][20], i, j;
ll cmp(ll len,ll lst){
if(len==0) return 1LL;
else if(dp[len][lst]) return dp[len][lst];
for(int i=lst;i<=16;i++)
dp[len][lst]+=cmp(len-1,i);
return dp[len][lst];
}
vector<int> heh[200];
ll dec(ll len,ll lst,ll id){
if(len==0) return 0LL;
ll ret = 0, idx = heh[id].size()-len;
ret = cmp(len,heh[id][idx]+1);
return ret+dec(len-1,heh[id][idx],id);
}
void decode(int N,int L,int *M){
for(i=0;i<200;i++) heh[i].clear();
for(i=0;i<L;i++){
ll idx = (M[i]>>4);
heh[idx].push_back(M[i]&15);
}
for(i=0;i<ceil(N/4.0);i++){
ll len = 5*min(N-4*i,4LL);
while(heh[i].size()<len) heh[i].push_back(16);
sort(heh[i].begin(),heh[i].end());
}
for(i=0;i<ceil(N/4.0);i++){
ll len = min(N-4*i,4LL);
ll wtf = dec(5*len,0,i);
for(j=0;j<len;j++){
output(wtf%256);
wtf/=256;
}
}
}
컴파일 시 표준 에러 (stderr) 메시지
decoder.cpp: In function 'void decode(int, int, int*)':
decoder.cpp:30:28: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
while(heh[i].size()<len) heh[i].push_back(16);
~~~~~~~~~~~~~^~~~
# | 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... |