답안 #923513

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
923513 2024-02-07T11:07:32 Z bachhoangxuan 앵무새 (IOI11_parrots) C++17
0 / 100
2 ms 1312 KB
#include "encoder.h"
#include "encoderlib.h"
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define fi first
#define se second
const int maxa = 256;
const int Max = 35;
const int Lim = 27;
ll dp[55][55];


void encode(int N, int M[])
{
    dp[0][0]=1;
    for(int i=0;i<Max;i++){
        for(int j=0;j<Lim;j++){
            if(i) dp[i][j]+=dp[i-1][j];
            if(j) dp[i][j]+=dp[i][j-1];
        }
    }
    int cur=0;
    for(int i=0;i<N;i+=7){
        ll num=0,mul=1;
        int cnt=0;
        for(int j=i;j<min(i+7,N);j++){
            num+=1LL*M[j]*mul,mul*=maxa,cnt++;
        }
        for(int j=cnt*5-1;j>=0;j--){
            for(int k=0;k<min(maxa-cur,Lim);k++){
                if(dp[j][k]>num){
                    if(k) num-=dp[j][k-1];
                    send(cur+k);
                    break;
                }
            }
        }
        cur+=Lim;
    }
}
#include "decoder.h"
#include "decoderlib.h"
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxa = 256;
const int Max = 35;
const int Lim = 27;
ll dp[55][55];

void decode(int N, int L, int X[])
{
    dp[0][0]=1;
    for(int i=0;i<Max;i++){
        for(int j=0;j<Lim;j++){
            if(i) dp[i][j]+=dp[i-1][j];
            if(j) dp[i][j]+=dp[i][j-1];
        }
    }
    vector<vector<int>> d(N);
    for(int i=0;i<L;i++) d[X[i]/Lim].push_back(X[i]%Lim);
    for(int i=0;i<N;i++){
        if(d[i].empty()) continue;
        sort(d[i].begin(),d[i].end());
        ll num=0;
        for(int j=(int)d[i].size()-1;j>=0;j--){
            int k=d[i][j];
            if(k) num+=dp[j][k-1];
        }
        for(int j=i*7;j<min((i+1)*7,N);j++){
            output(num%maxa);
            num/=maxa;
        }
    }
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 784 KB Error : Output is wrong
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 1304 KB Error : Output is wrong
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 1308 KB Error : Output is wrong
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 1312 KB Error : Output is wrong
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 1308 KB Error : Output is wrong
2 Halted 0 ms 0 KB -